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: sgam_mdw sgam_mdw_NUCLEOF429ZI_impl Cayenne-LPP
Revision 26:8c55aac7887f, committed 2019-07-13
- Comitter:
- AndersonIctus
- Date:
- Sat Jul 13 11:18:35 2019 -0300
- Parent:
- 25:5e1e54c6eb0e
- Child:
- 27:3b407427f564
- Commit message:
- - Mudancas para o write de conteudo !
Changed in this revision
--- a/main.cpp Fri Jul 12 01:50:10 2019 +0000
+++ b/main.cpp Sat Jul 13 11:18:35 2019 -0300
@@ -7,6 +7,8 @@
#include "LoRaWANInterface.h"
#include "lora_radio_helper.h"
+#include "CayenneLPP.h"
+
ControlImpl ctrl;
#define D_LOG(args...) printf(args)
@@ -55,8 +57,7 @@
data->prepareCallBack(callbacks);
// Flags de leitura !!
- data->read_port = MBED_CONF_LORA_APP_PORT;
- data->read_flags = MSG_CONFIRMED_FLAG|MSG_UNCONFIRMED_FLAG;
+ data->lora_port = MBED_CONF_LORA_APP_PORT;
/////////////////////////////////////////////////////////////////////////////////////////////
// 2 - INICIALIZA A CONEXAO
@@ -90,6 +91,9 @@
{
printf("receive_message()\n");
+ LoraData* data = (LoraData*) comm->getData();
+ data->read_write_flags = MSG_CONFIRMED_FLAG|MSG_UNCONFIRMED_FLAG;
+
uint8_t rx_buffer[50] = { 0 };
int16_t retcode = comm->read( rx_buffer, sizeof(rx_buffer) );
if (retcode < 0) {
@@ -112,36 +116,39 @@
printf("send_message()\n");
// YOUR CODE HERE
- // int16_t temperature = 10;
- // printf("temperature = (%d)\n", temperature);
+ int16_t temperature = 10;
+ printf("temperature = (%d)\n", temperature);
- // CayenneLPP payload(50);
- // payload.addTemperature(1, temperature);
+ CayenneLPP payload(50);
+ payload.addTemperature(1, temperature);
- // int16_t retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, payload.getBuffer(), payload.getSize(), MSG_UNCONFIRMED_FLAG);
- // printf("lorawan.send = retcode [%d]\n",retcode);
+ LoraData* data = (LoraData*) comm->getData();
+ data->read_write_flags = MSG_UNCONFIRMED_FLAG;
- // if (retcode < 0) {
- // retcode == LORAWAN_STATUS_WOULD_BLOCK
- // ? printf("send - Duty cycle violation\r\n")
- // : printf("send() - Error code %d \r\n", retcode);
+ int16_t retcode = comm->write(payload.getBuffer(), payload.getSize());
+ printf("lorawan.send = retcode [%d]\n",retcode);
+
+ if (retcode < 0) {
+ retcode == LORAWAN_STATUS_WOULD_BLOCK
+ ? printf("send - Duty cycle violation\r\n")
+ : printf("send() - Error code %d \r\n", retcode);
- // if (retcode == LORAWAN_STATUS_NO_ACTIVE_SESSIONS)
- // printf("\r\n|-1017 - LORAWAN_STATUS_NO_ACTIVE_SESSIONS");
+ if (retcode == LORAWAN_STATUS_NO_ACTIVE_SESSIONS)
+ printf("\r\n|-1017 - LORAWAN_STATUS_NO_ACTIVE_SESSIONS");
- // if (retcode == LORAWAN_STATUS_WOULD_BLOCK) { //retry in 3 seconds
- // ev_queue.call_in(3000, send_message);
- // } else {
- // ev_queue.call_in(TX_INTERVAL, send_message);
- // }
+ if (retcode == LORAWAN_STATUS_WOULD_BLOCK) { //retry in 3 seconds
+ ev_queue.call_in(3000, send_message);
+ } else {
+ ev_queue.call_in(TX_INTERVAL, send_message);
+ }
- // return;
- // }
+ return;
+ }
- // ev_queue.call_in(TX_INTERVAL, send_message);
+ ev_queue.call_in(TX_INTERVAL, send_message);
- // receive_message();
- // printf("%d bytes scheduled for transmission \r\n", retcode);
+ receive_message();
+ printf("%d bytes scheduled for transmission \r\n", retcode);
}
/**
--- a/sgam_mdw.lib Fri Jul 12 01:50:10 2019 +0000 +++ b/sgam_mdw.lib Sat Jul 13 11:18:35 2019 -0300 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/AndersonIctus/code/sgam_mdw/#5c06daa180c2 +https://os.mbed.com/users/AndersonIctus/code/sgam_mdw/#cb5a0a555a53
--- a/sgam_mdw_NUCLEOF429ZI_impl.lib Fri Jul 12 01:50:10 2019 +0000 +++ b/sgam_mdw_NUCLEOF429ZI_impl.lib Sat Jul 13 11:18:35 2019 -0300 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/AndersonIctus/code/sgam_mdw_NUCLEOF429ZI_impl/#4303afb2198f +https://os.mbed.com/users/AndersonIctus/code/sgam_mdw_NUCLEOF429ZI_impl/#2dda4a91be01