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:
7:3478c46cceef
Parent:
6:8dd20294b2aa
Child:
8:9eec2c246a85
--- a/ext_fota/BleMsgHandler.cpp	Fri Jul 17 14:04:12 2015 +0000
+++ b/ext_fota/BleMsgHandler.cpp	Mon Jul 20 09:22:15 2015 +0000
@@ -339,11 +339,12 @@
 void BleMsgHandler::FirmwareDataReceive(unsigned short code_size, char *version)
 {
     unsigned short stored_data_cnt = 0;
-    uint8_t databuf[FIRMWARE_DATA_FRAGMENT_SIZE]="/local/";
+    char path[20]="/local/";
+    char databuf[FIRMWARE_DATA_FRAGMENT_SIZE]="/local/";
     if(print_flag == 1)
         hostpc->printf("\n!!File name = %s!! code_size = %d\n",version,code_size);
-    memcpy(&databuf[7], version, 8);    
-    databuf[15] = '\0';   
+    strcat(databuf, version);
+    strcat(databuf, ".BIN");      
     hostpc->printf("\n!!name = %s!\n",databuf);
     
     
@@ -351,14 +352,19 @@
     struct dirent *p;
     while ((p = readdir(d)) != NULL)
     {
-        if(print_flag == 1)
-            hostpc->printf("%s\n", p->d_name);
+            hostpc->printf("%s,%d\n", p->d_name,strcmp(strchr(p->d_name,'.')+1,"BIN"));
+            if( strcmp(strchr(p->d_name,'.')+1,"BIN") == 0 ){
+                strcat(path,p->d_name);
+                hostpc->printf("%s\n",path);
+                remove(path);
+                strcpy(path,"/local/");
+            }
     }
     closedir(d); 
             
-    fp = fopen("/local/TEST.bin", "w");
+    fp = fopen(databuf, "w");
     
-    SerialM->DataReceive(databuf,2);
+    SerialM->DataReceive((uint8_t*)databuf,2);
     if(databuf[0] == 0x80 && databuf[1] == 0x46 ){
         if(print_flag == 1)
             hostpc->printf("\n!!Firmware Data Transmition Start!!\n");
@@ -372,18 +378,18 @@
     while( stored_data_cnt < code_size )
     {
         if( code_size - stored_data_cnt >= FIRMWARE_DATA_FRAGMENT_SIZE ){
-            SerialM->DataReceive(databuf,FIRMWARE_DATA_FRAGMENT_SIZE);
+            SerialM->DataReceive((uint8_t*)databuf,FIRMWARE_DATA_FRAGMENT_SIZE);
             fwrite(databuf, 1, FIRMWARE_DATA_FRAGMENT_SIZE, fp);
             stored_data_cnt += FIRMWARE_DATA_FRAGMENT_SIZE;    
         }else{
-            SerialM->DataReceive(databuf, code_size - stored_data_cnt);
+            SerialM->DataReceive((uint8_t*)databuf, code_size - stored_data_cnt);
             fwrite(databuf, 1, code_size - stored_data_cnt, fp);
             stored_data_cnt = code_size ;
         }
         memset(databuf,0,FIRMWARE_DATA_FRAGMENT_SIZE);      
     }
     
-    SerialM->DataReceive(databuf,2);
+    SerialM->DataReceive((uint8_t*)databuf,2);
     if(databuf[0] == 0x80 && databuf[1] == 0x46 ){
         if(print_flag == 1)
             hostpc->printf("\n!!Firmware Data Transmition END!!\n");