La idea es comunicarse con el nodeRed y realizar una conversion de float a string

Dependencies:   DHT HX711 libmDot-mbed5 ISL29011

Fork of EXPO_ANDA by Santiago García Eleisequi

Files at this revision

API Documentation at this revision

Comitter:
patricioalba
Date:
Sat Apr 28 01:01:09 2018 +0000
Parent:
27:3f2cb700dd45
Commit message:
Copi estuvo toqueteando el programa.; La idea es compartir los datos con el nodeRed para eso hay que hacer una conversion loca a de float a string y no se que...

Changed in this revision

examples/src/auto_ota_example.cpp Show annotated file Show diff for this revision Revisions of this file
examples/src/ota_example.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/examples/src/auto_ota_example.cpp	Tue Apr 17 18:10:04 2018 +0000
+++ b/examples/src/auto_ota_example.cpp	Sat Apr 28 01:01:09 2018 +0000
@@ -22,12 +22,12 @@
 // * either the network name and passphrase can be used or //
 //     the network ID (8 bytes) and KEY (16 bytes)         //
 /////////////////////////////////////////////////////////////
-static std::string network_name = "MultiTech";
-static std::string network_passphrase = "MultiTech";
+static std::string network_name = "xaviaiot";
+static std::string network_passphrase = "xaviaiot";
 static uint8_t network_id[] = { 0x6C, 0x4E, 0xEF, 0x66, 0xF4, 0x79, 0x86, 0xA6 };
 static uint8_t network_key[] = { 0x1F, 0x33, 0xA1, 0x70, 0xA5, 0xF1, 0xFD, 0xA0, 0xAB, 0x69, 0x7A, 0xAE, 0x2B, 0x95, 0x91, 0x6B };
-static uint8_t frequency_sub_band = 0;
-static bool public_network = false;
+static uint8_t frequency_sub_band = 1;
+static bool public_network = true;
 static uint8_t ack = 0;
 static bool adr = true;
 
--- a/examples/src/ota_example.cpp	Tue Apr 17 18:10:04 2018 +0000
+++ b/examples/src/ota_example.cpp	Sat Apr 28 01:01:09 2018 +0000
@@ -127,16 +127,15 @@
         logInfo("restoring network session from NVM");
         dot->restoreNetworkSession();
     }
-        uint16_t temp;
-        uint16_t hum;
-        uint16_t weight;
-        std::string datos;
-        
+                
         
     while (true) { 
+        float light;
+        float hum;
+        float weight;
+        uint8_t comma = 'T';
 
-    uint8_t array[8];
-        //std::vector<uint8_t> tx_data;
+        std::vector<uint8_t> tx_data;
 
         // join network if not joined
         if (!dot->getNetworkJoinStatus()) {
@@ -144,24 +143,41 @@
         }
         
 
-        temp = 20;//dht.ReadTemperature(CELCIUS);
-        hum = 30; //dht.ReadHumidity();
-        weight = 10;
+        light = 20.20;//dht.ReadTemperature(CELCIUS);
+        hum = 30.10; //dht.ReadHumidity();
+        weight = 10.52;
      
-        pc.printf("Temperatura: %d/t Humedad: %d/t Peso: %d\n",temp,hum,weight);
+        uint8_t* s_light;
+        int size_s_light = sprintf((char*)s_light,"%f",light);
+        //pc.printf("%s",s_light);
+        
+        //pc.printf("Temperatura: %d/t Humedad: %d/t Peso: %d\n",temp,hum,weight);
+        
+        //tx_data.push_back((light >> 8) & 0xFF);
+        //tx_data.push_back(light & 0xFF);
+        //logInfo("light: %lu [0x%04X]", light, light);
+        
+        //tx_data.push_back((comma >> 8) & 0xFF);
+        //tx_data.push_back(comma & 0xFF);
+        //logInfo("comma: %lu [0x%04X]", comma, comma);
         
-        //for (std::string::iterator it = datos.begin(); it != datos.end(); it++)
-        //tx_data.push_back((temp >> 8) & 0xFF);
-        //tx_data.push_back(temp & 0xFF);
+        //tx_data.push_back((hum >> 8) & 0xFF);
+        //tx_data.push_back(hum & 0xFF);
+        //logInfo("hum: %lu [0x%04X]", hum, hum);
+        
+        //tx_data.push_back(comma & 0xFF);
+        
+        //tx_data.push_back((weight >> 8) & 0xFF);
+        //tx_data.push_back(weight & 0xFF);
+        //logInfo("weight: %lu [0x%04X]", weight, weight);
+        
+        tx_data.begin();
+        tx_data.insert(s_light, size_s_light);
+        
+        send_data(tx_data);
+        
+        tx_data.end();
 
-int i;
-for (i = 0; i < 8; i++)
-{
-    array[i] = (temp >> (8 * i)) & 0xff;
-}
-
-        send(array);
-        
         //length = sprintf(pepe, "%d;%d;%d", weight, temp, hum);
         //std::vector<uint8_t> vec(pepe, pepe+ length / chat);