Digi International Inc. / Mbed 2 deprecated XBeeDM_modem_status

Dependencies:   XBeeLib mbed

Fork of XBeeZB_modem_status by Digi International Inc.

Committer:
hbujanda
Date:
Thu May 14 16:24:34 2015 +0200
Revision:
4:18ca486c0130
Child:
6:a75fe0a5c249
Automatic upload

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hbujanda 4:18ca486c0130 1 /**
hbujanda 4:18ca486c0130 2 * Copyright (c) 2015 Digi International Inc.,
hbujanda 4:18ca486c0130 3 * All rights not expressly granted are reserved.
hbujanda 4:18ca486c0130 4 *
hbujanda 4:18ca486c0130 5 * This Source Code Form is subject to the terms of the Mozilla Public
hbujanda 4:18ca486c0130 6 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
hbujanda 4:18ca486c0130 7 * You can obtain one at http://mozilla.org/MPL/2.0/.
hbujanda 4:18ca486c0130 8 *
hbujanda 4:18ca486c0130 9 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
hbujanda 4:18ca486c0130 10 * =======================================================================
hbujanda 4:18ca486c0130 11 */
hbujanda 4:18ca486c0130 12
hbujanda 4:18ca486c0130 13 #include "mbed.h"
hbujanda 4:18ca486c0130 14 #include "XBeeLib.h"
hbujanda 4:18ca486c0130 15 #if defined(ENABLE_LOGGING)
hbujanda 4:18ca486c0130 16 #include "DigiLoggerMbedSerial.h"
hbujanda 4:18ca486c0130 17 using namespace DigiLog;
hbujanda 4:18ca486c0130 18 #endif
hbujanda 4:18ca486c0130 19
hbujanda 4:18ca486c0130 20 using namespace XBeeLib;
hbujanda 4:18ca486c0130 21
hbujanda 4:18ca486c0130 22 Serial *log_serial;
hbujanda 4:18ca486c0130 23
hbujanda 4:18ca486c0130 24 /** Callback function, invoked at modem status reception */
hbujanda 4:18ca486c0130 25 static void modem_status_cb(AtCmdFrame::ModemStatus status)
hbujanda 4:18ca486c0130 26 {
hbujanda 4:18ca486c0130 27 log_serial->printf("\r\nModem Status: 0x%x\r\n", status);
hbujanda 4:18ca486c0130 28 }
hbujanda 4:18ca486c0130 29
hbujanda 4:18ca486c0130 30 int main()
hbujanda 4:18ca486c0130 31 {
hbujanda 4:18ca486c0130 32 log_serial = new Serial(DEBUG_TX, DEBUG_RX);
hbujanda 4:18ca486c0130 33 log_serial->baud(9600);
hbujanda 4:18ca486c0130 34 log_serial->printf("Sample application to demo how to receive modem status changes with the XBeeZB\r\n\r\n");
hbujanda 4:18ca486c0130 35 log_serial->printf(XB_LIB_BANNER);
hbujanda 4:18ca486c0130 36
hbujanda 4:18ca486c0130 37 #if defined(ENABLE_LOGGING)
hbujanda 4:18ca486c0130 38 new DigiLoggerMbedSerial(log_serial, LogLevelInfo);
hbujanda 4:18ca486c0130 39 #endif
hbujanda 4:18ca486c0130 40
hbujanda 4:18ca486c0130 41 XBeeZB xbee = XBeeZB(RADIO_TX, RADIO_RX, RADIO_RESET, NC, NC, 9600);
hbujanda 4:18ca486c0130 42
hbujanda 4:18ca486c0130 43 /* Register callbacks */
hbujanda 4:18ca486c0130 44 xbee.register_modem_status_cb(&modem_status_cb);
hbujanda 4:18ca486c0130 45
hbujanda 4:18ca486c0130 46 RadioStatus const radioStatus = xbee.init();
hbujanda 4:18ca486c0130 47 MBED_ASSERT(radioStatus == Success);
hbujanda 4:18ca486c0130 48
hbujanda 4:18ca486c0130 49 while (true) {
hbujanda 4:18ca486c0130 50 xbee.process_rx_frames();
hbujanda 4:18ca486c0130 51 wait_ms(100);
hbujanda 4:18ca486c0130 52 log_serial->printf(".");
hbujanda 4:18ca486c0130 53 }
hbujanda 4:18ca486c0130 54
hbujanda 4:18ca486c0130 55 delete(log_serial);
hbujanda 4:18ca486c0130 56 }