Program is unlisted and not meant for wide distribution. It doesn't contain any confidential information, but could use polishing and commenting

Revision:
1:71bd3e921d6c
Parent:
0:14ce95b48075
diff -r 14ce95b48075 -r 71bd3e921d6c SensorService.h
--- a/SensorService.h	Thu Jul 07 11:53:23 2016 +0000
+++ b/SensorService.h	Fri Oct 14 07:57:41 2016 +0000
@@ -3,7 +3,7 @@
 
 #include "BLE.h"
 #include "UUID.h"
-#include "Utils.h"
+//#include "Utils.h"
 
 const UUID::LongUUIDBytes_t SENS_SERVICE_UUID = {0x00,0x00,0x00,0x00,0x00,0x01,0x11,0xe1,0x9a,0xb4,0x00,0x02,0xa5,0xd5,0xc5,0x1b}; //Primary service
 const UUID::LongUUIDBytes_t VOLT_CHAR_UUID = {0x40,0x00,0x00,0x00,0x00,0x01,0x11,0xe1,0xac,0x36,0x00,0x02,0xa5,0xd5,0xc5,0x1b}; //Voltage characteristic
@@ -36,13 +36,13 @@
         //Voltage GATT server functions
             void sendVoltage (uint32_t volt_value, uint16_t TimeStamp)
             {
-                STORE_LE_16(voltage, TimeStamp);
-                STORE_LE_32(voltage+2, volt_value);
+                memcpy(&voltage, &TimeStamp, 2);
+                memcpy(&voltage+2, &volt_value, 4);
                 uint16_t volt_handle = voltageCharacteristic.getValueAttribute().getHandle();
-                //printf("Send voltage handle: %d\n", volt_handle);
+                printf("Send voltage handle: %d\n", volt_handle);
                 memcpy(pastVoltage, voltage, VOLT_DATA_LEN);
                 ble.gattServer().write(volt_handle, voltage, VOLT_DATA_LEN, 0);
-                //printf("Update\n");
+                printf("Update\n");
             }
             
             void updateVoltage(uint32_t volt_value, uint16_t TimeStamp)
@@ -59,13 +59,13 @@
           //Current GATT server functions
             void sendCurrent (uint32_t curr_value, uint16_t TimeStamp)
             {
-                STORE_LE_16(current, TimeStamp);
-                STORE_LE_32(current+2, curr_value);
+                memcpy(&current, &TimeStamp, 2);
+                memcpy(&current+2, &curr_value, 4);
                 uint16_t curr_handle = currentCharacteristic.getValueAttribute().getHandle();
-                //printf("Send voltage handle: %d\n", volt_handle);
+                printf("Send current handle: %d\n", curr_handle);
                 memcpy(pastCurrent, current, CURR_DATA_LEN);
                 ble.gattServer().write(curr_handle, current, CURR_DATA_LEN, 0);
-                //printf("Update\n");
+                printf("Update\n");
             }
             
             void updateCurrent(uint32_t curr_value, uint16_t TimeStamp)
@@ -83,8 +83,21 @@
             void enNotify (Gap::Handle_t handle)
             {
  //               printf("\n\r\n\renNotify, Handle: 0x%02X\n", handle);
-                if (isVoltageHandle(handle)) { isEnabledVoltageNotify = true; memset(voltage,0,VOLT_DATA_LEN); return; }
-                if (isCurrentHandle(handle)) { isEnabledCurrentNotify = true; memset(current,0,CURR_DATA_LEN); return; }                    
+                if (isVoltageHandle(handle))
+                {
+                    isEnabledVoltageNotify = true;
+                    memset(voltage,0,VOLT_DATA_LEN);
+                    memset(pastVoltage, 0, VOLT_DATA_LEN);
+                    return;
+                }
+                
+                if (isCurrentHandle(handle))
+                {
+                    isEnabledCurrentNotify = true;
+                    memset(current,0,CURR_DATA_LEN);
+                    memset(pastCurrent, 0, CURR_DATA_LEN);
+                    return;
+                }                    
             }
 
     void disNotify (Gap::Handle_t handle)