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.
Revision 10:9bf05e9b4cde, committed 2016-11-22
- Comitter:
- Sille Van Landschoot
- Date:
- Tue Nov 22 20:43:03 2016 +0100
- Parent:
- 9:cfe697b53d71
- Commit message:
- Add reset pin support with define directive
Changed in this revision
Node.cpp | Show annotated file Show diff for this revision Revisions of this file |
Node.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Node.cpp Sun Oct 16 09:57:58 2016 +0200 +++ b/Node.cpp Tue Nov 22 20:43:03 2016 +0100 @@ -37,8 +37,14 @@ namespace SimpleLoRaWAN { -Node::Node() +Node::Node():rfm95wReset(p15) { +#ifdef RFM95_RESET_CONNECTED + rfm95wReset = 0; + wait_ms(10); + rfm95wReset = 1; + wait_ms(10); +#endif init(); } @@ -53,12 +59,17 @@ // reset MAC state LMIC_reset(); - LMIC_setDrTxpow(DR_SF7, 14); + setSpreadFactor(DR_SF7); } void Node::send(char* data, int size) { + send((uint8_t*) data, size); +} + +void Node::send(uint8_t* data, int size) +{ memcpy (LMIC.frame, data, size); LMIC_setTxData2(15, LMIC.frame, size, 0); } @@ -100,5 +111,10 @@ LMIC_setLinkCheckMode(state); } +void Node::setSpreadFactor(int spreadfactor) +{ + LMIC_setDrTxpow(spreadfactor, 14); +} + } /* namespace SimpleLoRaWAN */
--- a/Node.h Sun Oct 16 09:57:58 2016 +0200 +++ b/Node.h Tue Nov 22 20:43:03 2016 +0100 @@ -24,9 +24,15 @@ #ifndef SIMPLE_LORAWAN_NODE_H_ #define SIMPLE_LORAWAN_NODE_H_ +#define RFM95_RESET_CONNECTED 1 // define if p15 is connected to RFM95W reset + #include "lmic.h" #include "stdint.h" +#ifdef RFM95_RESET_CONNECTED +#include "mbed.h" +#endif + namespace SimpleLoRaWAN { @@ -36,6 +42,7 @@ Node(); virtual ~Node(); void send(char* data, int size); + void send(uint8_t* data, int size); static void onEvent(ev_t ev); void process(); @@ -43,9 +50,14 @@ void disableLinkCheck(); void setLinkCheck(int state); + void setSpreadFactor(int spreadfactor); + private: void init(); void setLinkCheck(); +#ifdef RFM95_RESET_CONNECTED + DigitalOut rfm95wReset; +#endif }; } /* namespace SimpleLoRaWAN */