10.3.6.2 OTA Application Development
Compile MCC auto generated project:
- Compile the MCC auto generated project as the folloing.
Addressing the mandatory error (if not already done): User action required in app_user_edits.c. Follow the steps mentioned in the note and do the necessary changes. Then comment the #error message as below.
Call BLE OTA Init function in "app.c" and add the include file.
APP_OTA_HDL_Init();
#include "app_ota/app_ota_handler.h"
Call BLE OTA event handler function in
"app_ble/app_otaps_handler.c"
.APP_OTA_EvtHandler(p_event);
#include "../app_ota/app_ota_handler.h"
Uncomment timer message ID's in "app_timer/app_timer.c" needed for OTA error handling and reboot timer. When the timer is fired, the related message is posted in freeRTOS application task queue.
Define the timer message ID's in APP_MsgId_T structure in
app.h
.APP_TIMER_OTA_TIMEOUT_MSG,
APP_TIMER_OTA_REBOOT_MSG,
Call OTA timer handlers in APP_Tasks() in "app.c".
else if(p_appMsg->msgId == APP_TIMER_OTA_TIMEOUT_MSG)
{
APP_OTA_Timeout_Handler();
}
else if(p_appMsg->msgId== APP_TIMER_OTA_REBOOT_MSG)
{
APP_OTA_Reboot_Handler();
}
Call DIS service Init function in "app.c" and add the include file.
BLE_DIS_Add();
#include "ble_dis/ble_dis.h"
Call BLE gap connected/disconnected event handler in "app_ble/app_ble_handler.c" . app_ble_conn_handler.c handles the events and also restarts the Advertising when disconnected.
APP_BleGapConnEvtHandler(p_event);
#include "../app_ble_conn_handler.h"
If the Standby Sleep mode low power functionality is enabled in the application, during the OTA upgrade procedues, it is required to disable the device entering into sleep mode. Add the below check in app_idle_task() when the BT_SYS_EnterSleepMode() is called.
if (APP_OTA_HDL_GetOTAMode() != APP_OTA_MODE_OTA) BT_SYS_EnterSleepMode(RTC_Timer32FrequencyGet(), RTC_Timer32CounterGet());
- Compile the project for no errors.
API documentation reference: