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

Demo application of Transmitting BMA280 Accelerometer data on BLE(Bluetooth Low Energy) and UDP every configured interval (APP_CONTROLLER_TX_DELAY) More...

+ Collaboration diagram for SendAccelDataOverUdpandBle:

Files

file  AppController.c
 

Macros

#define APP_CONTROLLER_BLE_END_TRIGGER   UINT32_C(0)
 
#define APP_CONTROLLER_BLE_RX_BUFFER_SIZE   UINT8_C(20)
 
#define APP_CONTROLLER_BLE_SEND_TIMEOUT_IN_MS   UINT32_C(1000)
 
#define APP_CONTROLLER_BLE_START_TRIGGER   UINT32_C(1)
 
#define APP_CONTROLLER_BLE_TX_LEN   UINT8_C(16)
 
#define APP_CONTROLLER_TX_AXIS_COUNT   UINT8_C(3)
 
#define APP_TEMPERATURE_OFFSET_CORRECTION   (-3459)
 
#define BCDS_MODULE_ID   XDK_APP_MODULE_ID_APP_CONTROLLER
 

Functions

void AppController_Init (void *cmdProcessorHandle, uint32_t param2)
 Gives control to the Application controller. More...
 
static void AppControllerBleDataRxCB (uint8_t *rxBuffer, uint8_t rxDataLength, void *param)
 This is the BLE data receive callback function. More...
 
static void AppControllerBleStartOrEndMsgSend (void *param1, uint32_t param2)
 This will send start or stop message based on input parameter. More...
 
static void AppControllerEnable (void *param1, uint32_t param2)
 To enable the necessary modules for the application. More...
 
static void AppControllerFire (void *pvParameters)
 Responsible for controlling the UDP Example application control flow. More...
 
static void AppControllerSetup (void *param1, uint32_t param2)
 To setup the necessary modules for the application. More...
 
static void AppControllerValidateWLANConnectivity (void)
 This will validate the WLAN network connectivity. More...
 

Variables

static CmdProcessor_TAppCmdProcessor
 
static bool AppControllerBleTransmitPayload = false
 
static xTaskHandle AppControllerHandle = NULL
 
static BLE_Setup_T BLESetupInfo
 
static Sensor_Setup_T SensorSetup
 
static WLAN_Setup_T WLANSetupInfo
 

Detailed Description

This example demonstrates how to read sensor values from the BMA280 Acceleration sensor and streams them over Bluetooth Low Energy via custom Bi-Directional Service.
Either use your Android or iOS mobile phone (see Android or iOS App Store) to connect to XDK and receive the data. Send command start (HEX: 0x7374617274) to XDK via Bluetooth Low Energy, so that streaming of data begins. To stop the streaming send command end (HEX: 656e64)

This Application enables the bi-directional service in ble and sends Accelerometer Data over ble and UDP.
Bi-Directional Service :

Service Characteristic Attribute-Type UUID
BidirectionalService NA uint8_t b9e875c0-1cfa-11e6-b797-0002a5d5c51b
NA Rx uint8_t X[20] 0c68d100-266f-11e6-b388-0002a5d5c51b
NA Tx uint8_t X[20] 1ed9e2c0-266f-11e6-850b-0002a5d5c51b

Macro Definition Documentation

#define APP_CONTROLLER_BLE_END_TRIGGER   UINT32_C(0)

BLE end command send application logic

#define APP_CONTROLLER_BLE_RX_BUFFER_SIZE   UINT8_C(20)

Size of BLE receive buffer

#define APP_CONTROLLER_BLE_SEND_TIMEOUT_IN_MS   UINT32_C(1000)

Timeout for BLE send

#define APP_CONTROLLER_BLE_START_TRIGGER   UINT32_C(1)

BLE start command send application logic

#define APP_CONTROLLER_BLE_TX_LEN   UINT8_C(16)

Size of accelerometer complete payload in bytes with spaces in-between the axis values and NULL terminator

#define APP_CONTROLLER_TX_AXIS_COUNT   UINT8_C(3)

Number of accelerometer axis (x, y & z)

#define APP_TEMPERATURE_OFFSET_CORRECTION   (-3459)

Macro for static temperature offset correction. Self heating, temperature correction factor

#define BCDS_MODULE_ID   XDK_APP_MODULE_ID_APP_CONTROLLER

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 AppControllerBleDataRxCB ( uint8_t *  rxBuffer,
uint8_t  rxDataLength,
void *  param 
)
static

Callback function called on data reception over BLE.

Parameters
[in]rxBufferpointer to the received data buffer
[in]rxDataLengthLength of the received data
[in]paramunused
Note
Do not perform any heavy processing within this function and return ASAP.
Parameters
[in]rxBuffer: Buffer in which received data to be stored.
[in]rxDataLength: Length of received data.
[in]paramUnused

+ Here is the call graph for this function:

static void AppControllerBleStartOrEndMsgSend ( void *  param1,
uint32_t  param2 
)
static
Parameters
[in]param1Unused, Reserved for future use
[in]param2Differentiates start and stop command. APP_CONTROLLER_BLE_START_PAYLOAD for start. APP_CONTROLLER_BLE_END_PAYLOAD for stop.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void AppControllerEnable ( void *  param1,
uint32_t  param2 
)
static
  • WLAN
  • UDP
  • BLE
  • Sensor
Parameters
[in]param1Unused
[in]param2Unused

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void AppControllerFire ( void *  pvParameters)
static
  • Check whether the network connection is available
  • Triggers a Sensor data sampling
  • Read the sampled Sensor data
  • Creates a socket for communication
  • Sends the data to the remote server.
  • Closes the socket after successful communication.
  • Send sensor data via. BLE.
  • Wait for APP_CONTROLLER_UDP_TX_DELAY before proceeding to redoing the above steps except the first
Parameters
[in]pvParametersUnused

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void AppControllerSetup ( void *  param1,
uint32_t  param2 
)
static
  • WLAN
  • UDP
  • BLE
  • Sensor
Parameters
[in]param1Unused
[in]param2Unused

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void AppControllerValidateWLANConnectivity ( void  )
static

Currently, upon abrupt disconnection the event from the WiFi chip is not propagated / notified to the application. Until then, we manually validate prior to ever HTTP Rest Client POST/GET cycle to make sure that the possibility of software break is reduced. We check if the IP is valid to validate the same.

If there is no connectivity we will restart the node after 10 seconds.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

CmdProcessor_T* AppCmdProcessor
static

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

bool AppControllerBleTransmitPayload = false
static

Boolean representing if BLE needs to be streamed. Validate the repeated start flag

xTaskHandle AppControllerHandle = NULL
static

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

BLE_Setup_T BLESetupInfo
static
Initial value:
=
{
.IsMacAddrConfigured = false,
.MacAddr = 0UL,
.IsDeviceCharacteristicEnabled = false,
.CharacteristicValue =
{
.ModelNumber = NULL,
.Manufacturer = NULL,
.SoftwareRevision = NULL
},
.CustomServiceRegistryCB = NULL,
}
#define APP_CONTROLLER_BLE_DEVICE_NAME
Definition: AppController.h:106
#define NULL
Definition: BCDS_Basics.h:80
Definition: XDK_BLE.h:66
static void AppControllerBleDataRxCB(uint8_t *rxBuffer, uint8_t rxDataLength, void *param)
This is the BLE data receive callback function.
Definition: AppController.c:295

BLE setup parameters

Sensor_Setup_T SensorSetup
static

Sensor setup parameters

WLAN_Setup_T WLANSetupInfo
static
Initial value:
=
{
.IsEnterprise = false,
.IsHostPgmEnabled = false,
.SSID = WLAN_SSID,
.Username = WLAN_PSK,
.Password = WLAN_PSK,
.IsStatic = WLAN_STATIC_IP,
.IpAddr = WLAN_IP_ADDR,
.GwAddr = WLAN_GW_ADDR,
.DnsAddr = WLAN_DNS_ADDR,
.Mask = WLAN_MASK,
}
#define WLAN_DNS_ADDR
Definition: AppController.h:101
#define WLAN_PSK
Definition: AppController.h:75
#define WLAN_GW_ADDR
Definition: AppController.h:94
#define WLAN_IP_ADDR
Definition: AppController.h:87
#define WLAN_SSID
Definition: AppController.h:69
#define WLAN_STATIC_IP
Definition: AppController.h:80
#define WLAN_MASK
Definition: AppController.h:108

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