A mbed library for the RN2483. Heavily based on the Sodaq_RN2483 library for Arduino (https://github.com/SodaqMoja/Sodaq_RN2483). This is currently under-going initial testing, but seems to work! Tested on a NRF51 and FRDM K64F.

Dependents:   rn2483-TestProgram

Revision:
8:c4069091afa1
Parent:
7:100ab85cc6d7
diff -r 100ab85cc6d7 -r c4069091afa1 RN2483.cpp
--- a/RN2483.cpp	Tue Nov 22 10:39:17 2016 +0000
+++ b/RN2483.cpp	Mon Dec 19 08:25:35 2016 +0000
@@ -125,6 +125,7 @@
 */
 uint8_t RN2483::sendReqAck(uint8_t port, const uint8_t* payload, uint8_t size, uint8_t maxRetries)
 {
+    // Need to implement retries! mac set retx
     return macTransmit(STR_CONFIRMED, port, payload, size);
 }
 
@@ -244,7 +245,7 @@
 */
 void RN2483::wakeUp()
 {
-    // "emulate" break condition
+   // "emulate" break condition
     _RN2483.send_break();
     // set baudrate
     _RN2483.baud(getDefaultBaudRate());
@@ -257,7 +258,7 @@
 */
 void RN2483::sleep(uint32_t sleepLength)
 {
-    if(sleepLength < 4294967296 && sleepLength > 100) {
+    if(sleepLength > 100) {
         _RN2483.printf("%s%u",STR_CMD_SLEEP,sleepLength);
         _RN2483.printf(CRLF);
     }
@@ -424,11 +425,7 @@
 */
 bool RN2483::setLinkCheckInterval(uint8_t linkCheckInterval)
 {
-    if(linkCheckInterval <= 65535) {
-        return setMacParam(STR_LNK_CHK, linkCheckInterval);
-    } else {
-        return false;
-    }
+    return setMacParam(STR_LNK_CHK, linkCheckInterval);
 }
 
 /**
@@ -439,11 +436,7 @@
 */
 bool RN2483::setBattery(uint8_t batLvl)
 {
-    if(batLvl <= 255) {
-        return setMacParam(STR_BAT, batLvl);
-    } else {
-        return false;
-    }
+    return setMacParam(STR_BAT, batLvl);
 }
 
 /**
@@ -458,7 +451,7 @@
     if((channelID <= 15 && channelID >= 3)) {
         if((frequency <=870000000 && frequency >= 863000000)||(frequency <=434790000 && frequency >= 433050000)) {
             char buffer [15];
-            int bytesWritten = sprintf(buffer, "%d %d", channelID, frequency);
+            int bytesWritten = sprintf(buffer, "%d %lu", channelID, frequency);
             // Check to make sure sprintf did not return an error before sending.
             if(bytesWritten > 0) {
                 return setMacParam(STR_CH_FREQ, buffer);
@@ -553,8 +546,9 @@
 bool RN2483::saveConfiguration()
 {
     // Forced to return true currently.
-    _RN2483.printf(STR_CMD_SAVE);
-    _RN2483.printf(CRLF);
+    // Currently broken due to the long length of time it takes save to return.
+    //_RN2483.printf(STR_CMD_SAVE);
+    //_RN2483.printf(CRLF);
     return true;
 }
 
@@ -800,7 +794,7 @@
     int c;
     Timer t;
     t.start();
-    unsigned long _startMillis = t.read_ms(); // get milliseconds
+    long _startMillis = t.read_ms(); // get milliseconds
     do { 
         if(_RN2483.readable()){
             c = _RN2483.getc();