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:
3:1e70387e1337
Parent:
2:dba344c91bce
Child:
4:60be78a172c2
--- a/ext_fota/BleMsgHandler.cpp	Mon Jun 22 09:43:13 2015 +0000
+++ b/ext_fota/BleMsgHandler.cpp	Tue Jun 23 06:32:40 2015 +0000
@@ -1,4 +1,5 @@
 #include "BleMsgHandler.h"
+#include "dialog_fota_config.h"
 
 namespace sevencore_fota{
 
@@ -7,6 +8,8 @@
     print_flag = 0;
     device = _device;
     SerialM = new SerialManager(_device);
+    MsgQ = new MsgQueue(512);
+    memset(recv_msg,0,512);
 }
 
 BleMsgHandler::BleMsgHandler(Serial *_device, Serial *_hostpc)
@@ -15,11 +18,14 @@
     device = _device;
     hostpc = _hostpc;
     SerialM = new SerialManager(_device,_hostpc);
+    MsgQ = new MsgQueue(512);
+    memset(recv_msg,0,512);
 }
 
 BleMsgHandler::~BleMsgHandler(void)
 {
     free(SerialM);
+    free(MsgQ);
 }
 
 void BleMsgHandler::PrintTitle(void)
@@ -27,5 +33,64 @@
     if( print_flag == 1 )
         hostpc->printf("Sevencore Fota : BleMsg Handler Start\n");
 }
+
+void BleMsgHandler::BleMsgAlloc( unsigned short id,
+                                 unsigned short dest_id,
+                                 unsigned short src_id,
+                                 unsigned short data_len,
+                                 void *pdata,
+                                 uint8_t *msg )
+{
+    memset(msg,0,sizeof(msg));
+    msg[0] = 0x05;
+    memcpy(&msg[1],&id,sizeof(unsigned short));
+    memcpy(&msg[1+1*sizeof(unsigned short)],&dest_id,sizeof(unsigned short));
+    memcpy(&msg[1+2*sizeof(unsigned short)],&src_id,sizeof(unsigned short));
+    memcpy(&msg[1+3*sizeof(unsigned short)],&data_len,sizeof(unsigned short));
+    memcpy(&msg[1+4*sizeof(unsigned short)],pdata,data_len);
+}
+
+int BleMsgHandler::BleSendMsg(uint8_t *msg, unsigned short size)
+{
+   return  SerialM->SendToSerial(msg,size);
+}
+
+void BleMsgHandler::BleReceiveMsg(void)
+{
+    int receive_size = -1;//default
+    while(receive_size == -1)
+    {
+        receive_size = SerialM->ReceiveToSerial(recv_msg);
+    }
+    
+    uint8_t *msg;
+    msg = new uint8_t[receive_size];
+    memcpy(msg,recv_msg,receive_size);
+    memset(recv_msg,0,512);
+    MsgQ->EnQueue(msg);
+}
+
+void BleMsgHandler::BleMsgHandle(void)
+{
+    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 )
+        hostpc->printf(" handle msg : id(%d), dst(%d), src(%d), len(%d) !\n",
+         msg_hdr.bType, msg_hdr.bDstid, msg_hdr.bSrcid, msg_hdr.bLength);
+    
+    if (msg_hdr.bDstid != TASK_GTL)
+        return;
+    
+}
+
+
+
  
 }//namespace