App for BLE Nano to monitor the power consumption for a specific location, by intercepting the led flashes of a standard power meter. It counts and log the flashes for each second. It works with RedBear App for smart phone (Simple Chat App).

Dependencies:   BLE_API lib_mma8451q mbed nRF51822

Fork of nRF51822_DataLogger_with_Chat by Valentin Tanasa

Revision:
12:27e9c3db28b9
Parent:
11:baafa4f7a15e
diff -r baafa4f7a15e -r 27e9c3db28b9 myData.h
--- a/myData.h	Fri May 06 18:14:18 2016 +0000
+++ b/myData.h	Sun Aug 14 14:57:09 2016 +0000
@@ -1,11 +1,12 @@
 #include "ble_flash.h"
 #include "mbed.h"
 
-#define MAXBUFFER  99u //(((BLE_FLASH_PAGE_SIZE - 4 - sizeof(myData_t))/sizeof(myDataL_t))
-#define MAX_WORD_PAGE_DATA 254u // to be computed as round_next_int(MAXBUFFER*sizeof(myDataL_t)+sizeof(myData_t))
+//#define MAXBUFFER  99u //(((BLE_FLASH_PAGE_SIZE - 4 - sizeof(myData_t))/sizeof(myDataL_t))
+#define MAXBUFFER  251u //(((BLE_FLASH_PAGE_SIZE - 4 - sizeof(myData_t))/sizeof(myDataL_t))
+//#define MAX_WORD_PAGE_DATA 254u // to be computed as round_next_int(MAXBUFFER*sizeof(myDataL_t)+sizeof(myData_t))
 
 #define MAX_PAGE_NUM (NRF_FICR->CODESIZE - 1) // 255
-#define MIN_PAGE_NUM 155u
+#define MIN_PAGE_NUM 151u
 
 
 typedef struct{
@@ -32,11 +33,7 @@
 } connection_update_t;
 
 typedef struct {
-    uint16_t light;
-    uint16_t gndV;
-    uint16_t temp;
-    bool led_on;
-    bool led2_on;    
+    uint16_t hits;
 } myPayload_t;
 
 
@@ -48,7 +45,7 @@
 
 typedef struct {
     mdate_time_t datetime; // 6 bytes length
-    myPayload_t data; // 8 bytes lenth    
+    myPayload_t data; // 2 bytes lenth    
 } myData_t;
 
 typedef struct {
@@ -57,8 +54,8 @@
 } myDataLog_t;
 
 typedef struct {
-    myData_t startData;
-    myDataL_t myData;
+    myData_t startData; // 8 bytes
+    myDataL_t myData;   // 4 bytes
 } myDataLogShort_t;
 
 /* Return current page to be written in Flash */