DigiMesh Modem Status example for mbed XBeeLib By Digi
Fork of XBeeZB_modem_status by
Description
This example shows how to register a function callback to be aware of modem status changes. This library will call the registered callback whenever the XBee module radio modem changes its status
See Handling modem status changes chapter for more information.
Common Setup
Make sure you have a valid Example Common Setup
Example Setup
This example does not require any additional setup.
Running the example
Build and deploy the example to the mbed module.
Reset the mbed module so the example starts. You should see the example debug information through the debug interface configured in the 'Local Setup' chapter.
It you set up a network as described in the Common Setup section, you should see following modem status in the debug interface:
- Modem Status 0x0: Corresponds to 'HwReset' meaning 'Hardware reset'
main.cpp
- Committer:
- hbujanda
- Date:
- 2016-07-29
- Revision:
- 10:47db8cbb2e2d
- Parent:
- 9:51ef7cbb0037
File content as of revision 10:47db8cbb2e2d:
/** * Copyright (c) 2015 Digi International Inc., * All rights not expressly granted are reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. * * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 * ======================================================================= */ #include "mbed.h" #include "XBeeLib.h" #if defined(ENABLE_LOGGING) #include "DigiLoggerMbedSerial.h" using namespace DigiLog; #endif using namespace XBeeLib; Serial *log_serial; /** Callback function, invoked at modem status reception */ static void modem_status_cb(AtCmdFrame::ModemStatus status) { log_serial->printf("\r\nModem Status: 0x%x\r\n", status); } int main() { log_serial = new Serial(DEBUG_TX, DEBUG_RX); log_serial->baud(9600); log_serial->printf("Sample application to demo how to receive modem status changes with the XBeeDM\r\n\r\n"); log_serial->printf(XB_LIB_BANNER); #if defined(ENABLE_LOGGING) new DigiLoggerMbedSerial(log_serial, LogLevelInfo); #endif XBeeDM xbee = XBeeDM(RADIO_TX, RADIO_RX, RADIO_RESET, NC, NC, 9600); /* Register callbacks */ xbee.register_modem_status_cb(&modem_status_cb); RadioStatus const radioStatus = xbee.init(); MBED_ASSERT(radioStatus == Success); while (true) { xbee.process_rx_frames(); wait_ms(100); log_serial->printf("."); } delete(log_serial); }