FireBLE Buy

Using the FS-QN9021 Bluetooth low energy (BLE) Module,The core is based on 32 Quintic company ARM Cortex-M0 processor architecture and single mode BT4.0 Low Energy (BLE) BLE designed single-chip system QN9021.

OTA updata profile

Update time:2018-04-13 Views:1940

Introduction

The OTA is used to upgrade the firmware of QN902x over the air.

Open OTA function

Quintic has Closed OTA profile's source code,and provide a lib for user programmes. we will programmes with API document.this chapter has introduce how to open The OTA function and it will be suitable for other profile.

Macro Definition

In usr_config.h:

 /// OTA Server Role
 #define CFG_PRF_OTAS
 #define CFG_TASK_OTAS   TASK_PRF7

add lib to project

Add ota.lib to group directory of project.Double click group in the project,and choose the lib file when The  dialog popup,lib file's path is fireblue/Demo_BLE/src/profile/ota/otas
Keil add OTA lib.png

add updata code to usr_design.c

In app_ota_task.c:

 /*
  ****************************************************************************************
  * @brief Handle OTAS_TRANSIMIT_STATUS_IND msg fro OTA  *//**
  *
  * @param[in] msgid     OTAS_TRANSIMIT_STATUS_IND
  * @param[in] param     Pointer to struct otas_transimit_status_ind
  * @param[in] dest_id   TASK_APP
  * @param[in] src_id    TASK_OTA
  *
  * @return If the message was consumed or not.
  * @description
  *
  * This handler is used to inform the application of the ota transimition status now 
  ****************************************************************************************
  */
  int app_otas_start_handler(ke_msg_id_t const msgid, struct otas_transimit_status_ind const * param,
                             ke_task_id_t const dest_id, ke_task_id_t const src_id)
  {
      app_task_msg_hdl(msgid, param);
      
      return (KE_MSG_CONSUMED);    
  }

It means when OTA updata start,Client will send msg OTAS_TRANSIMIT_STATUS_IND to TASK_APP,then we will response for Client and start updata.

   case OTAS_TRANSIMIT_STATUS_IND:
   //only need response once when ota status is in ota status start request
   if(((struct otas_transimit_status_ind*)param)->status == OTA_STATUS_START_REQ)  
   {
      app_ota_ctrl_resp(START_OTA);
   }
   break;

OTA updata configure success.