add senet packet format

Dependencies:   Senet_Packet mDot_X_NUCLEO_IKS01A1 libmDot-dev-mbed5-deprecated

Fork of mDot-IKS01A1 by Peter Ferland

Files at this revision

API Documentation at this revision

Comitter:
mfiore
Date:
Fri Apr 07 22:18:38 2017 +0000
Parent:
11:1425f2e65663
Child:
13:3a0a00664054
Commit message:
add senet packet format

Changed in this revision

Senet_Packet.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Senet_Packet.lib	Fri Apr 07 22:18:38 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Senet/code/Senet_Packet/#17e4e5f99d0c
--- a/main.cpp	Tue Feb 14 20:36:21 2017 +0000
+++ b/main.cpp	Fri Apr 07 22:18:38 2017 +0000
@@ -3,6 +3,7 @@
 #include "x_nucleo_iks01a1.h"
 #include "dot_util.h"
 #include "RadioEvent.h"
+#include "senet_packet.h"
 #include <cmath>
 
 // mDot UDK board demo with X-NUCLEO-IKS01A1 sensor card
@@ -22,12 +23,12 @@
 static bool public_network = true;
 #elif defined(SENET)
 // Network Id for Senet public network
-static uint8_t network_id[] = {0x00,0x25,0x0C,0x00,0x00,0x01,0x00,0x01};
+static uint8_t network_id[] = { 0x00, 0x25, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x01 };
 // Register at or Sign in to http://portal.senetco.com/ and register your NodeId to receive your AppId
 // {0xD3,0x5A,0x30,0x60,0xA6,0x0D,0x9E,0xEA,0xD9,0xA1,0x19,0x61,0x4F,0x29,0x9E,0x5B}
-static uint8_t network_key[] =  {0x5F,0x7B,0x08,0x15,0x55,0x69,0x9A,0x2E,0x3C,0x91,0xE3,0xFE,0xF0,0x2A,0x77,0x79};
+static uint8_t network_key[] =  { 0xFD, 0x68, 0xE9, 0xB5, 0x7C, 0xCA, 0x5E, 0xD6, 0xAD, 0xF6, 0x23, 0xCB, 0x03, 0x26, 0x68, 0xF4 };
 // 1 For Senet, configurable on your Conduit
-static uint8_t frequency_sub_band = 1;
+static uint8_t frequency_sub_band = 0;
 // True for Senet, false for your Conduit.
 static bool public_network = true;
 #else
@@ -135,8 +136,6 @@
 
     
     while (true) {
-        std::vector<uint8_t> tx_data;
-
         // join network if not joined
         if (!dot->getNetworkJoinStatus()) {
             join_network();
@@ -189,6 +188,7 @@
          * Resolution: 0.01 degrees/s signed msb per axis
         */
         
+        /*
         //temp floats
         float value1, value2;
         
@@ -249,8 +249,21 @@
             tx_data.push_back(uint8_t(0xFF & (accel_vector[i] >> 8)));
             tx_data.push_back(uint8_t(0xFF & accel_vector[i]));
         }
+        */
         
+        std::vector<uint8_t> tx_data;
+        uint8_t buffer[64];
+        float value;
         
+        SensorPacket packet(buffer, sizeof(buffer));
+        
+        // get temperature
+        temp_sensor1->GetTemperature(&value);
+        logInfo("temperature: %2.1f C", value);
+        packet.addSensorValue(0, 2, (int16_t)value);
+        packet.serialize();
+        
+        tx_data.assign(packet.payload(), packet.payload() + packet.length());
         send_data(tx_data);
         
         if(deep_sleep){
@@ -262,10 +275,12 @@
         
 
         // ONLY ONE of the three functions below should be uncommented depending on the desired wakeup method
-        sleep_wake_rtc_only(deep_sleep);
+        //sleep_wake_rtc_only(deep_sleep);
         //sleep_wake_interrupt_only(deep_sleep);
         //sleep_wake_rtc_or_interrupt(deep_sleep);
         
+        wait(5);
+        
     }
 
     return 0;