4.2.1.1 Expanding/Customising the Application
- The protocol parser is
implemented in app_trps.c and app_trps.h
- Request and Response: when user wants to get and modify data on the device
- Notify: when there is a new data to be sent to mobile app.
- The protocol commands are defined
in app_ble_sensor.h and related sensor functionalities are implemented in
app_ble_sensor.c
- Request and Response: When a command request is received from mobile app, app_trps.c parse the data and forward to specific command callback handler in app_ble_sensor.c
- Notify: When specific Sensor data to be sent to mobile app, app_ble_sensor.c places the data in data base and calls for notify handler in app_trps.c (/ref APP_TRPS_SendNotification())
Example: To add a command to get temperature in Fahrenheit
Complete the SDK Setup and open the "ble_sensor.x" located in "<Harmony Content Path>\wireless_apps_pic32cxbz3_wbz35\apps\ble\advanced_applications\ble_sensor_touch\firmware" using MPLABX IDE Changes to - app_ble_sensor.h- Define request, response, size of response payload (not including size of length byte and response ID)
- Define a new control command ID
- Define a new control command response
- Define the length for the new response command
- Inside the existing APP_TRPS_SensorData_T structure, add the new data structure which holds the response data
- Increase the list size BLE_SENSOR_CMD_RESP_LST_SIZE by one
- Add new command request/response set in BLE_SENSOR_DEFINE_CTRL_CMD_RESP() list
- Read the temperature periodically and store in above defined data structure. Add the below code in App_TRPS_Sensor_TimerHandler()
- After doing the above changes follow the instruction in select option Build Project in IDE to compile the application example
-
Select option Run Project in IDE to program the target – the onboard debugger will program the example application
Testing with MBD mobile app
The "BLE Sensor" sub app in MBD mobile app is designed only to work with specific functionality. So, if new command is added in BLE sensor application, "BLE Sensor" mobile app will not know about it. To test the above newly added code, "BLE Smart" sub app in MBD can be used. Follow the below screenshots after launching MBD mobile app.





