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: MPU6050 Grove_temperature
Diff: communication/LoRaWanComm.cpp
- Revision:
- 8:e00fa6ea253c
- Parent:
- 7:8db3e62ac4e2
- Child:
- 10:d2ce206bd94e
diff -r 8db3e62ac4e2 -r e00fa6ea253c communication/LoRaWanComm.cpp
--- a/communication/LoRaWanComm.cpp Wed Jun 26 23:46:44 2019 -0300
+++ b/communication/LoRaWanComm.cpp Fri Jun 28 23:10:08 2019 -0300
@@ -1,28 +1,36 @@
#include "sgam_mdw.h"
#include "mbed.h"
#include "mbed_events.h"
+#include "LoRaWANInterface.h"
#include "LoRAWanComm.h"
-LoRAWanComm::LoRAWanComm(const char* parameters) { }
+LoRAWanComm::LoRAWanComm(const char* parameters): ev_queue() { }
LoRAWanComm::~LoRAWanComm() { }
int LoRAWanComm::initialize(LoraData* data) {
D_LOG("INITIALIZE %s! \r\n", this->getName() );
+
// INICIANDO O LORAWAN !!
- // lorawan(radio);
+ lorawan = new LoRaWANInterface(*data->radio);
- // // ev_queue
- // // 1 - Initialize LoRaWAN stack
- // if (lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) {
- // printf("LoRa initialization failed! \r\n");
- // return -1;
- // }
+ // 1 - Initialize LoRaWAN stack
+ if (lorawan->initialize(&ev_queue) != LORAWAN_STATUS_OK) {
+ printf("LoRa initialization failed! \r\n");
+ return -1;
+ }
return 1;
}
-int LoRAWanComm::finalize() { D_LOG("FINALIZE %s! \r\n", this->getName() ); return 1; }
+
+int LoRAWanComm::finalize() {
+ D_LOG("FINALIZE %s! \r\n", this->getName() );
+
+ if(lorawan != NULL) delete lorawan;
+
+ return 1;
+}
const char* LoRAWanComm::getName() {
return "LoRAWAN";
@@ -37,6 +45,17 @@
}
////////////////////////////////////////////////////////////////////////////////////
+
+void LoRAWanComm::prepareCallBack( lorawan_app_callbacks_t &callbacks ) {
+ // prepare application callbacks
+ lorawan->add_app_callbacks(&callbacks);
+}
+
+void LoRAWanComm::lora_event_handler(lorawan_event_t event) {
+
+}
+
+////////////////////////////////////////////////////////////////////////////////////
int LoRAWanComm::write(const char* data) {
return 0;
}