![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
rfsdfg
Diff: main.cpp
- Revision:
- 60:f84a58324d38
- Parent:
- 56:39847849d219
--- a/main.cpp Thu Nov 28 09:01:59 2019 +0000 +++ b/main.cpp Wed Feb 03 12:24:26 2021 +0000 @@ -24,6 +24,7 @@ #include "DummySensor.h" #include "trace_helper.h" #include "lora_radio_helper.h" +#include "CayenneLPP.h" using namespace events; @@ -36,7 +37,7 @@ /* * Sets up an application dependent transmission timer in ms. Used only when Duty Cycling is off for testing */ -#define TX_TIMER 10000 +#define TX_TIMER 20000 /** * Maximum number of events for the event queue. @@ -59,7 +60,8 @@ * Dummy sensor class object */ DS1820 ds1820(PC_9); - +CayenneLPP cayenne(100); +AnalogIn lm35(A0); /** * This event queue is the global event queue for both the * application and stack. To conserve memory, the stack is designed to run @@ -152,23 +154,36 @@ { uint16_t packet_len; int16_t retcode; - int32_t sensor_value; + float sensor_value; + float lm35temp; if (ds1820.begin()) { ds1820.startConversion(); sensor_value = ds1820.read(); - printf("\r\n Dummy Sensor Value = %d \r\n", sensor_value); + printf("\r\n Dummy Sensor Value = %f \r\n", sensor_value); ds1820.startConversion(); } else { printf("\r\n No sensor found \r\n"); return; } + lm35temp=lm35.read()*330.0; - packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %d", - sensor_value); + cayenne.reset(); // vidage du payload cayenne + cayenne.addTemperature(2, lm35temp); + cayenne.addTemperature(1, sensor_value); // ajout de la valeur t° + cayenne.copy(tx_buffer); // copie dans le buffer LORA + packet_len=cayenne.getSize(); + retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len, +MSG_CONFIRMED_FLAG); + + packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %f",sensor_value); retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len, MSG_UNCONFIRMED_FLAG); + printf("\n lm35 : %.2f\n",lm35temp); + printf("\nMessage: "); + for(int i=0;i<packet_len;i++) printf("%02X ",tx_buffer[i]); + printf("\n"); if (retcode < 0) { retcode == LORAWAN_STATUS_WOULD_BLOCK ? printf("send - WOULD BLOCK\r\n")