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:
15:c099dd509203
Parent:
14:f62d55b7dead
Child:
16:5552833a3401
--- a/src/main.cpp	Thu Apr 07 16:54:50 2016 +0000
+++ b/src/main.cpp	Fri Apr 08 16:45:17 2016 +0000
@@ -11,7 +11,8 @@
 #include "ringBuffer.h"
 #include "application.h"
 
-#define DEVICE_NAME                      "myble3"
+#define DEVICE_NAME                      "ket_041"
+#define CODE_VERSION                     2
 
 #define SDA_PIN                          P0_8
 #define SCL_PIN                          P0_9
@@ -139,6 +140,8 @@
 AnalogIn aniUSBChargeVolt(ANI_USB_CHARGE_PIN);
 AnalogIn aniBatterVolt(ANI_BATTERY_VOLTAGE_PIN); //P0_2 
 
+static const uint8_t codeVersion = CODE_VERSION; 
+
 /* State variables for application status, UARTRX data parsing status, 
     waiting header type and main loop trigger */
 static SystemStateTypeDef systemState = SYS_RELAXING_BUTTON;
@@ -163,6 +166,7 @@
 
 static bool isCheckBuf = false;
 static bool isRoutine = false;
+static bool isInserted = false;
 static bool isEnterMainLoop = false;
 static bool infoNotification = false;
 static bool salivaPeriodically = false;
@@ -586,8 +590,8 @@
                 lowPowerCounter++;
             }
             #endif
-                
-            if(systemState == SYS_LOCKING_BUTTON)
+            
+            if(isInserted && systemState == SYS_LOCKING_BUTTON)
                 timerFlashInsertionLed();    
         }
     
@@ -624,11 +628,16 @@
     
     if(result == false){
         pLedInsertion->write(1);
+        isInserted = false;
         buf[1] = 0xFF;
         buf[2] = 0xFF;
     }
     else{
-        pLedInsertion->write(0);
+        isInserted = true;
+        if(systemState != SYS_LOCKING_BUTTON){
+            pLedInsertion->write(0);
+        }
+            
         if(systemState == SYS_POWERSAVING){
             pLedInsertion->write(1);
         }