Bluetooth Low Energy based Firmware Over The Air with Mbed. Mbed part is a external processor of the IoT devices and communicate with a Bluetooth module. The Bluetooth module have to support BLE and implement BLE FOTA profile designed by ours. BLE FOTA profile specification is available from our GIT hub wiki(https://github.com/sevencore/BLEFOTA).

Dependencies:   mbed

Fork of mbed_fota by KIM HyoengJun

Bluetooth Low Energy based Firmware Over The Air with Mbed. Mbed part is a external processor of the IoT devices and communicate with a Bluetooth module. The Bluetooth module have to support BLE and implement BLE FOTA profile designed by ours. BLE FOTA profile specification is available from our GIT hub wiki.

Revision:
4:60be78a172c2
Parent:
3:1e70387e1337
Child:
5:e11b23f9aacc
--- a/ext_fota/BleMsgHandler.cpp	Tue Jun 23 06:32:40 2015 +0000
+++ b/ext_fota/BleMsgHandler.cpp	Wed Jun 24 08:50:07 2015 +0000
@@ -1,5 +1,8 @@
 #include "BleMsgHandler.h"
 #include "dialog_fota_config.h"
+#include "diss_task.h"
+#include "app_task.h"
+
 
 namespace sevencore_fota{
 
@@ -72,13 +75,14 @@
 
 void BleMsgHandler::BleMsgHandle(void)
 {
+    uint8_t *msg;
+    ble_hdr msg_hdr;
+    unsigned short paramPos = 1 + sizeof(msg_hdr);
+    
     if( print_flag == 1)
         hostpc->printf("Ble-Massage Handle Function!\n");
-        
-    uint8_t *msg;
+    
     msg = (uint8_t*)MsgQ->DeQueue();
-    
-    ble_hdr msg_hdr;
     memcpy(&msg_hdr, &msg[1], sizeof(msg_hdr));
     
     if( print_flag == 1 )
@@ -88,8 +92,147 @@
     if (msg_hdr.bDstid != TASK_GTL)
         return;
     
+    switch( msg_hdr.bType )
+    {
+        case GAPM_CMP_EVT:
+            HandleGapmCmpEvt(msg_hdr.bType,(struct gapm_cmp_evt *)&msg[paramPos],msg_hdr.bDstid,msg_hdr.bSrcid);
+            break;
+        case GAPM_DEVICE_READY_IND:
+            gapm_device_ready_ind_handler(msg_hdr.bType,(void *)&msg[paramPos],msg_hdr.bDstid,msg_hdr.bSrcid,this);
+            break;
+        case GAPM_ADV_REPORT_IND:
+            gapm_adv_report_ind_handler(msg_hdr.bType,(struct gapm_adv_report_ind *)&msg[paramPos],msg_hdr.bDstid,msg_hdr.bSrcid);
+            break;
+        case GAPC_CMP_EVT:
+            HandleGapcCmpEvt(msg_hdr.bType,(struct gapc_cmp_evt *)&msg[paramPos],msg_hdr.bDstid,msg_hdr.bSrcid);
+            break;
+        case DISS_CREATE_DB_CFM:
+            diss_create_db_cfm_handler(msg_hdr.bType,(struct diss_create_db_cfm *)&msg[paramPos],msg_hdr.bDstid,msg_hdr.bSrcid,this);
+            break;
+        case DISS_DISABLE_IND:
+            break;
+        case DISS_ERROR_IND:
+            if ( print_flag == 1)
+                hostpc->printf("Rcved DISS_ERROR_IND Msg\n");
+            break;
+        default:
+            if( print_flag == 1)
+                hostpc->printf("Massage Type Not Defined ! \n");
+            break;
+    }
 }
 
+void BleMsgHandler::HandleGapmCmpEvt(unsigned short msgid,
+                    struct gapm_cmp_evt *param,
+                    unsigned short dest_id,
+                    unsigned short src_id)
+{
+    if (param->status == CO_ERROR_NO_ERROR)
+    {
+        switch(param->operation)
+        {
+            case GAPM_NO_OP:// No operation.
+                break;
+            case GAPM_RESET:// Reset BLE subsystem: LL and HL.
+                gapm_reset_completion_handler (msgid, (struct gapm_cmp_evt *)param, dest_id, src_id,this);
+                break;
+            case GAPM_CANCEL:// Cancel currently executed operation.
+                break;
+            case GAPM_SET_DEV_CONFIG:// Set device configuration
+                if( print_flag == 1)
+                    hostpc->printf("Adverting Start...\n");
+                gapm_set_dev_config_completion_handler(msgid, (struct gapm_cmp_evt *)param, dest_id, src_id,this);
+                break;
+            case GAPM_SET_DEV_NAME: // Set device name
+                break;
+            case GAPM_SET_CHANNEL_MAP:// Set device channel map
+                break;
+            case  GAPM_GET_DEV_NAME:// Get Local device name
+                break;
+            case GAPM_GET_DEV_VERSION:// Get Local device version
+                break;
+            case GAPM_GET_DEV_BDADDR:// Get Local device BD Address
+                break;
+            case GAPM_GET_WLIST_SIZE:// Get White List Size.
+                break;
+            case GAPM_ADD_DEV_IN_WLIST:// Add devices in white list.
+                break;
+            case GAPM_RMV_DEV_FRM_WLIST:// Remove devices form white list.
+                break;
+            case GAPM_CLEAR_WLIST:// Clear all devices from white list.
+                break;
+            case GAPM_ADV_NON_CONN:// Start non connectable advertising
+            case GAPM_ADV_UNDIRECT:// Start undirected connectable advertising
+            case GAPM_ADV_DIRECT:// Start directed connectable advertising
+                    break;
+            case GAPM_SCAN_ACTIVE:// Start active scan operation
+            case GAPM_SCAN_PASSIVE:   // Start passive scan operation
+                break;
+            case GAPM_CONNECTION_DIRECT:// Direct connection operation
+                break;
+            case GAPM_CONNECTION_AUTO:// Automatic connection operation
+                break;
+            case GAPM_CONNECTION_SELECTIVE:// Selective connection operation
+                break;
+            case GAPM_CONNECTION_NAME_REQUEST:// Name Request operation (requires to start a direct connection)
+                break;
+            case GAPM_RESOLV_ADDR:// Resolve device address
+                break;
+            case GAPM_GEN_RAND_ADDR:// Generate a random address
+                break;
+            case GAPM_USE_ENC_BLOCK:// Use the controller's AES-128 block
+                break;
+            case GAPM_GEN_RAND_NB:// Generate a 8-byte random number
+                break;
+            case GAPM_DBG_GET_MEM_INFO:// Get memory usage
+                break;
+            case GAPM_PLF_RESET:// Perform a platform reset
+                break;
+            case GAPM_GET_DEV_ADV_TX_POWER:// Get device advertising power level
+                break;
+        }
+    } 
+}
+
+void BleMsgHandler::HandleGapcCmpEvt(unsigned short msgid,
+                    struct gapc_cmp_evt *param,
+                    unsigned short dest_id,
+                    unsigned short src_id)
+{
+     switch(param->operation)
+    {
+        case GAPC_NO_OP: // No operation
+            break;
+        case GAPC_DISCONNECT: // Disconnect link
+            break;
+        case GAPC_GET_PEER_NAME: // Retrieve name of peer device
+            break; 
+        case GAPC_GET_PEER_VERSION: // Retrieve peer device version info.
+            break; 
+        case GAPC_GET_PEER_FEATURES: // Retrieve peer device features.
+            break; 
+        case GAPC_GET_CON_RSSI: // Retrieve connection RSSI.
+            break; 
+        case GAPC_GET_PRIVACY: // Retrieve Privacy Info.
+            break; 
+        case GAPC_GET_RECON_ADDR: // Retrieve Reconnection Address Value.
+            break; 
+        case GAPC_SET_PRIVACY: // Set Privacy flag.
+            break; 
+        case GAPC_SET_RECON_ADDR: // Set Reconnection Address Value.
+            break; 
+        case GAPC_UPDATE_PARAMS: // Perform update of connection parameters.
+            break; 
+        case GAPC_BOND: // Start bonding procedure.
+            break; 
+        case GAPC_ENCRYPT: // Start encryption procedure.
+            break; 
+        case GAPC_SECURITY_REQ: // Start security request procedure
+            break; 
+        case GAPC_GET_CON_CHANNEL_MAP: // Retrieve Connection Channel MAP.
+            break;
+    }
+}