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.
Fork of XBeeZB_power_mngmnt_pin_sleep by
Revision 7:adbc169e77b2, committed 2016-07-28
- Comitter:
- hbujanda
- Date:
- Thu Jul 28 10:35:08 2016 +0000
- Parent:
- 6:024d3461b982
- Child:
- 8:2ed4afd4964b
- Commit message:
- Initial commit
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- 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);
}
--- a/mbed.bld Thu Jul 28 10:20:26 2016 +0200 +++ b/mbed.bld Thu Jul 28 10:35:08 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/f9eeca106725 \ No newline at end of file
