XDK API  3.6.0
Documentation
Files | Macros | Functions | Variables
BoschXDKCloudConnectivity

The BoschXDKCloudConnectivity Application for the XDK implements a simple client, which enables a LWM2M server to read and receive sensor data from the XDK. More...

+ Collaboration diagram for BoschXDKCloudConnectivity:

Files

file  AppController.c
 

Macros

#define APP_CONTROLLER_STEP1   UINT32_C(0)
 
#define APP_CONTROLLER_STEP2   UINT32_C(1)
 
#define APP_RESPONSE_FROM_SNTP_SERVER_TIMEOUT   UINT32_C(10000)
 
#define APP_SYNC_TIME_INTERVAL_MAX_MS   UINT32_C(1800000)
 
#define APP_WLAN_MONITOR_MAX_MS   UINT32_C(10000)
 
#define BCDS_MODULE_ID   XDK_APP_MODULE_ID_APP_CONTROLLER
 
#define LWM2M_CLIENT_PORT   UINT32_C(12345)
 
#define SD_CARD_RENAME_FILE_NAME   "0:config.bkp"
 
#define SERIAL_CONNECT_TIME_INTERVAL_IN_MS   UINT32_C(5000)
 
#define WIFI_CFG_FILE_READ_BUFFER   UINT32_C(2024)
 
#define WIFI_CONFIG_FILE_NAME   "config.txt"
 

Functions

void AppController_Init (void *cmdProcessorHandle, uint32_t param2)
 Gives control to the Application controller. More...
 
static void AppControllerEnable (void *param1, uint32_t param2)
 To enable the necessary modules for the application. It is done in 2 steps. In Step 1, the modules enabled are: More...
 
static void AppControllerFire (void *param1, uint32_t param2)
 To fire the necessary modules for the application. It is done in 2 steps. In Step 1, the modules run functionality are: More...
 
static void AppControllerFireTask (void *pvParameters)
 This task triggers the below. More...
 
static const char * AppControllerGetWlanConnectDescription (WlanNetworkConnect_Status_T wlanStatus)
 
static void AppControllerSetup (void *param1, uint32_t param2)
 To setup the necessary modules for the application. It is done in 2 steps. In Step 1, the modules setup are: More...
 
void AppControllerSyncSNTP (void)
 This will synchronizing the SNTP server time with the node. More...
 
void AppControllerWLANMonitor (void)
 This will monitor the WLAN health. More...
 
static void AppLWM2MStatusNotificationCB (LWM2M_StatusNotification_T status)
 LWM2M status notification callback. More...
 
static void Button1Callback (ButtonEvent_T buttonEvent)
 Callback for Button 1. More...
 
static void Button2Callback (ButtonEvent_T buttonEvent)
 Callback for Button 2. More...
 

Variables

static uint32_t ActualFileReadSize = 0UL
 
static CmdProcessor_TAppCmdProcessor
 
static xTaskHandle AppControllerHandle = NULL
 
static volatile bool Button1State = false
 
static volatile bool Button2State = false
 
static Button_Setup_T ButtonSetup
 
static uint8_t FileReadBuffer [WIFI_CFG_FILE_READ_BUFFER] = { 0 }
 
static LWM2M_Setup_T Lwm2mSetup
 
static SNTP_Setup_T SNTPSetupInfo
 
static Storage_Setup_T StorageSetup
 
static bool UseButtonsForLWM2MAlert = false
 
static WlanNetworkConnect_Status_T WlanConnectStatus = WLANNWCT_STATUS_DISCONNECTED
 
static WLAN_Setup_T WLANSetupInfo
 

Detailed Description

The BoschXDKCloudConnectivity Application implements two tasks:

The first task is controlled by the LWM2MObjectSensorDevice.h. The sensor device contains a timer, which updates all enabled sensor values every 100msec and processes the value according the SensorDeviceResource_S.preprocessingMode. After the LWM2MOSensorDeviceResource_S.transportInterval, the timer also notifies all enabled LWM2M object instances of the new calculated values. Reads will the get responses with the new values and observes may be notified of changes.

The second task requires to maintain a "registration state", which is implemented in XDK_LWM2M.h. Depending on the registration state of the device and the LWM2M lifetime the device sends registration or update registration messages to the server. Therefore the LWM2M uses a timer, which checks every second the registration state.

The application starts here in main with the initialization of freeRTOS (Real Time Operation System).

Please have a look on Bosch XDK Cloud Connectivity
Please have also a look into the Bosch XDK Cloud Connectivity Guide

Macro Definition Documentation

#define APP_CONTROLLER_STEP1   UINT32_C(0)
#define APP_CONTROLLER_STEP2   UINT32_C(1)
#define APP_RESPONSE_FROM_SNTP_SERVER_TIMEOUT   UINT32_C(10000)

Timeout for SNTP server time sync

#define APP_SYNC_TIME_INTERVAL_MAX_MS   UINT32_C(1800000)

APP_SYNC_TIME_INTERVAL_MAX_MS is the synchronization time with SNTP server.

#define APP_WLAN_MONITOR_MAX_MS   UINT32_C(10000)

APP_WLAN_MONITOR_MAX_MS is the interval for monitoring the WLAN health.

#define BCDS_MODULE_ID   XDK_APP_MODULE_ID_APP_CONTROLLER
#define LWM2M_CLIENT_PORT   UINT32_C(12345)

Macro to represent LWM2M client port

#define SD_CARD_RENAME_FILE_NAME   "0:config.bkp"
#define SERIAL_CONNECT_TIME_INTERVAL_IN_MS   UINT32_C(5000)

Macro to represent connect time interval

#define WIFI_CFG_FILE_READ_BUFFER   UINT32_C(2024)
#define WIFI_CONFIG_FILE_NAME   "config.txt"

Function Documentation

void AppController_Init ( void *  cmdProcessorHandle,
uint32_t  param2 
)

This is a template function where the user can write his custom application.

Refer interface header for description

+ Here is the call graph for this function:

static void AppControllerEnable ( void *  param1,
uint32_t  param2 
)
static
  • Storage In Step 2, the modules enabled are:
  • WLAN
  • ServalPAL
  • SNTP
  • LWM2M
Parameters
[in]param1Unused
[in]param2Step to be enabled

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void AppControllerFire ( void *  param1,
uint32_t  param2 
)
static
  • Validate if SD Card storage if available
  • If SD Card storage is available, validate if WIFI_CONFIG_FILE_NAME is available
  • If WIFI_CONFIG_FILE_NAME is available, copy it to the WiFi file system
  • Rename WIFI_CONFIG_FILE_NAME to SD_CARD_RENAME_FILE_NAME
  • Read WIFI_CONFIG_FILE_NAME from the WiFi file system and store the contents to a global memory
  • Enqueue AppControllerSetup APP_CONTROLLER_STEP2 and exit In Step 2, the modules run functionality are:
  • Create a task to perform the following
    • enable the button support
    • Sync SNTP server time
    • trigger a LWM2M registration
Parameters
[in]param1Unused
[in]param2Step to be fired

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void AppControllerFireTask ( void *  pvParameters)
static
  • Button support
  • Synchronizing the SNTP server time
  • LWM2M registration After that it periodically (APP_SYNC_TIME_INTERVAL_MAX_MS) synchronizes the SNTP time stamp
Parameters
[in]pvParametersUnused

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static const char* AppControllerGetWlanConnectDescription ( WlanNetworkConnect_Status_T  wlanStatus)
static

+ Here is the caller graph for this function:

static void AppControllerSetup ( void *  param1,
uint32_t  param2 
)
static

Refer function definition for description

  • Wait for serial port to be enumerated
  • Storage
  • Button In Step 2, the modules setup are:
  • Fetch the MAC address of the WLAN chip
  • AppTxtParser
  • WLAN
  • ServalPAL
  • SNTP
  • LWM2M
Parameters
[in]param1Unused
[in]param2Step to be setup

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AppControllerSyncSNTP ( void  )

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AppControllerWLANMonitor ( void  )

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void AppLWM2MStatusNotificationCB ( LWM2M_StatusNotification_T  status)
static
Parameters
[in]statusrun-time status of the LWM2M stack

Refer function prototype for description

+ Here is the call graph for this function:

static void Button1Callback ( ButtonEvent_T  buttonEvent)
static
Parameters
[in]buttonEventButton 1 event

Refer function prototype for description

+ Here is the call graph for this function:

static void Button2Callback ( ButtonEvent_T  buttonEvent)
static
Parameters
[in]buttonEventButton 2 event

Refer function prototype for description

+ Here is the call graph for this function:

Variable Documentation

uint32_t ActualFileReadSize = 0UL
static

Length of store the configuration file retrieved from the SD card / WiFi storage

CmdProcessor_T* AppCmdProcessor
static

Handle to store the main Command processor handle to be used by run-time event driven threads

xTaskHandle AppControllerHandle = NULL
static

OS thread handle for Application controller to be used by run-time blocking threads

volatile bool Button1State = false
static

Boolean to represent the Button 1 state ("true" if pressed, "false" otherwise)

volatile bool Button2State = false
static

Boolean to represent the Button 2 state ("true" if pressed, "false" otherwise)

Button_Setup_T ButtonSetup
static
Initial value:
=
{
.CmdProcessorHandle = NULL,
.InternalButton1isEnabled = true,
.InternalButton2isEnabled = true,
.InternalButton1Callback = Button1Callback,
.InternalButton2Callback = Button2Callback,
}
#define NULL
Definition: BCDS_Basics.h:80
static void Button1Callback(ButtonEvent_T buttonEvent)
Callback for Button 1.
Definition: AppController.c:306
static void Button2Callback(ButtonEvent_T buttonEvent)
Callback for Button 2.
Definition: AppController.c:381

Button setup parameters

uint8_t FileReadBuffer[WIFI_CFG_FILE_READ_BUFFER] = { 0 }
static

Buffer to store the configuration file from the SD card / WiFi storage

LWM2M_Setup_T Lwm2mSetup
static
Initial value:
=
{
.CmdProcessorHandle = NULL,
.IsSecure = false,
.SecurityPreSharedKey =
{
.Identity = NULL,
.Key = NULL,
.KeyLength = 0UL,
},
.EndPointName = NULL,
.Binding = NULL,
.Lifetime = 0UL,
.ConfirmableNotification = false,
.MACAddr = NULL,
.TestMode = LWM2M_TEST_MODE_NO,
.ServerURL = NULL,
.ServerPort = 0U,
.ClientPort = LWM2M_CLIENT_PORT,
.StatusNotificationCB = AppLWM2MStatusNotificationCB,
}
static void AppLWM2MStatusNotificationCB(LWM2M_StatusNotification_T status)
LWM2M status notification callback.
Definition: AppController.c:234
Definition: XDK_LWM2M.h:146
#define NULL
Definition: BCDS_Basics.h:80
#define LWM2M_CLIENT_PORT
Definition: AppController.c:117
Definition: XDK_LWM2M.h:80

LWM2M setup parameters. Many parameters are updated in run time

SNTP_Setup_T SNTPSetupInfo
static
Initial value:
=
{
.ServerUrl = SNTP_SERVER_URL,
.ServerPort = SNTP_SERVER_PORT,
}
#define SNTP_SERVER_PORT
Definition: AppController.h:120
#define SNTP_SERVER_URL
Definition: AppController.h:115

SNTP setup parameters

Storage_Setup_T StorageSetup
static
Initial value:
=
{
.SDCard = true,
.WiFiFileSystem = true,
}

Storage setup parameters

bool UseButtonsForLWM2MAlert = false
static

Boolean to represent if LWM2M alerts can be done for button triggers

WLAN connection status

WLAN_Setup_T WLANSetupInfo
static
Initial value:
=
{
.IsEnterprise = false,
.IsHostPgmEnabled = false,
.SSID = NULL,
.Username = NULL,
.Password = NULL,
.IsStatic = false,
.IpAddr = 0UL,
.GwAddr = 0UL,
.DnsAddr = 0UL,
.Mask = 0UL,
}
#define NULL
Definition: BCDS_Basics.h:80

WLAN setup parameters


All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:54 by doxygen 1.8.8