[RN2483] Add some example code for new RN2483 library

Since I have rewritten the entire library, I may also add some short example code to illustrate the new async features.
This commit is contained in:
Gijs Noorlander
2020-02-17 23:28:24 +01:00
parent da5c15258e
commit ebd0dcf7c2
5 changed files with 290 additions and 6 deletions
@@ -27,6 +27,10 @@ void rn2xx3::setAsyncMode(bool enabled) {
_rn2xx3_handler.setAsyncMode(enabled);
}
bool rn2xx3::getAsyncMode() const {
return _rn2xx3_handler.getAsyncMode();
}
bool rn2xx3::autobaud()
{
// FIXME TD-er: Must fix this, as it is not working well.
@@ -166,6 +170,11 @@ rn2xx3_handler::RN_state rn2xx3::wait_command_accepted(unsigned long timeout)
return _rn2xx3_handler.wait_command_accepted(timeout);
}
bool rn2xx3::command_finished() const
{
return _rn2xx3_handler.command_finished();
}
String rn2xx3::getRx() {
return _rn2xx3_handler.get_rx_message();
}
+4
View File
@@ -40,6 +40,8 @@ public:
*/
void setAsyncMode(bool enabled);
bool getAsyncMode() const;
/*
* Transmit the correct sequence to the rn2xx3 to trigger its autobauding feature.
* After this operation the rn2xx3 should communicate at the same baud rate than us.
@@ -208,6 +210,8 @@ public:
rn2xx3_handler::RN_state wait_command_accepted(unsigned long timeout = 10000);
bool command_finished() const;
/*
* Change the datarate at which the RN2xx3 transmits.
* A value of between 0 and 5 can be specified,
@@ -456,6 +456,10 @@ void rn2xx3_handler::setAsyncMode(bool enabled) {
_asyncMode = enabled;
}
bool rn2xx3_handler::getAsyncMode() const {
return _asyncMode;
}
bool rn2xx3_handler::useOTAA() const {
return _otaa;
}
@@ -52,13 +52,17 @@ public:
// It will return when the state waiting for reply_received_rx2 has been reached, or the command has finished (due to error)
RN_state wait_command_accepted(unsigned long timeout = 10000);
// Check whether a command has finished.
bool command_finished() const;
/*
* Initialise the RN2xx3 and join the LoRa network (if applicable).
* This function can only be called after calling initABP() or initOTAA().
* The sole purpose of this function is to re-initialise the radio if it
* is in an unknown state.
*/
bool init();
bool init();
/*
* Initialise the RN2xx3 and join a network using personalization.
@@ -70,9 +74,9 @@ public:
* NwkSKey: Network Session Key as a HEX string.
* Example "AE17E567AECC8787F749A62F5541D522"
*/
bool initABP(const String& addr,
const String& AppSKey,
const String& NwkSKey);
bool initABP(const String& addr,
const String& AppSKey,
const String& NwkSKey);
// TODO: initABP(uint8_t * addr, uint8_t * AppSKey, uint8_t * NwkSKey)
@@ -128,6 +132,8 @@ public:
void setAsyncMode(bool enabled);
bool getAsyncMode() const;
bool useOTAA() const;
void setLastUsedJoinMode(bool isOTAA);
@@ -151,8 +157,6 @@ public:
private:
bool command_finished() const;
// Return the data to send
const String& get_send_data() const;