first commit

Fork of XBeeLib by Digi International Inc.

Revision:
6:06522f3a6642
Parent:
4:629712865107
Child:
8:b5f4a0e92249
diff -r da2ea7a76243 -r 06522f3a6642 XBee802/XBee802.cpp
--- a/XBee802/XBee802.cpp	Thu Mar 31 11:39:30 2016 +0200
+++ b/XBee802/XBee802.cpp	Thu Jul 28 10:17:20 2016 +0200
@@ -58,16 +58,8 @@
 {
     AtCmdFrame::AtCmdResp cmdresp;
 
-    if (is_PRO()) {
-        if (channel < 0x0C || channel > 0x17) {
-            return Failure;
-        }
-    } else {
-        if (channel < 0x0B || channel > 0x1A) {
-            return Failure;
-        }
-    }
-
+    /* Pro and Non-Pro modules have different channels available. The at 
+       command will return an error if the selected channel is not available */
     cmdresp = set_param("CH", channel);
     if (cmdresp != AtCmdFrame::AtCmdRespOk) {
         return Failure;
@@ -118,6 +110,22 @@
     return Success;
 }
 
+RadioStatus XBee802::get_network_address(uint16_t * const  addr16)
+{
+    if (addr16 == NULL) {
+        return Failure;
+    }
+    AtCmdFrame::AtCmdResp cmdresp;
+
+    uint32_t var32;
+    cmdresp = get_param("MY", &var32);
+    if (cmdresp != AtCmdFrame::AtCmdRespOk) {
+        return Failure;
+    }
+    *addr16 = var32;
+    return Success;
+}
+
 RadioStatus XBee802::set_network_address(uint16_t  addr16)
 {
     AtCmdFrame::AtCmdResp cmdresp;
@@ -129,6 +137,34 @@
     return Success;
 }
 
+RadioStatus XBee802::get_node_discovery_timeout(uint16_t * const timeout_ms)
+{
+    AtCmdFrame::AtCmdResp cmdresp;
+    uint32_t var32;
+
+    cmdresp = get_param("NT", &var32);
+    if (cmdresp != AtCmdFrame::AtCmdRespOk) {
+        return Failure;
+    }
+    *timeout_ms = (uint16_t)var32;
+
+    /* No N? command available for this protocol. Add a fix 1s guard time */
+    *timeout_ms += 1000;
+
+    return Success;
+}
+
+RadioStatus XBee802::get_node_discovery_timeout(uint16_t * const timeout_ms, bool * const wait_for_complete_timeout)
+{
+    const RadioStatus status = get_node_discovery_timeout(timeout_ms);
+
+    /* This protocol requires to wait for the complete timeout before attempting
+       to execute other commands */
+    *wait_for_complete_timeout = true;
+
+    return status;
+}
+
 void XBee802::radio_status_update(AtCmdFrame::ModemStatus modem_status)
 {
     /* Update the radio status variables */