Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Servo Cayenne-LPP
Diff: main.cpp
- Revision:
- 57:5ec0379d69d6
- Parent:
- 56:39847849d219
- Child:
- 58:81c66fac6476
--- a/main.cpp Wed Aug 21 07:01:49 2019 +0100
+++ b/main.cpp Mon Sep 30 18:06:49 2019 +0000
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#include <stdio.h>
-
+#include "CayenneLPP.h"
#include "lorawan/LoRaWANInterface.h"
#include "lorawan/system/lorawan_data_structures.h"
#include "events/EventQueue.h"
@@ -33,6 +33,23 @@
uint8_t tx_buffer[30];
uint8_t rx_buffer[30];
+#define MAX_SIZE 200 // depends on spreading factor and frequency used
+
+CayenneLPP Payload(MAX_SIZE);
+
+float celsius = -4.1;
+float accel[] = {1.234, -1.234, 0};
+float rh = 30;
+float hpa = 1014.1;
+float latitude = 42.3519;
+float longitude = -87.9094;
+float altitude=10;
+
+int size = 0;
+
+
+
+
/*
* Sets up an application dependent transmission timer in ms. Used only when Duty Cycling is off for testing
*/
@@ -149,7 +166,9 @@
* Sends a message to the Network Server
*/
static void send_message()
+
{
+
uint16_t packet_len;
int16_t retcode;
int32_t sensor_value;
@@ -164,11 +183,19 @@
return;
}
- packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %d",
- sensor_value);
+ /* packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %d",
+ sensor_value);*/
+
+ Payload.reset();
+ size = Payload.addTemperature(1, (float) sensor_value*10.0);
+ // LORA_SEND(Payload.getBuffer(), Payload.getSize());
+ // Payload.copy(tx_buffer);
+ retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, Payload.getBuffer(), Payload.getSize(),
+ MSG_UNCONFIRMED_FLAG);
+
- retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len,
- MSG_UNCONFIRMED_FLAG);
+ /* retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len,
+ MSG_UNCONFIRMED_FLAG);*/
if (retcode < 0) {
retcode == LORAWAN_STATUS_WOULD_BLOCK ? printf("send - WOULD BLOCK\r\n")