nRF51822 serves as the bridge between BLE central and MCU, which makes cental able to fetch photos from serial camera.

Dependencies:   BLE_API mbed nRF51822

Fork of nRF51822_blinky by RedBearLab

Revision:
19:03d39b923919
Parent:
18:d146cee0a80e
Child:
20:f6e313950373
--- a/src/main.cpp	Sun May 01 09:45:51 2016 +0000
+++ b/src/main.cpp	Thu May 19 14:55:06 2016 +0000
@@ -12,7 +12,7 @@
 #include "application.h"
 
 #define DEVICE_NAME                      "ket_041"
-#define CODE_VERSION                     5
+#define CODE_VERSION                     6
 
 #define SDA_PIN                          P0_8
 #define SCL_PIN                          P0_9
@@ -501,8 +501,11 @@
             shutdownDevice();
             break;
         case BLE_UNLOCK_BUTTON:
+        {
             systemState = SYS_RELAXING_BUTTON;
+            buttonState = BTN_IDLE;
             break;
+        }
         case BLE_UART_DEBUG:
         {
             uint8_t debugHeader = 0xF1;
@@ -610,8 +613,10 @@
             }
             #endif
             
-            if(isInserted && systemState == SYS_LOCKING_BUTTON)
-                timerFlashInsertionLed();    
+            if(isInserted && systemState == SYS_LOCKING_BUTTON){
+                timerFlashInsertionLed();
+            }
+            
         }
     
         if ( time % 400 == 4 ) {                       // 1s
@@ -650,6 +655,12 @@
         isInserted = false;
         buf[1] = 0xFF;
         buf[2] = 0xFF;
+        
+        // If no ID detected, system will unlock button automatically.  5/17
+        if(systemState == SYS_LOCKING_BUTTON){
+            systemState = SYS_RELAXING_BUTTON;
+            buttonState = BTN_IDLE;
+        }
     }
     else{
         isInserted = true;
@@ -814,7 +825,8 @@
         }
         break;
     }
-    case STM32_IMAGE_FORWARDING:{
+    case STM32_IMAGE_FORWARDING:
+    {
         if(setImgPktPayloadByID == false){
             if(numBytes >= UART_DATA_PACKET_PAYLOAD){
                 isEnterMainLoop = true;