Lora

Dependencies:   Cayenne-LPP HTU21D

Files at this revision

API Documentation at this revision

Comitter:
lenriquez389
Date:
Fri Mar 01 23:54:58 2019 +0000
Parent:
48:dfce67eca082
Commit message:
er4Lora

Changed in this revision

Cayenne-LPP.lib Show annotated file Show diff for this revision Revisions of this file
HTU21D.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
mbed-lora-radio-drv.lib Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
diff -r dfce67eca082 -r 120e166cb735 Cayenne-LPP.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cayenne-LPP.lib	Fri Mar 01 23:54:58 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/myDevicesIoT/code/Cayenne-LPP/#5a9d65b33e85
diff -r dfce67eca082 -r 120e166cb735 HTU21D.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTU21D.lib	Fri Mar 01 23:54:58 2019 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/alipford3/code/HTU21D/#4fd07be6bad8
diff -r dfce67eca082 -r 120e166cb735 main.cpp
--- a/main.cpp	Wed Feb 13 18:37:07 2019 +0000
+++ b/main.cpp	Fri Mar 01 23:54:58 2019 +0000
@@ -19,20 +19,21 @@
 #include "lorawan/LoRaWANInterface.h"
 #include "lorawan/system/lorawan_data_structures.h"
 #include "events/EventQueue.h"
-
+#include "HTU21D.h"
 // Application helpers
 #include "DummySensor.h"
 #include "trace_helper.h"
 #include "lora_radio_helper.h"
-
+#include "CayenneLPP.h"
+#define MAX_SIZE 20
 using namespace events;
 
 // Max payload size can be LORAMAC_PHY_MAXPAYLOAD.
 // This example only communicates with much shorter messages (<30 bytes).
 // If longer messages are used, these buffers must be changed accordingly.
-uint8_t tx_buffer[30];
+//uint8_t tx_buffer[30];
 uint8_t rx_buffer[30];
-
+CayenneLPP Payload(MAX_SIZE);
 /*
  * Sets up an application dependent transmission timer in ms. Used only when Duty Cycling is off for testing
  */
@@ -59,7 +60,7 @@
  * Dummy sensor class object
  */
 DS1820  ds1820(PC_9);
-
+HTU21D temphumid(PB_14, PB_13); //Temp humid sensor || SDA, SCL
 /**
 * This event queue is the global event queue for both the
 * application and stack. To conserve memory, the stack is designed to run
@@ -150,26 +151,28 @@
  */
 static void send_message()
 {
-    uint16_t packet_len;
+    
     int16_t retcode;
-    float sensor_value;
+    int sensor_value;
+    int sensor_value_2;
 
-    if (ds1820.begin()) {
-        ds1820.startConversion();
-        sensor_value = ds1820.read();
-        printf("\r\n Dummy Sensor Value = %3.1f \r\n", sensor_value);
-        ds1820.startConversion();
-    } else {
-        printf("\r\n No sensor found \r\n");
-        return;
-    }
+    sensor_value = temphumid.sample_ctemp();
+    sensor_value_2=temphumid.sample_humid();
+    //uint16_t value=uint16_t(10*sensor_value);
+    // uint8_t tx_buffer[4]={0x01,0x67,uint8_t(value>>8),uint8_t(value%256)};
+    //packet_len=sizeof(tx_buffer);
+    //retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len,MSG_UNCONFIRMED_FLAG);
 
-    packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %3.1f",
-                         sensor_value);
+    
+    Payload.reset();
+    Payload.addTemperature(1, float(sensor_value));
+    Payload.addRelativeHumidity(0, float(sensor_value_2));
+    retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, Payload.getBuffer(), Payload.getSize(),MSG_UNCONFIRMED_FLAG);
+    //lorawan.send(Payload.getBuffer(), Payload.getSize());
 
-    retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len,
-                           MSG_UNCONFIRMED_FLAG);
-
+    
+    printf("Temperature: %d C\n\r", sensor_value);
+    printf("Humidite: %d \n\r", sensor_value_2);
     if (retcode < 0) {
         retcode == LORAWAN_STATUS_WOULD_BLOCK ? printf("send - WOULD BLOCK\r\n")
         : printf("\r\n send() - Error code %d \r\n", retcode);
@@ -182,9 +185,10 @@
         }
         return;
     }
-
+    /*
     printf("\r\n %d bytes scheduled for transmission \r\n", retcode);
     memset(tx_buffer, 0, sizeof(tx_buffer));
+    */
 }
 
 /**
@@ -206,7 +210,7 @@
         printf("%02x ", rx_buffer[i]);
     }
     printf("\r\n");
-    
+
     memset(rx_buffer, 0, sizeof(rx_buffer));
 }
 
diff -r dfce67eca082 -r 120e166cb735 mbed-lora-radio-drv.lib
--- a/mbed-lora-radio-drv.lib	Wed Feb 13 18:37:07 2019 +0000
+++ b/mbed-lora-radio-drv.lib	Fri Mar 01 23:54:58 2019 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-semtech-lora-rf-drivers#16958f814d505cfbbedfa16d9bf8b9dff0e0442b
+https://github.com/ARMmbed/mbed-semtech-lora-rf-drivers/#16958f814d505cfbbedfa16d9bf8b9dff0e0442b
diff -r dfce67eca082 -r 120e166cb735 mbed_app.json
--- a/mbed_app.json	Wed Feb 13 18:37:07 2019 +0000
+++ b/mbed_app.json	Fri Mar 01 23:54:58 2019 +0000
@@ -33,9 +33,9 @@
             "lora.over-the-air-activation": true,
             "lora.duty-cycle-on": true,
             "lora.phy": "EU868",
-            "lora.device-eui": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }",
-            "lora.application-eui": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }",
-            "lora.application-key": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }"
+            "lora.device-eui": "{ 0x00, 0x4E, 0xF9, 0x0F, 0x33, 0xAF, 0x0F, 0x57 }",
+            "lora.application-eui": "{ 0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x01, 0x7F, 0x8C }",
+            "lora.application-key": "{ 0x61, 0x81, 0x0B, 0xC9, 0xAE, 0x71, 0xBB, 0xF3, 0x4D, 0x0C, 0x5D, 0x53, 0x85, 0xAD, 0x03, 0x69 }"
         },
 
         "K64F": {