5.2.1.1 Expanding/Customising the Application
Configuration for OTA DFU
The MCC project graph for BLE sensor can be seen as below. 
The following steps provide the configuration settings for various components which have
to be configured as shown.
- Enable “DFU module” in “BLE Stack” configuration.
- Configuration options for “Over-The- Air Profile” is shown below.
-
Figure 5-165. PDS_SubSystem configuration -
Figure 5-166. System configuration -
Figure 5-167. RTOS configuration - Project properties
configuration
Figure 5-168. Header Configuration Figure 5-169. OTA Configuration After the configurations, click Create OTA File. The Upgradable
.bin
image with selected “Output File Name” will be created in .X folder. This is the image stored in OTAU Manager to send to OTAU Target.
- The protocol parser is
implemented in
app_trps.c
andapp_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 inapp_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 inapp_trps.c
(/ref APP_TRPS_SendNotification()
)
- Request and
Response: When a command request is received from mobile app,
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_pic32_bz6\apps\ble\advanced_applications\ble_sensor\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
app_ble_sensor.c
- 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.





