test code

Dependencies:   HX711_weight

Revision:
81:883a1a95f20b
Parent:
80:167f8aabffca
Child:
82:d40c223b65f9
--- a/source/WEIGHTService.h	Mon Jun 24 03:57:20 2019 +0000
+++ b/source/WEIGHTService.h	Mon Jun 24 14:17:40 2019 +0000
@@ -18,9 +18,9 @@
 #define __BLE_WEIGHT_SERVICE_H__
 
 typedef struct  {
-        uint16_t integer;
+        int32_t integer;
         uint8_t decimal;
-    }WeightType_t;
+    }PACKED WeightType_t;
     
 class WEIGHTService {
 public:
@@ -46,12 +46,12 @@
 //        float newWeight = (float) newValue;
 //        ble.gattServer().write(weightState.getValueHandle(), 
 //        (uint8_t *)&newWeight, sizeof(float));
-        WeightType_t *weight;
-        weight->integer = (uint16_t)newValue;
-        float f_decimal = newValue - weight->integer;
-        weight->decimal = (uint8_t)(f_decimal* 100.0f);
+        WeightType_t weight;
+        weight.integer = (int32_t)newValue;
+        float f_decimal = newValue - weight.integer;
+        weight.decimal = (uint8_t)(f_decimal* 100.0f);
         ble.gattServer().write(weightState.getValueHandle(), 
-        (uint8_t *)weight, sizeof(WeightType_t));
+        (uint8_t *)&weight, sizeof(WeightType_t));
     }
 
 private: