Xbee changes 2
Fork of XBeeLib by
Diff: XBee/XBee.cpp
- Revision:
- 2:2ee1b6d51df2
- Parent:
- 1:794d1d3e4a08
- Child:
- 3:8662ebe83570
diff -r 794d1d3e4a08 -r 2ee1b6d51df2 XBee/XBee.cpp --- a/XBee/XBee.cpp Mon May 11 17:58:00 2015 +0200 +++ b/XBee/XBee.cpp Thu May 14 16:21:39 2015 +0200 @@ -28,9 +28,43 @@ Timer XBee::_timer; FrameBuffer XBee::_framebuf; +#if defined(DEVICE_SERIAL_FC) +bool XBee::check_radio_flow_control() +{ + AtCmdFrame::AtCmdResp cmdresp; + uint32_t value; + + if (_serial_flow_type == SerialBase::RTSCTS || _serial_flow_type == SerialBase::CTS) { + cmdresp = get_param("D7", &value); + if (cmdresp != AtCmdFrame::AtCmdRespOk) { + digi_log(LogLevelError, "Could not read CTS configuration. Error %d\r\n", cmdresp); + return false; + } + else if (value != 1) { + digi_log(LogLevelError, "Bad CTS configuration. Radio 'D7' param is %d and should be 1\r\n", value); + return false; + } + } + + if (_serial_flow_type == SerialBase::RTSCTS || _serial_flow_type == SerialBase::RTS) { + cmdresp = get_param("D6", &value); + if (cmdresp != AtCmdFrame::AtCmdRespOk) { + digi_log(LogLevelError, "Could not read RTS configuration. Error %d\r\n", cmdresp); + return false; + } + else if (value != 1) { + digi_log(LogLevelError, "Bad RTS configuration. Radio 'D6' param is %d and should be 1\r\n", value); + return false; + } + } + + return true; +} +#endif + /* Class constructor */ XBee::XBee(PinName tx, PinName rx, PinName reset, PinName rts, PinName cts, int baud) : - _mode(ModeUnknown), _type(Unknown), _timeout_ms(SYNC_OPS_TIMEOUT_MS), _hw_version(0), _fw_version(0), _dev_addr64(ADDR64_UNASSIGNED), _dev_addr16(ADDR16_UNKNOWN), + _mode(ModeUnknown), _type(Unknown), _hw_version(0), _fw_version(0), _timeout_ms(SYNC_OPS_TIMEOUT_MS), _dev_addr64(ADDR64_UNASSIGNED), _dev_addr16(ADDR16_UNKNOWN), _reset(NULL), _tx_options(0), _bc_radius(0), _hw_reset_cnt(0), _wd_reset_cnt(0), _reset_timeout(0), _modem_status_handler(NULL), _modem_status(AtCmdFrame::HwReset), _initializing(true), _pm_mode(SleepDisabled) { @@ -48,13 +82,8 @@ _serial_flow_type = SerialBase::Disabled; #if defined(DEVICE_SERIAL_FC) if (rts != NC && cts != NC) { -#if !(defined AVOID_USING_RTS) _serial_flow_type = SerialBase::RTSCTS; _uart->set_flow_control(_serial_flow_type, rts, cts); -#else - _serial_flow_type = SerialBase::CTS; - _uart->set_flow_control(_serial_flow_type, cts); -#endif } else if (rts != NC && cts == NC) { _serial_flow_type = SerialBase::RTS; @@ -142,6 +171,11 @@ digi_log(LogLevelInfo, "ADDR64: %08x:%08x\r\n", UINT64_HI32(_dev_addr64), UINT64_LO32(_dev_addr64)); digi_log(LogLevelInfo, "ADDR16: %04x\r\n", _dev_addr16); +#if defined(DEVICE_SERIAL_FC) + bool valid_radio_fc = check_radio_flow_control(); + assert(valid_radio_fc == true); +#endif + _initializing = false; if (_modem_status_handler != NULL) { const ApiFrame frame = ApiFrame(ApiFrame::AtModemStatus, (uint8_t *)&_modem_status, sizeof(_modem_status)); @@ -304,6 +338,7 @@ * object has been completed and the virtual functions filled */ void XBee::radio_status_update(AtCmdFrame::ModemStatus modem_status) { + UNUSED_PARAMETER(modem_status); } void XBee::set_timeout(uint16_t timeout_ms) @@ -653,6 +688,8 @@ RadioStatus XBee::config_pm_timing(uint32_t before_sleep_ms, uint32_t total_sleep_period_ms) { + UNUSED_PARAMETER(before_sleep_ms); + UNUSED_PARAMETER(total_sleep_period_ms); return Success; }