C++ Wrapper around the IBM LMiC LoRaWAN implementation
Diff: Node.cpp
- Revision:
- 2:6fac10decfb3
- Parent:
- 1:7cfc59ba0797
- Child:
- 3:63ac55b3514a
--- a/Node.cpp Thu Jun 30 17:32:14 2016 +0000 +++ b/Node.cpp Thu Jun 30 18:49:11 2016 +0000 @@ -47,26 +47,14 @@ LMIC_setTxData2(15, LMIC.frame, 10, 0); } -int32_t randr(int32_t min, int32_t max) -{ - return (int32_t)rand() % (max - min + 1) + min; -} + namespace SimpleLoRaWAN { Node::Node() { - os_init(); - - // reset MAC state - LMIC_reset(); - LMIC_setDrTxpow(DR_SF12, 14); - - LMIC_startJoining(); - //while(LMIC.devaddr == 0){ - process(); - //}; + init(); } Node::~Node() @@ -74,6 +62,15 @@ } +void Node::init() +{ + os_init(); + + // reset MAC state + LMIC_reset(); + LMIC_setDrTxpow(DR_SF12, 14); +} + void Node::send(char* data, int size) { @@ -103,5 +100,6 @@ os_runloop_once(); } + } /* namespace SimpleLoRaWAN */