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

Files at this revision

API Documentation at this revision

Comitter:
stormysun513
Date:
Sun May 22 14:29:58 2016 +0000
Parent:
20:f6e313950373
Commit message:
Saperate turn on and off command into different packet headers

Changed in this revision

src/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/src/main.cpp	Sat May 21 09:13:27 2016 +0000
+++ b/src/main.cpp	Sun May 22 14:29:58 2016 +0000
@@ -11,8 +11,8 @@
 #include "ringBuffer.h"
 #include "application.h"
 
-#define DEVICE_NAME                      "ket_048"
-#define CODE_VERSION                     7
+#define DEVICE_NAME                      "ket_045"
+#define CODE_VERSION                     8
 
 #define SDA_PIN                          P0_8
 #define SCL_PIN                          P0_9
@@ -88,7 +88,7 @@
 }UARTRxStateTypeDef;
 
 typedef enum {
-    BLE_SWITCH_MONITORING = 0,                      // Enable/Disable device monitoring
+    BLE_TURNON_MONITORING = 0,                      // Enable/Disable device monitoring
     BLE_CHANGE_CASSETTE_ID,                         // Write ID to saliva cassette
     BLE_REQUEST_SALIVA_VOLTAGE,                     // Turn on saliva sampling periodically
     BLE_REQUEST_IMAGE_INFO,                         // Request image header
@@ -98,7 +98,8 @@
     BLE_SHUTDOWN,                                   // Shutdown device
     BLE_UNLOCK_BUTTON,                              // Unlock Button
     BLE_UART_DEBUG,                                 // Reserved for debug   Value: 0x09
-    BLE_REQUEST_DEVICE_INFO                         // Request code version
+    BLE_REQUEST_DEVICE_INFO,                        // Request code version
+    BLE_CLOSE_MONITORING
 }BLECommandTypeDef;
 
 /* BLE Callback functions */
@@ -475,8 +476,11 @@
         BLECommandTypeDef command = static_cast<BLECommandTypeDef>(uartTxPayload[0]);
         bool isUARTCommand = false;
         switch(command){
-        case BLE_SWITCH_MONITORING:
-            isMonitoring = !isMonitoring;
+        case BLE_TURNON_MONITORING:
+            isMonitoring = true;
+            break;
+        case BLE_CLOSE_MONITORING:
+            isMonitoring = false;
             break;
         case BLE_REQUEST_SALIVA_VOLTAGE:
             waitHeader = SYS_HEADER_SALIVA_VOLTAGE;