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:
11:baafa4f7a15e
Parent:
9:303d3628986a
Child:
12:27e9c3db28b9
--- a/myData.h	Tue Apr 26 20:15:41 2016 +0000
+++ b/myData.h	Fri May 06 18:14:18 2016 +0000
@@ -7,31 +7,23 @@
 #define MAX_PAGE_NUM (NRF_FICR->CODESIZE - 1) // 255
 #define MIN_PAGE_NUM 155u
 
-typedef struct{
-    uint8_t hour;
-    uint8_t min;
-    uint8_t sec;
-} mtime_t;
 
 typedef struct{
-    mtime_t currentTime;
-    mtime_t newTime;
-    bool updateTime;  // true if currentTime needs to be updated with newTime;
-} mtime_manager_t;
-
-
-typedef struct {
     uint8_t year;  // 20_XX, 2016 => 16;
     uint8_t month; // 1..12
     uint8_t day;  // 1..31    
-}date_t;
+    uint8_t hours;
+    uint8_t minutes;
+    uint8_t seconds;
+} mdate_time_t;
 
 
 typedef struct{
-    date_t currentDate;
-    date_t newDate;
-    bool updateDate;  // true if currentDate needs to be updated with newDate;
-} mdate_manager_t;
+    mdate_time_t currentDateTime;
+    mdate_time_t newDateTime;
+    bool updateDateTime;  // true if currentTime needs to be updated with newTime;
+} mdatetime_manager_t;
+
 
 typedef enum {
         eStartAdvertising =0,
@@ -50,14 +42,13 @@
 
 typedef struct {
     myPayload_t data;
-    uint8_t sec;
-    uint8_t min;    
+    uint8_t seconds;
+    uint8_t minutes;    
 } myDataL_t;
 
 typedef struct {
-    myPayload_t data;
-    mtime_t time;
-    date_t date;
+    mdate_time_t datetime; // 6 bytes length
+    myPayload_t data; // 8 bytes lenth    
 } myData_t;
 
 typedef struct {
@@ -79,21 +70,14 @@
 /* Return  page-N (thas has been written in Flash) */
 uint8_t flash_prev_N_Page(uint8_t nr_of_pages);
 
-/* save the current page Nr to flash*/
-void save_flash_curr_pageNr(date_t mdata);
-
-/* load from flash the current PageNr*/
-void load_flash_curr_pageNr(date_t* mdata);
-
 /*search the latest page written and extract the page_nr, date, and time*/
-void search_latest_in_flash(date_t * outDate, mtime_t * outTime);
+void search_latest_in_flash(mdate_time_t * outDateTime);
 
 /* Update current date and time with tseconds and also if there is a new date/time given */
-void update_time(mtime_manager_t* myTimeVar, mdate_manager_t* myDateVar, uint16_t tseconds);
+void update_time(mdatetime_manager_t* myDateTimeVar, uint16_t tseconds);
 
 /* Update buzzer with period in ms =0..9 and duty cycle = 0..9*/
 int buzz_int(PwmOut* buzzer, uint8_t period, uint8_t duty_cycle);
 
 /* Print on serial some error from main app*/
 void assert_error_app(bool condition, Serial *pc, uint16_t error, uint16_t line, const char* file);
-