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 XBeeLib by
Revision 3:8662ebe83570, committed 2015-05-18
- Comitter:
- spastor
- Date:
- Mon May 18 13:16:55 2015 +0200
- Parent:
- 2:2ee1b6d51df2
- Child:
- 4:629712865107
- Commit message:
- Automatic upload
Changed in this revision
--- a/DigiLogger.lib Thu May 14 16:21:39 2015 +0200 +++ b/DigiLogger.lib Mon May 18 13:16:55 2015 +0200 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/Digi-International-Inc/code/DigiLogger/#304026cffaf3 +http://developer.mbed.org/teams/Digi-International-Inc/code/DigiLogger/#b67d49554d8c
--- a/FrameBuffer/FrameBuffer.cpp Thu May 14 16:21:39 2015 +0200
+++ b/FrameBuffer/FrameBuffer.cpp Mon May 18 13:16:55 2015 +0200
@@ -126,6 +126,3 @@
return dropped_frames;
}
-
-
-
--- a/FrameBuffer/FrameBuffer.h Thu May 14 16:21:39 2015 +0200 +++ b/FrameBuffer/FrameBuffer.h Mon May 18 13:16:55 2015 +0200 @@ -110,5 +110,3 @@ }; #endif /* __FRAME_BUFFER_H_ */ - -
--- a/FrameHandlers/FH_AtCmdResp.h Thu May 14 16:21:39 2015 +0200 +++ b/FrameHandlers/FH_AtCmdResp.h Mon May 18 13:16:55 2015 +0200 @@ -121,5 +121,3 @@ } /* namespace XBeeLib */ #endif /* __FH_AT_CMD_RESP_H_ */ - -
--- a/FrameHandlers/FH_IoDataSample802.cpp Thu May 14 16:21:39 2015 +0200
+++ b/FrameHandlers/FH_IoDataSample802.cpp Mon May 18 13:16:55 2015 +0200
@@ -102,5 +102,3 @@
io_data_cb(sender, ioSample);
}
-
-
--- a/FrameHandlers/FH_ModemStatus.cpp Thu May 14 16:21:39 2015 +0200
+++ b/FrameHandlers/FH_ModemStatus.cpp Mon May 18 13:16:55 2015 +0200
@@ -43,5 +43,3 @@
modem_status_cb((AtCmdFrame::ModemStatus)frame->get_data_at(0));
}
-
-
--- a/FrameHandlers/FH_ModemStatus.h Thu May 14 16:21:39 2015 +0200 +++ b/FrameHandlers/FH_ModemStatus.h Mon May 18 13:16:55 2015 +0200 @@ -44,5 +44,3 @@ }; #endif /* __FH_MODEM_STATUS_H_ */ - -
--- a/FrameHandlers/FH_RxPacket802.h Thu May 14 16:21:39 2015 +0200 +++ b/FrameHandlers/FH_RxPacket802.h Mon May 18 13:16:55 2015 +0200 @@ -82,5 +82,3 @@ } /* namespace XBeeLib */ #endif /* __FH_RX_PACKET_802_H_ */ - -
--- a/FrameHandlers/FH_RxPacketZB.h Thu May 14 16:21:39 2015 +0200 +++ b/FrameHandlers/FH_RxPacketZB.h Mon May 18 13:16:55 2015 +0200 @@ -61,5 +61,3 @@ } /* namespace XBeeLib */ #endif /* __FH_RX_PACKET_ZB_H_ */ - -
--- a/FrameHandlers/FrameHandler.cpp Thu May 14 16:21:39 2015 +0200
+++ b/FrameHandlers/FrameHandler.cpp Mon May 18 13:16:55 2015 +0200
@@ -24,6 +24,3 @@
{
return _type;
}
-
-
-
--- a/FrameHandlers/FrameHandler.h Thu May 14 16:21:39 2015 +0200 +++ b/FrameHandlers/FrameHandler.h Mon May 18 13:16:55 2015 +0200 @@ -50,5 +50,3 @@ }; #endif /* defined(__FRAME_HANDLER_H_) */ - -
--- a/Frames/802_Frames.cpp Thu May 14 16:21:39 2015 +0200
+++ b/Frames/802_Frames.cpp Mon May 18 13:16:55 2015 +0200
@@ -61,4 +61,3 @@
set_api_frame(TxReq16Bit, frame_data, TX_REQUEST_OVERHEAD2 + len);
}
-
--- a/Frames/802_Frames.h Thu May 14 16:21:39 2015 +0200 +++ b/Frames/802_Frames.h Mon May 18 13:16:55 2015 +0200 @@ -26,5 +26,3 @@ }; #endif /* __802_FRAMES_H_ */ - -
--- a/Frames/ApiFrame.cpp Thu May 14 16:21:39 2015 +0200
+++ b/Frames/ApiFrame.cpp Mon May 18 13:16:55 2015 +0200
@@ -127,6 +127,3 @@
{
return _frame_id;
}
-
-
-
--- a/Frames/ApiFrame.h Thu May 14 16:21:39 2015 +0200 +++ b/Frames/ApiFrame.h Mon May 18 13:16:55 2015 +0200 @@ -173,5 +173,3 @@ }; #endif /* __API_FRAME_H_ */ - -
--- a/Frames/ZigbeeFrames.cpp Thu May 14 16:21:39 2015 +0200
+++ b/Frames/ZigbeeFrames.cpp Mon May 18 13:16:55 2015 +0200
@@ -84,4 +84,3 @@
set_api_frame(ExpAddrCmd, frame_data, EXP_ADDR_OVERHEAD + len);
}
-
--- a/Frames/ZigbeeFrames.h Thu May 14 16:21:39 2015 +0200 +++ b/Frames/ZigbeeFrames.h Mon May 18 13:16:55 2015 +0200 @@ -29,5 +29,3 @@ }; #endif /* __ZIGBEE_FRAME_H_ */ - -
--- a/IO/IO.h Thu May 14 16:21:39 2015 +0200
+++ b/IO/IO.h Mon May 18 13:16:55 2015 +0200
@@ -10,13 +10,11 @@
* =======================================================================
*/
-#if !defined(__IO_H_)
+#ifndef __IO_H_
#define __IO_H_
#define DR_PWM_MAX_VAL 0x3FF
-#define MAX_IO_SAMPLE_BUF_LEN 22 /* 1 + 2 + 1 + 2 + 16 */
-
namespace XBeeLib {
/**
@@ -58,5 +56,3 @@
#endif /* __IO_H_ */
-
-
--- a/IO/IOSample802.cpp Thu May 14 16:21:39 2015 +0200
+++ b/IO/IOSample802.cpp Mon May 18 13:16:55 2015 +0200
@@ -1,3 +1,15 @@
+/**
+ * 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 "XBeeLib.h"
#include "IO/IOSample802.h"
#include "Utils/Debug.h"
@@ -10,6 +22,10 @@
IOSample802::IOSample802(const uint8_t* const raw_data, size_t size)
{
+ if (raw_data == NULL || size == 0) {
+ _channel_mask = 0;
+ return;
+ }
assert(size >= IO_SAMPLE_802_MIN_SIZE);
assert(size <= sizeof _sampled_data);
--- a/IO/IOSample802.h Thu May 14 16:21:39 2015 +0200
+++ b/IO/IOSample802.h Mon May 18 13:16:55 2015 +0200
@@ -1,6 +1,4 @@
/**
- * Digi XBee library for mbed. This is the only header you have to include from your application to use the library.
- *
* Copyright (c) 2015 Digi International Inc.,
* All rights not expressly granted are reserved.
*
@@ -8,7 +6,8 @@
* 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.
+ * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
+ * =======================================================================
*/
#ifndef _IO_IOSAMPLE802_H_
@@ -25,7 +24,7 @@
* @param raw_data The IO Sample data, as returned by an "IS" command response or in the Io16Bit (0x83) or Io64Bit (0x82) frames
* @param size size (in bytes) of raw_data
*/
- IOSample802(const uint8_t* const raw_data, size_t size);
+ IOSample802(const uint8_t* const raw_data = NULL, size_t size = 0);
/** Class destructor */
~IOSample802();
@@ -50,6 +49,14 @@
*/
RadioStatus get_adc(XBee802::IoLine line, uint16_t* const val) const;
+ /** is_valid - checks if the IOSample802 object has at least one DIO or ADC sample.
+ * @returns true if valid, false otherwise
+ */
+ inline bool is_valid()
+ {
+ return _channel_mask == 0;
+ }
+
protected:
uint16_t _channel_mask;
uint8_t _sampled_data[MAX_IO_SAMPLE_802_LEN];
--- a/IO/IOSampleZB.cpp Thu May 14 16:21:39 2015 +0200
+++ b/IO/IOSampleZB.cpp Mon May 18 13:16:55 2015 +0200
@@ -1,3 +1,15 @@
+/**
+ * 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 "XBeeLib.h"
#include "IO/IOSampleZB.h"
@@ -7,6 +19,11 @@
IOSampleZB::IOSampleZB(const uint8_t* const raw_data, size_t size)
{
+ if (raw_data == NULL || size == 0) {
+ _digital_mask = 0;
+ _analog_mask = 0;
+ return;
+ }
assert(size >= IO_SAMPLE_ZB_MIN_SIZE);
assert(size <= sizeof _sampled_data);
--- a/IO/IOSampleZB.h Thu May 14 16:21:39 2015 +0200
+++ b/IO/IOSampleZB.h Mon May 18 13:16:55 2015 +0200
@@ -1,6 +1,4 @@
/**
- * Digi XBee library for mbed. This is the only header you have to include from your application to use the library.
- *
* Copyright (c) 2015 Digi International Inc.,
* All rights not expressly granted are reserved.
*
@@ -8,7 +6,8 @@
* 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.
+ * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
+ * =======================================================================
*/
#ifndef _IO_IOSAMPLEZB_H_
@@ -25,7 +24,7 @@
* @param raw_data The IO Sample data, as returned by an "IS" command response or in the IoSampleRxZB (0x92) frames
* @param size size (in bytes) of raw_data.
*/
- IOSampleZB(const uint8_t* const raw_data, size_t size);
+ IOSampleZB(const uint8_t* const raw_data = NULL, size_t size = 0);
/** Class destructor */
~IOSampleZB();
@@ -50,6 +49,14 @@
*/
RadioStatus get_adc(XBeeZB::IoLine line, uint16_t* const val) const;
+ /** is_valid - checks if the IOSampleZB object has at least one DIO or ADC sample.
+ * @returns true if valid, false otherwise
+ */
+ inline bool is_valid()
+ {
+ return _digital_mask == 0 && _analog_mask == 0;
+ }
+
protected:
uint16_t _digital_mask;
uint8_t _analog_mask;
--- a/RemoteXBee/RemoteXBee.h Thu May 14 16:21:39 2015 +0200 +++ b/RemoteXBee/RemoteXBee.h Mon May 18 13:16:55 2015 +0200 @@ -157,6 +157,3 @@ } /* namespace XBeeLib */ #endif /* defined(__XBEE_REMOTE_H_) */ - - -
--- a/Utils/Utils.h Thu May 14 16:21:39 2015 +0200 +++ b/Utils/Utils.h Mon May 18 13:16:55 2015 +0200 @@ -34,5 +34,3 @@ void rmemcpy(uint8_t * const dest, const uint8_t * const src, uint16_t bytes); #endif /* __XB_UTILS_H_ */ - -
--- a/XBee/Addresses.h Thu May 14 16:21:39 2015 +0200 +++ b/XBee/Addresses.h Mon May 18 13:16:55 2015 +0200 @@ -10,7 +10,7 @@ * ======================================================================= */ -#if !defined(__ADDRESSES_H_) +#ifndef __ADDRESSES_H_ #define __ADDRESSES_H_ #include <stdint.h>
--- a/XBee/RadioConfig.cpp Thu May 14 16:21:39 2015 +0200
+++ b/XBee/RadioConfig.cpp Mon May 18 13:16:55 2015 +0200
@@ -275,15 +275,14 @@
return Success;
}
-RadioStatus XBee::get_iosample(const RemoteXBee& remote, uint8_t * const io_sample, uint16_t * const len)
+RadioStatus XBee::_get_iosample(const RemoteXBee& remote, uint8_t * const io_sample, uint16_t * const len)
{
AtCmdFrame::AtCmdResp cmdresp;
- *len = MAX_IO_SAMPLE_BUF_LEN;
/* Force a sample read */
cmdresp = get_param(remote, "IS", io_sample, len);
if (cmdresp != AtCmdFrame::AtCmdRespOk) {
- digi_log(LogLevelError, "get_iosample error %d:\r\n", cmdresp);
+ digi_log(LogLevelError, "_get_iosample error %d:\r\n", cmdresp);
return Failure;
}
--- a/XBee/XBee.cpp Thu May 14 16:21:39 2015 +0200
+++ b/XBee/XBee.cpp Mon May 18 13:16:55 2015 +0200
@@ -657,10 +657,10 @@
return resp;
}
-TxStatus XBee::send_data_broadcast(const uint8_t *const data, uint16_t len)
+TxStatus XBee::send_data_broadcast(const uint8_t *const data, uint16_t len, bool syncr)
{
const RemoteXBee remoteDevice = RemoteXBee(ADDR64_BROADCAST);
- return send_data(remoteDevice, data, len);
+ return send_data(remoteDevice, data, len, syncr);
}
#if defined(ENABLE_PM_SUPPORT)
--- a/XBee/XBee.h Thu May 14 16:21:39 2015 +0200
+++ b/XBee/XBee.h Mon May 18 13:16:55 2015 +0200
@@ -448,29 +448,28 @@
/* ... */
/*********************** send_data member methods ************************/
- /** send_data - sends data to a remote device waiting for the packet
- * answer with the result of the operation
+ /** send_data - sends data to a remote device
*
* @param remote remote device
* @param data pointer to the data that will be sent
* @param len number of bytes that will be transmitted
+ * @param syncr if true, method waits for the packet answer with the result of the operation
* @returns the result of the data transfer
* TxStatusSuccess if the operation was successful,
* the error code otherwise
*/
- virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len) = 0;
+ virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr = true) = 0;
- /** send_data_broadcast - sends data to all devices in the network, using the
- * broadcast address. The method waits for the packet
- * answer with the result of the operation
+ /** send_data_broadcast - sends data to all devices in the network, using the broadcast address.
*
* @param data pointer to the data that will be sent
* @param len number of bytes that will be transmitted
+ * @param syncr if true, method waits for the packet answer with the result of the operation
* @returns the result of the data transfer
* TxStatusSuccess if the operation was successful,
* the error code otherwise
*/
- TxStatus send_data_broadcast(const uint8_t *const data, uint16_t len);
+ TxStatus send_data_broadcast(const uint8_t *const data, uint16_t len, bool syncr = true);
/** set_param - sets a parameter in the local radio by sending an AT command and waiting for the response.
*
@@ -758,7 +757,7 @@
*/
RadioProtocol get_radio_protocol(void) const;
- /** get_iosample - forces an io_sample read (reads all digital and analog inputs)
+ /** _get_iosample - forces an io_sample read (reads all digital and analog inputs)
*
* @param remote remote device
* @param io_sample buffer where the io_sample response is copied
@@ -767,7 +766,7 @@
* Success if the operation was successful,
* Failure otherwise
*/
- RadioStatus get_iosample(const RemoteXBee& remote, uint8_t * const io_sample, uint16_t * const len);
+ RadioStatus _get_iosample(const RemoteXBee& remote, uint8_t * const io_sample, uint16_t * const len);
void _get_remote_node_by_id(const char * const node_id, uint64_t * addr64, uint16_t * addr16);
--- a/XBee802/XBee802.cpp Thu May 14 16:21:39 2015 +0200
+++ b/XBee802/XBee802.cpp Mon May 18 13:16:55 2015 +0200
@@ -135,7 +135,7 @@
digi_log(LogLevelDebug, "\r\nUpdating radio status: %02x\r\n", modem_status);
}
-TxStatus XBee802::send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len)
+TxStatus XBee802::send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr)
{
if (remote.is_valid_addr64b()) {
const uint64_t remote64 = remote.get_addr64();
@@ -144,7 +144,13 @@
TxFrame802 frame = TxFrame802(remote64, _tx_options, data, len);
- return send_data(&frame);
+ if (syncr) {
+ return send_data(&frame);
+ } else {
+ frame.set_data(0, 0); /* Set frame id to 0 so there is no answer */
+ send_api_frame(&frame);
+ return TxStatusSuccess;
+ }
}
if (remote.is_valid_addr16b()) {
@@ -154,34 +160,13 @@
TxFrame802 frame = TxFrame802(remote16, _tx_options, data, len);
- return send_data(&frame);
- }
-
- return TxStatusInvalidAddr;
-}
-
-TxStatus XBee802::send_data_asyncr(const RemoteXBee& remote, const uint8_t *const data, uint16_t len)
-{
- if (remote.is_valid_addr64b()) {
- const uint64_t remote64 = remote.get_addr64();
-
- digi_log(LogLevelDebug, "send_data ADDR64: %08x:%08x\r\n", UINT64_HI32(remote64), UINT64_LO32(remote64));
-
- TxFrame802 frame = TxFrame802(remote64, _tx_options, data, len);
-
- send_api_frame(&frame);
- return TxStatusSuccess;
- }
-
- if (remote.is_valid_addr16b()) {
- const uint16_t remote16 = remote.get_addr16();
-
- digi_log(LogLevelDebug, "send_data ADDR16: %04x\r\n", remote16);
-
- TxFrame802 frame = TxFrame802(remote16, _tx_options, data, len);
-
- send_api_frame(&frame);
- return TxStatusSuccess;
+ if (syncr) {
+ return send_data(&frame);
+ } else {
+ frame.set_data(0, 0); /* Set frame id to 0 so there is no answer */
+ send_api_frame(&frame);
+ return TxStatusSuccess;
+ }
}
return TxStatusInvalidAddr;
@@ -422,39 +407,12 @@
RadioStatus XBee802::get_dio(const RemoteXBee& remote, IoLine line, DioVal * const val)
{
- uint8_t io_sample[MAX_IO_SAMPLE_BUF_LEN];
- uint16_t len;
-
- if (line > DI8) {
- digi_log(LogLevelError, "get_dio: Pin %d not supported as IO\r\n", line);
- return Failure;
- }
-
- RadioStatus resp = get_iosample(remote, io_sample, &len);
- if (resp != Success)
- return resp;
-
- IOSample802 ioSample = IOSample802(io_sample, len);
- return ioSample.get_dio(line, val);
+ return get_iosample(remote).get_dio(line, val);
}
RadioStatus XBee802::get_adc(const RemoteXBee& remote, IoLine line, uint16_t * const val)
{
- uint8_t io_sample[MAX_IO_SAMPLE_BUF_LEN];
- uint16_t len;
-
- if (line > DIO5_AD5) {
- digi_log(LogLevelError, "get_adc: Pin %d not supported as ADC\r\n", line);
- return Failure;
- }
-
- RadioStatus resp = get_iosample(remote, io_sample, &len);
- if (resp != Success) {
- return resp;
- }
-
- IOSample802 ioSample = IOSample802(io_sample, len);
- return ioSample.get_adc(line, val);
+ return get_iosample(remote).get_adc(line, val);
}
RadioStatus XBee802::set_pwm(const RemoteXBee& remote, IoLine line, float duty_cycle)
@@ -478,6 +436,19 @@
return Success;
}
+IOSample802 XBee802::get_iosample(const RemoteXBee& remote)
+{
+ uint8_t io_sample[MAX_IO_SAMPLE_802_LEN];
+ uint16_t len = sizeof io_sample;
+
+ RadioStatus resp = _get_iosample(remote, io_sample, &len);
+ if (resp != Success) {
+ digi_log(LogLevelError, "XBee802::get_iosample failed to get an IOSample\r\n");
+ len = 0;
+ }
+ return IOSample802(io_sample, len);
+}
+
static uint8_t get_dio_mask(XBee802::IoLine line)
{
switch (line) {
--- a/XBee802/XBee802.h Thu May 14 16:21:39 2015 +0200
+++ b/XBee802/XBee802.h Mon May 18 13:16:55 2015 +0200
@@ -141,28 +141,17 @@
void unregister_io_sample_cb();
/*********************** send_data member methods ************************/
- /** send_data - sends data to a remote device waiting for the packet
- * answer with the result of the operation
+ /** send_data - sends data to a remote device
*
* @param remote remote device
* @param data pointer to the data that will be sent
* @param len number of bytes that will be transmitted
+ * @param syncr if true, method waits for the packet answer with the result of the operation
* @returns the result of the data transfer
* TxStatusSuccess if the operation was successful,
* the error code otherwise
*/
- virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len);
-
- /** send_data_asyncr - sends data to a remote device not waiting for the packet answer
- *
- * @param remote remote device
- * @param data pointer to the data that will be sent
- * @param len number of bytes that will be transmitted
- * @returns the result of the data transfer
- * TxStatusSuccess if the operation was successful,
- * the error code otherwise
- */
- TxStatus send_data_asyncr(const RemoteXBee& remote, const uint8_t *const data, uint16_t len);
+ virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr = true);
/** get_remote_node_by_id - searches for a device in the network with the specified Node Identifier.
*
@@ -272,6 +261,13 @@
*/
RadioStatus get_adc(const RemoteXBee& remote, IoLine line, uint16_t * const val);
+ /** get_iosample - retrieves an @ref IOSample802 from a remote node. This object can be used to get the remote node's ADC and DIO values.
+ *
+ * @param remote remote device
+ * @returns IOSample802 object with the remote node's DIO and ADC values.
+ */
+ IOSample802 get_iosample(const RemoteXBee& remote);
+
/** set_pwm - sets the duty cycle of a PWM line
*
* @param remote remote device
@@ -364,5 +360,3 @@
} /* namespace XBeeLib */
#endif /* __XBEE_802_H_ */
-
-
--- a/XBeeLib.h Thu May 14 16:21:39 2015 +0200
+++ b/XBeeLib.h Mon May 18 13:16:55 2015 +0200
@@ -1,6 +1,4 @@
/**
- * Digi XBee library for mbed. This is the only header you have to include from your application to use the library.
- *
* Copyright (c) 2015 Digi International Inc.,
* All rights not expressly granted are reserved.
*
@@ -8,13 +6,14 @@
* 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.
+ * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
+ * =======================================================================
*/
/** @file
*/
-#if !defined(__XBEE_H_)
+#ifndef __XBEE_H_
#define __XBEE_H_
#define XB_LIBRARY_VERSION 0x00010500U
@@ -24,7 +23,7 @@
#define XB_BUILD_ID (XB_LIBRARY_VERSION & 0xFFU)
/**/
-#define XB_LIB_BANNER "\r\n\r\nmbed Digi Radio library v%d.%d.%d\r\n", \
+#define XB_LIB_BANNER "\r\n\r\n" "mbed Digi International Inc., XBeeLib v%d.%d.%d" "\r\n", \
XB_MAJOR_VERSION, XB_MINOR_VERSION, XB_PATCH_LEVEL
#include "XBeeZB/XBeeZB.h"
@@ -35,5 +34,3 @@
#include "RemoteXBee/RemoteXBee.h"
#endif /* __XBEE_H_ */
-
-
--- a/XBeeZB/XBeeZB.cpp Thu May 14 16:21:39 2015 +0200
+++ b/XBeeZB/XBeeZB.cpp Mon May 18 13:16:55 2015 +0200
@@ -30,10 +30,18 @@
RadioStatus retval = XBee::init();
/* Determine the role of this device in the network */
switch(_fw_version & 0xFF00) {
- case 0x2100: _nw_role = Coordinator; break;
- case 0x2300: _nw_role = Router; break;
- case 0x2900: _nw_role = EndDevice; break;
- default: _nw_role = UnknownRole; break;
+ case 0x2100:
+ _nw_role = Coordinator;
+ break;
+ case 0x2300:
+ _nw_role = Router;
+ break;
+ case 0x2900:
+ _nw_role = EndDevice;
+ break;
+ default:
+ _nw_role = UnknownRole;
+ break;
}
const RadioProtocol radioProtocol = get_radio_protocol();
@@ -271,7 +279,7 @@
digi_log(LogLevelDebug, "\r\nUpdating radio status: %02x\r\n", modem_status);
}
-TxStatus XBeeZB::send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len)
+TxStatus XBeeZB::send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr)
{
if (!remote.is_valid_addr64b())
return TxStatusInvalidAddr;
@@ -281,27 +289,18 @@
TxFrameZB frame = TxFrameZB(remote64, remote16, _broadcast_radious,
_tx_options, data, len);
- return send_data(&frame);
-}
-
-TxStatus XBeeZB::send_data_asyncr(const RemoteXBee& remote, const uint8_t *const data, uint16_t len)
-{
- if (!remote.is_valid_addr64b())
- return TxStatusInvalidAddr;
-
- const uint64_t remote64 = remote.get_addr64();
- const uint16_t remote16 = remote.get_addr16();
-
- TxFrameZB frame = TxFrameZB(remote64, remote16, _broadcast_radious,
- _tx_options, data, len);
-
- send_api_frame(&frame);
- return TxStatusSuccess;
+ if (syncr) {
+ return send_data(&frame);
+ } else {
+ frame.set_data(0, 0); /* Set frame id to 0 so there is no answer */
+ send_api_frame(&frame);
+ return TxStatusSuccess;
+ }
}
TxStatus XBeeZB::send_data(const RemoteXBee& remote, uint8_t source_ep,
uint8_t dest_ep, uint16_t cluster_id, uint16_t profile_id,
- const uint8_t *const data, uint16_t len)
+ const uint8_t *const data, uint16_t len, bool syncr)
{
if (!remote.is_valid_addr64b())
return TxStatusInvalidAddr;
@@ -312,16 +311,29 @@
TxFrameZB frame = TxFrameZB(remote64, remote16, source_ep, dest_ep,
cluster_id, profile_id, _broadcast_radious,
_tx_options, data, len);
- return send_data(&frame);
+ if (syncr) {
+ return send_data(&frame);
+ } else {
+ frame.set_data(0, 0); /* Set frame id to 0 so there is no answer */
+ send_api_frame(&frame);
+ return TxStatusSuccess;
+
+ }
}
-TxStatus XBeeZB::send_data_to_coordinator(const uint8_t *const data, uint16_t len)
+TxStatus XBeeZB::send_data_to_coordinator(const uint8_t *const data, uint16_t len, bool syncr)
{
const uint64_t remaddr = ADDR64_COORDINATOR;
TxFrameZB frame = TxFrameZB(remaddr, ADDR16_UNKNOWN, _broadcast_radious,
_tx_options, data, len);
- return send_data(&frame);
+ if (syncr) {
+ return send_data(&frame);
+ } else {
+ frame.set_data(0, 0); /* Set frame id to 0 so there is no answer */
+ send_api_frame(&frame);
+ return TxStatusSuccess;
+ }
}
RemoteXBeeZB XBeeZB::get_remote_node_by_id(const char * const node_id)
@@ -510,40 +522,26 @@
RadioStatus XBeeZB::get_dio(const RemoteXBee& remote, IoLine line, DioVal * const val)
{
- uint8_t io_sample[MAX_IO_SAMPLE_BUF_LEN];
- uint16_t len;
-
- RadioStatus resp = get_iosample(remote, io_sample, &len);
- if (resp != Success)
- return resp;
-
- IOSampleZB ioSample = IOSampleZB(io_sample, len);
- return ioSample.get_dio(line, val);
+ return get_iosample(remote).get_dio(line, val);
}
RadioStatus XBeeZB::get_adc(const RemoteXBee& remote, IoLine line, uint16_t * const val)
{
- uint8_t io_sample[MAX_IO_SAMPLE_BUF_LEN];
- uint16_t len;
+ return get_iosample(remote).get_adc(line, val);
+}
- switch (line) {
- case SUPPLY_VOLTAGE:
- case DIO3_AD3:
- case DIO2_AD2:
- case DIO1_AD1:
- case DIO0_AD0:
- break;
- default:
- digi_log(LogLevelError, "get_adc: Pin %d not supported as ADC\r\n", line);
- return Failure;
+IOSampleZB XBeeZB::get_iosample(const RemoteXBee& remote)
+{
+ uint8_t io_sample[MAX_IO_SAMPLE_ZB_LEN];
+ uint16_t len = sizeof io_sample;
+
+ RadioStatus resp = _get_iosample(remote, io_sample, &len);
+ if (resp != Success) {
+ digi_log(LogLevelError, "XBeeZB::get_iosample failed to get an IOSample\r\n");
+ len = 0;
}
- RadioStatus resp = get_iosample(remote, io_sample, &len);
- if (resp != Success)
- return resp;
-
- IOSampleZB ioSample = IOSampleZB(io_sample, len);
- return ioSample.get_adc(line, val);
+ return IOSampleZB(io_sample, len);
}
static uint16_t get_dio_pr_mask(XBeeZB::IoLine line)
--- a/XBeeZB/XBeeZB.h Thu May 14 16:21:39 2015 +0200
+++ b/XBeeZB/XBeeZB.h Mon May 18 13:16:55 2015 +0200
@@ -240,31 +240,19 @@
/** */
/*********************** send_data member methods ************************/
- /** send_data - sends data to a remote device waiting for the packet
- * answer with the result of the operation
+ /** send_data - sends data to a remote device
*
* @param remote remote device
* @param data pointer to the data that will be sent
* @param len number of bytes that will be transmitted
+ * @param syncr if true, method waits for the packet answer with the result of the operation
* @returns the result of the data transfer
* TxStatusSuccess if the operation was successful,
* the error code otherwise
*/
- virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len);
+ virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr = true);
- /** send_data_asyncr - sends data to a remote device not waiting for the packet answer
- *
- * @param remote remote device
- * @param data pointer to the data that will be sent
- * @param len number of bytes that will be transmitted
- * @returns the result of the data transfer
- * TxStatusSuccess if the operation was successful,
- * the error code otherwise
- */
- TxStatus send_data_asyncr(const RemoteXBee& remote, const uint8_t *const data, uint16_t len);
-
- /** send_data - sends data to a remote device waiting for the packet
- * answer with the result of the operation. This method uses
+ /** send_data - sends data to a remote device. This method uses
* the explicit addressing frame, allowing to use source and
* destination end points and cluster and profile IDs
*
@@ -275,24 +263,25 @@
* @param profile_id profile ID
* @param data pointer to the data that will be sent
* @param len number of bytes that will be transmitted
+ * @param syncr if true, method waits for the packet answer with the result of the operation
* @returns the result of the data transfer
* TxStatusSuccess if the operation was successful,
* the error code otherwise
*/
TxStatus send_data(const RemoteXBee& remote, uint8_t source_ep,
uint8_t dest_ep, uint16_t cluster_id, uint16_t profile_id,
- const uint8_t *const data, uint16_t len);
+ const uint8_t *const data, uint16_t len, bool syncr = true);
- /** send_data_to_coordinator - sends data to the ZigBee coordinator waiting for the
- * packet answer with the result of the operation
+ /** send_data_to_coordinator - sends data to the ZigBee coordinator
*
* @param data pointer to the data that will be sent
* @param len number of bytes that will be transmitted
+ * @param syncr if true, method waits for the packet answer with the result of the operation
* @returns the result of the data transfer
* TxStatusSuccess if the operation was successful,
* the error code otherwise
*/
- TxStatus send_data_to_coordinator(const uint8_t *const data, uint16_t len);
+ TxStatus send_data_to_coordinator(const uint8_t *const data, uint16_t len, bool syncr = true);
/** is_joined - checks if the device is joined to ZigBee network
* @returns true if joined, false otherwise
@@ -407,6 +396,13 @@
*/
RadioStatus get_adc(const RemoteXBee& remote, IoLine line, uint16_t * const val);
+ /** get_iosample - retrieves an @ref IOSampleZB from a remote node. This object can be used to get the remote node's ADC and DIO values.
+ *
+ * @param remote remote device
+ * @returns IOSampleZB object with the remote node's DIO and ADC values.
+ */
+ IOSampleZB get_iosample(const RemoteXBee& remote);
+
/** set_pin_pull_up - enables or disables the internal pull-up resistor of a line
*
* @param remote remote device
@@ -467,5 +463,3 @@
} /* namespace XBeeLib */
#endif /* __XBEE_ZB_H_ */
-
-
