Digi International Inc. / Mbed 2 deprecated XBeeDM_power_mngmnt_pin_sleep

Dependencies:   XBeeLib mbed

Fork of XBeeZB_power_mngmnt_pin_sleep by Digi International Inc.

Revision:
7:adbc169e77b2
Parent:
4:247facc3db2a
--- a/main.cpp	Thu Jul 28 10:20:26 2016 +0200
+++ b/main.cpp	Thu Jul 28 10:35:08 2016 +0000
@@ -57,18 +57,18 @@
     while(is_radio_sleeping());
 }
 
-static void send_sample(XBeeZB& xbee)
+static void send_sample(XBeeDM& xbee)
 {
     char data[60];
     static uint16_t sample = 0;
     const uint16_t data_len = sprintf(data, "\r\nSensor sample: %u, next sample in %lu seconds\r\n",
 								 sample++, (uint32_t)SLEEP_SECONDS);
 
-    const TxStatus txStatus = xbee.send_data_to_coordinator((const uint8_t *)data, data_len);
+    const TxStatus txStatus = xbee.send_data_broadcast((const uint8_t *)data, data_len);
     if (txStatus == TxStatusSuccess)
-        log_serial->printf("send_data_to_coordinator OK\r\n");
+        log_serial->printf("send_data OK\r\n");
     else
-        log_serial->printf("send_data_to_coordinator failed with %d\r\n", (int) txStatus);
+        log_serial->printf("send_data failed with %d\r\n", (int) txStatus);
 }
 
 int main()
@@ -86,45 +86,33 @@
 
     log_serial = new Serial(DEBUG_TX, DEBUG_RX);
     log_serial->baud(9600);
-    log_serial->printf("Sample application to demo pin sleep power management with the XBeeZB\r\n\r\n");
+    log_serial->printf("Sample application to demo pin sleep power management with the XBeeDM\r\n\r\n");
     log_serial->printf(XB_LIB_BANNER);
 
 #if defined(ENABLE_LOGGING)
     new DigiLoggerMbedSerial(log_serial, LogLevelInfo);
 #endif
 
-    XBeeZB xbee = XBeeZB(RADIO_TX, RADIO_RX, RADIO_RESET, NC, NC, 9600);
+    XBeeDM xbee = XBeeDM(RADIO_TX, RADIO_RX, RADIO_RESET, NC, NC, 9600);
 
     RadioStatus radioStatus = xbee.init();
     MBED_ASSERT(radioStatus == Success);
 
     /* Configure Sleep mode */
-    cmdresp = xbee.set_param("SM", 1);  /* Pin Sleep */
+    cmdresp = xbee.set_param("SM", 1); /* Pin Hibernate */
     if (cmdresp != AtCmdFrame::AtCmdRespOk) {
         log_serial->printf("SM Failed!!\r\n");
     }
 
-    awake_radio();
-
-    /* Wait until the device has joined the network */
-    log_serial->printf("Waiting for device to join the network: ");
-    while (!xbee.is_joined()) {
-        wait_ms(1000);
-        log_serial->printf(".");
-    }
-    log_serial->printf("OK\r\n");
-
     /* Start sending samples */
     while (1) {
-        if (xbee.is_joined()) {
-            /* Awake the radio */
-            awake_radio();
+        /* Awake the radio */
+        awake_radio();
 
-            send_sample(xbee);
+        send_sample(xbee);
 
-            /* Sleep the radio again */
-            sleep_radio();
-        }
+        /* Sleep the radio again */
+        sleep_radio();
 
         wait(SLEEP_SECONDS);
     }