mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 09:27:47 +00:00
[ncp] make NCP sources pretty (#2811)
This commit is contained in:
@@ -60,6 +60,7 @@ endif
|
||||
PRETTY_SUBDIRS = \
|
||||
cli \
|
||||
core \
|
||||
ncp \
|
||||
$(NULL)
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "changed_props_set.hpp"
|
||||
|
||||
#include "common/code_utils.hpp"
|
||||
@@ -45,44 +44,43 @@ namespace Ncp {
|
||||
// Since a `uint32_t` is used as bit-mask to track which entries are in the changed set, we should ensure that the
|
||||
// number of entries in the list is always less than or equal to 32.
|
||||
//
|
||||
const ChangedPropsSet::Entry ChangedPropsSet::mSupportedProps[] =
|
||||
{
|
||||
const ChangedPropsSet::Entry ChangedPropsSet::mSupportedProps[] = {
|
||||
// Spinel property Status (if prop is `LAST_STATUS`) IsFilterable?
|
||||
|
||||
{ SPINEL_PROP_LAST_STATUS, SPINEL_STATUS_RESET_UNKNOWN, false }, // 0
|
||||
{ SPINEL_PROP_STREAM_DEBUG, SPINEL_STATUS_OK, true }, // 1
|
||||
{ SPINEL_PROP_IPV6_ADDRESS_TABLE, SPINEL_STATUS_OK, true }, // 2
|
||||
{ SPINEL_PROP_NET_ROLE, SPINEL_STATUS_OK, true }, // 3
|
||||
{ SPINEL_PROP_IPV6_LL_ADDR, SPINEL_STATUS_OK, true }, // 4
|
||||
{ SPINEL_PROP_IPV6_ML_ADDR, SPINEL_STATUS_OK, true }, // 5
|
||||
{ SPINEL_PROP_NET_PARTITION_ID, SPINEL_STATUS_OK, true }, // 6
|
||||
{ SPINEL_PROP_NET_KEY_SEQUENCE_COUNTER, SPINEL_STATUS_OK, true }, // 7
|
||||
{ SPINEL_PROP_THREAD_LEADER_NETWORK_DATA, SPINEL_STATUS_OK, true }, // 8
|
||||
{ SPINEL_PROP_THREAD_CHILD_TABLE, SPINEL_STATUS_OK, true }, // 9
|
||||
{ SPINEL_PROP_THREAD_ON_MESH_NETS, SPINEL_STATUS_OK, true }, // 10
|
||||
{ SPINEL_PROP_THREAD_OFF_MESH_ROUTES, SPINEL_STATUS_OK, true }, // 11
|
||||
{ SPINEL_PROP_NET_STACK_UP, SPINEL_STATUS_OK, true }, // 12
|
||||
{ SPINEL_PROP_NET_REQUIRE_JOIN_EXISTING, SPINEL_STATUS_OK, true }, // 13
|
||||
{ SPINEL_PROP_LAST_STATUS, SPINEL_STATUS_NOMEM, true }, // 14
|
||||
{ SPINEL_PROP_LAST_STATUS, SPINEL_STATUS_DROPPED, true }, // 15
|
||||
{SPINEL_PROP_LAST_STATUS, SPINEL_STATUS_RESET_UNKNOWN, false}, // 0
|
||||
{SPINEL_PROP_STREAM_DEBUG, SPINEL_STATUS_OK, true}, // 1
|
||||
{SPINEL_PROP_IPV6_ADDRESS_TABLE, SPINEL_STATUS_OK, true}, // 2
|
||||
{SPINEL_PROP_NET_ROLE, SPINEL_STATUS_OK, true}, // 3
|
||||
{SPINEL_PROP_IPV6_LL_ADDR, SPINEL_STATUS_OK, true}, // 4
|
||||
{SPINEL_PROP_IPV6_ML_ADDR, SPINEL_STATUS_OK, true}, // 5
|
||||
{SPINEL_PROP_NET_PARTITION_ID, SPINEL_STATUS_OK, true}, // 6
|
||||
{SPINEL_PROP_NET_KEY_SEQUENCE_COUNTER, SPINEL_STATUS_OK, true}, // 7
|
||||
{SPINEL_PROP_THREAD_LEADER_NETWORK_DATA, SPINEL_STATUS_OK, true}, // 8
|
||||
{SPINEL_PROP_THREAD_CHILD_TABLE, SPINEL_STATUS_OK, true}, // 9
|
||||
{SPINEL_PROP_THREAD_ON_MESH_NETS, SPINEL_STATUS_OK, true}, // 10
|
||||
{SPINEL_PROP_THREAD_OFF_MESH_ROUTES, SPINEL_STATUS_OK, true}, // 11
|
||||
{SPINEL_PROP_NET_STACK_UP, SPINEL_STATUS_OK, true}, // 12
|
||||
{SPINEL_PROP_NET_REQUIRE_JOIN_EXISTING, SPINEL_STATUS_OK, true}, // 13
|
||||
{SPINEL_PROP_LAST_STATUS, SPINEL_STATUS_NOMEM, true}, // 14
|
||||
{SPINEL_PROP_LAST_STATUS, SPINEL_STATUS_DROPPED, true}, // 15
|
||||
#if OPENTHREAD_ENABLE_JAM_DETECTION
|
||||
{ SPINEL_PROP_JAM_DETECTED, SPINEL_STATUS_OK, true }, // 16
|
||||
{SPINEL_PROP_JAM_DETECTED, SPINEL_STATUS_OK, true}, // 16
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_LEGACY
|
||||
{ SPINEL_PROP_NEST_LEGACY_ULA_PREFIX, SPINEL_STATUS_OK, true }, // 17
|
||||
{ SPINEL_PROP_NEST_LEGACY_LAST_NODE_JOINED, SPINEL_STATUS_OK, true }, // 18
|
||||
{SPINEL_PROP_NEST_LEGACY_ULA_PREFIX, SPINEL_STATUS_OK, true}, // 17
|
||||
{SPINEL_PROP_NEST_LEGACY_LAST_NODE_JOINED, SPINEL_STATUS_OK, true}, // 18
|
||||
#endif
|
||||
{ SPINEL_PROP_LAST_STATUS, SPINEL_STATUS_JOIN_FAILURE, false }, // 19
|
||||
{ SPINEL_PROP_MAC_SCAN_STATE, SPINEL_STATUS_OK, false }, // 20
|
||||
{ SPINEL_PROP_IPV6_MULTICAST_ADDRESS_TABLE, SPINEL_STATUS_OK, true }, // 21
|
||||
{ SPINEL_PROP_PHY_CHAN, SPINEL_STATUS_OK, true }, // 22
|
||||
{ SPINEL_PROP_MAC_15_4_PANID, SPINEL_STATUS_OK, true }, // 23
|
||||
{ SPINEL_PROP_NET_NETWORK_NAME, SPINEL_STATUS_OK, true }, // 24
|
||||
{ SPINEL_PROP_NET_XPANID, SPINEL_STATUS_OK, true }, // 25
|
||||
{ SPINEL_PROP_NET_MASTER_KEY, SPINEL_STATUS_OK, true }, // 26
|
||||
{ SPINEL_PROP_NET_PSKC, SPINEL_STATUS_OK, true }, // 27
|
||||
{SPINEL_PROP_LAST_STATUS, SPINEL_STATUS_JOIN_FAILURE, false}, // 19
|
||||
{SPINEL_PROP_MAC_SCAN_STATE, SPINEL_STATUS_OK, false}, // 20
|
||||
{SPINEL_PROP_IPV6_MULTICAST_ADDRESS_TABLE, SPINEL_STATUS_OK, true}, // 21
|
||||
{SPINEL_PROP_PHY_CHAN, SPINEL_STATUS_OK, true}, // 22
|
||||
{SPINEL_PROP_MAC_15_4_PANID, SPINEL_STATUS_OK, true}, // 23
|
||||
{SPINEL_PROP_NET_NETWORK_NAME, SPINEL_STATUS_OK, true}, // 24
|
||||
{SPINEL_PROP_NET_XPANID, SPINEL_STATUS_OK, true}, // 25
|
||||
{SPINEL_PROP_NET_MASTER_KEY, SPINEL_STATUS_OK, true}, // 26
|
||||
{SPINEL_PROP_NET_PSKC, SPINEL_STATUS_OK, true}, // 27
|
||||
#if OPENTHREAD_ENABLE_CHANNEL_MANAGER
|
||||
{ SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL, SPINEL_STATUS_OK, true }, // 28
|
||||
{SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL, SPINEL_STATUS_OK, true}, // 28
|
||||
#endif
|
||||
|
||||
};
|
||||
@@ -94,7 +92,7 @@ uint8_t ChangedPropsSet::GetNumEntries(void) const
|
||||
|
||||
void ChangedPropsSet::Add(spinel_prop_key_t aPropKey, spinel_status_t aStatus)
|
||||
{
|
||||
uint8_t numEntries;
|
||||
uint8_t numEntries;
|
||||
const Entry *entry;
|
||||
|
||||
entry = GetSupportedEntries(numEntries);
|
||||
@@ -115,9 +113,9 @@ void ChangedPropsSet::Add(spinel_prop_key_t aPropKey, spinel_status_t aStatus)
|
||||
|
||||
otError ChangedPropsSet::EnablePropertyFilter(spinel_prop_key_t aPropKey, bool aEnable)
|
||||
{
|
||||
uint8_t numEntries;
|
||||
uint8_t numEntries;
|
||||
const Entry *entry;
|
||||
bool didFind = false;
|
||||
bool didFind = false;
|
||||
|
||||
entry = GetSupportedEntries(numEntries);
|
||||
|
||||
@@ -157,8 +155,8 @@ otError ChangedPropsSet::EnablePropertyFilter(spinel_prop_key_t aPropKey, bool a
|
||||
|
||||
bool ChangedPropsSet::IsPropertyFiltered(spinel_prop_key_t aPropKey) const
|
||||
{
|
||||
bool isFiltered = false;
|
||||
uint8_t numEntries;
|
||||
bool isFiltered = false;
|
||||
uint8_t numEntries;
|
||||
const Entry *entry;
|
||||
|
||||
entry = GetSupportedEntries(numEntries);
|
||||
|
||||
@@ -68,16 +68,17 @@ public:
|
||||
* This constructor initializes the set.
|
||||
*
|
||||
*/
|
||||
ChangedPropsSet(void):
|
||||
mChangedSet(0),
|
||||
mFilterSet(0)
|
||||
{ }
|
||||
ChangedPropsSet(void)
|
||||
: mChangedSet(0)
|
||||
, mFilterSet(0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method clears the set.
|
||||
*
|
||||
*/
|
||||
void Clear(void) { mChangedSet = 0; }
|
||||
void Clear(void) { mChangedSet = 0; }
|
||||
|
||||
/**
|
||||
* This method indicates if the set is empty or not.
|
||||
@@ -104,7 +105,7 @@ public:
|
||||
* @param[in] aStatus The spinel status update to be added to set.
|
||||
*
|
||||
*/
|
||||
void AddLastStatus(spinel_status_t aStatus) { Add(SPINEL_PROP_LAST_STATUS, aStatus); }
|
||||
void AddLastStatus(spinel_status_t aStatus) { Add(SPINEL_PROP_LAST_STATUS, aStatus); }
|
||||
|
||||
/**
|
||||
* This method returns a pointer to array of entries of supported property/status updates. The list includes
|
||||
@@ -115,7 +116,8 @@ public:
|
||||
* @returns A pointer to the supported entries array.
|
||||
*
|
||||
*/
|
||||
const Entry *GetSupportedEntries(uint8_t &aNumEntries) const {
|
||||
const Entry *GetSupportedEntries(uint8_t &aNumEntries) const
|
||||
{
|
||||
aNumEntries = GetNumEntries();
|
||||
return &mSupportedProps[0];
|
||||
}
|
||||
@@ -128,9 +130,7 @@ public:
|
||||
* @returns A pointer to the entry associated with @p aIndex, or NULL if the index is beyond end of array.
|
||||
*
|
||||
*/
|
||||
const Entry *GetEntry(uint8_t aIndex) const {
|
||||
return (aIndex < GetNumEntries()) ? &mSupportedProps[aIndex] : NULL;
|
||||
}
|
||||
const Entry *GetEntry(uint8_t aIndex) const { return (aIndex < GetNumEntries()) ? &mSupportedProps[aIndex] : NULL; }
|
||||
|
||||
/**
|
||||
* This method indicates if the entry associated with an index is in the set (i.e., it has been changed and
|
||||
@@ -194,11 +194,11 @@ public:
|
||||
|
||||
private:
|
||||
uint8_t GetNumEntries(void) const;
|
||||
void Add(spinel_prop_key_t aPropKey, spinel_status_t aStatus);
|
||||
void Add(spinel_prop_key_t aPropKey, spinel_status_t aStatus);
|
||||
|
||||
static void SetBit (uint32_t &aBitset, uint8_t aBitIndex) { aBitset |= (1U << aBitIndex); }
|
||||
static void ClearBit(uint32_t &aBitset, uint8_t aBitIndex) { aBitset &= ~(1U << aBitIndex); }
|
||||
static bool IsBitSet(uint32_t aBitset, uint8_t aBitIndex) { return (aBitset & (1U << aBitIndex)) != 0; }
|
||||
static void SetBit(uint32_t &aBitset, uint8_t aBitIndex) { aBitset |= (1U << aBitIndex); }
|
||||
static void ClearBit(uint32_t &aBitset, uint8_t aBitIndex) { aBitset &= ~(1U << aBitIndex); }
|
||||
static bool IsBitSet(uint32_t aBitset, uint8_t aBitIndex) { return (aBitset & (1U << aBitIndex)) != 0; }
|
||||
|
||||
static const Entry mSupportedProps[];
|
||||
|
||||
|
||||
+56
-69
@@ -56,8 +56,8 @@ enum
|
||||
{
|
||||
kFlagXOn = 0x11,
|
||||
kFlagXOff = 0x13,
|
||||
kFlagSequence = 0x7e, ///< HDLC Flag value
|
||||
kEscapeSequence = 0x7d, ///< HDLC Escape value
|
||||
kFlagSequence = 0x7e, ///< HDLC Flag value
|
||||
kEscapeSequence = 0x7d, ///< HDLC Escape value
|
||||
kFlagSpecial = 0xf8,
|
||||
};
|
||||
|
||||
@@ -67,47 +67,32 @@ enum
|
||||
*/
|
||||
enum
|
||||
{
|
||||
kInitFcs = 0xffff, ///< Initial FCS value.
|
||||
kGoodFcs = 0xf0b8, ///< Good FCS value.
|
||||
kInitFcs = 0xffff, ///< Initial FCS value.
|
||||
kGoodFcs = 0xf0b8, ///< Good FCS value.
|
||||
};
|
||||
|
||||
uint16_t UpdateFcs(uint16_t aFcs, uint8_t aByte)
|
||||
{
|
||||
static const uint16_t sFcsTable[256] =
|
||||
{
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
||||
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
||||
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
||||
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
||||
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
||||
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
||||
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
|
||||
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
||||
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
||||
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
|
||||
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
||||
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
||||
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
||||
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
||||
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
||||
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
||||
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
||||
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
||||
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
||||
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
|
||||
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
||||
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
||||
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
||||
};
|
||||
static const uint16_t sFcsTable[256] = {
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5,
|
||||
0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52,
|
||||
0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3,
|
||||
0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9,
|
||||
0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e,
|
||||
0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f,
|
||||
0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862,
|
||||
0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb,
|
||||
0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948,
|
||||
0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226,
|
||||
0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497,
|
||||
0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704,
|
||||
0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb,
|
||||
0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c,
|
||||
0x3de3, 0x2c6a, 0x1ef1, 0x0f78};
|
||||
return (aFcs >> 8) ^ sFcsTable[(aFcs ^ aByte) & 0xff];
|
||||
}
|
||||
|
||||
@@ -129,7 +114,7 @@ bool HdlcByteNeedsEscape(uint8_t aByte)
|
||||
|
||||
Encoder::BufferWriteIterator::BufferWriteIterator(void)
|
||||
{
|
||||
mWritePointer = NULL;
|
||||
mWritePointer = NULL;
|
||||
mRemainingLength = 0;
|
||||
}
|
||||
|
||||
@@ -151,8 +136,8 @@ bool Encoder::BufferWriteIterator::CanWrite(uint16_t aWriteLength) const
|
||||
return (mRemainingLength >= aWriteLength);
|
||||
}
|
||||
|
||||
Encoder::Encoder(void):
|
||||
mFcs(0)
|
||||
Encoder::Encoder(void)
|
||||
: mFcs(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -169,7 +154,7 @@ otError Encoder::Encode(uint8_t aInByte, BufferWriteIterator &aIterator)
|
||||
|
||||
if (HdlcByteNeedsEscape(aInByte))
|
||||
{
|
||||
VerifyOrExit(aIterator.CanWrite(2) , error = OT_ERROR_NO_BUFS);
|
||||
VerifyOrExit(aIterator.CanWrite(2), error = OT_ERROR_NO_BUFS);
|
||||
|
||||
aIterator.WriteByte(kEscapeSequence);
|
||||
aIterator.WriteByte(aInByte ^ 0x20);
|
||||
@@ -187,9 +172,9 @@ exit:
|
||||
|
||||
otError Encoder::Encode(const uint8_t *aInBuf, uint16_t aInLength, BufferWriteIterator &aIterator)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
BufferWriteIterator oldIterator(aIterator);
|
||||
uint16_t oldFcs = mFcs;
|
||||
uint16_t oldFcs = mFcs;
|
||||
|
||||
for (int i = 0; i < aInLength; i++)
|
||||
{
|
||||
@@ -201,7 +186,7 @@ exit:
|
||||
if (error != OT_ERROR_NONE)
|
||||
{
|
||||
aIterator = oldIterator;
|
||||
mFcs = oldFcs;
|
||||
mFcs = oldFcs;
|
||||
}
|
||||
|
||||
return error;
|
||||
@@ -209,10 +194,10 @@ exit:
|
||||
|
||||
otError Encoder::Finalize(BufferWriteIterator &aIterator)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
BufferWriteIterator oldIterator(aIterator);
|
||||
uint16_t oldFcs = mFcs;
|
||||
uint16_t fcs = mFcs;
|
||||
uint16_t oldFcs = mFcs;
|
||||
uint16_t fcs = mFcs;
|
||||
|
||||
fcs ^= 0xffff;
|
||||
|
||||
@@ -226,22 +211,25 @@ exit:
|
||||
if (error != OT_ERROR_NONE)
|
||||
{
|
||||
aIterator = oldIterator;
|
||||
mFcs = oldFcs;
|
||||
mFcs = oldFcs;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
Decoder::Decoder(uint8_t *aOutBuf, uint16_t aOutLength, FrameHandler aFrameHandler, ErrorHandler aErrorHandler,
|
||||
void *aContext):
|
||||
mState(kStateNoSync),
|
||||
mFrameHandler(aFrameHandler),
|
||||
mErrorHandler(aErrorHandler),
|
||||
mContext(aContext),
|
||||
mOutBuf(aOutBuf),
|
||||
mOutOffset(0),
|
||||
mOutLength(aOutLength),
|
||||
mFcs(0)
|
||||
Decoder::Decoder(uint8_t * aOutBuf,
|
||||
uint16_t aOutLength,
|
||||
FrameHandler aFrameHandler,
|
||||
ErrorHandler aErrorHandler,
|
||||
void * aContext)
|
||||
: mState(kStateNoSync)
|
||||
, mFrameHandler(aFrameHandler)
|
||||
, mErrorHandler(aErrorHandler)
|
||||
, mContext(aContext)
|
||||
, mOutBuf(aOutBuf)
|
||||
, mOutOffset(0)
|
||||
, mOutLength(aOutLength)
|
||||
, mFcs(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -258,9 +246,9 @@ void Decoder::Decode(const uint8_t *aInBuf, uint16_t aInLength)
|
||||
case kStateNoSync:
|
||||
if (byte == kFlagSequence)
|
||||
{
|
||||
mState = kStateSync;
|
||||
mState = kStateSync;
|
||||
mOutOffset = 0;
|
||||
mFcs = kInitFcs;
|
||||
mFcs = kInitFcs;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -289,14 +277,14 @@ void Decoder::Decode(const uint8_t *aInBuf, uint16_t aInLength)
|
||||
}
|
||||
|
||||
mOutOffset = 0;
|
||||
mFcs = kInitFcs;
|
||||
mFcs = kInitFcs;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if (mOutOffset < mOutLength)
|
||||
{
|
||||
mFcs = UpdateFcs(mFcs, byte);
|
||||
mFcs = UpdateFcs(mFcs, byte);
|
||||
mOutBuf[mOutOffset++] = byte;
|
||||
}
|
||||
else
|
||||
@@ -318,9 +306,9 @@ void Decoder::Decode(const uint8_t *aInBuf, uint16_t aInLength)
|
||||
if (mOutOffset < mOutLength)
|
||||
{
|
||||
byte ^= 0x20;
|
||||
mFcs = UpdateFcs(mFcs, byte);
|
||||
mFcs = UpdateFcs(mFcs, byte);
|
||||
mOutBuf[mOutOffset++] = byte;
|
||||
mState = kStateSync;
|
||||
mState = kStateSync;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -332,13 +320,12 @@ void Decoder::Decode(const uint8_t *aInBuf, uint16_t aInLength)
|
||||
mState = kStateNoSync;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Hdlc
|
||||
} // namespace ot
|
||||
} // namespace Hdlc
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_NCP_UART
|
||||
|
||||
+12
-12
@@ -55,7 +55,6 @@ namespace Hdlc {
|
||||
class Encoder
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* This class defines a write iterator into a buffer used by Encoder.
|
||||
*
|
||||
@@ -64,7 +63,6 @@ public:
|
||||
class BufferWriteIterator
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* This method writes a byte to the buffer and updates the iterator (if space is available).
|
||||
*
|
||||
@@ -86,11 +84,10 @@ public:
|
||||
bool CanWrite(uint16_t aWriteLength) const;
|
||||
|
||||
protected:
|
||||
BufferWriteIterator(void); ///< Protected constructor to ensure no direct instantiation.
|
||||
|
||||
BufferWriteIterator(void); ///< Protected constructor to ensure no direct instantiation.
|
||||
|
||||
uint8_t *mWritePointer; ///< A pointer to current write position in the buffer.
|
||||
uint16_t mRemainingLength; ///< Number of remaining bytes available to write.
|
||||
uint8_t *mWritePointer; ///< A pointer to current write position in the buffer.
|
||||
uint16_t mRemainingLength; ///< Number of remaining bytes available to write.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -192,8 +189,11 @@ public:
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
*/
|
||||
Decoder(uint8_t *aOutBuf, uint16_t aOutLength, FrameHandler aFrameHandler, ErrorHandler aErrorHandler,
|
||||
void *aContext);
|
||||
Decoder(uint8_t * aOutBuf,
|
||||
uint16_t aOutLength,
|
||||
FrameHandler aFrameHandler,
|
||||
ErrorHandler aErrorHandler,
|
||||
void * aContext);
|
||||
|
||||
/**
|
||||
* This method streams bytes into the decoder.
|
||||
@@ -215,7 +215,7 @@ private:
|
||||
|
||||
FrameHandler mFrameHandler;
|
||||
ErrorHandler mErrorHandler;
|
||||
void *mContext;
|
||||
void * mContext;
|
||||
|
||||
uint8_t *mOutBuf;
|
||||
uint16_t mOutOffset;
|
||||
@@ -224,7 +224,7 @@ private:
|
||||
uint16_t mFcs;
|
||||
};
|
||||
|
||||
} // namespace Hdlc
|
||||
} // namespace ot
|
||||
} // namespace Hdlc
|
||||
} // namespace ot
|
||||
|
||||
#endif // HDLC_HPP_
|
||||
#endif // HDLC_HPP_
|
||||
|
||||
+165
-154
@@ -53,10 +53,12 @@ namespace Ncp {
|
||||
// MARK: Property Handler Jump Tables and Methods
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define NCP_GET_PROP_HANDLER_ENTRY(name) { SPINEL_PROP_##name, &NcpBase::GetPropertyHandler_##name }
|
||||
#define NCP_GET_PROP_HANDLER_ENTRY(name) \
|
||||
{ \
|
||||
SPINEL_PROP_##name, &NcpBase::GetPropertyHandler_##name \
|
||||
}
|
||||
|
||||
const NcpBase::PropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] =
|
||||
{
|
||||
const NcpBase::PropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] = {
|
||||
NCP_GET_PROP_HANDLER_ENTRY(CAPS),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(DEBUG_TEST_ASSERT),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(DEBUG_TEST_WATCHDOG),
|
||||
@@ -258,10 +260,12 @@ const NcpBase::PropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
#define NCP_SET_PROP_HANDLER_ENTRY(name) { SPINEL_PROP_##name, &NcpBase::SetPropertyHandler_##name }
|
||||
#define NCP_SET_PROP_HANDLER_ENTRY(name) \
|
||||
{ \
|
||||
SPINEL_PROP_##name, &NcpBase::SetPropertyHandler_##name \
|
||||
}
|
||||
|
||||
const NcpBase::PropertyHandlerEntry NcpBase::mSetPropertyHandlerTable[] =
|
||||
{
|
||||
const NcpBase::PropertyHandlerEntry NcpBase::mSetPropertyHandlerTable[] = {
|
||||
#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
NCP_SET_PROP_HANDLER_ENTRY(MAC_15_4_SADDR),
|
||||
NCP_SET_PROP_HANDLER_ENTRY(MAC_SRC_MATCH_ENABLED),
|
||||
@@ -360,10 +364,12 @@ const NcpBase::PropertyHandlerEntry NcpBase::mSetPropertyHandlerTable[] =
|
||||
#endif // #if OPENTHREAD_FTD
|
||||
};
|
||||
|
||||
#define NCP_INSERT_PROP_HANDLER_ENTRY(name) { SPINEL_PROP_##name, &NcpBase::InsertPropertyHandler_##name }
|
||||
#define NCP_INSERT_PROP_HANDLER_ENTRY(name) \
|
||||
{ \
|
||||
SPINEL_PROP_##name, &NcpBase::InsertPropertyHandler_##name \
|
||||
}
|
||||
|
||||
const NcpBase::PropertyHandlerEntry NcpBase::mInsertPropertyHandlerTable[] =
|
||||
{
|
||||
const NcpBase::PropertyHandlerEntry NcpBase::mInsertPropertyHandlerTable[] = {
|
||||
NCP_INSERT_PROP_HANDLER_ENTRY(UNSOL_UPDATE_FILTER),
|
||||
#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
NCP_INSERT_PROP_HANDLER_ENTRY(MAC_SRC_MATCH_SHORT_ADDRESSES),
|
||||
@@ -390,10 +396,12 @@ const NcpBase::PropertyHandlerEntry NcpBase::mInsertPropertyHandlerTable[] =
|
||||
#endif // OPENTHREAD_FTD
|
||||
};
|
||||
|
||||
#define NCP_REMOVE_PROP_HANDLER_ENTRY(name) { SPINEL_PROP_##name, &NcpBase::RemovePropertyHandler_##name }
|
||||
#define NCP_REMOVE_PROP_HANDLER_ENTRY(name) \
|
||||
{ \
|
||||
SPINEL_PROP_##name, &NcpBase::RemovePropertyHandler_##name \
|
||||
}
|
||||
|
||||
const NcpBase::PropertyHandlerEntry NcpBase::mRemovePropertyHandlerTable[] =
|
||||
{
|
||||
const NcpBase::PropertyHandlerEntry NcpBase::mRemovePropertyHandlerTable[] = {
|
||||
NCP_REMOVE_PROP_HANDLER_ENTRY(UNSOL_UPDATE_FILTER),
|
||||
#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
NCP_REMOVE_PROP_HANDLER_ENTRY(MAC_SRC_MATCH_SHORT_ADDRESSES),
|
||||
@@ -545,58 +553,65 @@ static spinel_status_t ResetReasonToSpinelStatus(otPlatResetReason aReason)
|
||||
|
||||
NcpBase *NcpBase::sNcpInstance = NULL;
|
||||
|
||||
NcpBase::NcpBase(Instance *aInstance):
|
||||
mInstance(aInstance),
|
||||
mTxFrameBuffer(mTxBuffer, sizeof(mTxBuffer)),
|
||||
mEncoder(mTxFrameBuffer),
|
||||
mDecoder(),
|
||||
mHostPowerStateInProgress(false),
|
||||
mLastStatus(SPINEL_STATUS_OK),
|
||||
mSupportedChannelMask(OT_RADIO_SUPPORTED_CHANNELS),
|
||||
mChannelMask(OT_RADIO_SUPPORTED_CHANNELS),
|
||||
mScanPeriod(200), // ms
|
||||
mDiscoveryScanJoinerFlag(false),
|
||||
mDiscoveryScanEnableFiltering(false),
|
||||
mDiscoveryScanPanId(0xffff),
|
||||
mUpdateChangedPropsTask(*aInstance, &NcpBase::UpdateChangedProps, this),
|
||||
mThreadChangedFlags(0),
|
||||
mChangedPropsSet(),
|
||||
mHostPowerState(SPINEL_HOST_POWER_STATE_ONLINE),
|
||||
mHostPowerReplyFrameTag(NcpFrameBuffer::kInvalidTag),
|
||||
mHostPowerStateHeader(0),
|
||||
NcpBase::NcpBase(Instance *aInstance)
|
||||
: mInstance(aInstance)
|
||||
, mTxFrameBuffer(mTxBuffer, sizeof(mTxBuffer))
|
||||
, mEncoder(mTxFrameBuffer)
|
||||
, mDecoder()
|
||||
, mHostPowerStateInProgress(false)
|
||||
, mLastStatus(SPINEL_STATUS_OK)
|
||||
, mSupportedChannelMask(OT_RADIO_SUPPORTED_CHANNELS)
|
||||
, mChannelMask(OT_RADIO_SUPPORTED_CHANNELS)
|
||||
, mScanPeriod(200)
|
||||
, // ms
|
||||
mDiscoveryScanJoinerFlag(false)
|
||||
, mDiscoveryScanEnableFiltering(false)
|
||||
, mDiscoveryScanPanId(0xffff)
|
||||
, mUpdateChangedPropsTask(*aInstance, &NcpBase::UpdateChangedProps, this)
|
||||
, mThreadChangedFlags(0)
|
||||
, mChangedPropsSet()
|
||||
, mHostPowerState(SPINEL_HOST_POWER_STATE_ONLINE)
|
||||
, mHostPowerReplyFrameTag(NcpFrameBuffer::kInvalidTag)
|
||||
, mHostPowerStateHeader(0)
|
||||
,
|
||||
#if OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE
|
||||
mAllowPeekDelegate(NULL),
|
||||
mAllowPokeDelegate(NULL),
|
||||
mAllowPeekDelegate(NULL)
|
||||
, mAllowPokeDelegate(NULL)
|
||||
,
|
||||
#endif
|
||||
mNextExpectedTid(0),
|
||||
mResponseQueueHead(0),
|
||||
mResponseQueueTail(0),
|
||||
mAllowLocalNetworkDataChange(false),
|
||||
mRequireJoinExistingNetwork(false),
|
||||
mIsRawStreamEnabled(false),
|
||||
mDisableStreamWrite(false),
|
||||
mShouldEmitChildTableUpdate(false),
|
||||
mNextExpectedTid(0)
|
||||
, mResponseQueueHead(0)
|
||||
, mResponseQueueTail(0)
|
||||
, mAllowLocalNetworkDataChange(false)
|
||||
, mRequireJoinExistingNetwork(false)
|
||||
, mIsRawStreamEnabled(false)
|
||||
, mDisableStreamWrite(false)
|
||||
, mShouldEmitChildTableUpdate(false)
|
||||
,
|
||||
#if OPENTHREAD_FTD
|
||||
mPreferredRouteId(0),
|
||||
mPreferredRouteId(0)
|
||||
,
|
||||
#endif
|
||||
#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
mCurTransmitTID(0),
|
||||
mCurScanChannel(kInvalidScanChannel),
|
||||
mSrcMatchEnabled(false),
|
||||
mCurTransmitTID(0)
|
||||
, mCurScanChannel(kInvalidScanChannel)
|
||||
, mSrcMatchEnabled(false)
|
||||
,
|
||||
#endif // OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
#if OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
mInboundSecureIpFrameCounter(0),
|
||||
mInboundInsecureIpFrameCounter(0),
|
||||
mOutboundSecureIpFrameCounter(0),
|
||||
mOutboundInsecureIpFrameCounter(0),
|
||||
mDroppedOutboundIpFrameCounter(0),
|
||||
mDroppedInboundIpFrameCounter(0),
|
||||
mInboundSecureIpFrameCounter(0)
|
||||
, mInboundInsecureIpFrameCounter(0)
|
||||
, mOutboundSecureIpFrameCounter(0)
|
||||
, mOutboundInsecureIpFrameCounter(0)
|
||||
, mDroppedOutboundIpFrameCounter(0)
|
||||
, mDroppedInboundIpFrameCounter(0)
|
||||
,
|
||||
#endif // OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
mFramingErrorCounter(0),
|
||||
mRxSpinelFrameCounter(0),
|
||||
mRxSpinelOutOfOrderTidCounter(0),
|
||||
mTxSpinelFrameCounter(0),
|
||||
mDidInitialUpdates(false)
|
||||
mFramingErrorCounter(0)
|
||||
, mRxSpinelFrameCounter(0)
|
||||
, mRxSpinelOutOfOrderTidCounter(0)
|
||||
, mTxSpinelFrameCounter(0)
|
||||
, mDidInitialUpdates(false)
|
||||
{
|
||||
assert(mInstance != NULL);
|
||||
|
||||
@@ -621,7 +636,7 @@ NcpBase::NcpBase(Instance *aInstance):
|
||||
#endif // OPENTHREAD_FTD
|
||||
#if OPENTHREAD_ENABLE_LEGACY
|
||||
mLegacyNodeDidJoin = false;
|
||||
mLegacyHandlers = NULL;
|
||||
mLegacyHandlers = NULL;
|
||||
memset(mLegacyUlaPrefix, 0, sizeof(mLegacyUlaPrefix));
|
||||
memset(&mLegacyLastJoinedNode, 0, sizeof(mLegacyLastJoinedNode));
|
||||
#endif
|
||||
@@ -646,9 +661,9 @@ NcpFrameBuffer::FrameTag NcpBase::GetLastOutboundFrameTag(void)
|
||||
|
||||
void NcpBase::HandleReceive(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t header = 0;
|
||||
spinel_tid_t tid = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t header = 0;
|
||||
spinel_tid_t tid = 0;
|
||||
|
||||
mDisableStreamWrite = true;
|
||||
|
||||
@@ -656,7 +671,7 @@ void NcpBase::HandleReceive(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
mDecoder.Init(aBuf, aBufLength);
|
||||
|
||||
// Receiving any message from the host has the side effect of transitioning the host power state to online.
|
||||
mHostPowerState = SPINEL_HOST_POWER_STATE_ONLINE;
|
||||
mHostPowerState = SPINEL_HOST_POWER_STATE_ONLINE;
|
||||
mHostPowerStateInProgress = false;
|
||||
|
||||
// Skip if there is no header byte to read or this isn't a spinel frame.
|
||||
@@ -707,8 +722,10 @@ exit:
|
||||
mDisableStreamWrite = false;
|
||||
}
|
||||
|
||||
void NcpBase::HandleFrameRemovedFromNcpBuffer(void *aContext, NcpFrameBuffer::FrameTag aFrameTag,
|
||||
NcpFrameBuffer::Priority aPriority, NcpFrameBuffer *aNcpBuffer)
|
||||
void NcpBase::HandleFrameRemovedFromNcpBuffer(void * aContext,
|
||||
NcpFrameBuffer::FrameTag aFrameTag,
|
||||
NcpFrameBuffer::Priority aPriority,
|
||||
NcpFrameBuffer * aNcpBuffer)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aNcpBuffer);
|
||||
OT_UNUSED_VARIABLE(aPriority);
|
||||
@@ -750,12 +767,11 @@ void NcpBase::HandleFrameRemovedFromNcpBuffer(NcpFrameBuffer::FrameTag aFrameTag
|
||||
|
||||
if (mHostPowerState != SPINEL_HOST_POWER_STATE_ONLINE)
|
||||
{
|
||||
mHostPowerReplyFrameTag = GetLastOutboundFrameTag();
|
||||
mHostPowerReplyFrameTag = GetLastOutboundFrameTag();
|
||||
mHostPowerStateInProgress = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
|
||||
// Send any queued IPv6 datagram message.
|
||||
@@ -788,8 +804,8 @@ void NcpBase::IncrementFrameErrorCounter(void)
|
||||
|
||||
otError NcpBase::StreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
spinel_prop_key_t streamPropKey;
|
||||
|
||||
if (aStreamId == 0)
|
||||
@@ -865,7 +881,6 @@ unsigned int NcpBase::ConvertLogRegion(otLogRegion aLogRegion)
|
||||
|
||||
switch (aLogRegion)
|
||||
{
|
||||
|
||||
case OT_LOG_REGION_API:
|
||||
spinelLogRegion = SPINEL_NCP_LOG_REGION_OT_API;
|
||||
break;
|
||||
@@ -936,7 +951,7 @@ unsigned int NcpBase::ConvertLogRegion(otLogRegion aLogRegion)
|
||||
|
||||
void NcpBase::Log(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aLogString)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
|
||||
VerifyOrExit(!mDisableStreamWrite);
|
||||
@@ -985,8 +1000,8 @@ void NcpBase::HandleRawFrame(const otRadioFrame *aFrame, void *aContext)
|
||||
|
||||
void NcpBase::HandleRawFrame(const otRadioFrame *aFrame)
|
||||
{
|
||||
uint16_t flags = 0;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
uint16_t flags = 0;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
|
||||
if (!mIsRawStreamEnabled)
|
||||
{
|
||||
@@ -1006,15 +1021,15 @@ void NcpBase::HandleRawFrame(const otRadioFrame *aFrame)
|
||||
SuccessOrExit(mEncoder.WriteData(aFrame->mPsdu, aFrame->mLength));
|
||||
|
||||
// Append metadata (rssi, etc)
|
||||
SuccessOrExit(mEncoder.WriteInt8(aFrame->mInfo.mRxInfo.mRssi)); // RSSI
|
||||
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise floor (Currently unused)
|
||||
SuccessOrExit(mEncoder.WriteUint16(flags)); // Flags
|
||||
SuccessOrExit(mEncoder.WriteInt8(aFrame->mInfo.mRxInfo.mRssi)); // RSSI
|
||||
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise floor (Currently unused)
|
||||
SuccessOrExit(mEncoder.WriteUint16(flags)); // Flags
|
||||
|
||||
SuccessOrExit(mEncoder.OpenStruct()); // PHY-data
|
||||
SuccessOrExit(mEncoder.OpenStruct()); // PHY-data
|
||||
// Empty for now
|
||||
SuccessOrExit(mEncoder.CloseStruct());
|
||||
|
||||
SuccessOrExit(mEncoder.OpenStruct()); // Vendor-data
|
||||
SuccessOrExit(mEncoder.OpenStruct()); // Vendor-data
|
||||
// Empty for now
|
||||
SuccessOrExit(mEncoder.CloseStruct());
|
||||
|
||||
@@ -1040,8 +1055,8 @@ uint8_t NcpBase::GetWrappedResponseQueueIndex(uint8_t aPosition)
|
||||
|
||||
otError NcpBase::PrepareResponse(uint8_t aHeader, bool aIsLastStatus, bool aIsGetResponse, unsigned int aKeyOrStatus)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
spinel_tid_t tid = SPINEL_HEADER_GET_TID(aHeader);
|
||||
otError error = OT_ERROR_NONE;
|
||||
spinel_tid_t tid = SPINEL_HEADER_GET_TID(aHeader);
|
||||
ResponseEntry *entry;
|
||||
|
||||
if (tid == 0)
|
||||
@@ -1094,10 +1109,10 @@ otError NcpBase::PrepareResponse(uint8_t aHeader, bool aIsLastStatus, bool aIsGe
|
||||
|
||||
entry = &mResponseQueue[GetWrappedResponseQueueIndex(mResponseQueueTail)];
|
||||
|
||||
entry->mTid = tid;
|
||||
entry->mIsInUse = true;
|
||||
entry->mIsLastStatus = aIsLastStatus;
|
||||
entry->mIsGetResponse = aIsGetResponse;
|
||||
entry->mTid = tid;
|
||||
entry->mIsInUse = true;
|
||||
entry->mIsLastStatus = aIsLastStatus;
|
||||
entry->mIsGetResponse = aIsGetResponse;
|
||||
entry->mPropKeyOrStatus = aKeyOrStatus;
|
||||
|
||||
mResponseQueueTail++;
|
||||
@@ -1169,8 +1184,8 @@ void NcpBase::UpdateChangedProps(Tasklet &aTasklet)
|
||||
|
||||
void NcpBase::UpdateChangedProps(void)
|
||||
{
|
||||
uint8_t numEntries;
|
||||
spinel_prop_key_t propKey;
|
||||
uint8_t numEntries;
|
||||
spinel_prop_key_t propKey;
|
||||
const ChangedPropsSet::Entry *entry;
|
||||
|
||||
#if OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
@@ -1221,7 +1236,7 @@ exit:
|
||||
|
||||
otError NcpBase::HandleCommand(uint8_t aHeader)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
unsigned int command;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUintPacked(command));
|
||||
@@ -1289,8 +1304,9 @@ exit:
|
||||
// MARK: Property Get/Set/Insert/Remove Commands
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
NcpBase::PropertyHandler NcpBase::FindPropertyHandler(spinel_prop_key_t aKey, const PropertyHandlerEntry *aTableEntry,
|
||||
size_t aTableLen)
|
||||
NcpBase::PropertyHandler NcpBase::FindPropertyHandler(spinel_prop_key_t aKey,
|
||||
const PropertyHandlerEntry *aTableEntry,
|
||||
size_t aTableLen)
|
||||
{
|
||||
PropertyHandler handler = NULL;
|
||||
|
||||
@@ -1320,7 +1336,7 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
|
||||
|
||||
NcpBase::PropertyHandler NcpBase::FindInsertPropertyHandler(spinel_prop_key_t aKey)
|
||||
{
|
||||
return FindPropertyHandler(aKey, mInsertPropertyHandlerTable, OT_ARRAY_LENGTH(mInsertPropertyHandlerTable));
|
||||
return FindPropertyHandler(aKey, mInsertPropertyHandlerTable, OT_ARRAY_LENGTH(mInsertPropertyHandlerTable));
|
||||
}
|
||||
|
||||
NcpBase::PropertyHandler NcpBase::FindRemovePropertyHandler(spinel_prop_key_t aKey)
|
||||
@@ -1368,13 +1384,13 @@ exit:
|
||||
|
||||
otError NcpBase::HandleCommandPropertySet(uint8_t aHeader, spinel_prop_key_t aKey)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
PropertyHandler handler = FindSetPropertyHandler(aKey);
|
||||
|
||||
if (handler != NULL)
|
||||
{
|
||||
mDisableStreamWrite = false;
|
||||
error = (this->*handler)();
|
||||
error = (this->*handler)();
|
||||
mDisableStreamWrite = true;
|
||||
}
|
||||
else
|
||||
@@ -1390,7 +1406,7 @@ otError NcpBase::HandleCommandPropertySet(uint8_t aHeader, spinel_prop_key_t aKe
|
||||
if (aKey >= SPINEL_PROP_VENDOR__BEGIN && aKey < SPINEL_PROP_VENDOR__END)
|
||||
{
|
||||
mDisableStreamWrite = false;
|
||||
error = VendorSetPropertyHandler(aKey);
|
||||
error = VendorSetPropertyHandler(aKey);
|
||||
mDisableStreamWrite = true;
|
||||
|
||||
// An `OT_ERROR_NOT_FOUND` status from vendor handler indicates
|
||||
@@ -1421,21 +1437,21 @@ exit:
|
||||
|
||||
otError NcpBase::HandleCommandPropertyInsertRemove(uint8_t aHeader, spinel_prop_key_t aKey, unsigned int aCommand)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
PropertyHandler handler = NULL;
|
||||
unsigned int responseCommand = 0;
|
||||
const uint8_t *valuePtr;
|
||||
uint16_t valueLen;
|
||||
otError error = OT_ERROR_NONE;
|
||||
PropertyHandler handler = NULL;
|
||||
unsigned int responseCommand = 0;
|
||||
const uint8_t * valuePtr;
|
||||
uint16_t valueLen;
|
||||
|
||||
switch (aCommand)
|
||||
{
|
||||
case SPINEL_CMD_PROP_VALUE_INSERT:
|
||||
handler = FindInsertPropertyHandler(aKey);
|
||||
handler = FindInsertPropertyHandler(aKey);
|
||||
responseCommand = SPINEL_CMD_PROP_VALUE_INSERTED;
|
||||
break;
|
||||
|
||||
case SPINEL_CMD_PROP_VALUE_REMOVE:
|
||||
handler = FindRemovePropertyHandler(aKey);
|
||||
handler = FindRemovePropertyHandler(aKey);
|
||||
responseCommand = SPINEL_CMD_PROP_VALUE_REMOVED;
|
||||
break;
|
||||
|
||||
@@ -1500,7 +1516,7 @@ exit:
|
||||
|
||||
otError NcpBase::WritePropertyValueIsFrame(uint8_t aHeader, spinel_prop_key_t aPropKey, bool aIsGetResponse)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
PropertyHandler handler = FindGetPropertyHandler(aPropKey);
|
||||
|
||||
if (handler != NULL)
|
||||
@@ -1545,9 +1561,11 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError NcpBase::WritePropertyValueInsertedRemovedFrame(uint8_t aHeader, unsigned int aResponseCommand,
|
||||
spinel_prop_key_t aPropKey, const uint8_t *aValuePtr,
|
||||
uint16_t aValueLen)
|
||||
otError NcpBase::WritePropertyValueInsertedRemovedFrame(uint8_t aHeader,
|
||||
unsigned int aResponseCommand,
|
||||
spinel_prop_key_t aPropKey,
|
||||
const uint8_t * aValuePtr,
|
||||
uint16_t aValueLen)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
@@ -1600,7 +1618,7 @@ otError NcpBase::CommandHandler_RESET(uint8_t aHeader)
|
||||
|
||||
otError NcpBase::CommandHandler_PROP_VALUE_update(uint8_t aHeader, unsigned int aCommand)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
unsigned int propKey = 0;
|
||||
|
||||
error = mDecoder.ReadUintPacked(propKey);
|
||||
@@ -1634,8 +1652,8 @@ exit:
|
||||
|
||||
otError NcpBase::CommandHandler_PEEK(uint8_t aHeader)
|
||||
{
|
||||
otError parseError = OT_ERROR_NONE;
|
||||
otError responseError = OT_ERROR_NONE;
|
||||
otError parseError = OT_ERROR_NONE;
|
||||
otError responseError = OT_ERROR_NONE;
|
||||
uint32_t address;
|
||||
uint16_t count;
|
||||
|
||||
@@ -1666,11 +1684,11 @@ exit:
|
||||
|
||||
otError NcpBase::CommandHandler_POKE(uint8_t aHeader)
|
||||
{
|
||||
otError parseError = OT_ERROR_NONE;
|
||||
uint32_t address;
|
||||
uint16_t count;
|
||||
otError parseError = OT_ERROR_NONE;
|
||||
uint32_t address;
|
||||
uint16_t count;
|
||||
const uint8_t *dataPtr = NULL;
|
||||
uint16_t dataLen;
|
||||
uint16_t dataLen;
|
||||
|
||||
SuccessOrExit(parseError = mDecoder.ReadUint32(address));
|
||||
SuccessOrExit(parseError = mDecoder.ReadUint16(count));
|
||||
@@ -1692,10 +1710,9 @@ exit:
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MARK: Individual Property Getters and Setters
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// MARK: Individual Property Getters and Setters
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
|
||||
@@ -1703,7 +1720,7 @@ otError NcpBase::SetPropertyHandler_NEST_STREAM_MFG(uint8_t aHeader)
|
||||
{
|
||||
const char *string = NULL;
|
||||
const char *output = NULL;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
error = mDecoder.ReadUtf8(string);
|
||||
|
||||
@@ -1725,9 +1742,9 @@ exit:
|
||||
otError NcpBase::GetPropertyHandler_PHY_ENABLED(void)
|
||||
{
|
||||
#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
return mEncoder.WriteBool(otLinkRawIsEnabled(mInstance));
|
||||
return mEncoder.WriteBool(otLinkRawIsEnabled(mInstance));
|
||||
#else
|
||||
return mEncoder.WriteBool(false);
|
||||
return mEncoder.WriteBool(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1739,7 +1756,7 @@ otError NcpBase::GetPropertyHandler_PHY_CHAN(void)
|
||||
otError NcpBase::SetPropertyHandler_PHY_CHAN(void)
|
||||
{
|
||||
unsigned int channel = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUintPacked(channel));
|
||||
|
||||
@@ -1764,15 +1781,13 @@ exit:
|
||||
|
||||
otError NcpBase::GetPropertyHandler_MAC_PROMISCUOUS_MODE(void)
|
||||
{
|
||||
return mEncoder.WriteUint8(otPlatRadioGetPromiscuous(mInstance)
|
||||
? SPINEL_MAC_PROMISCUOUS_MODE_FULL
|
||||
: SPINEL_MAC_PROMISCUOUS_MODE_OFF
|
||||
);
|
||||
return mEncoder.WriteUint8(otPlatRadioGetPromiscuous(mInstance) ? SPINEL_MAC_PROMISCUOUS_MODE_FULL
|
||||
: SPINEL_MAC_PROMISCUOUS_MODE_OFF);
|
||||
}
|
||||
|
||||
otError NcpBase::SetPropertyHandler_MAC_PROMISCUOUS_MODE(void)
|
||||
{
|
||||
uint8_t mode = 0;
|
||||
uint8_t mode = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(mode));
|
||||
@@ -1805,7 +1820,7 @@ otError NcpBase::GetPropertyHandler_MAC_15_4_PANID(void)
|
||||
otError NcpBase::SetPropertyHandler_MAC_15_4_PANID(void)
|
||||
{
|
||||
uint16_t panid;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint16(panid));
|
||||
|
||||
@@ -1823,7 +1838,7 @@ otError NcpBase::GetPropertyHandler_MAC_15_4_LADDR(void)
|
||||
otError NcpBase::SetPropertyHandler_MAC_15_4_LADDR(void)
|
||||
{
|
||||
const otExtAddress *extAddress;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadEui64(extAddress));
|
||||
|
||||
@@ -1845,8 +1860,8 @@ otError NcpBase::GetPropertyHandler_MAC_RAW_STREAM_ENABLED(void)
|
||||
|
||||
otError NcpBase::SetPropertyHandler_MAC_RAW_STREAM_ENABLED(void)
|
||||
{
|
||||
bool enabled = false;
|
||||
otError error = OT_ERROR_NONE;
|
||||
bool enabled = false;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadBool(enabled));
|
||||
|
||||
@@ -1874,8 +1889,8 @@ exit:
|
||||
|
||||
otError NcpBase::GetPropertyHandler_UNSOL_UPDATE_FILTER(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t numEntries;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t numEntries;
|
||||
const ChangedPropsSet::Entry *entry;
|
||||
|
||||
entry = mChangedPropsSet.GetSupportedEntries(numEntries);
|
||||
@@ -1895,7 +1910,7 @@ exit:
|
||||
otError NcpBase::SetPropertyHandler_UNSOL_UPDATE_FILTER(void)
|
||||
{
|
||||
unsigned int propKey;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
// First clear the current filter.
|
||||
mChangedPropsSet.ClearFilter();
|
||||
@@ -1923,7 +1938,7 @@ exit:
|
||||
|
||||
otError NcpBase::InsertPropertyHandler_UNSOL_UPDATE_FILTER(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
unsigned int propKey;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUintPacked(propKey));
|
||||
@@ -1936,7 +1951,7 @@ exit:
|
||||
|
||||
otError NcpBase::RemovePropertyHandler_UNSOL_UPDATE_FILTER(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
unsigned int propKey;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUintPacked(propKey));
|
||||
@@ -1970,7 +1985,7 @@ otError NcpBase::GetPropertyHandler_INTERFACE_TYPE(void)
|
||||
|
||||
otError NcpBase::GetPropertyHandler_VENDOR_ID(void)
|
||||
{
|
||||
return mEncoder.WriteUintPacked(0); // Vendor ID. Zero for unknown.
|
||||
return mEncoder.WriteUintPacked(0); // Vendor ID. Zero for unknown.
|
||||
}
|
||||
|
||||
otError NcpBase::GetPropertyHandler_CAPS(void)
|
||||
@@ -2082,9 +2097,9 @@ otError NcpBase::GetPropertyHandler_MCU_POWER_STATE(void)
|
||||
|
||||
otError NcpBase::SetPropertyHandler_MCU_POWER_STATE(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otPlatMcuPowerState powerState;
|
||||
uint8_t state;
|
||||
uint8_t state;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(state));
|
||||
|
||||
@@ -2251,8 +2266,8 @@ otError NcpBase::SetPropertyHandler_HOST_POWER_STATE(uint8_t aHeader)
|
||||
|
||||
otError NcpBase::GetPropertyHandler_UNSOL_UPDATE_LIST(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t numEntries;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t numEntries;
|
||||
const ChangedPropsSet::Entry *entry;
|
||||
|
||||
entry = mChangedPropsSet.GetSupportedEntries(numEntries);
|
||||
@@ -2276,7 +2291,7 @@ otError NcpBase::GetPropertyHandler_PHY_RX_SENSITIVITY(void)
|
||||
|
||||
otError NcpBase::GetPropertyHandler_PHY_TX_POWER(void)
|
||||
{
|
||||
int8_t power;
|
||||
int8_t power;
|
||||
otError error;
|
||||
|
||||
error = otPlatRadioGetTransmitPower(mInstance, &power);
|
||||
@@ -2295,8 +2310,8 @@ otError NcpBase::GetPropertyHandler_PHY_TX_POWER(void)
|
||||
|
||||
otError NcpBase::SetPropertyHandler_PHY_TX_POWER(void)
|
||||
{
|
||||
int8_t txPower = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t txPower = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadInt8(txPower));
|
||||
error = otPlatRadioSetTransmitPower(mInstance, txPower);
|
||||
@@ -2314,9 +2329,7 @@ otError NcpBase::GetPropertyHandler_DEBUG_TEST_ASSERT(void)
|
||||
// In such a case we return `false` as the
|
||||
// property value to indicate this.
|
||||
|
||||
OT_UNREACHABLE_CODE(
|
||||
return mEncoder.WriteBool(false);
|
||||
)
|
||||
OT_UNREACHABLE_CODE(return mEncoder.WriteBool(false);)
|
||||
}
|
||||
|
||||
otError NcpBase::GetPropertyHandler_DEBUG_TEST_WATCHDOG(void)
|
||||
@@ -2324,9 +2337,7 @@ otError NcpBase::GetPropertyHandler_DEBUG_TEST_WATCHDOG(void)
|
||||
while (true)
|
||||
;
|
||||
|
||||
OT_UNREACHABLE_CODE(
|
||||
return OT_ERROR_NONE;
|
||||
)
|
||||
OT_UNREACHABLE_CODE(return OT_ERROR_NONE;)
|
||||
}
|
||||
|
||||
otError NcpBase::GetPropertyHandler_DEBUG_NCP_LOG_LEVEL(void)
|
||||
@@ -2336,9 +2347,9 @@ otError NcpBase::GetPropertyHandler_DEBUG_NCP_LOG_LEVEL(void)
|
||||
|
||||
otError NcpBase::SetPropertyHandler_DEBUG_NCP_LOG_LEVEL(void)
|
||||
{
|
||||
uint8_t spinelNcpLogLevel = 0;
|
||||
uint8_t spinelNcpLogLevel = 0;
|
||||
otLogLevel logLevel;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(spinelNcpLogLevel));
|
||||
|
||||
@@ -2381,8 +2392,8 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MARK: Peek/Poke delegate API
|
||||
@@ -2417,8 +2428,8 @@ otError otNcpRegisterPeekPokeDelagates(otNcpDelegateAllowPeekPoke aAllowPeekDele
|
||||
|
||||
otError otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen)
|
||||
{
|
||||
otError error = OT_ERROR_INVALID_STATE;
|
||||
ot::Ncp::NcpBase *ncp = ot::Ncp::NcpBase::GetNcpInstance();
|
||||
otError error = OT_ERROR_INVALID_STATE;
|
||||
ot::Ncp::NcpBase *ncp = ot::Ncp::NcpBase::GetNcpInstance();
|
||||
|
||||
if (ncp != NULL)
|
||||
{
|
||||
@@ -2431,7 +2442,7 @@ otError otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen)
|
||||
extern "C" void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs)
|
||||
{
|
||||
char logString[OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE];
|
||||
int charsWritten;
|
||||
int charsWritten;
|
||||
|
||||
if ((charsWritten = vsnprintf(logString, sizeof(logString), aFormat, aArgs)) > 0)
|
||||
{
|
||||
@@ -2451,8 +2462,8 @@ extern "C" void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, cons
|
||||
|
||||
extern "C" void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
char logString[OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE];
|
||||
va_list args;
|
||||
char logString[OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE];
|
||||
ot::Ncp::NcpBase *ncp = ot::Ncp::NcpBase::GetNcpInstance();
|
||||
|
||||
va_start(args, aFormat);
|
||||
|
||||
+88
-77
@@ -59,15 +59,14 @@
|
||||
namespace ot {
|
||||
namespace Ncp {
|
||||
|
||||
#define NCP_GET_PROP_HANDLER(name) otError GetPropertyHandler_##name(void)
|
||||
#define NCP_SET_PROP_HANDLER(name) otError SetPropertyHandler_##name(void)
|
||||
#define NCP_GET_PROP_HANDLER(name) otError GetPropertyHandler_##name(void)
|
||||
#define NCP_SET_PROP_HANDLER(name) otError SetPropertyHandler_##name(void)
|
||||
#define NCP_INSERT_PROP_HANDLER(name) otError InsertPropertyHandler_##name(void)
|
||||
#define NCP_REMOVE_PROP_HANDLER(name) otError RemovePropertyHandler_##name(void)
|
||||
|
||||
class NcpBase
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* This constructor creates and initializes an NcpBase instance.
|
||||
*
|
||||
@@ -112,7 +111,6 @@ public:
|
||||
*/
|
||||
void Log(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aLogString);
|
||||
|
||||
|
||||
#if OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE
|
||||
/**
|
||||
* This method registers peek/poke delegate functions with NCP module.
|
||||
@@ -184,7 +182,7 @@ protected:
|
||||
struct PropertyHandlerEntry
|
||||
{
|
||||
spinel_prop_key_t mPropKey;
|
||||
PropertyHandler mHandler;
|
||||
PropertyHandler mHandler;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -196,11 +194,11 @@ protected:
|
||||
*/
|
||||
struct ResponseEntry
|
||||
{
|
||||
uint8_t mTid : 4; ///< Spinel transaction id.
|
||||
bool mIsInUse : 1; ///< `true` if this entry is in use, `false` otherwise.
|
||||
bool mIsLastStatus : 1; ///< `true` if entry is a `LAST_STATUS`, otherwise it is a property update.
|
||||
bool mIsGetResponse : 1; ///< `true` if response is for `VALUE_GET`, 'false` otherwise.
|
||||
uint32_t mPropKeyOrStatus : 24; ///< 3 bytes for either property key or spinel status.
|
||||
uint8_t mTid : 4; ///< Spinel transaction id.
|
||||
bool mIsInUse : 1; ///< `true` if this entry is in use, `false` otherwise.
|
||||
bool mIsLastStatus : 1; ///< `true` if entry is a `LAST_STATUS`, otherwise it is a property update.
|
||||
bool mIsGetResponse : 1; ///< `true` if response is for `VALUE_GET`, 'false` otherwise.
|
||||
uint32_t mPropKeyOrStatus : 24; ///< 3 bytes for either property key or spinel status.
|
||||
};
|
||||
|
||||
NcpFrameBuffer::FrameTag GetLastOutboundFrameTag(void);
|
||||
@@ -213,79 +211,89 @@ protected:
|
||||
PropertyHandler FindInsertPropertyHandler(spinel_prop_key_t aKey);
|
||||
PropertyHandler FindRemovePropertyHandler(spinel_prop_key_t aKey);
|
||||
|
||||
bool HandlePropertySetForSpecialProperties(uint8_t aHeader, spinel_prop_key_t aKey, otError &aError);
|
||||
bool HandlePropertySetForSpecialProperties(uint8_t aHeader, spinel_prop_key_t aKey, otError &aError);
|
||||
otError HandleCommandPropertySet(uint8_t aHeader, spinel_prop_key_t aKey);
|
||||
otError HandleCommandPropertyInsertRemove(uint8_t aHeader, spinel_prop_key_t aKey, unsigned int aCommand);
|
||||
|
||||
otError WriteLastStatusFrame(uint8_t aHeader, spinel_status_t aLastStatus);
|
||||
otError WritePropertyValueIsFrame(uint8_t aHeader, spinel_prop_key_t aPropKey, bool aIsGetResponse = true);
|
||||
otError WritePropertyValueInsertedRemovedFrame(uint8_t aHeader, unsigned int aResponseCommand,
|
||||
spinel_prop_key_t aPropKey, const uint8_t *aValuePtr,
|
||||
uint16_t aValueLen);
|
||||
otError WritePropertyValueInsertedRemovedFrame(uint8_t aHeader,
|
||||
unsigned int aResponseCommand,
|
||||
spinel_prop_key_t aPropKey,
|
||||
const uint8_t * aValuePtr,
|
||||
uint16_t aValueLen);
|
||||
|
||||
otError SendQueuedResponses(void);
|
||||
bool IsResponseQueueEmpty(void) { return (mResponseQueueHead == mResponseQueueTail); }
|
||||
bool IsResponseQueueEmpty(void) { return (mResponseQueueHead == mResponseQueueTail); }
|
||||
otError PrepareResponse(uint8_t aHeader, bool aIsLastStatus, bool aIsGetResponse, unsigned int aPropKeyOrStatus);
|
||||
otError PrepareGetResponse(uint8_t aHeader, spinel_prop_key_t aPropKey) {
|
||||
otError PrepareGetResponse(uint8_t aHeader, spinel_prop_key_t aPropKey)
|
||||
{
|
||||
return PrepareResponse(aHeader, false /* aIsLastStatus */, true /* aIsGetResponse*/, aPropKey);
|
||||
}
|
||||
otError PrepareSetResponse(uint8_t aHeader, spinel_prop_key_t aPropKey) {
|
||||
otError PrepareSetResponse(uint8_t aHeader, spinel_prop_key_t aPropKey)
|
||||
{
|
||||
return PrepareResponse(aHeader, false /* aIsLastStatus */, false /* aIsGetResponse*/, aPropKey);
|
||||
}
|
||||
otError PrepareLastStatusResponse(uint8_t aHeader, spinel_status_t aStatus) {
|
||||
otError PrepareLastStatusResponse(uint8_t aHeader, spinel_status_t aStatus)
|
||||
{
|
||||
return PrepareResponse(aHeader, true /*aIsLastStatus */, false, aStatus);
|
||||
}
|
||||
static uint8_t GetWrappedResponseQueueIndex(uint8_t aPosition);
|
||||
|
||||
static void UpdateChangedProps(Tasklet &aTasklet);
|
||||
void UpdateChangedProps(void);
|
||||
void UpdateChangedProps(void);
|
||||
|
||||
static void HandleFrameRemovedFromNcpBuffer(void *aContext, NcpFrameBuffer::FrameTag aFrameTag,
|
||||
NcpFrameBuffer::Priority aPriority, NcpFrameBuffer *aNcpBuffer);
|
||||
void HandleFrameRemovedFromNcpBuffer(NcpFrameBuffer::FrameTag aFrameTag);
|
||||
static void HandleFrameRemovedFromNcpBuffer(void * aContext,
|
||||
NcpFrameBuffer::FrameTag aFrameTag,
|
||||
NcpFrameBuffer::Priority aPriority,
|
||||
NcpFrameBuffer * aNcpBuffer);
|
||||
void HandleFrameRemovedFromNcpBuffer(NcpFrameBuffer::FrameTag aFrameTag);
|
||||
|
||||
static void HandleRawFrame(const otRadioFrame *aFrame, void *aContext);
|
||||
void HandleRawFrame(const otRadioFrame *aFrame);
|
||||
void HandleRawFrame(const otRadioFrame *aFrame);
|
||||
|
||||
#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
|
||||
static void LinkRawReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError);
|
||||
void LinkRawReceiveDone(otRadioFrame *aFrame, otError aError);
|
||||
void LinkRawReceiveDone(otRadioFrame *aFrame, otError aError);
|
||||
|
||||
static void LinkRawTransmitDone(otInstance *aInstance, otRadioFrame *aFrame, otRadioFrame *aAckFrame, otError aError);
|
||||
void LinkRawTransmitDone(otRadioFrame *aFrame, otRadioFrame *aAckFrame, otError aError);
|
||||
static void LinkRawTransmitDone(otInstance * aInstance,
|
||||
otRadioFrame *aFrame,
|
||||
otRadioFrame *aAckFrame,
|
||||
otError aError);
|
||||
void LinkRawTransmitDone(otRadioFrame *aFrame, otRadioFrame *aAckFrame, otError aError);
|
||||
|
||||
static void LinkRawEnergyScanDone(otInstance *aInstance, int8_t aEnergyScanMaxRssi);
|
||||
void LinkRawEnergyScanDone(int8_t aEnergyScanMaxRssi);
|
||||
void LinkRawEnergyScanDone(int8_t aEnergyScanMaxRssi);
|
||||
|
||||
#endif // OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
|
||||
#if OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
static void HandleStateChanged(uint32_t aFlags, void *aContext);
|
||||
void ProcessThreadChangedFlags(void);
|
||||
void ProcessThreadChangedFlags(void);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
static void HandleChildTableChanged(otThreadChildTableEvent aEvent, const otChildInfo *aChildInfo);
|
||||
void HandleChildTableChanged(otThreadChildTableEvent aEvent, const otChildInfo &aChildInfo);
|
||||
void HandleChildTableChanged(otThreadChildTableEvent aEvent, const otChildInfo &aChildInfo);
|
||||
#endif
|
||||
|
||||
static void HandleDatagramFromStack(otMessage *aMessage, void *aContext);
|
||||
void HandleDatagramFromStack(otMessage *aMessage);
|
||||
void HandleDatagramFromStack(otMessage *aMessage);
|
||||
|
||||
otError SendQueuedDatagramMessages(void);
|
||||
otError SendDatagramMessage(otMessage *aMessage);
|
||||
|
||||
static void HandleActiveScanResult_Jump(otActiveScanResult *aResult, void *aContext);
|
||||
void HandleActiveScanResult(otActiveScanResult *aResult);
|
||||
void HandleActiveScanResult(otActiveScanResult *aResult);
|
||||
|
||||
static void HandleEnergyScanResult_Jump(otEnergyScanResult *aResult, void *aContext);
|
||||
void HandleEnergyScanResult(otEnergyScanResult *aResult);
|
||||
void HandleEnergyScanResult(otEnergyScanResult *aResult);
|
||||
|
||||
static void HandleJamStateChange_Jump(bool aJamState, void *aContext);
|
||||
void HandleJamStateChange(bool aJamState);
|
||||
void HandleJamStateChange(bool aJamState);
|
||||
|
||||
static void SendDoneTask(void *aContext);
|
||||
void SendDoneTask(void);
|
||||
void SendDoneTask(void);
|
||||
|
||||
otError EncodeChannelMask(uint32_t aChannelMask);
|
||||
otError DecodeChannelMask(uint32_t &aChannelMask);
|
||||
@@ -300,7 +308,7 @@ protected:
|
||||
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_ENABLE_TMF_PROXY
|
||||
static void HandleTmfProxyStream(otMessage *aMessage, uint16_t aLocator, uint16_t aPort, void *aContext);
|
||||
void HandleTmfProxyStream(otMessage *aMessage, uint16_t aLocator, uint16_t aPort);
|
||||
void HandleTmfProxyStream(otMessage *aMessage, uint16_t aLocator, uint16_t aPort);
|
||||
#endif // OPENTHREAD_FTD && OPENTHREAD_ENABLE_TMF_PROXY
|
||||
|
||||
otError CommandHandler_NOOP(uint8_t aHeader);
|
||||
@@ -712,11 +720,11 @@ protected:
|
||||
void StartLegacy(void);
|
||||
void StopLegacy(void);
|
||||
#else
|
||||
void StartLegacy(void) { }
|
||||
void StopLegacy(void) { }
|
||||
void StartLegacy(void) {}
|
||||
void StopLegacy(void) {}
|
||||
#endif
|
||||
|
||||
static uint8_t ConvertLogLevel(otLogLevel aLogLevel);
|
||||
static uint8_t ConvertLogLevel(otLogLevel aLogLevel);
|
||||
static unsigned int ConvertLogRegion(otLogRegion aLogRegion);
|
||||
|
||||
#if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK
|
||||
@@ -786,20 +794,23 @@ protected:
|
||||
#endif // OPENTHREAD_ENABLE_NCP_VENDOR_HOOK
|
||||
|
||||
protected:
|
||||
static NcpBase *sNcpInstance;
|
||||
static NcpBase * sNcpInstance;
|
||||
static spinel_status_t ThreadErrorToSpinelStatus(otError aError);
|
||||
static uint8_t LinkFlagsToFlagByte(bool aRxOnWhenIdle, bool aSecureDataRequests, bool aDeviceType, bool aNetworkData);
|
||||
Instance *mInstance;
|
||||
NcpFrameBuffer mTxFrameBuffer;
|
||||
SpinelEncoder mEncoder;
|
||||
SpinelDecoder mDecoder;
|
||||
bool mHostPowerStateInProgress;
|
||||
static uint8_t LinkFlagsToFlagByte(bool aRxOnWhenIdle,
|
||||
bool aSecureDataRequests,
|
||||
bool aDeviceType,
|
||||
bool aNetworkData);
|
||||
Instance * mInstance;
|
||||
NcpFrameBuffer mTxFrameBuffer;
|
||||
SpinelEncoder mEncoder;
|
||||
SpinelDecoder mDecoder;
|
||||
bool mHostPowerStateInProgress;
|
||||
|
||||
enum
|
||||
{
|
||||
kTxBufferSize = OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE, // Tx Buffer size (used by mTxFrameBuffer).
|
||||
kResponseQueueSize = OPENTHREAD_CONFIG_NCP_SPINEL_RESPONSE_QUEUE_SIZE,
|
||||
kInvalidScanChannel = -1, // Invalid scan channel.
|
||||
kTxBufferSize = OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE, // Tx Buffer size (used by mTxFrameBuffer).
|
||||
kResponseQueueSize = OPENTHREAD_CONFIG_NCP_SPINEL_RESPONSE_QUEUE_SIZE,
|
||||
kInvalidScanChannel = -1, // Invalid scan channel.
|
||||
};
|
||||
|
||||
// Command Handlers
|
||||
@@ -809,20 +820,20 @@ protected:
|
||||
static const PropertyHandlerEntry mRemovePropertyHandlerTable[];
|
||||
|
||||
spinel_status_t mLastStatus;
|
||||
uint32_t mSupportedChannelMask;
|
||||
uint32_t mChannelMask;
|
||||
uint16_t mScanPeriod;
|
||||
bool mDiscoveryScanJoinerFlag;
|
||||
bool mDiscoveryScanEnableFiltering;
|
||||
uint16_t mDiscoveryScanPanId;
|
||||
uint32_t mSupportedChannelMask;
|
||||
uint32_t mChannelMask;
|
||||
uint16_t mScanPeriod;
|
||||
bool mDiscoveryScanJoinerFlag;
|
||||
bool mDiscoveryScanEnableFiltering;
|
||||
uint16_t mDiscoveryScanPanId;
|
||||
|
||||
Tasklet mUpdateChangedPropsTask;
|
||||
uint32_t mThreadChangedFlags;
|
||||
Tasklet mUpdateChangedPropsTask;
|
||||
uint32_t mThreadChangedFlags;
|
||||
ChangedPropsSet mChangedPropsSet;
|
||||
|
||||
spinel_host_power_state_t mHostPowerState;
|
||||
NcpFrameBuffer::FrameTag mHostPowerReplyFrameTag;
|
||||
uint8_t mHostPowerStateHeader;
|
||||
NcpFrameBuffer::FrameTag mHostPowerReplyFrameTag;
|
||||
uint8_t mHostPowerStateHeader;
|
||||
|
||||
#if OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE
|
||||
otNcpDelegateAllowPeekPoke mAllowPeekDelegate;
|
||||
@@ -833,8 +844,8 @@ protected:
|
||||
|
||||
spinel_tid_t mNextExpectedTid;
|
||||
|
||||
uint8_t mResponseQueueHead;
|
||||
uint8_t mResponseQueueTail;
|
||||
uint8_t mResponseQueueHead;
|
||||
uint8_t mResponseQueueTail;
|
||||
ResponseEntry mResponseQueue[kResponseQueueSize];
|
||||
|
||||
bool mAllowLocalNetworkDataChange;
|
||||
@@ -859,29 +870,29 @@ protected:
|
||||
#if OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
otMessageQueue mMessageQueue;
|
||||
|
||||
uint32_t mInboundSecureIpFrameCounter; // Number of secure inbound data/IP frames.
|
||||
uint32_t mInboundInsecureIpFrameCounter; // Number of insecure inbound data/IP frames.
|
||||
uint32_t mOutboundSecureIpFrameCounter; // Number of secure outbound data/IP frames.
|
||||
uint32_t mOutboundInsecureIpFrameCounter; // Number of insecure outbound data/IP frames.
|
||||
uint32_t mDroppedOutboundIpFrameCounter; // Number of dropped outbound data/IP frames.
|
||||
uint32_t mDroppedInboundIpFrameCounter; // Number of dropped inbound data/IP frames.
|
||||
#endif // OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
uint32_t mFramingErrorCounter; // Number of improperly formed received spinel frames.
|
||||
uint32_t mRxSpinelFrameCounter; // Number of received (inbound) spinel frames.
|
||||
uint32_t mRxSpinelOutOfOrderTidCounter; // Number of out of order received spinel frames (tid increase > 1).
|
||||
uint32_t mTxSpinelFrameCounter; // Number of sent (outbound) spinel frames.
|
||||
uint32_t mInboundSecureIpFrameCounter; // Number of secure inbound data/IP frames.
|
||||
uint32_t mInboundInsecureIpFrameCounter; // Number of insecure inbound data/IP frames.
|
||||
uint32_t mOutboundSecureIpFrameCounter; // Number of secure outbound data/IP frames.
|
||||
uint32_t mOutboundInsecureIpFrameCounter; // Number of insecure outbound data/IP frames.
|
||||
uint32_t mDroppedOutboundIpFrameCounter; // Number of dropped outbound data/IP frames.
|
||||
uint32_t mDroppedInboundIpFrameCounter; // Number of dropped inbound data/IP frames.
|
||||
#endif // OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
uint32_t mFramingErrorCounter; // Number of improperly formed received spinel frames.
|
||||
uint32_t mRxSpinelFrameCounter; // Number of received (inbound) spinel frames.
|
||||
uint32_t mRxSpinelOutOfOrderTidCounter; // Number of out of order received spinel frames (tid increase > 1).
|
||||
uint32_t mTxSpinelFrameCounter; // Number of sent (outbound) spinel frames.
|
||||
|
||||
#if OPENTHREAD_ENABLE_LEGACY
|
||||
const otNcpLegacyHandlers *mLegacyHandlers;
|
||||
uint8_t mLegacyUlaPrefix[OT_NCP_LEGACY_ULA_PREFIX_LENGTH];
|
||||
otExtAddress mLegacyLastJoinedNode;
|
||||
bool mLegacyNodeDidJoin;
|
||||
uint8_t mLegacyUlaPrefix[OT_NCP_LEGACY_ULA_PREFIX_LENGTH];
|
||||
otExtAddress mLegacyLastJoinedNode;
|
||||
bool mLegacyNodeDidJoin;
|
||||
#endif
|
||||
|
||||
bool mDidInitialUpdates;
|
||||
};
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
#endif // NCP_BASE_HPP_
|
||||
#endif // NCP_BASE_HPP_
|
||||
|
||||
+69
-79
@@ -30,8 +30,8 @@
|
||||
* This file implements full thread device specified Spinel interface to the OpenThread stack.
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include "ncp_base.hpp"
|
||||
#include <openthread/config.h>
|
||||
|
||||
#if OPENTHREAD_ENABLE_CHANNEL_MANAGER
|
||||
#include <openthread/channel_manager.h>
|
||||
@@ -41,8 +41,8 @@
|
||||
#include <openthread/icmp6.h>
|
||||
#include <openthread/ncp.h>
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
#include <openthread/thread_ftd.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
|
||||
#if OPENTHREAD_ENABLE_TMF_PROXY
|
||||
#include <openthread/tmf_proxy.h>
|
||||
@@ -64,12 +64,8 @@ otError NcpBase::EncodeChildInfo(const otChildInfo &aChildInfo)
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t modeFlags;
|
||||
|
||||
modeFlags = LinkFlagsToFlagByte(
|
||||
aChildInfo.mRxOnWhenIdle,
|
||||
aChildInfo.mSecureDataRequest,
|
||||
aChildInfo.mFullFunction,
|
||||
aChildInfo.mFullNetworkData
|
||||
);
|
||||
modeFlags = LinkFlagsToFlagByte(aChildInfo.mRxOnWhenIdle, aChildInfo.mSecureDataRequest, aChildInfo.mFullFunction,
|
||||
aChildInfo.mFullNetworkData);
|
||||
|
||||
SuccessOrExit(error = mEncoder.WriteEui64(aChildInfo.mExtAddress));
|
||||
SuccessOrExit(error = mEncoder.WriteUint16(aChildInfo.mRloc16));
|
||||
@@ -96,8 +92,8 @@ void NcpBase::HandleChildTableChanged(otThreadChildTableEvent aEvent, const otCh
|
||||
|
||||
void NcpBase::HandleChildTableChanged(otThreadChildTableEvent aEvent, const otChildInfo &aChildInfo)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
unsigned int command = 0;
|
||||
|
||||
VerifyOrExit(!mChangedPropsSet.IsPropertyFiltered(SPINEL_PROP_THREAD_CHILD_TABLE));
|
||||
@@ -155,16 +151,15 @@ otError NcpBase::GetPropertyHandler_THREAD_LEADER_WEIGHT(void)
|
||||
|
||||
otError NcpBase::GetPropertyHandler_THREAD_CHILD_TABLE(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otChildInfo childInfo;
|
||||
uint8_t maxChildren;
|
||||
uint8_t maxChildren;
|
||||
|
||||
maxChildren = otThreadGetMaxAllowedChildren(mInstance);
|
||||
|
||||
for (uint8_t index = 0; index < maxChildren; index++)
|
||||
{
|
||||
if ((otThreadGetChildInfoByIndex(mInstance, index, &childInfo) != OT_ERROR_NONE) ||
|
||||
childInfo.mIsStateRestoring)
|
||||
if ((otThreadGetChildInfoByIndex(mInstance, index, &childInfo) != OT_ERROR_NONE) || childInfo.mIsStateRestoring)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -180,9 +175,9 @@ exit:
|
||||
|
||||
otError NcpBase::GetPropertyHandler_THREAD_ROUTER_TABLE(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otRouterInfo routerInfo;
|
||||
uint8_t maxRouterId;
|
||||
uint8_t maxRouterId;
|
||||
|
||||
maxRouterId = otThreadGetMaxRouterId(mInstance);
|
||||
|
||||
@@ -214,10 +209,10 @@ exit:
|
||||
|
||||
otError NcpBase::GetPropertyHandler_THREAD_CHILD_TABLE_ADDRESSES(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otChildInfo childInfo;
|
||||
uint8_t maxChildren;
|
||||
otIp6Address ip6Address;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otChildInfo childInfo;
|
||||
uint8_t maxChildren;
|
||||
otIp6Address ip6Address;
|
||||
otChildIp6AddressIterator iterator = OT_CHILD_IP6_ADDRESS_ITERATOR_INIT;
|
||||
|
||||
maxChildren = otThreadGetMaxAllowedChildren(mInstance);
|
||||
@@ -256,7 +251,7 @@ otError NcpBase::GetPropertyHandler_THREAD_ROUTER_ROLE_ENABLED(void)
|
||||
|
||||
otError NcpBase::SetPropertyHandler_THREAD_ROUTER_ROLE_ENABLED(void)
|
||||
{
|
||||
bool enabled;
|
||||
bool enabled;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadBool(enabled));
|
||||
@@ -275,8 +270,8 @@ otError NcpBase::GetPropertyHandler_NET_PSKC(void)
|
||||
otError NcpBase::SetPropertyHandler_NET_PSKC(void)
|
||||
{
|
||||
const uint8_t *ptr = NULL;
|
||||
uint16_t len;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t len;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(ptr, len));
|
||||
|
||||
@@ -296,7 +291,7 @@ otError NcpBase::GetPropertyHandler_THREAD_CHILD_COUNT_MAX(void)
|
||||
otError NcpBase::SetPropertyHandler_THREAD_CHILD_COUNT_MAX(void)
|
||||
{
|
||||
uint8_t maxChildren = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(maxChildren));
|
||||
|
||||
@@ -314,7 +309,7 @@ otError NcpBase::GetPropertyHandler_THREAD_ROUTER_UPGRADE_THRESHOLD(void)
|
||||
otError NcpBase::SetPropertyHandler_THREAD_ROUTER_UPGRADE_THRESHOLD(void)
|
||||
{
|
||||
uint8_t threshold = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(threshold));
|
||||
|
||||
@@ -332,7 +327,7 @@ otError NcpBase::GetPropertyHandler_THREAD_ROUTER_DOWNGRADE_THRESHOLD(void)
|
||||
otError NcpBase::SetPropertyHandler_THREAD_ROUTER_DOWNGRADE_THRESHOLD(void)
|
||||
{
|
||||
uint8_t threshold = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(threshold));
|
||||
|
||||
@@ -350,7 +345,7 @@ otError NcpBase::GetPropertyHandler_THREAD_ROUTER_SELECTION_JITTER(void)
|
||||
otError NcpBase::SetPropertyHandler_THREAD_ROUTER_SELECTION_JITTER(void)
|
||||
{
|
||||
uint8_t jitter = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(jitter));
|
||||
|
||||
@@ -368,13 +363,13 @@ otError NcpBase::GetPropertyHandler_THREAD_CONTEXT_REUSE_DELAY(void)
|
||||
otError NcpBase::SetPropertyHandler_THREAD_CONTEXT_REUSE_DELAY(void)
|
||||
{
|
||||
uint32_t delay = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint32(delay));
|
||||
|
||||
otThreadSetContextIdReuseDelay(mInstance, delay);
|
||||
|
||||
exit:
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -386,13 +381,13 @@ otError NcpBase::GetPropertyHandler_THREAD_NETWORK_ID_TIMEOUT(void)
|
||||
otError NcpBase::SetPropertyHandler_THREAD_NETWORK_ID_TIMEOUT(void)
|
||||
{
|
||||
uint8_t timeout = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(timeout));
|
||||
|
||||
otThreadSetNetworkIdTimeout(mInstance, timeout);
|
||||
|
||||
exit:
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -404,8 +399,8 @@ otError NcpBase::GetPropertyHandler_THREAD_COMMISSIONER_ENABLED(void)
|
||||
|
||||
otError NcpBase::SetPropertyHandler_THREAD_COMMISSIONER_ENABLED(uint8_t aHeader)
|
||||
{
|
||||
bool enabled = false;
|
||||
otError error = OT_ERROR_NONE;
|
||||
bool enabled = false;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadBool(enabled));
|
||||
|
||||
@@ -424,10 +419,10 @@ exit:
|
||||
|
||||
otError NcpBase::InsertPropertyHandler_THREAD_JOINERS(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
const otExtAddress *eui64 = NULL;
|
||||
const char *aPSKd = NULL;
|
||||
uint32_t joinerTimeout = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
const otExtAddress *eui64 = NULL;
|
||||
const char * aPSKd = NULL;
|
||||
uint32_t joinerTimeout = 0;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUtf8(aPSKd));
|
||||
SuccessOrExit(error = mDecoder.ReadUint32(joinerTimeout));
|
||||
@@ -480,7 +475,7 @@ exit:
|
||||
otError NcpBase::SetPropertyHandler_THREAD_CHILD_TIMEOUT(void)
|
||||
{
|
||||
uint32_t timeout = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint32(timeout));
|
||||
|
||||
@@ -533,7 +528,7 @@ otError NcpBase::GetPropertyHandler_THREAD_ADDRESS_CACHE_TABLE(void)
|
||||
otError error = OT_ERROR_NONE;
|
||||
otEidCacheEntry entry;
|
||||
|
||||
for (uint8_t index = 0; ; index++)
|
||||
for (uint8_t index = 0;; index++)
|
||||
{
|
||||
SuccessOrExit(otThreadGetEidCacheEntry(mInstance, index, &entry));
|
||||
|
||||
@@ -562,11 +557,11 @@ otError NcpBase::GetPropertyHandler_THREAD_TMF_PROXY_ENABLED(void)
|
||||
otError NcpBase::SetPropertyHandler_THREAD_TMF_PROXY_STREAM(void)
|
||||
{
|
||||
const uint8_t *framePtr = NULL;
|
||||
uint16_t frameLen = 0;
|
||||
uint16_t locator;
|
||||
uint16_t port;
|
||||
otMessage *message;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t frameLen = 0;
|
||||
uint16_t locator;
|
||||
uint16_t port;
|
||||
otMessage * message;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
// THREAD_TMF_PROXY_STREAM requires layer 2 security.
|
||||
message = otIp6NewMessage(mInstance, true);
|
||||
@@ -596,7 +591,7 @@ exit:
|
||||
|
||||
otError NcpBase::SetPropertyHandler_THREAD_TMF_PROXY_ENABLED(void)
|
||||
{
|
||||
bool enabled;
|
||||
bool enabled;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadBool(enabled));
|
||||
@@ -621,15 +616,11 @@ void NcpBase::HandleTmfProxyStream(otMessage *aMessage, uint16_t aLocator, uint1
|
||||
|
||||
void NcpBase::HandleTmfProxyStream(otMessage *aMessage, uint16_t aLocator, uint16_t aPort)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t length = otMessageGetLength(aMessage);
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
|
||||
SuccessOrExit(error = mEncoder.BeginFrame(
|
||||
header,
|
||||
SPINEL_CMD_PROP_VALUE_IS,
|
||||
SPINEL_PROP_THREAD_TMF_PROXY_STREAM
|
||||
));
|
||||
SuccessOrExit(error = mEncoder.BeginFrame(header, SPINEL_CMD_PROP_VALUE_IS, SPINEL_PROP_THREAD_TMF_PROXY_STREAM));
|
||||
SuccessOrExit(error = mEncoder.WriteUint16(length));
|
||||
SuccessOrExit(error = mEncoder.WriteMessage(aMessage));
|
||||
|
||||
@@ -696,7 +687,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset, const
|
||||
case SPINEL_PROP_NET_MASTER_KEY:
|
||||
{
|
||||
const uint8_t *key;
|
||||
uint16_t len;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(key, len));
|
||||
VerifyOrExit(len == OT_MASTER_KEY_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
@@ -708,7 +699,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset, const
|
||||
case SPINEL_PROP_NET_NETWORK_NAME:
|
||||
{
|
||||
const char *name;
|
||||
size_t len;
|
||||
size_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUtf8(name));
|
||||
len = strlen(name);
|
||||
@@ -721,7 +712,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset, const
|
||||
case SPINEL_PROP_NET_XPANID:
|
||||
{
|
||||
const uint8_t *xpanid;
|
||||
uint16_t len;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(xpanid, len));
|
||||
VerifyOrExit(len == OT_EXT_PAN_ID_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
@@ -733,7 +724,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset, const
|
||||
case SPINEL_PROP_IPV6_ML_PREFIX:
|
||||
{
|
||||
const otIp6Address *addr;
|
||||
uint8_t prefixLen;
|
||||
uint8_t prefixLen;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadIp6Address(addr));
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(prefixLen));
|
||||
@@ -758,7 +749,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset, const
|
||||
uint8_t channel;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(channel));
|
||||
aDataset.mChannel = channel;
|
||||
aDataset.mChannel = channel;
|
||||
aDataset.mIsChannelSet = true;
|
||||
break;
|
||||
}
|
||||
@@ -766,7 +757,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset, const
|
||||
case SPINEL_PROP_NET_PSKC:
|
||||
{
|
||||
const uint8_t *psk;
|
||||
uint16_t len;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(psk, len));
|
||||
VerifyOrExit(len == OT_PSKC_MAX_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
@@ -801,7 +792,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset, const
|
||||
case SPINEL_PROP_DATASET_RAW_TLVS:
|
||||
{
|
||||
const uint8_t *tlvs;
|
||||
uint16_t len;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(tlvs, len));
|
||||
VerifyOrExit(len <= 255, error = OT_ERROR_INVALID_ARGS);
|
||||
@@ -832,7 +823,7 @@ exit:
|
||||
|
||||
otError NcpBase::SetPropertyHandler_THREAD_ACTIVE_DATASET(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, NULL, NULL));
|
||||
@@ -844,7 +835,7 @@ exit:
|
||||
|
||||
otError NcpBase::SetPropertyHandler_THREAD_PENDING_DATASET(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, NULL, NULL));
|
||||
@@ -856,25 +847,24 @@ exit:
|
||||
|
||||
otError NcpBase::SetPropertyHandler_THREAD_MGMT_ACTIVE_DATASET(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
const uint8_t *extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
const uint8_t * extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, &extraTlvs, &extraTlvsLength));
|
||||
error = otDatasetSendMgmtActiveSet(mInstance, &dataset, extraTlvs, extraTlvsLength);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
}
|
||||
|
||||
otError NcpBase::SetPropertyHandler_THREAD_MGMT_PENDING_DATASET(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
const uint8_t *extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
const uint8_t * extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, &extraTlvs, &extraTlvsLength));
|
||||
error = otDatasetSendMgmtPendingSet(mInstance, &dataset, extraTlvs, extraTlvsLength);
|
||||
@@ -911,7 +901,7 @@ otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_DELAY(void)
|
||||
otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_DELAY(void)
|
||||
{
|
||||
uint16_t delay;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint16(delay));
|
||||
|
||||
@@ -929,7 +919,7 @@ otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_SUPPORTED_CHANNELS(void)
|
||||
otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_SUPPORTED_CHANNELS(void)
|
||||
{
|
||||
uint32_t channelMask = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = DecodeChannelMask(channelMask));
|
||||
otChannelManagerSetSupportedChannels(mInstance, channelMask);
|
||||
@@ -946,7 +936,7 @@ otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_FAVORED_CHANNELS(void)
|
||||
otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_FAVORED_CHANNELS(void)
|
||||
{
|
||||
uint32_t channelMask = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = DecodeChannelMask(channelMask));
|
||||
otChannelManagerSetFavoredChannels(mInstance, channelMask);
|
||||
@@ -962,8 +952,8 @@ otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_CHANNEL_SELECT(void)
|
||||
|
||||
otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_CHANNEL_SELECT(void)
|
||||
{
|
||||
bool skipQualityCheck = false;
|
||||
otError error = OT_ERROR_NONE;
|
||||
bool skipQualityCheck = false;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadBool(skipQualityCheck));
|
||||
error = otChannelManagerRequestChannelSelect(mInstance, skipQualityCheck);
|
||||
@@ -979,8 +969,8 @@ otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_AUTO_SELECT_ENABLED(void)
|
||||
|
||||
otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_AUTO_SELECT_ENABLED(void)
|
||||
{
|
||||
bool enabled = false;
|
||||
otError error = OT_ERROR_NONE;
|
||||
bool enabled = false;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadBool(enabled));
|
||||
otChannelManagerSetAutoChannelSelectionEnabled(mInstance, enabled);
|
||||
@@ -997,7 +987,7 @@ otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_AUTO_SELECT_INTERVAL(void)
|
||||
otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_AUTO_SELECT_INTERVAL(void)
|
||||
{
|
||||
uint32_t interval;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint32(interval));
|
||||
error = otChannelManagerSetAutoChannelSelectionInterval(mInstance, interval);
|
||||
@@ -1008,7 +998,7 @@ exit:
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_CHANNEL_MANAGER
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_FTD
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
+207
-260
File diff suppressed because it is too large
Load Diff
+38
-46
@@ -59,8 +59,8 @@ void NcpBase::LinkRawReceiveDone(otInstance *, otRadioFrame *aFrame, otError aEr
|
||||
|
||||
void NcpBase::LinkRawReceiveDone(otRadioFrame *aFrame, otError aError)
|
||||
{
|
||||
uint16_t flags = 0;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
uint16_t flags = 0;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
|
||||
if (aFrame->mDidTx)
|
||||
{
|
||||
@@ -78,19 +78,19 @@ void NcpBase::LinkRawReceiveDone(otRadioFrame *aFrame, otError aError)
|
||||
}
|
||||
|
||||
// Append metadata (rssi, etc)
|
||||
SuccessOrExit(mEncoder.WriteInt8(aFrame->mInfo.mRxInfo.mRssi)); // RSSI
|
||||
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise Floor (Currently unused)
|
||||
SuccessOrExit(mEncoder.WriteUint16(flags)); // Flags
|
||||
SuccessOrExit(mEncoder.WriteInt8(aFrame->mInfo.mRxInfo.mRssi)); // RSSI
|
||||
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise Floor (Currently unused)
|
||||
SuccessOrExit(mEncoder.WriteUint16(flags)); // Flags
|
||||
|
||||
SuccessOrExit(mEncoder.OpenStruct()); // PHY-data
|
||||
SuccessOrExit(mEncoder.WriteUint8(aFrame->mChannel)); // 802.15.4 channel (Receive channel)
|
||||
SuccessOrExit(mEncoder.WriteUint8(aFrame->mInfo.mRxInfo.mLqi)); // 802.15.4 LQI
|
||||
SuccessOrExit(mEncoder.WriteUint32(aFrame->mInfo.mRxInfo.mMsec)); // The timestamp milliseconds
|
||||
SuccessOrExit(mEncoder.WriteUint16(aFrame->mInfo.mRxInfo.mUsec)); // The timestamp microseconds, offset to mMsec
|
||||
SuccessOrExit(mEncoder.OpenStruct()); // PHY-data
|
||||
SuccessOrExit(mEncoder.WriteUint8(aFrame->mChannel)); // 802.15.4 channel (Receive channel)
|
||||
SuccessOrExit(mEncoder.WriteUint8(aFrame->mInfo.mRxInfo.mLqi)); // 802.15.4 LQI
|
||||
SuccessOrExit(mEncoder.WriteUint32(aFrame->mInfo.mRxInfo.mMsec)); // The timestamp milliseconds
|
||||
SuccessOrExit(mEncoder.WriteUint16(aFrame->mInfo.mRxInfo.mUsec)); // The timestamp microseconds, offset to mMsec
|
||||
SuccessOrExit(mEncoder.CloseStruct());
|
||||
|
||||
SuccessOrExit(mEncoder.OpenStruct()); // Vendor-data
|
||||
SuccessOrExit(mEncoder.WriteUintPacked(aError)); // Receive error
|
||||
SuccessOrExit(mEncoder.OpenStruct()); // Vendor-data
|
||||
SuccessOrExit(mEncoder.WriteUintPacked(aError)); // Receive error
|
||||
SuccessOrExit(mEncoder.CloseStruct());
|
||||
|
||||
SuccessOrExit(mEncoder.EndFrame());
|
||||
@@ -99,8 +99,7 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void NcpBase::LinkRawTransmitDone(otInstance *, otRadioFrame *aFrame,
|
||||
otRadioFrame *aAckFrame, otError aError)
|
||||
void NcpBase::LinkRawTransmitDone(otInstance *, otRadioFrame *aFrame, otRadioFrame *aAckFrame, otError aError)
|
||||
{
|
||||
sNcpInstance->LinkRawTransmitDone(aFrame, aAckFrame, aError);
|
||||
}
|
||||
@@ -109,8 +108,8 @@ void NcpBase::LinkRawTransmitDone(otRadioFrame *aFrame, otRadioFrame *aAckFrame,
|
||||
{
|
||||
if (mCurTransmitTID)
|
||||
{
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0 | mCurTransmitTID;
|
||||
bool framePending = (aAckFrame != NULL && static_cast<Mac::Frame *>(aAckFrame)->GetFramePending());
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0 | mCurTransmitTID;
|
||||
bool framePending = (aAckFrame != NULL && static_cast<Mac::Frame *>(aAckFrame)->GetFramePending());
|
||||
|
||||
// Clear cached transmit TID
|
||||
mCurTransmitTID = 0;
|
||||
@@ -124,14 +123,14 @@ void NcpBase::LinkRawTransmitDone(otRadioFrame *aFrame, otRadioFrame *aAckFrame,
|
||||
SuccessOrExit(mEncoder.WriteUint16(aAckFrame->mLength));
|
||||
SuccessOrExit(mEncoder.WriteData(aAckFrame->mPsdu, aAckFrame->mLength));
|
||||
|
||||
SuccessOrExit(mEncoder.WriteInt8(aAckFrame->mInfo.mRxInfo.mRssi)); // RSSI
|
||||
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise Floor (Currently unused)
|
||||
SuccessOrExit(mEncoder.WriteUint16(0)); // Flags
|
||||
SuccessOrExit(mEncoder.WriteInt8(aAckFrame->mInfo.mRxInfo.mRssi)); // RSSI
|
||||
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise Floor (Currently unused)
|
||||
SuccessOrExit(mEncoder.WriteUint16(0)); // Flags
|
||||
|
||||
SuccessOrExit(mEncoder.OpenStruct()); // PHY-data
|
||||
SuccessOrExit(mEncoder.OpenStruct()); // PHY-data
|
||||
|
||||
SuccessOrExit(mEncoder.WriteUint8(aAckFrame->mChannel)); // Receive channel
|
||||
SuccessOrExit(mEncoder.WriteUint8(aAckFrame->mInfo.mRxInfo.mLqi)); // Link Quality Indicator
|
||||
SuccessOrExit(mEncoder.WriteUint8(aAckFrame->mChannel)); // Receive channel
|
||||
SuccessOrExit(mEncoder.WriteUint8(aAckFrame->mInfo.mRxInfo.mLqi)); // Link Quality Indicator
|
||||
|
||||
SuccessOrExit(mEncoder.CloseStruct());
|
||||
}
|
||||
@@ -160,12 +159,8 @@ void NcpBase::LinkRawEnergyScanDone(int8_t aEnergyScanMaxRssi)
|
||||
// since the energy scan could have been on a different channel.
|
||||
otLinkRawReceive(mInstance, &NcpBase::LinkRawReceiveDone);
|
||||
|
||||
SuccessOrExit(
|
||||
mEncoder.BeginFrame(
|
||||
SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0,
|
||||
SPINEL_CMD_PROP_VALUE_IS,
|
||||
SPINEL_PROP_MAC_ENERGY_SCAN_RESULT
|
||||
));
|
||||
SuccessOrExit(mEncoder.BeginFrame(SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0, SPINEL_CMD_PROP_VALUE_IS,
|
||||
SPINEL_PROP_MAC_ENERGY_SCAN_RESULT));
|
||||
|
||||
SuccessOrExit(mEncoder.WriteUint8(static_cast<uint8_t>(scanChannel)));
|
||||
SuccessOrExit(mEncoder.WriteInt8(aEnergyScanMaxRssi));
|
||||
@@ -173,12 +168,8 @@ void NcpBase::LinkRawEnergyScanDone(int8_t aEnergyScanMaxRssi)
|
||||
|
||||
// We are finished with the scan, so send out
|
||||
// a property update indicating such.
|
||||
SuccessOrExit(
|
||||
mEncoder.BeginFrame(
|
||||
SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0,
|
||||
SPINEL_CMD_PROP_VALUE_IS,
|
||||
SPINEL_PROP_MAC_SCAN_STATE
|
||||
));
|
||||
SuccessOrExit(mEncoder.BeginFrame(SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0, SPINEL_CMD_PROP_VALUE_IS,
|
||||
SPINEL_PROP_MAC_SCAN_STATE));
|
||||
|
||||
SuccessOrExit(mEncoder.WriteUint8(SPINEL_SCAN_STATE_IDLE));
|
||||
SuccessOrExit(mEncoder.EndFrame());
|
||||
@@ -249,7 +240,7 @@ exit:
|
||||
|
||||
otError NcpBase::RemovePropertyHandler_MAC_SRC_MATCH_SHORT_ADDRESSES(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t shortAddress;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint16(shortAddress));
|
||||
@@ -262,10 +253,11 @@ exit:
|
||||
|
||||
otError NcpBase::RemovePropertyHandler_MAC_SRC_MATCH_EXTENDED_ADDRESSES(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
const otExtAddress *extAddress;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadEui64(extAddress));;
|
||||
SuccessOrExit(error = mDecoder.ReadEui64(extAddress));
|
||||
;
|
||||
|
||||
error = otLinkRawSrcMatchClearExtEntry(mInstance, extAddress);
|
||||
|
||||
@@ -275,7 +267,7 @@ exit:
|
||||
|
||||
otError NcpBase::InsertPropertyHandler_MAC_SRC_MATCH_SHORT_ADDRESSES(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t shortAddress;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint16(shortAddress));
|
||||
@@ -288,7 +280,7 @@ exit:
|
||||
|
||||
otError NcpBase::InsertPropertyHandler_MAC_SRC_MATCH_EXTENDED_ADDRESSES(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
const otExtAddress *extAddress = NULL;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadEui64(extAddress));
|
||||
@@ -301,7 +293,7 @@ exit:
|
||||
|
||||
otError NcpBase::SetPropertyHandler_PHY_ENABLED(void)
|
||||
{
|
||||
bool value = false;
|
||||
bool value = false;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadBool(value));
|
||||
@@ -334,7 +326,7 @@ exit:
|
||||
otError NcpBase::SetPropertyHandler_MAC_15_4_SADDR(void)
|
||||
{
|
||||
uint16_t shortAddress;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint16(shortAddress));
|
||||
|
||||
@@ -347,9 +339,9 @@ exit:
|
||||
otError NcpBase::SetPropertyHandler_STREAM_RAW(uint8_t aHeader)
|
||||
{
|
||||
const uint8_t *frameBuffer = NULL;
|
||||
otRadioFrame *frame;
|
||||
uint16_t frameLen = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otRadioFrame * frame;
|
||||
uint16_t frameLen = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
VerifyOrExit(otLinkRawIsEnabled(mInstance), error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
@@ -388,7 +380,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
|
||||
+61
-62
@@ -32,19 +32,19 @@
|
||||
|
||||
#include "ncp_buffer.hpp"
|
||||
|
||||
#include "utils/wrap_string.h"
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/debug.hpp"
|
||||
#include "utils/wrap_string.h"
|
||||
|
||||
namespace ot {
|
||||
namespace Ncp {
|
||||
|
||||
const NcpFrameBuffer::FrameTag NcpFrameBuffer::kInvalidTag = NULL;
|
||||
|
||||
NcpFrameBuffer::NcpFrameBuffer(uint8_t *aBuffer, uint16_t aBufferLen) :
|
||||
mBuffer(aBuffer),
|
||||
mBufferEnd(aBuffer + aBufferLen),
|
||||
mBufferLength(aBufferLen)
|
||||
NcpFrameBuffer::NcpFrameBuffer(uint8_t *aBuffer, uint16_t aBufferLen)
|
||||
: mBuffer(aBuffer)
|
||||
, mBufferEnd(aBuffer + aBufferLen)
|
||||
, mBufferLength(aBufferLen)
|
||||
{
|
||||
for (uint8_t priority = 0; priority < kNumPrios; priority++)
|
||||
{
|
||||
@@ -62,27 +62,27 @@ void NcpFrameBuffer::Clear(void)
|
||||
otMessage *message;
|
||||
|
||||
// Write (InFrame) related variables
|
||||
mWriteFrameStart[kPriorityLow] = mBuffer;
|
||||
mWriteFrameStart[kPriorityLow] = mBuffer;
|
||||
mWriteFrameStart[kPriorityHigh] = GetUpdatedBufPtr(mBuffer, 1, kBackward);
|
||||
mWriteDirection = kUnknown;
|
||||
mWriteSegmentHead = mBuffer;
|
||||
mWriteSegmentTail = mBuffer;
|
||||
mWriteFrameTag = kInvalidTag;
|
||||
mWriteDirection = kUnknown;
|
||||
mWriteSegmentHead = mBuffer;
|
||||
mWriteSegmentTail = mBuffer;
|
||||
mWriteFrameTag = kInvalidTag;
|
||||
|
||||
// Read (OutFrame) related variables
|
||||
mReadDirection = kForward;
|
||||
mReadState = kReadStateNotActive;
|
||||
mReadDirection = kForward;
|
||||
mReadState = kReadStateNotActive;
|
||||
mReadFrameLength = kUnknownFrameLength;
|
||||
|
||||
mReadFrameStart[kPriorityLow] = mBuffer;
|
||||
mReadFrameStart[kPriorityLow] = mBuffer;
|
||||
mReadFrameStart[kPriorityHigh] = GetUpdatedBufPtr(mBuffer, 1, kBackward);
|
||||
mReadSegmentHead = mBuffer;
|
||||
mReadSegmentTail = mBuffer;
|
||||
mReadPointer = mBuffer;
|
||||
mReadSegmentHead = mBuffer;
|
||||
mReadSegmentTail = mBuffer;
|
||||
mReadPointer = mBuffer;
|
||||
|
||||
mReadMessage = NULL;
|
||||
mReadMessage = NULL;
|
||||
mReadMessageOffset = 0;
|
||||
mReadMessageTail = mMessageBuffer;
|
||||
mReadMessageTail = mMessageBuffer;
|
||||
|
||||
// Free all messages in the queues.
|
||||
|
||||
@@ -108,13 +108,13 @@ void NcpFrameBuffer::Clear(void)
|
||||
void NcpFrameBuffer::SetFrameAddedCallback(BufferCallback aFrameAddedCallback, void *aFrameAddedContext)
|
||||
{
|
||||
mFrameAddedCallback = aFrameAddedCallback;
|
||||
mFrameAddedContext = aFrameAddedContext;
|
||||
mFrameAddedContext = aFrameAddedContext;
|
||||
}
|
||||
|
||||
void NcpFrameBuffer::SetFrameRemovedCallback(BufferCallback aFrameRemovedCallback, void *aFrameRemovedContext)
|
||||
{
|
||||
mFrameRemovedCallback = aFrameRemovedCallback;
|
||||
mFrameRemovedContext = aFrameRemovedContext;
|
||||
mFrameRemovedContext = aFrameRemovedContext;
|
||||
}
|
||||
|
||||
// Returns an updated buffer pointer by moving forward/backward (based on `aDirection`) from `aBufPtr` by a given
|
||||
@@ -168,7 +168,7 @@ uint16_t NcpFrameBuffer::GetDistance(uint8_t *aStartPtr, uint8_t *aEndPtr, Direc
|
||||
}
|
||||
else
|
||||
{
|
||||
distance = static_cast<size_t>(mBufferEnd - aStartPtr);
|
||||
distance = static_cast<size_t>(mBufferEnd - aStartPtr);
|
||||
distance += static_cast<size_t>(aEndPtr - mBuffer);
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ uint16_t NcpFrameBuffer::GetDistance(uint8_t *aStartPtr, uint8_t *aEndPtr, Direc
|
||||
}
|
||||
else
|
||||
{
|
||||
distance = static_cast<size_t>(mBufferEnd - aEndPtr);
|
||||
distance = static_cast<size_t>(mBufferEnd - aEndPtr);
|
||||
distance += static_cast<size_t>(aStartPtr - mBuffer);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ uint16_t NcpFrameBuffer::GetDistance(uint8_t *aStartPtr, uint8_t *aEndPtr, Direc
|
||||
// Writes a uint16 value at the given buffer pointer (big-endian style).
|
||||
void NcpFrameBuffer::WriteUint16At(uint8_t *aBufPtr, uint16_t aValue, Direction aDirection)
|
||||
{
|
||||
*aBufPtr = (aValue >> 8);
|
||||
*aBufPtr = (aValue >> 8);
|
||||
*GetUpdatedBufPtr(aBufPtr, 1, aDirection) = (aValue & 0xff);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ uint16_t NcpFrameBuffer::ReadUint16At(uint8_t *aBufPtr, Direction aDirection)
|
||||
// Appends a byte at the write tail and updates the tail, discards the frame if buffer gets full.
|
||||
otError NcpFrameBuffer::InFrameAppend(uint8_t aByte)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t *newTail;
|
||||
|
||||
assert(mWriteDirection != kUnknown);
|
||||
@@ -228,7 +228,7 @@ otError NcpFrameBuffer::InFrameAppend(uint8_t aByte)
|
||||
if (newTail != mWriteFrameStart[(mWriteDirection == kForward) ? kBackward : kForward])
|
||||
{
|
||||
*mWriteSegmentTail = aByte;
|
||||
mWriteSegmentTail = newTail;
|
||||
mWriteSegmentTail = newTail;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -242,7 +242,7 @@ otError NcpFrameBuffer::InFrameAppend(uint8_t aByte)
|
||||
// This method begins a new segment (if one is not already open).
|
||||
otError NcpFrameBuffer::InFrameBeginSegment(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t headerFlags = kSegmentHeaderNoFlag;
|
||||
|
||||
// Verify that segment is not yet started (i.e., head and tail are the same).
|
||||
@@ -412,17 +412,18 @@ otError NcpFrameBuffer::InFrameGetPosition(WritePosition &aPosition)
|
||||
// Begin a new segment (if we are not in middle of segment already).
|
||||
SuccessOrExit(error = InFrameBeginSegment());
|
||||
|
||||
aPosition.mPosition = mWriteSegmentTail;
|
||||
aPosition.mPosition = mWriteSegmentTail;
|
||||
aPosition.mSegmentHead = mWriteSegmentHead;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError NcpFrameBuffer::InFrameOverwrite(const WritePosition &aPosition, const uint8_t *aDataBuffer,
|
||||
uint16_t aDataBufferLength)
|
||||
otError NcpFrameBuffer::InFrameOverwrite(const WritePosition &aPosition,
|
||||
const uint8_t * aDataBuffer,
|
||||
uint16_t aDataBufferLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t *bufPtr;
|
||||
uint16_t segmentLength;
|
||||
uint16_t distance;
|
||||
@@ -433,7 +434,7 @@ otError NcpFrameBuffer::InFrameOverwrite(const WritePosition &aPosition, const u
|
||||
|
||||
// Ensure the overwrite does not go beyond current sgement tail.
|
||||
segmentLength = GetDistance(mWriteSegmentHead, mWriteSegmentTail, mWriteDirection);
|
||||
distance = GetDistance(mWriteSegmentHead, aPosition.mPosition, mWriteDirection);
|
||||
distance = GetDistance(mWriteSegmentHead, aPosition.mPosition, mWriteDirection);
|
||||
VerifyOrExit(distance + aDataBufferLength <= segmentLength, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
bufPtr = aPosition.mPosition;
|
||||
@@ -461,7 +462,7 @@ uint16_t NcpFrameBuffer::InFrameGetDistance(const WritePosition &aPosition) cons
|
||||
VerifyOrExit(aPosition.mSegmentHead == mWriteSegmentHead);
|
||||
|
||||
segmentLength = GetDistance(mWriteSegmentHead, mWriteSegmentTail, mWriteDirection);
|
||||
offset = GetDistance(mWriteSegmentHead, aPosition.mPosition, mWriteDirection);
|
||||
offset = GetDistance(mWriteSegmentHead, aPosition.mPosition, mWriteDirection);
|
||||
VerifyOrExit(offset < segmentLength);
|
||||
|
||||
distance = GetDistance(aPosition.mPosition, mWriteSegmentTail, mWriteDirection);
|
||||
@@ -472,7 +473,7 @@ exit:
|
||||
|
||||
otError NcpFrameBuffer::InFrameReset(const WritePosition &aPosition)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t segmentLength;
|
||||
uint16_t offset;
|
||||
|
||||
@@ -480,7 +481,7 @@ otError NcpFrameBuffer::InFrameReset(const WritePosition &aPosition)
|
||||
VerifyOrExit(aPosition.mSegmentHead == mWriteSegmentHead, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
segmentLength = GetDistance(mWriteSegmentHead, mWriteSegmentTail, mWriteDirection);
|
||||
offset = GetDistance(mWriteSegmentHead, aPosition.mPosition, mWriteDirection);
|
||||
offset = GetDistance(mWriteSegmentHead, aPosition.mPosition, mWriteDirection);
|
||||
VerifyOrExit(offset < segmentLength, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
mWriteSegmentTail = aPosition.mPosition;
|
||||
@@ -492,7 +493,7 @@ exit:
|
||||
otError NcpFrameBuffer::InFrameEnd(void)
|
||||
{
|
||||
otMessage *message;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
VerifyOrExit(mWriteDirection != kUnknown, error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
@@ -549,7 +550,7 @@ void NcpFrameBuffer::OutFrameSelectReadDirection(void)
|
||||
// Start/Prepare a new segment for reading.
|
||||
otError NcpFrameBuffer::OutFramePrepareSegment(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t header;
|
||||
|
||||
while (true)
|
||||
@@ -572,7 +573,7 @@ otError NcpFrameBuffer::OutFramePrepareSegment(void)
|
||||
|
||||
// Find tail/end of current segment.
|
||||
mReadSegmentTail = GetUpdatedBufPtr(mReadSegmentHead, kSegmentHeaderSize + (header & kSegmentHeaderLengthMask),
|
||||
mReadDirection);
|
||||
mReadDirection);
|
||||
|
||||
// Update the current read pointer to skip the segment header.
|
||||
mReadPointer = GetUpdatedBufPtr(mReadSegmentHead, kSegmentHeaderSize, mReadDirection);
|
||||
@@ -609,7 +610,7 @@ exit:
|
||||
// ThreadError_NotFound if there is no message or if the message has no content.
|
||||
otError NcpFrameBuffer::OutFramePrepareMessage(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t header;
|
||||
|
||||
// Read the segment header
|
||||
@@ -619,9 +620,8 @@ otError NcpFrameBuffer::OutFramePrepareMessage(void)
|
||||
VerifyOrExit((header & kSegmentHeaderMessageIndicatorFlag) != 0, error = OT_ERROR_NOT_FOUND);
|
||||
|
||||
// Update the current message from the queue.
|
||||
mReadMessage = (mReadMessage == NULL) ?
|
||||
otMessageQueueGetHead(&mMessageQueue[mReadDirection]) :
|
||||
otMessageQueueGetNext(&mMessageQueue[mReadDirection], mReadMessage);
|
||||
mReadMessage = (mReadMessage == NULL) ? otMessageQueueGetHead(&mMessageQueue[mReadDirection])
|
||||
: otMessageQueueGetNext(&mMessageQueue[mReadDirection], mReadMessage);
|
||||
|
||||
VerifyOrExit(mReadMessage != NULL, error = OT_ERROR_NOT_FOUND);
|
||||
|
||||
@@ -643,7 +643,7 @@ exit:
|
||||
otError NcpFrameBuffer::OutFrameFillMessageBuffer(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
int readLength;
|
||||
int readLength;
|
||||
|
||||
VerifyOrExit(mReadMessage != NULL, error = OT_ERROR_NOT_FOUND);
|
||||
|
||||
@@ -711,7 +711,7 @@ uint8_t NcpFrameBuffer::OutFrameReadByte(void)
|
||||
case kReadStateInSegment:
|
||||
|
||||
// Read a byte from current read pointer and move the read pointer by 1 byte in the read direction.
|
||||
retval = *mReadPointer;
|
||||
retval = *mReadPointer;
|
||||
mReadPointer = GetUpdatedBufPtr(mReadPointer, 1, mReadDirection);
|
||||
|
||||
// Check if at end of current segment.
|
||||
@@ -768,12 +768,12 @@ uint16_t NcpFrameBuffer::OutFrameRead(uint16_t aReadLength, uint8_t *aDataBuffer
|
||||
|
||||
otError NcpFrameBuffer::OutFrameRemove(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t *bufPtr;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t * bufPtr;
|
||||
otMessage *message;
|
||||
uint16_t header;
|
||||
uint8_t numSegments;
|
||||
FrameTag tag;
|
||||
uint16_t header;
|
||||
uint8_t numSegments;
|
||||
FrameTag tag;
|
||||
|
||||
VerifyOrExit(!IsEmpty(), error = OT_ERROR_NOT_FOUND);
|
||||
|
||||
@@ -784,7 +784,7 @@ otError NcpFrameBuffer::OutFrameRemove(void)
|
||||
|
||||
// Begin at the start of current frame and move through all segments.
|
||||
|
||||
bufPtr = mReadFrameStart[mReadDirection];
|
||||
bufPtr = mReadFrameStart[mReadDirection];
|
||||
numSegments = 0;
|
||||
|
||||
while (bufPtr != mWriteFrameStart[mReadDirection])
|
||||
@@ -826,7 +826,7 @@ otError NcpFrameBuffer::OutFrameRemove(void)
|
||||
|
||||
UpdateReadWriteStartPointers();
|
||||
|
||||
mReadState = kReadStateNotActive;
|
||||
mReadState = kReadStateNotActive;
|
||||
mReadFrameLength = kUnknownFrameLength;
|
||||
|
||||
if (mFrameRemovedCallback != NULL)
|
||||
@@ -845,7 +845,7 @@ void NcpFrameBuffer::UpdateReadWriteStartPointers(void)
|
||||
{
|
||||
// Move the high priority pointers to be right behind the low priority start.
|
||||
mWriteFrameStart[kPriorityHigh] = GetUpdatedBufPtr(mReadFrameStart[kPriorityLow], 1, kBackward);
|
||||
mReadFrameStart[kPriorityHigh] = mWriteFrameStart[kPriorityHigh];
|
||||
mReadFrameStart[kPriorityHigh] = mWriteFrameStart[kPriorityHigh];
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
@@ -854,7 +854,7 @@ void NcpFrameBuffer::UpdateReadWriteStartPointers(void)
|
||||
{
|
||||
// Move the low priority pointers to be 1 byte after the high priority start.
|
||||
mWriteFrameStart[kPriorityLow] = GetUpdatedBufPtr(mReadFrameStart[kPriorityHigh], 1, kForward);
|
||||
mReadFrameStart[kPriorityLow] = mWriteFrameStart[kPriorityLow];
|
||||
mReadFrameStart[kPriorityLow] = mWriteFrameStart[kPriorityLow];
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -863,10 +863,10 @@ exit:
|
||||
|
||||
uint16_t NcpFrameBuffer::OutFrameGetLength(void)
|
||||
{
|
||||
uint16_t frameLength = 0;
|
||||
uint16_t header;
|
||||
uint8_t *bufPtr;
|
||||
uint8_t numSegments;
|
||||
uint16_t frameLength = 0;
|
||||
uint16_t header;
|
||||
uint8_t * bufPtr;
|
||||
uint8_t numSegments;
|
||||
otMessage *message = NULL;
|
||||
|
||||
// If the frame length was calculated before, return the previously calculated length.
|
||||
@@ -878,7 +878,7 @@ uint16_t NcpFrameBuffer::OutFrameGetLength(void)
|
||||
|
||||
// Calculate frame length by adding length of all segments and messages within the current frame.
|
||||
|
||||
bufPtr = mReadFrameStart[mReadDirection];
|
||||
bufPtr = mReadFrameStart[mReadDirection];
|
||||
numSegments = 0;
|
||||
|
||||
while (bufPtr != mWriteFrameStart[mReadDirection])
|
||||
@@ -899,9 +899,8 @@ uint16_t NcpFrameBuffer::OutFrameGetLength(void)
|
||||
// If current segment has an associated message, add its length to frame length.
|
||||
if (header & kSegmentHeaderMessageIndicatorFlag)
|
||||
{
|
||||
message = (message == NULL) ?
|
||||
otMessageQueueGetHead(&mMessageQueue[mReadDirection]) :
|
||||
otMessageQueueGetNext(&mMessageQueue[mReadDirection], message);
|
||||
message = (message == NULL) ? otMessageQueueGetHead(&mMessageQueue[mReadDirection])
|
||||
: otMessageQueueGetNext(&mMessageQueue[mReadDirection], message);
|
||||
|
||||
if (message != NULL)
|
||||
{
|
||||
@@ -942,5 +941,5 @@ NcpFrameBuffer::FrameTag NcpFrameBuffer::OutFrameGetTag(void)
|
||||
return IsEmpty() ? kInvalidTag : mReadFrameStart[mReadDirection];
|
||||
}
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
+70
-67
@@ -53,8 +53,8 @@ namespace Ncp {
|
||||
class NcpFrameBuffer
|
||||
{
|
||||
friend class SpinelEncoder;
|
||||
public:
|
||||
|
||||
public:
|
||||
/**
|
||||
* Defines the priority of a frame. High priority frames are read before low priority frames. Within same priority
|
||||
* level FIFO order is preserved.
|
||||
@@ -62,8 +62,8 @@ public:
|
||||
*/
|
||||
enum Priority
|
||||
{
|
||||
kPriorityLow = 0, //< Indicates low/normal priority for a frame.
|
||||
kPriorityHigh = 1, //< Indicates high priority for a frame.
|
||||
kPriorityLow = 0, //< Indicates low/normal priority for a frame.
|
||||
kPriorityHigh = 1, //< Indicates high priority for a frame.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -92,11 +92,15 @@ public:
|
||||
* The constructor for a `WritePosition` object.
|
||||
*
|
||||
*/
|
||||
WritePosition(void): mPosition(0), mSegmentHead(0) { }
|
||||
WritePosition(void)
|
||||
: mPosition(0)
|
||||
, mSegmentHead(0)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t *mPosition; //< Pointer into buffer corresponding to saved write position.
|
||||
uint8_t *mSegmentHead; //< Pointer to segment head.
|
||||
uint8_t *mPosition; //< Pointer into buffer corresponding to saved write position.
|
||||
uint8_t *mSegmentHead; //< Pointer to segment head.
|
||||
|
||||
friend class NcpFrameBuffer;
|
||||
};
|
||||
@@ -442,7 +446,6 @@ public:
|
||||
FrameTag OutFrameGetTag(void);
|
||||
|
||||
private:
|
||||
|
||||
/*
|
||||
* `NcpFrameBuffer` Implementation
|
||||
* -------------------------------
|
||||
@@ -566,91 +569,91 @@ private:
|
||||
|
||||
enum
|
||||
{
|
||||
kReadByteAfterFrameHasEnded = 0, // Value returned by ReadByte() when frame has ended.
|
||||
kMessageReadBufferSize = 16, // Size of message buffer array `mMessageBuffer`.
|
||||
kUnknownFrameLength = 0xffff, // Value used when frame length is unknown.
|
||||
kSegmentHeaderSize = 2, // Length of the segment header.
|
||||
kSegmentHeaderLengthMask = 0x3fff, // Bit mask to get the length from the segment header
|
||||
kMaxSegments = 10, // Max number of segments allowed in a frame
|
||||
kReadByteAfterFrameHasEnded = 0, // Value returned by ReadByte() when frame has ended.
|
||||
kMessageReadBufferSize = 16, // Size of message buffer array `mMessageBuffer`.
|
||||
kUnknownFrameLength = 0xffff, // Value used when frame length is unknown.
|
||||
kSegmentHeaderSize = 2, // Length of the segment header.
|
||||
kSegmentHeaderLengthMask = 0x3fff, // Bit mask to get the length from the segment header
|
||||
kMaxSegments = 10, // Max number of segments allowed in a frame
|
||||
|
||||
kSegmentHeaderNoFlag = 0, // No flags are set.
|
||||
kSegmentHeaderNewFrameFlag = (1 << 15), // Indicates that this segment starts a new frame.
|
||||
kSegmentHeaderMessageIndicatorFlag = (1 << 14), // Indicates this segment ends with a Message.
|
||||
kSegmentHeaderNoFlag = 0, // No flags are set.
|
||||
kSegmentHeaderNewFrameFlag = (1 << 15), // Indicates that this segment starts a new frame.
|
||||
kSegmentHeaderMessageIndicatorFlag = (1 << 14), // Indicates this segment ends with a Message.
|
||||
|
||||
kNumPrios = (kPriorityHigh + 1), // Number of priorities.
|
||||
kNumPrios = (kPriorityHigh + 1), // Number of priorities.
|
||||
};
|
||||
|
||||
enum ReadState
|
||||
{
|
||||
kReadStateNotActive, // No current prepared output frame.
|
||||
kReadStateInSegment, // In middle of a data segment while reading current frame.
|
||||
kReadStateInMessage, // In middle of a message while reading current frame.
|
||||
kReadStateDone, // Current output frame is read fully.
|
||||
kReadStateNotActive, // No current prepared output frame.
|
||||
kReadStateInSegment, // In middle of a data segment while reading current frame.
|
||||
kReadStateInMessage, // In middle of a message while reading current frame.
|
||||
kReadStateDone, // Current output frame is read fully.
|
||||
};
|
||||
|
||||
enum Direction
|
||||
{
|
||||
kForward = kPriorityLow,
|
||||
kBackward = kPriorityHigh,
|
||||
kForward = kPriorityLow,
|
||||
kBackward = kPriorityHigh,
|
||||
kUnknown,
|
||||
};
|
||||
|
||||
uint8_t * GetUpdatedBufPtr(uint8_t *aBufPtr, uint16_t aOffset, Direction aDirection) const;
|
||||
uint16_t GetDistance(uint8_t *aStartPtr, uint8_t *aEndPtr, Direction aDirection) const;
|
||||
uint8_t *GetUpdatedBufPtr(uint8_t *aBufPtr, uint16_t aOffset, Direction aDirection) const;
|
||||
uint16_t GetDistance(uint8_t *aStartPtr, uint8_t *aEndPtr, Direction aDirection) const;
|
||||
|
||||
uint16_t ReadUint16At(uint8_t *aBufPtr, Direction aDirection);
|
||||
void WriteUint16At(uint8_t *aBufPtr, uint16_t aValue, Direction aDirection);
|
||||
uint16_t ReadUint16At(uint8_t *aBufPtr, Direction aDirection);
|
||||
void WriteUint16At(uint8_t *aBufPtr, uint16_t aValue, Direction aDirection);
|
||||
|
||||
bool HasFrame(Priority aPriority) const;
|
||||
void UpdateReadWriteStartPointers(void);
|
||||
bool HasFrame(Priority aPriority) const;
|
||||
void UpdateReadWriteStartPointers(void);
|
||||
|
||||
otError InFrameAppend(uint8_t aByte);
|
||||
otError InFrameBeginSegment(void);
|
||||
void InFrameEndSegment(uint16_t aSegmentHeaderFlags);
|
||||
void InFrameDiscard(void);
|
||||
bool InFrameIsWriting(Priority aPriority) const;
|
||||
otError InFrameAppend(uint8_t aByte);
|
||||
otError InFrameBeginSegment(void);
|
||||
void InFrameEndSegment(uint16_t aSegmentHeaderFlags);
|
||||
void InFrameDiscard(void);
|
||||
bool InFrameIsWriting(Priority aPriority) const;
|
||||
|
||||
void OutFrameSelectReadDirection(void);
|
||||
otError OutFramePrepareSegment(void);
|
||||
void OutFrameMoveToNextSegment(void);
|
||||
otError OutFramePrepareMessage(void);
|
||||
otError OutFrameFillMessageBuffer(void);
|
||||
void OutFrameSelectReadDirection(void);
|
||||
otError OutFramePrepareSegment(void);
|
||||
void OutFrameMoveToNextSegment(void);
|
||||
otError OutFramePrepareMessage(void);
|
||||
otError OutFrameFillMessageBuffer(void);
|
||||
|
||||
uint8_t * const mBuffer; // Pointer to the buffer used to store the data.
|
||||
uint8_t * const mBufferEnd; // Points to after the end of buffer.
|
||||
const uint16_t mBufferLength; // Length of the the buffer.
|
||||
uint8_t *const mBuffer; // Pointer to the buffer used to store the data.
|
||||
uint8_t *const mBufferEnd; // Points to after the end of buffer.
|
||||
const uint16_t mBufferLength; // Length of the the buffer.
|
||||
|
||||
BufferCallback mFrameAddedCallback; // Callback to signal when a new frame is added
|
||||
void * mFrameAddedContext; // Context passed to `mFrameAddedCallback`.
|
||||
BufferCallback mFrameRemovedCallback; // Callback to signal when a frame is removed.
|
||||
void * mFrameRemovedContext; // Context passed to `mFrameRemovedCallback`.
|
||||
BufferCallback mFrameAddedCallback; // Callback to signal when a new frame is added
|
||||
void * mFrameAddedContext; // Context passed to `mFrameAddedCallback`.
|
||||
BufferCallback mFrameRemovedCallback; // Callback to signal when a frame is removed.
|
||||
void * mFrameRemovedContext; // Context passed to `mFrameRemovedCallback`.
|
||||
|
||||
otMessageQueue mMessageQueue[kNumPrios]; // Main message queues.
|
||||
otMessageQueue mMessageQueue[kNumPrios]; // Main message queues.
|
||||
|
||||
Direction mWriteDirection; // Direction (priority) for current frame being read.
|
||||
otMessageQueue mWriteFrameMessageQueue; // Message queue for the current frame being written.
|
||||
uint8_t * mWriteFrameStart[kNumPrios]; // Pointer to start of current frame being written.
|
||||
uint8_t * mWriteSegmentHead; // Pointer to start of current segment in the frame being written.
|
||||
uint8_t * mWriteSegmentTail; // Pointer to end of current segment in the frame being written.
|
||||
FrameTag mWriteFrameTag; // Tag associated with last successfully written frame.
|
||||
Direction mWriteDirection; // Direction (priority) for current frame being read.
|
||||
otMessageQueue mWriteFrameMessageQueue; // Message queue for the current frame being written.
|
||||
uint8_t * mWriteFrameStart[kNumPrios]; // Pointer to start of current frame being written.
|
||||
uint8_t * mWriteSegmentHead; // Pointer to start of current segment in the frame being written.
|
||||
uint8_t * mWriteSegmentTail; // Pointer to end of current segment in the frame being written.
|
||||
FrameTag mWriteFrameTag; // Tag associated with last successfully written frame.
|
||||
|
||||
Direction mReadDirection; // Direction (priority) for current frame being read.
|
||||
ReadState mReadState; // Read state.
|
||||
uint16_t mReadFrameLength; // Length of current frame being read.
|
||||
Direction mReadDirection; // Direction (priority) for current frame being read.
|
||||
ReadState mReadState; // Read state.
|
||||
uint16_t mReadFrameLength; // Length of current frame being read.
|
||||
|
||||
uint8_t * mReadFrameStart[kNumPrios]; // Pointer to start of current frame being read.
|
||||
uint8_t * mReadSegmentHead; // Pointer to start of current segment in the frame being read.
|
||||
uint8_t * mReadSegmentTail; // Pointer to end of current segment in the frame being read.
|
||||
uint8_t * mReadPointer; // Pointer to next byte to read (either in segment or in msg buffer).
|
||||
uint8_t *mReadFrameStart[kNumPrios]; // Pointer to start of current frame being read.
|
||||
uint8_t *mReadSegmentHead; // Pointer to start of current segment in the frame being read.
|
||||
uint8_t *mReadSegmentTail; // Pointer to end of current segment in the frame being read.
|
||||
uint8_t *mReadPointer; // Pointer to next byte to read (either in segment or in msg buffer).
|
||||
|
||||
otMessage * mReadMessage; // Current Message in the frame being read.
|
||||
uint16_t mReadMessageOffset; // Offset within current message being read.
|
||||
otMessage *mReadMessage; // Current Message in the frame being read.
|
||||
uint16_t mReadMessageOffset; // Offset within current message being read.
|
||||
|
||||
uint8_t mMessageBuffer[kMessageReadBufferSize]; // Buffer to hold part of current message being read.
|
||||
uint8_t * mReadMessageTail; // Pointer to end of current part in mMessageBuffer.
|
||||
uint8_t mMessageBuffer[kMessageReadBufferSize]; // Buffer to hold part of current message being read.
|
||||
uint8_t *mReadMessageTail; // Pointer to end of current part in mMessageBuffer.
|
||||
};
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
#endif // NCP_FRAME_BUFFER_HPP_
|
||||
#endif // NCP_FRAME_BUFFER_HPP_
|
||||
|
||||
+13
-25
@@ -49,7 +49,7 @@ class SpiFrame
|
||||
public:
|
||||
enum
|
||||
{
|
||||
kHeaderSize = 5, ///< SPI header size (in bytes).
|
||||
kHeaderSize = 5, ///< SPI header size (in bytes).
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,10 @@ public:
|
||||
* @param[in] aBuffer Pointer to buffer containing the frame.
|
||||
*
|
||||
*/
|
||||
SpiFrame(uint8_t *aBuffer) : mBuffer(aBuffer) { }
|
||||
SpiFrame(uint8_t *aBuffer)
|
||||
: mBuffer(aBuffer)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets a pointer to data portion in the SPI frame skipping the header.
|
||||
@@ -76,10 +79,7 @@ public:
|
||||
* @returns TRUE if the frame is valid, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsValid(void) const
|
||||
{
|
||||
return ((mBuffer[kIndexFlagByte] & kFlagPatternMask) == kFlagPattern);
|
||||
}
|
||||
bool IsValid(void) const { return ((mBuffer[kIndexFlagByte] & kFlagPatternMask) == kFlagPattern); }
|
||||
|
||||
/**
|
||||
* This method sets the "flag byte" field in the SPI frame header.
|
||||
@@ -87,10 +87,7 @@ public:
|
||||
* @param[in] aResetFalg The status of reset flag (TRUE to set the flag, FALSE to clear flag).
|
||||
*
|
||||
*/
|
||||
void SetHeaderFlagByte(bool aResetFlag)
|
||||
{
|
||||
mBuffer[kIndexFlagByte] = kFlagPattern | (aResetFlag ? kFlagReset : 0);
|
||||
}
|
||||
void SetHeaderFlagByte(bool aResetFlag) { mBuffer[kIndexFlagByte] = kFlagPattern | (aResetFlag ? kFlagReset : 0); }
|
||||
|
||||
/**
|
||||
* This method sets the "accept len" field in the SPI frame header.
|
||||
@@ -111,10 +108,7 @@ public:
|
||||
* @returns The accept length in bytes.
|
||||
*
|
||||
*/
|
||||
uint16_t GetHeaderAcceptLen(void) const
|
||||
{
|
||||
return Encoding::LittleEndian::ReadUint16(mBuffer + kIndexAcceptLen);
|
||||
}
|
||||
uint16_t GetHeaderAcceptLen(void) const { return Encoding::LittleEndian::ReadUint16(mBuffer + kIndexAcceptLen); }
|
||||
|
||||
/**
|
||||
* This method sets the "data len" field in the SPI frame header.
|
||||
@@ -124,10 +118,7 @@ public:
|
||||
* @param[in] aDataLen The data length in bytes.
|
||||
*
|
||||
*/
|
||||
void SetHeaderDataLen(uint16_t aDataLen)
|
||||
{
|
||||
Encoding::LittleEndian::WriteUint16(aDataLen, mBuffer + kIndexDataLen);
|
||||
}
|
||||
void SetHeaderDataLen(uint16_t aDataLen) { Encoding::LittleEndian::WriteUint16(aDataLen, mBuffer + kIndexDataLen); }
|
||||
|
||||
/**
|
||||
* This method gets the "data len" field in the SPI frame header.
|
||||
@@ -135,10 +126,7 @@ public:
|
||||
* @returns The data length in bytes.
|
||||
*
|
||||
*/
|
||||
uint16_t GetHeaderDataLen(void) const
|
||||
{
|
||||
return Encoding::LittleEndian::ReadUint16(mBuffer + kIndexDataLen);
|
||||
}
|
||||
uint16_t GetHeaderDataLen(void) const { return Encoding::LittleEndian::ReadUint16(mBuffer + kIndexDataLen); }
|
||||
|
||||
private:
|
||||
enum
|
||||
@@ -147,9 +135,9 @@ private:
|
||||
kIndexAcceptLen = 1, // accept len (uint16_t little-endian encoding).
|
||||
kIndexDataLen = 3, // data len (uint16_t little-endian encoding).
|
||||
|
||||
kFlagReset = (1 << 7), // Flag byte RESET bit.
|
||||
kFlagPattern = 0x02, // Flag byte PATTERN bits.
|
||||
kFlagPatternMask = 0x03, // Flag byte PATTERN mask.
|
||||
kFlagReset = (1 << 7), // Flag byte RESET bit.
|
||||
kFlagPattern = 0x02, // Flag byte PATTERN bits.
|
||||
kFlagPatternMask = 0x03, // Flag byte PATTERN mask.
|
||||
};
|
||||
|
||||
uint8_t *mBuffer;
|
||||
|
||||
+30
-26
@@ -36,14 +36,14 @@
|
||||
|
||||
#include <openthread/ncp.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/uart.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
#include <openthread/platform/uart.h>
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/new.hpp"
|
||||
#include "common/debug.hpp"
|
||||
#include "common/instance.hpp"
|
||||
#include "common/new.hpp"
|
||||
#include "net/ip6.hpp"
|
||||
|
||||
#if OPENTHREAD_ENABLE_NCP_UART
|
||||
@@ -57,10 +57,10 @@ static otDEFINE_ALIGNED_VAR(sNcpRaw, sizeof(NcpUart), uint64_t);
|
||||
|
||||
extern "C" void otNcpInit(otInstance *aInstance)
|
||||
{
|
||||
NcpUart *ncpUart = NULL;
|
||||
NcpUart * ncpUart = NULL;
|
||||
Instance *instance = static_cast<Instance *>(aInstance);
|
||||
|
||||
ncpUart = new(&sNcpRaw) NcpUart(instance);
|
||||
ncpUart = new (&sNcpRaw) NcpUart(instance);
|
||||
|
||||
if (ncpUart == NULL || ncpUart != NcpBase::GetNcpInstance())
|
||||
{
|
||||
@@ -78,7 +78,7 @@ NcpUart::UartTxBuffer::UartTxBuffer(void)
|
||||
|
||||
void NcpUart::UartTxBuffer::Clear(void)
|
||||
{
|
||||
mWritePointer = mBuffer;
|
||||
mWritePointer = mBuffer;
|
||||
mRemainingLength = sizeof(mBuffer);
|
||||
}
|
||||
|
||||
@@ -97,14 +97,14 @@ const uint8_t *NcpUart::UartTxBuffer::GetBuffer(void) const
|
||||
return mBuffer;
|
||||
}
|
||||
|
||||
NcpUart::NcpUart(Instance *aInstance):
|
||||
NcpBase(aInstance),
|
||||
mFrameDecoder(mRxBuffer, sizeof(mRxBuffer), &NcpUart::HandleFrame, &NcpUart::HandleError, this),
|
||||
mUartBuffer(),
|
||||
mState(kStartingFrame),
|
||||
mByte(0),
|
||||
mUartSendImmediate(false),
|
||||
mUartSendTask(*aInstance, EncodeAndSendToUart, this)
|
||||
NcpUart::NcpUart(Instance *aInstance)
|
||||
: NcpBase(aInstance)
|
||||
, mFrameDecoder(mRxBuffer, sizeof(mRxBuffer), &NcpUart::HandleFrame, &NcpUart::HandleError, this)
|
||||
, mUartBuffer()
|
||||
, mState(kStartingFrame)
|
||||
, mByte(0)
|
||||
, mUartSendImmediate(false)
|
||||
, mUartSendTask(*aInstance, EncodeAndSendToUart, this)
|
||||
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
, mTxFrameBufferEncrypterReader(mTxFrameBuffer)
|
||||
#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
@@ -114,8 +114,10 @@ NcpUart::NcpUart(Instance *aInstance):
|
||||
otPlatUartEnable();
|
||||
}
|
||||
|
||||
void NcpUart::HandleFrameAddedToNcpBuffer(void *aContext, NcpFrameBuffer::FrameTag aTag,
|
||||
NcpFrameBuffer::Priority aPriority, NcpFrameBuffer *aNcpFrameBuffer)
|
||||
void NcpUart::HandleFrameAddedToNcpBuffer(void * aContext,
|
||||
NcpFrameBuffer::FrameTag aTag,
|
||||
NcpFrameBuffer::Priority aPriority,
|
||||
NcpFrameBuffer * aNcpFrameBuffer)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aNcpFrameBuffer);
|
||||
OT_UNUSED_VARIABLE(aTag);
|
||||
@@ -144,7 +146,7 @@ void NcpUart::EncodeAndSendToUart(Tasklet &aTasklet)
|
||||
void NcpUart::EncodeAndSendToUart(void)
|
||||
{
|
||||
uint16_t len;
|
||||
bool prevHostPowerState;
|
||||
bool prevHostPowerState;
|
||||
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
NcpFrameBufferEncrypterReader &txFrameBuffer = mTxFrameBufferEncrypterReader;
|
||||
#else
|
||||
@@ -173,7 +175,7 @@ void NcpUart::EncodeAndSendToUart(void)
|
||||
{
|
||||
mByte = txFrameBuffer.OutFrameReadByte();
|
||||
|
||||
case kEncodingFrame:
|
||||
case kEncodingFrame:
|
||||
|
||||
SuccessOrExit(mFrameEncoder.Encode(mByte, mUartBuffer));
|
||||
}
|
||||
@@ -282,7 +284,7 @@ void NcpUart::HandleError(void *aContext, otError aError, uint8_t *aBuf, uint16_
|
||||
|
||||
void NcpUart::HandleError(otError aError, uint8_t *aBuf, uint16_t aBufLength)
|
||||
{
|
||||
char hexbuf[128];
|
||||
char hexbuf[128];
|
||||
uint16_t i = 0;
|
||||
|
||||
super_t::IncrementFrameErrorCounter();
|
||||
@@ -315,10 +317,12 @@ void NcpUart::HandleError(otError aError, uint8_t *aBuf, uint16_t aBufLength)
|
||||
|
||||
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
|
||||
NcpUart::NcpFrameBufferEncrypterReader::NcpFrameBufferEncrypterReader(NcpFrameBuffer &aTxFrameBuffer) :
|
||||
mTxFrameBuffer(aTxFrameBuffer),
|
||||
mDataBufferReadIndex(0),
|
||||
mOutputDataLength(0) {}
|
||||
NcpUart::NcpFrameBufferEncrypterReader::NcpFrameBufferEncrypterReader(NcpFrameBuffer &aTxFrameBuffer)
|
||||
: mTxFrameBuffer(aTxFrameBuffer)
|
||||
, mDataBufferReadIndex(0)
|
||||
, mOutputDataLength(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool NcpUart::NcpFrameBufferEncrypterReader::IsEmpty(void) const
|
||||
{
|
||||
@@ -343,7 +347,7 @@ otError NcpUart::NcpFrameBufferEncrypterReader::OutFrameBegin(void)
|
||||
if (!SpinelEncrypter::EncryptOutbound(mDataBuffer, sizeof(mDataBuffer), &mOutputDataLength))
|
||||
{
|
||||
mOutputDataLength = 0;
|
||||
status = OT_ERROR_FAILED;
|
||||
status = OT_ERROR_FAILED;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -372,13 +376,13 @@ otError NcpUart::NcpFrameBufferEncrypterReader::OutFrameRemove(void)
|
||||
|
||||
void NcpUart::NcpFrameBufferEncrypterReader::Reset(void)
|
||||
{
|
||||
mOutputDataLength = 0;
|
||||
mOutputDataLength = 0;
|
||||
mDataBufferReadIndex = 0;
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_NCP_UART
|
||||
|
||||
+35
-34
@@ -71,19 +71,18 @@ public:
|
||||
void HandleUartReceiveDone(const uint8_t *aBuf, uint16_t aBufLength);
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
kUartTxBufferSize = OPENTHREAD_CONFIG_NCP_UART_TX_CHUNK_SIZE, // Uart tx buffer size.
|
||||
kRxBufferSize = OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE + // Rx buffer size (should be large enough to fit
|
||||
kUartTxBufferSize = OPENTHREAD_CONFIG_NCP_UART_TX_CHUNK_SIZE, // Uart tx buffer size.
|
||||
kRxBufferSize = OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE + // Rx buffer size (should be large enough to fit
|
||||
OPENTHREAD_CONFIG_NCP_SPINEL_ENCRYPTER_EXTRA_DATA_SIZE, // one whole (decoded) received frame).
|
||||
};
|
||||
|
||||
enum UartTxState
|
||||
{
|
||||
kStartingFrame, // Starting a new frame.
|
||||
kEncodingFrame, // In middle of encoding a frame.
|
||||
kFinalizingFrame, // Finalizing a frame.
|
||||
kStartingFrame, // Starting a new frame.
|
||||
kEncodingFrame, // In middle of encoding a frame.
|
||||
kFinalizingFrame, // Finalizing a frame.
|
||||
};
|
||||
|
||||
class UartTxBuffer : public Hdlc::Encoder::BufferWriteIterator
|
||||
@@ -97,7 +96,7 @@ private:
|
||||
const uint8_t *GetBuffer(void) const;
|
||||
|
||||
private:
|
||||
uint8_t mBuffer[kUartTxBufferSize];
|
||||
uint8_t mBuffer[kUartTxBufferSize];
|
||||
};
|
||||
|
||||
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
@@ -113,9 +112,9 @@ private:
|
||||
* Takes a reference to NcpFrameBuffer in order to read spinel frames.
|
||||
*/
|
||||
explicit NcpFrameBufferEncrypterReader(NcpFrameBuffer &aTxFrameBuffer);
|
||||
bool IsEmpty(void) const;
|
||||
bool IsEmpty(void) const;
|
||||
otError OutFrameBegin(void);
|
||||
bool OutFrameHasEnded(void);
|
||||
bool OutFrameHasEnded(void);
|
||||
uint8_t OutFrameReadByte(void);
|
||||
otError OutFrameRemove(void);
|
||||
|
||||
@@ -123,39 +122,41 @@ private:
|
||||
void Reset(void);
|
||||
|
||||
NcpFrameBuffer &mTxFrameBuffer;
|
||||
uint8_t mDataBuffer[kRxBufferSize];
|
||||
size_t mDataBufferReadIndex;
|
||||
size_t mOutputDataLength;
|
||||
uint8_t mDataBuffer[kRxBufferSize];
|
||||
size_t mDataBufferReadIndex;
|
||||
size_t mOutputDataLength;
|
||||
};
|
||||
#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
|
||||
void EncodeAndSendToUart(void);
|
||||
void HandleFrame(uint8_t *aBuf, uint16_t aBufLength);
|
||||
void HandleError(otError aError, uint8_t *aBuf, uint16_t aBufLength);
|
||||
void TxFrameBufferHasData(void);
|
||||
void HandleFrameAddedToNcpBuffer(void);
|
||||
void EncodeAndSendToUart(void);
|
||||
void HandleFrame(uint8_t *aBuf, uint16_t aBufLength);
|
||||
void HandleError(otError aError, uint8_t *aBuf, uint16_t aBufLength);
|
||||
void TxFrameBufferHasData(void);
|
||||
void HandleFrameAddedToNcpBuffer(void);
|
||||
|
||||
static void EncodeAndSendToUart(Tasklet &aTasklet);
|
||||
static void HandleFrame(void *context, uint8_t *aBuf, uint16_t aBufLength);
|
||||
static void HandleError(void *context, otError aError, uint8_t *aBuf, uint16_t aBufLength);
|
||||
static void HandleFrameAddedToNcpBuffer(void *aContext, NcpFrameBuffer::FrameTag aTag,
|
||||
NcpFrameBuffer::Priority aPriority, NcpFrameBuffer *aNcpFrameBuffer);
|
||||
static void EncodeAndSendToUart(Tasklet &aTasklet);
|
||||
static void HandleFrame(void *context, uint8_t *aBuf, uint16_t aBufLength);
|
||||
static void HandleError(void *context, otError aError, uint8_t *aBuf, uint16_t aBufLength);
|
||||
static void HandleFrameAddedToNcpBuffer(void * aContext,
|
||||
NcpFrameBuffer::FrameTag aTag,
|
||||
NcpFrameBuffer::Priority aPriority,
|
||||
NcpFrameBuffer * aNcpFrameBuffer);
|
||||
|
||||
Hdlc::Encoder mFrameEncoder;
|
||||
Hdlc::Decoder mFrameDecoder;
|
||||
UartTxBuffer mUartBuffer;
|
||||
UartTxState mState;
|
||||
uint8_t mByte;
|
||||
uint8_t mRxBuffer[kRxBufferSize];
|
||||
bool mUartSendImmediate;
|
||||
Tasklet mUartSendTask;
|
||||
Hdlc::Encoder mFrameEncoder;
|
||||
Hdlc::Decoder mFrameDecoder;
|
||||
UartTxBuffer mUartBuffer;
|
||||
UartTxState mState;
|
||||
uint8_t mByte;
|
||||
uint8_t mRxBuffer[kRxBufferSize];
|
||||
bool mUartSendImmediate;
|
||||
Tasklet mUartSendTask;
|
||||
|
||||
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
NcpFrameBufferEncrypterReader mTxFrameBufferEncrypterReader;
|
||||
NcpFrameBufferEncrypterReader mTxFrameBufferEncrypterReader;
|
||||
#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
|
||||
};
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
#endif // NCP_UART_HPP_
|
||||
#endif // NCP_UART_HPP_
|
||||
|
||||
+155
-142
@@ -101,51 +101,55 @@ static int spinel_errno_workaround_;
|
||||
|
||||
#ifndef assert_printf
|
||||
#if SPINEL_PLATFORM_DOESNT_IMPLEMENT_FPRINTF
|
||||
#define assert_printf(fmt, ...) \
|
||||
printf(__FILE__ ":%d: " fmt "\n", __LINE__, __VA_ARGS__)
|
||||
#define assert_printf(fmt, ...) printf(__FILE__ ":%d: " fmt "\n", __LINE__, __VA_ARGS__)
|
||||
#else // if SPINEL_PLATFORM_DOESNT_IMPLEMENT_FPRINTF
|
||||
#define assert_printf(fmt, ...) \
|
||||
fprintf(stderr, __FILE__ ":%d: " fmt "\n", __LINE__, __VA_ARGS__)
|
||||
#define assert_printf(fmt, ...) fprintf(stderr, __FILE__ ":%d: " fmt "\n", __LINE__, __VA_ARGS__)
|
||||
#endif // else SPINEL_PLATFORM_DOESNT_IMPLEMENT_FPRINTF
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef require_action
|
||||
#if SPINEL_PLATFORM_SHOULD_LOG_ASSERTS
|
||||
#define require_action(c, l, a) \
|
||||
do { if (!(c)) { \
|
||||
assert_printf("Requirement Failed (%s)", # c); \
|
||||
a; \
|
||||
goto l; \
|
||||
} } while (0)
|
||||
#define require_action(c, l, a) \
|
||||
do \
|
||||
{ \
|
||||
if (!(c)) \
|
||||
{ \
|
||||
assert_printf("Requirement Failed (%s)", #c); \
|
||||
a; \
|
||||
goto l; \
|
||||
} \
|
||||
} while (0)
|
||||
#else // if DEBUG
|
||||
#define require_action(c, l, a) \
|
||||
do { if (!(c)) { \
|
||||
a; \
|
||||
goto l; \
|
||||
} } while (0)
|
||||
do \
|
||||
{ \
|
||||
if (!(c)) \
|
||||
{ \
|
||||
a; \
|
||||
goto l; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif // else DEBUG
|
||||
#endif // ifndef require_action
|
||||
|
||||
#ifndef require
|
||||
#define require(c, l) require_action(c, l, {})
|
||||
#define require(c, l) require_action(c, l, {})
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
va_list obj;
|
||||
} va_list_obj;
|
||||
|
||||
#define SPINEL_MAX_PACK_LENGTH 32767
|
||||
#define SPINEL_MAX_PACK_LENGTH 32767
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MARK: -
|
||||
|
||||
spinel_ssize_t
|
||||
spinel_packed_uint_decode(const uint8_t *bytes, spinel_size_t len, unsigned int *value_ptr)
|
||||
spinel_ssize_t spinel_packed_uint_decode(const uint8_t *bytes, spinel_size_t len, unsigned int *value_ptr)
|
||||
{
|
||||
spinel_ssize_t ret = 0;
|
||||
unsigned int value = 0;
|
||||
spinel_ssize_t ret = 0;
|
||||
unsigned int value = 0;
|
||||
|
||||
int i = 0;
|
||||
|
||||
@@ -162,8 +166,7 @@ spinel_packed_uint_decode(const uint8_t *bytes, spinel_size_t len, unsigned int
|
||||
ret += sizeof(uint8_t);
|
||||
bytes += sizeof(uint8_t);
|
||||
len -= sizeof(uint8_t);
|
||||
}
|
||||
while ((bytes[-1] & 0x80) == 0x80);
|
||||
} while ((bytes[-1] & 0x80) == 0x80);
|
||||
|
||||
if ((ret > 0) && (value_ptr != NULL))
|
||||
{
|
||||
@@ -173,8 +176,7 @@ spinel_packed_uint_decode(const uint8_t *bytes, spinel_size_t len, unsigned int
|
||||
return ret;
|
||||
}
|
||||
|
||||
spinel_ssize_t
|
||||
spinel_packed_uint_size(unsigned int value)
|
||||
spinel_ssize_t spinel_packed_uint_size(unsigned int value)
|
||||
{
|
||||
spinel_ssize_t ret;
|
||||
|
||||
@@ -202,8 +204,7 @@ spinel_packed_uint_size(unsigned int value)
|
||||
return ret;
|
||||
}
|
||||
|
||||
spinel_ssize_t
|
||||
spinel_packed_uint_encode(uint8_t *bytes, spinel_size_t len, unsigned int value)
|
||||
spinel_ssize_t spinel_packed_uint_encode(uint8_t *bytes, spinel_size_t len, unsigned int value)
|
||||
{
|
||||
const spinel_ssize_t encoded_size = spinel_packed_uint_size(value);
|
||||
|
||||
@@ -214,7 +215,7 @@ spinel_packed_uint_encode(uint8_t *bytes, spinel_size_t len, unsigned int value)
|
||||
for (i = 0; i != encoded_size - 1; ++i)
|
||||
{
|
||||
*bytes++ = (value & 0x7F) | 0x80;
|
||||
value = (value >> 7);
|
||||
value = (value >> 7);
|
||||
}
|
||||
|
||||
*bytes++ = (value & 0x7F);
|
||||
@@ -223,8 +224,7 @@ spinel_packed_uint_encode(uint8_t *bytes, spinel_size_t len, unsigned int value)
|
||||
return encoded_size;
|
||||
}
|
||||
|
||||
const char *
|
||||
spinel_next_packed_datatype(const char *pack_format)
|
||||
const char *spinel_next_packed_datatype(const char *pack_format)
|
||||
{
|
||||
int depth = 0;
|
||||
|
||||
@@ -246,14 +246,16 @@ spinel_next_packed_datatype(const char *pack_format)
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ((depth > 0) && *pack_format != 0);
|
||||
} while ((depth > 0) && *pack_format != 0);
|
||||
|
||||
return pack_format;
|
||||
}
|
||||
|
||||
static spinel_ssize_t
|
||||
spinel_datatype_vunpack_(bool in_place, const uint8_t *data_ptr, spinel_size_t data_len, const char *pack_format, va_list_obj *args)
|
||||
static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
|
||||
const uint8_t *data_ptr,
|
||||
spinel_size_t data_len,
|
||||
const char * pack_format,
|
||||
va_list_obj * args)
|
||||
{
|
||||
spinel_ssize_t ret = 0;
|
||||
|
||||
@@ -440,7 +442,7 @@ spinel_datatype_vunpack_(bool in_place, const uint8_t *data_ptr, spinel_size_t d
|
||||
|
||||
case SPINEL_DATATYPE_UINT_PACKED_C:
|
||||
{
|
||||
unsigned int *arg_ptr = va_arg(args->obj, unsigned int *);
|
||||
unsigned int * arg_ptr = va_arg(args->obj, unsigned int *);
|
||||
spinel_ssize_t pui_len = spinel_packed_uint_decode(data_ptr, data_len, arg_ptr);
|
||||
|
||||
// Range check
|
||||
@@ -473,7 +475,7 @@ spinel_datatype_vunpack_(bool in_place, const uint8_t *data_ptr, spinel_size_t d
|
||||
|
||||
if (in_place)
|
||||
{
|
||||
char *arg = va_arg(args->obj, char *);
|
||||
char * arg = va_arg(args->obj, char *);
|
||||
size_t len_arg = va_arg(args->obj, size_t);
|
||||
if (arg)
|
||||
{
|
||||
@@ -499,16 +501,15 @@ spinel_datatype_vunpack_(bool in_place, const uint8_t *data_ptr, spinel_size_t d
|
||||
case SPINEL_DATATYPE_DATA_C:
|
||||
case SPINEL_DATATYPE_DATA_WLEN_C:
|
||||
{
|
||||
spinel_ssize_t pui_len = 0;
|
||||
uint16_t block_len = 0;
|
||||
const uint8_t *block_ptr = data_ptr;
|
||||
void *arg_ptr = va_arg(args->obj, void *);
|
||||
unsigned int *block_len_ptr = va_arg(args->obj, unsigned int *);
|
||||
char nextformat = *spinel_next_packed_datatype(pack_format);
|
||||
spinel_ssize_t pui_len = 0;
|
||||
uint16_t block_len = 0;
|
||||
const uint8_t *block_ptr = data_ptr;
|
||||
void * arg_ptr = va_arg(args->obj, void *);
|
||||
unsigned int * block_len_ptr = va_arg(args->obj, unsigned int *);
|
||||
char nextformat = *spinel_next_packed_datatype(pack_format);
|
||||
|
||||
if ( (pack_format[0] == SPINEL_DATATYPE_DATA_WLEN_C)
|
||||
|| ( (nextformat != 0) && (nextformat != ')') )
|
||||
) {
|
||||
if ((pack_format[0] == SPINEL_DATATYPE_DATA_WLEN_C) || ((nextformat != 0) && (nextformat != ')')))
|
||||
{
|
||||
pui_len = spinel_datatype_unpack(data_ptr, data_len, SPINEL_DATATYPE_UINT16_S, &block_len);
|
||||
block_ptr += pui_len;
|
||||
|
||||
@@ -518,20 +519,19 @@ spinel_datatype_vunpack_(bool in_place, const uint8_t *data_ptr, spinel_size_t d
|
||||
else
|
||||
{
|
||||
block_len = (uint16_t)data_len;
|
||||
pui_len = 0;
|
||||
pui_len = 0;
|
||||
}
|
||||
|
||||
require_action((spinel_ssize_t)data_len >= (block_len + pui_len), bail, (ret = -1, errno = EOVERFLOW));
|
||||
|
||||
if (in_place)
|
||||
{
|
||||
require_action(NULL != block_len_ptr && *block_len_ptr >= block_len,
|
||||
bail, (ret = -1, errno = EINVAL));
|
||||
require_action(NULL != block_len_ptr && *block_len_ptr >= block_len, bail, (ret = -1, errno = EINVAL));
|
||||
memcpy(arg_ptr, block_ptr, block_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
const uint8_t **block_ptr_ptr = (const uint8_t **)arg_ptr;
|
||||
const uint8_t **block_ptr_ptr = (const uint8_t **)arg_ptr;
|
||||
if (NULL != block_ptr_ptr)
|
||||
{
|
||||
*block_ptr_ptr = block_ptr;
|
||||
@@ -550,19 +550,17 @@ spinel_datatype_vunpack_(bool in_place, const uint8_t *data_ptr, spinel_size_t d
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 'T':
|
||||
case SPINEL_DATATYPE_STRUCT_C:
|
||||
{
|
||||
spinel_ssize_t pui_len = 0;
|
||||
uint16_t block_len = 0;
|
||||
spinel_ssize_t pui_len = 0;
|
||||
uint16_t block_len = 0;
|
||||
spinel_ssize_t actual_len = 0;
|
||||
const uint8_t *block_ptr = data_ptr;
|
||||
char nextformat = *spinel_next_packed_datatype(pack_format);
|
||||
const uint8_t *block_ptr = data_ptr;
|
||||
char nextformat = *spinel_next_packed_datatype(pack_format);
|
||||
|
||||
if ( (pack_format[0] == SPINEL_DATATYPE_STRUCT_C)
|
||||
|| ( (nextformat != 0) && (nextformat != ')') )
|
||||
) {
|
||||
if ((pack_format[0] == SPINEL_DATATYPE_STRUCT_C) || ((nextformat != 0) && (nextformat != ')')))
|
||||
{
|
||||
pui_len = spinel_datatype_unpack(data_ptr, data_len, SPINEL_DATATYPE_UINT16_S, &block_len);
|
||||
block_ptr += pui_len;
|
||||
|
||||
@@ -572,7 +570,7 @@ spinel_datatype_vunpack_(bool in_place, const uint8_t *data_ptr, spinel_size_t d
|
||||
else
|
||||
{
|
||||
block_len = (uint16_t)data_len;
|
||||
pui_len = 0;
|
||||
pui_len = 0;
|
||||
}
|
||||
|
||||
require_action((spinel_ssize_t)data_len >= (block_len + pui_len), bail, (ret = -1, errno = EOVERFLOW));
|
||||
@@ -603,7 +601,7 @@ spinel_datatype_vunpack_(bool in_place, const uint8_t *data_ptr, spinel_size_t d
|
||||
case SPINEL_DATATYPE_ARRAY_C:
|
||||
default:
|
||||
// Unsupported Type!
|
||||
ret = -1;
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
goto bail;
|
||||
}
|
||||
@@ -615,11 +613,13 @@ bail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
spinel_ssize_t
|
||||
spinel_datatype_unpack_in_place(const uint8_t *data_ptr, spinel_size_t data_len, const char *pack_format, ...)
|
||||
spinel_ssize_t spinel_datatype_unpack_in_place(const uint8_t *data_ptr,
|
||||
spinel_size_t data_len,
|
||||
const char * pack_format,
|
||||
...)
|
||||
{
|
||||
spinel_ssize_t ret;
|
||||
va_list_obj args;
|
||||
va_list_obj args;
|
||||
va_start(args.obj, pack_format);
|
||||
|
||||
ret = spinel_datatype_vunpack_(true, data_ptr, data_len, pack_format, &args);
|
||||
@@ -628,11 +628,10 @@ spinel_datatype_unpack_in_place(const uint8_t *data_ptr, spinel_size_t data_len,
|
||||
return ret;
|
||||
}
|
||||
|
||||
spinel_ssize_t
|
||||
spinel_datatype_unpack(const uint8_t *data_ptr, spinel_size_t data_len, const char *pack_format, ...)
|
||||
spinel_ssize_t spinel_datatype_unpack(const uint8_t *data_ptr, spinel_size_t data_len, const char *pack_format, ...)
|
||||
{
|
||||
spinel_ssize_t ret;
|
||||
va_list_obj args;
|
||||
va_list_obj args;
|
||||
va_start(args.obj, pack_format);
|
||||
|
||||
ret = spinel_datatype_vunpack_(false, data_ptr, data_len, pack_format, &args);
|
||||
@@ -641,11 +640,13 @@ spinel_datatype_unpack(const uint8_t *data_ptr, spinel_size_t data_len, const ch
|
||||
return ret;
|
||||
}
|
||||
|
||||
spinel_ssize_t
|
||||
spinel_datatype_vunpack_in_place(const uint8_t *data_ptr, spinel_size_t data_len, const char *pack_format, va_list args)
|
||||
spinel_ssize_t spinel_datatype_vunpack_in_place(const uint8_t *data_ptr,
|
||||
spinel_size_t data_len,
|
||||
const char * pack_format,
|
||||
va_list args)
|
||||
{
|
||||
spinel_ssize_t ret;
|
||||
va_list_obj args_obj;
|
||||
va_list_obj args_obj;
|
||||
va_copy(args_obj.obj, args);
|
||||
|
||||
ret = spinel_datatype_vunpack_(true, data_ptr, data_len, pack_format, &args_obj);
|
||||
@@ -654,11 +655,13 @@ spinel_datatype_vunpack_in_place(const uint8_t *data_ptr, spinel_size_t data_len
|
||||
return ret;
|
||||
}
|
||||
|
||||
spinel_ssize_t
|
||||
spinel_datatype_vunpack(const uint8_t *data_ptr, spinel_size_t data_len, const char *pack_format, va_list args)
|
||||
spinel_ssize_t spinel_datatype_vunpack(const uint8_t *data_ptr,
|
||||
spinel_size_t data_len,
|
||||
const char * pack_format,
|
||||
va_list args)
|
||||
{
|
||||
spinel_ssize_t ret;
|
||||
va_list_obj args_obj;
|
||||
va_list_obj args_obj;
|
||||
va_copy(args_obj.obj, args);
|
||||
|
||||
ret = spinel_datatype_vunpack_(false, data_ptr, data_len, pack_format, &args_obj);
|
||||
@@ -667,8 +670,10 @@ spinel_datatype_vunpack(const uint8_t *data_ptr, spinel_size_t data_len, const c
|
||||
return ret;
|
||||
}
|
||||
|
||||
static spinel_ssize_t
|
||||
spinel_datatype_vpack_(uint8_t *data_ptr, spinel_size_t data_len_max, const char *pack_format, va_list_obj *args)
|
||||
static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
|
||||
spinel_size_t data_len_max,
|
||||
const char * pack_format,
|
||||
va_list_obj * args)
|
||||
{
|
||||
spinel_ssize_t ret = 0;
|
||||
|
||||
@@ -855,11 +860,14 @@ spinel_datatype_vpack_(uint8_t *data_ptr, spinel_size_t data_len_max, const char
|
||||
|
||||
case SPINEL_DATATYPE_UINT_PACKED_C:
|
||||
{
|
||||
uint32_t arg = va_arg(args->obj, uint32_t);
|
||||
uint32_t arg = va_arg(args->obj, uint32_t);
|
||||
spinel_ssize_t encoded_size;
|
||||
|
||||
// Range Check
|
||||
require_action(arg < SPINEL_MAX_UINT_PACKED, bail, {ret = -1; errno = EINVAL;});
|
||||
require_action(arg < SPINEL_MAX_UINT_PACKED, bail, {
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
});
|
||||
|
||||
encoded_size = spinel_packed_uint_encode(data_ptr, data_len_max, arg);
|
||||
ret += encoded_size;
|
||||
@@ -879,8 +887,8 @@ spinel_datatype_vpack_(uint8_t *data_ptr, spinel_size_t data_len_max, const char
|
||||
|
||||
case SPINEL_DATATYPE_UTF8_C:
|
||||
{
|
||||
const char *string_arg = va_arg(args->obj, const char *);
|
||||
size_t string_arg_len = 0;
|
||||
const char *string_arg = va_arg(args->obj, const char *);
|
||||
size_t string_arg_len = 0;
|
||||
|
||||
if (string_arg)
|
||||
{
|
||||
@@ -888,7 +896,7 @@ spinel_datatype_vpack_(uint8_t *data_ptr, spinel_size_t data_len_max, const char
|
||||
}
|
||||
else
|
||||
{
|
||||
string_arg = "";
|
||||
string_arg = "";
|
||||
string_arg_len = 1;
|
||||
}
|
||||
|
||||
@@ -912,16 +920,18 @@ spinel_datatype_vpack_(uint8_t *data_ptr, spinel_size_t data_len_max, const char
|
||||
case SPINEL_DATATYPE_DATA_WLEN_C:
|
||||
case SPINEL_DATATYPE_DATA_C:
|
||||
{
|
||||
const uint8_t *arg = va_arg(args->obj, const uint8_t *);
|
||||
uint32_t data_size_arg = va_arg(args->obj, uint32_t);
|
||||
spinel_ssize_t size_len = 0;
|
||||
char nextformat = *spinel_next_packed_datatype(pack_format);
|
||||
const uint8_t *arg = va_arg(args->obj, const uint8_t *);
|
||||
uint32_t data_size_arg = va_arg(args->obj, uint32_t);
|
||||
spinel_ssize_t size_len = 0;
|
||||
char nextformat = *spinel_next_packed_datatype(pack_format);
|
||||
|
||||
if ( (pack_format[0] == SPINEL_DATATYPE_DATA_WLEN_C)
|
||||
|| ( (nextformat != 0) && (nextformat != ')') )
|
||||
) {
|
||||
if ((pack_format[0] == SPINEL_DATATYPE_DATA_WLEN_C) || ((nextformat != 0) && (nextformat != ')')))
|
||||
{
|
||||
size_len = spinel_datatype_pack(data_ptr, data_len_max, SPINEL_DATATYPE_UINT16_S, data_size_arg);
|
||||
require_action(size_len > 0, bail, {ret = -1; errno = EINVAL;});
|
||||
require_action(size_len > 0, bail, {
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
});
|
||||
}
|
||||
|
||||
ret += (spinel_size_t)size_len + data_size_arg;
|
||||
@@ -948,10 +958,13 @@ spinel_datatype_vpack_(uint8_t *data_ptr, spinel_size_t data_len_max, const char
|
||||
case SPINEL_DATATYPE_STRUCT_C:
|
||||
{
|
||||
spinel_ssize_t struct_len = 0;
|
||||
spinel_ssize_t size_len = 0;
|
||||
char nextformat = *spinel_next_packed_datatype(pack_format);
|
||||
spinel_ssize_t size_len = 0;
|
||||
char nextformat = *spinel_next_packed_datatype(pack_format);
|
||||
|
||||
require_action(pack_format[1] == '(', bail, {ret = -1; errno = EINVAL;});
|
||||
require_action(pack_format[1] == '(', bail, {
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
});
|
||||
|
||||
// First we figure out the size of the struct
|
||||
{
|
||||
@@ -961,11 +974,13 @@ spinel_datatype_vpack_(uint8_t *data_ptr, spinel_size_t data_len_max, const char
|
||||
va_end(subargs.obj);
|
||||
}
|
||||
|
||||
if ( (pack_format[0] == SPINEL_DATATYPE_STRUCT_C)
|
||||
|| ( (nextformat != 0) && (nextformat != ')') )
|
||||
) {
|
||||
if ((pack_format[0] == SPINEL_DATATYPE_STRUCT_C) || ((nextformat != 0) && (nextformat != ')')))
|
||||
{
|
||||
size_len = spinel_datatype_pack(data_ptr, data_len_max, SPINEL_DATATYPE_UINT16_S, struct_len);
|
||||
require_action(size_len > 0, bail, {ret = -1; errno = EINVAL;});
|
||||
require_action(size_len > 0, bail, {
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
});
|
||||
}
|
||||
|
||||
ret += size_len + struct_len;
|
||||
@@ -994,10 +1009,9 @@ spinel_datatype_vpack_(uint8_t *data_ptr, spinel_size_t data_len_max, const char
|
||||
|
||||
default:
|
||||
// Unsupported Type!
|
||||
ret = -1;
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
goto bail;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1005,10 +1019,9 @@ bail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
spinel_ssize_t
|
||||
spinel_datatype_pack(uint8_t *data_ptr, spinel_size_t data_len_max, const char *pack_format, ...)
|
||||
spinel_ssize_t spinel_datatype_pack(uint8_t *data_ptr, spinel_size_t data_len_max, const char *pack_format, ...)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
va_list_obj args;
|
||||
va_start(args.obj, pack_format);
|
||||
|
||||
@@ -1018,11 +1031,12 @@ spinel_datatype_pack(uint8_t *data_ptr, spinel_size_t data_len_max, const char *
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
spinel_ssize_t
|
||||
spinel_datatype_vpack(uint8_t *data_ptr, spinel_size_t data_len_max, const char *pack_format, va_list args)
|
||||
spinel_ssize_t spinel_datatype_vpack(uint8_t * data_ptr,
|
||||
spinel_size_t data_len_max,
|
||||
const char * pack_format,
|
||||
va_list args)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
va_list_obj args_obj;
|
||||
va_copy(args_obj.obj, args);
|
||||
|
||||
@@ -1032,14 +1046,12 @@ spinel_datatype_vpack(uint8_t *data_ptr, spinel_size_t data_len_max, const char
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MARK: -
|
||||
|
||||
// **** LCOV_EXCL_START ****
|
||||
|
||||
const char *
|
||||
spinel_prop_key_to_cstr(spinel_prop_key_t prop_key)
|
||||
const char *spinel_prop_key_to_cstr(spinel_prop_key_t prop_key)
|
||||
{
|
||||
const char *ret = "UNKNOWN";
|
||||
|
||||
@@ -2245,22 +2257,22 @@ const char *spinel_capability_to_cstr(unsigned int capability)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// **** LCOV_EXCL_STOP ****
|
||||
// **** LCOV_EXCL_STOP ****
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#if SPINEL_SELF_TEST
|
||||
|
||||
int
|
||||
main(void)
|
||||
int main(void)
|
||||
{
|
||||
int ret = -1;
|
||||
const spinel_eui64_t static_eui64 = { {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 } };
|
||||
const char static_string[] = "static_string";
|
||||
uint8_t buffer[1024];
|
||||
ssize_t len;
|
||||
int ret = -1;
|
||||
const spinel_eui64_t static_eui64 = {{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}};
|
||||
const char static_string[] = "static_string";
|
||||
uint8_t buffer[1024];
|
||||
ssize_t len;
|
||||
|
||||
len = spinel_datatype_pack(buffer, sizeof(buffer), "CiiLUE", 0x88, 9, 0xA3, 0xDEADBEEF, static_string, &static_eui64);
|
||||
len =
|
||||
spinel_datatype_pack(buffer, sizeof(buffer), "CiiLUE", 0x88, 9, 0xA3, 0xDEADBEEF, static_string, &static_eui64);
|
||||
|
||||
if (len != 30)
|
||||
{
|
||||
@@ -2290,11 +2302,11 @@ main(void)
|
||||
len = 30;
|
||||
|
||||
{
|
||||
uint8_t c = 0;
|
||||
unsigned int i1 = 0;
|
||||
unsigned int i2 = 0;
|
||||
uint32_t l = 0;
|
||||
const char *str = NULL;
|
||||
uint8_t c = 0;
|
||||
unsigned int i1 = 0;
|
||||
unsigned int i2 = 0;
|
||||
uint32_t l = 0;
|
||||
const char * str = NULL;
|
||||
const spinel_eui64_t *eui64 = NULL;
|
||||
|
||||
len = spinel_datatype_unpack(buffer, (spinel_size_t)len, "CiiLUE", &c, &i1, &i2, &l, &str, &eui64);
|
||||
@@ -2343,14 +2355,15 @@ main(void)
|
||||
}
|
||||
|
||||
{
|
||||
uint8_t c = 0;
|
||||
unsigned int i1 = 0;
|
||||
unsigned int i2 = 0;
|
||||
uint32_t l = 0;
|
||||
char str[sizeof(static_string)];
|
||||
uint8_t c = 0;
|
||||
unsigned int i1 = 0;
|
||||
unsigned int i2 = 0;
|
||||
uint32_t l = 0;
|
||||
char str[sizeof(static_string)];
|
||||
spinel_eui64_t eui64 = {{0}};
|
||||
|
||||
len = spinel_datatype_unpack_in_place(buffer, (spinel_size_t)len, "CiiLUE", &c, &i1, &i2, &l, &str, sizeof(str), &eui64);
|
||||
len = spinel_datatype_unpack_in_place(buffer, (spinel_size_t)len, "CiiLUE", &c, &i1, &i2, &l, &str, sizeof(str),
|
||||
&eui64);
|
||||
|
||||
if (len != 30)
|
||||
{
|
||||
@@ -2399,7 +2412,8 @@ main(void)
|
||||
|
||||
memset(buffer, 0xAA, sizeof(buffer));
|
||||
|
||||
len = spinel_datatype_pack(buffer, sizeof(buffer), "Cit(iL)UE", 0x88, 9, 0xA3, 0xDEADBEEF, static_string, &static_eui64);
|
||||
len = spinel_datatype_pack(buffer, sizeof(buffer), "Cit(iL)UE", 0x88, 9, 0xA3, 0xDEADBEEF, static_string,
|
||||
&static_eui64);
|
||||
|
||||
if (len != 32)
|
||||
{
|
||||
@@ -2407,14 +2421,12 @@ main(void)
|
||||
goto bail;
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
uint8_t c = 0;
|
||||
unsigned int i1 = 0;
|
||||
unsigned int i2 = 0;
|
||||
uint32_t l = 0;
|
||||
const char *str = NULL;
|
||||
uint8_t c = 0;
|
||||
unsigned int i1 = 0;
|
||||
unsigned int i2 = 0;
|
||||
uint32_t l = 0;
|
||||
const char * str = NULL;
|
||||
spinel_eui64_t *eui64 = NULL;
|
||||
|
||||
len = spinel_datatype_unpack(buffer, (spinel_size_t)len, "Cit(iL)UE", &c, &i1, &i2, &l, &str, &eui64);
|
||||
@@ -2463,14 +2475,15 @@ main(void)
|
||||
}
|
||||
|
||||
{
|
||||
uint8_t c = 0;
|
||||
unsigned int i1 = 0;
|
||||
unsigned int i2 = 0;
|
||||
uint32_t l = 0;
|
||||
char str[sizeof(static_string)];
|
||||
uint8_t c = 0;
|
||||
unsigned int i1 = 0;
|
||||
unsigned int i2 = 0;
|
||||
uint32_t l = 0;
|
||||
char str[sizeof(static_string)];
|
||||
spinel_eui64_t eui64 = {{0}};
|
||||
|
||||
len = spinel_datatype_unpack_in_place(buffer, (spinel_size_t)len, "Cit(iL)UE", &c, &i1, &i2, &l, &str, sizeof(str), &eui64);
|
||||
len = spinel_datatype_unpack_in_place(buffer, (spinel_size_t)len, "Cit(iL)UE", &c, &i1, &i2, &l, &str,
|
||||
sizeof(str), &eui64);
|
||||
|
||||
if (len != 32)
|
||||
{
|
||||
|
||||
+593
-647
File diff suppressed because it is too large
Load Diff
+41
-47
@@ -39,21 +39,21 @@
|
||||
namespace ot {
|
||||
namespace Ncp {
|
||||
|
||||
SpinelDecoder::SpinelDecoder(void) :
|
||||
mFrame(NULL),
|
||||
mLength(0),
|
||||
mIndex(0),
|
||||
mEnd(0),
|
||||
mNumOpenStructs(0),
|
||||
mSavedNumOpenStructs(0),
|
||||
mSavedIndex(0),
|
||||
mSavedEnd(0)
|
||||
SpinelDecoder::SpinelDecoder(void)
|
||||
: mFrame(NULL)
|
||||
, mLength(0)
|
||||
, mIndex(0)
|
||||
, mEnd(0)
|
||||
, mNumOpenStructs(0)
|
||||
, mSavedNumOpenStructs(0)
|
||||
, mSavedIndex(0)
|
||||
, mSavedEnd(0)
|
||||
{
|
||||
}
|
||||
|
||||
void SpinelDecoder::Init(const uint8_t *aFrame, uint16_t aLength)
|
||||
{
|
||||
mFrame = aFrame;
|
||||
mFrame = aFrame;
|
||||
mLength = (mFrame != NULL) ? aLength : 0;
|
||||
|
||||
Reset();
|
||||
@@ -62,8 +62,8 @@ void SpinelDecoder::Init(const uint8_t *aFrame, uint16_t aLength)
|
||||
|
||||
void SpinelDecoder::Reset(void)
|
||||
{
|
||||
mIndex = 0;
|
||||
mEnd = mLength;
|
||||
mIndex = 0;
|
||||
mEnd = mLength;
|
||||
mNumOpenStructs = 0;
|
||||
ClearSavedPosition();
|
||||
}
|
||||
@@ -133,7 +133,7 @@ exit:
|
||||
|
||||
otError SpinelDecoder::ReadInt16(int16_t &aInt16)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t u16;
|
||||
|
||||
SuccessOrExit(error = ReadUint16(u16));
|
||||
@@ -149,10 +149,8 @@ otError SpinelDecoder::ReadUint32(uint32_t &aUint32)
|
||||
|
||||
VerifyOrExit(mIndex + sizeof(uint32_t) <= mEnd, error = OT_ERROR_PARSE);
|
||||
|
||||
aUint32 = ((static_cast<uint32_t>(mFrame[mIndex + 0]) << 0) |
|
||||
(static_cast<uint32_t>(mFrame[mIndex + 1]) << 8) |
|
||||
(static_cast<uint32_t>(mFrame[mIndex + 2]) << 16) |
|
||||
(static_cast<uint32_t>(mFrame[mIndex + 3]) << 24));
|
||||
aUint32 = ((static_cast<uint32_t>(mFrame[mIndex + 0]) << 0) | (static_cast<uint32_t>(mFrame[mIndex + 1]) << 8) |
|
||||
(static_cast<uint32_t>(mFrame[mIndex + 2]) << 16) | (static_cast<uint32_t>(mFrame[mIndex + 3]) << 24));
|
||||
|
||||
mIndex += sizeof(uint32_t);
|
||||
|
||||
@@ -162,7 +160,7 @@ exit:
|
||||
|
||||
otError SpinelDecoder::ReadInt32(int32_t &aInt32)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t u32;
|
||||
|
||||
SuccessOrExit(error = ReadUint32(u32));
|
||||
@@ -178,14 +176,10 @@ otError SpinelDecoder::ReadUint64(uint64_t &aUint64)
|
||||
|
||||
VerifyOrExit(mIndex + sizeof(uint64_t) <= mEnd, error = OT_ERROR_PARSE);
|
||||
|
||||
aUint64 = ((static_cast<uint64_t>(mFrame[mIndex + 0]) << 0) |
|
||||
(static_cast<uint64_t>(mFrame[mIndex + 1]) << 8) |
|
||||
(static_cast<uint64_t>(mFrame[mIndex + 2]) << 16) |
|
||||
(static_cast<uint64_t>(mFrame[mIndex + 3]) << 24) |
|
||||
(static_cast<uint64_t>(mFrame[mIndex + 4]) << 32) |
|
||||
(static_cast<uint64_t>(mFrame[mIndex + 5]) << 40) |
|
||||
(static_cast<uint64_t>(mFrame[mIndex + 6]) << 48) |
|
||||
(static_cast<uint64_t>(mFrame[mIndex + 7]) << 56));
|
||||
aUint64 = ((static_cast<uint64_t>(mFrame[mIndex + 0]) << 0) | (static_cast<uint64_t>(mFrame[mIndex + 1]) << 8) |
|
||||
(static_cast<uint64_t>(mFrame[mIndex + 2]) << 16) | (static_cast<uint64_t>(mFrame[mIndex + 3]) << 24) |
|
||||
(static_cast<uint64_t>(mFrame[mIndex + 4]) << 32) | (static_cast<uint64_t>(mFrame[mIndex + 5]) << 40) |
|
||||
(static_cast<uint64_t>(mFrame[mIndex + 6]) << 48) | (static_cast<uint64_t>(mFrame[mIndex + 7]) << 56));
|
||||
|
||||
mIndex += sizeof(uint64_t);
|
||||
|
||||
@@ -195,7 +189,7 @@ exit:
|
||||
|
||||
otError SpinelDecoder::ReadInt64(int64_t &aInt64)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint64_t u64;
|
||||
|
||||
SuccessOrExit(error = ReadUint64(u64));
|
||||
@@ -207,9 +201,9 @@ exit:
|
||||
|
||||
otError SpinelDecoder::ReadUintPacked(unsigned int &aUint)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
spinel_ssize_t parsedLen;
|
||||
unsigned int uint;
|
||||
unsigned int uint;
|
||||
|
||||
parsedLen = spinel_packed_uint_decode(&mFrame[mIndex], mEnd - mIndex, &uint);
|
||||
VerifyOrExit(parsedLen > 0, error = OT_ERROR_PARSE);
|
||||
@@ -238,7 +232,7 @@ exit:
|
||||
|
||||
otError SpinelDecoder::ReadIp6Address(spinel_ipv6addr_t &aIp6Addr)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
const spinel_ipv6addr_t *ipv6AddrPtr;
|
||||
|
||||
SuccessOrExit(error = ReadIp6Address(ipv6AddrPtr));
|
||||
@@ -250,7 +244,7 @@ exit:
|
||||
|
||||
otError SpinelDecoder::ReadIp6Address(otIp6Address &aIp6Addr)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
const otIp6Address *ipv6AddrPtr;
|
||||
|
||||
SuccessOrExit(error = ReadIp6Address(ipv6AddrPtr));
|
||||
@@ -262,7 +256,7 @@ exit:
|
||||
|
||||
otError SpinelDecoder::ReadEui64(spinel_eui64_t &aEui64)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
const spinel_eui64_t *eui64Ptr;
|
||||
|
||||
SuccessOrExit(error = ReadEui64(eui64Ptr));
|
||||
@@ -274,7 +268,7 @@ exit:
|
||||
|
||||
otError SpinelDecoder::ReadEui64(otExtAddress &aEui64)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
const otExtAddress *eui64Ptr;
|
||||
|
||||
SuccessOrExit(error = ReadEui64(eui64Ptr));
|
||||
@@ -286,7 +280,7 @@ exit:
|
||||
|
||||
otError SpinelDecoder::ReadEui48(spinel_eui48_t &aEui48)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
const spinel_eui48_t *eui48Ptr;
|
||||
|
||||
SuccessOrExit(error = ReadEui48(eui48Ptr));
|
||||
@@ -299,7 +293,7 @@ exit:
|
||||
otError SpinelDecoder::ReadUtf8(const char *&aUtf8)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
size_t len;
|
||||
size_t len;
|
||||
|
||||
// Ensure there is at least one byte (for null character).
|
||||
VerifyOrExit(mIndex + sizeof(uint8_t) <= mEnd, error = OT_ERROR_PARSE);
|
||||
@@ -309,7 +303,7 @@ otError SpinelDecoder::ReadUtf8(const char *&aUtf8)
|
||||
|
||||
aUtf8 = reinterpret_cast<const char *>(&mFrame[mIndex]);
|
||||
|
||||
mIndex += (len + sizeof(uint8_t)); // `sizeof(uint8_t)` is added for the terminating null character.
|
||||
mIndex += (len + sizeof(uint8_t)); // `sizeof(uint8_t)` is added for the terminating null character.
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -324,7 +318,7 @@ otError SpinelDecoder::ReadData(const uint8_t *&aData, uint16_t &aDataLen)
|
||||
|
||||
otError SpinelDecoder::ReadDataWithLen(const uint8_t *&aData, uint16_t &aDataLen)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = ReadUint16(len));
|
||||
@@ -337,7 +331,7 @@ exit:
|
||||
|
||||
otError SpinelDecoder::OpenStruct(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t structLen;
|
||||
|
||||
VerifyOrExit(mNumOpenStructs < kMaxNestedStructs, error = OT_ERROR_INVALID_STATE);
|
||||
@@ -346,7 +340,7 @@ otError SpinelDecoder::OpenStruct(void)
|
||||
VerifyOrExit(structLen <= mEnd - mIndex, error = OT_ERROR_PARSE);
|
||||
|
||||
mPrevEnd[mNumOpenStructs] = mEnd;
|
||||
mEnd = (mIndex + structLen);
|
||||
mEnd = (mIndex + structLen);
|
||||
mNumOpenStructs++;
|
||||
|
||||
exit:
|
||||
@@ -371,7 +365,7 @@ otError SpinelDecoder::CloseStruct(void)
|
||||
|
||||
mNumOpenStructs--;
|
||||
mIndex = mEnd;
|
||||
mEnd = mPrevEnd[mNumOpenStructs];
|
||||
mEnd = mPrevEnd[mNumOpenStructs];
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -379,8 +373,8 @@ exit:
|
||||
|
||||
void SpinelDecoder::SavePosition(void)
|
||||
{
|
||||
mSavedIndex = mIndex;
|
||||
mSavedEnd = mEnd;
|
||||
mSavedIndex = mIndex;
|
||||
mSavedEnd = mEnd;
|
||||
mSavedNumOpenStructs = mNumOpenStructs;
|
||||
}
|
||||
|
||||
@@ -390,13 +384,13 @@ otError SpinelDecoder::ResetToSaved(void)
|
||||
|
||||
VerifyOrExit(IsSavedPositionValid(), error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
mIndex = mSavedIndex;
|
||||
mEnd = mSavedEnd;
|
||||
mNumOpenStructs = mSavedNumOpenStructs;
|
||||
mIndex = mSavedIndex;
|
||||
mEnd = mSavedEnd;
|
||||
mNumOpenStructs = mSavedNumOpenStructs;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
+30
-29
@@ -51,7 +51,6 @@ namespace Ncp {
|
||||
class SpinelDecoder
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* This constructor initializes a `SpinelDecoder` object
|
||||
*
|
||||
@@ -259,7 +258,8 @@ public:
|
||||
* @retval OT_ERROR_PARSE Failed to parse/decode the value.
|
||||
*
|
||||
*/
|
||||
otError ReadIp6Address(const spinel_ipv6addr_t *&aIp6AddrPtr) {
|
||||
otError ReadIp6Address(const spinel_ipv6addr_t *&aIp6AddrPtr)
|
||||
{
|
||||
return ReadItem(reinterpret_cast<const uint8_t **>(&aIp6AddrPtr), sizeof(spinel_ipv6addr_t));
|
||||
}
|
||||
|
||||
@@ -275,7 +275,8 @@ public:
|
||||
* @retval OT_ERROR_PARSE Failed to parse/decode the value.
|
||||
*
|
||||
*/
|
||||
otError ReadIp6Address(const otIp6Address *&aIp6AddrPtr) {
|
||||
otError ReadIp6Address(const otIp6Address *&aIp6AddrPtr)
|
||||
{
|
||||
return ReadItem(reinterpret_cast<const uint8_t **>(&aIp6AddrPtr), sizeof(spinel_ipv6addr_t));
|
||||
}
|
||||
|
||||
@@ -291,7 +292,8 @@ public:
|
||||
* @retval OT_ERROR_PARSE Failed to parse/decode the value.
|
||||
*
|
||||
*/
|
||||
otError ReadIp6Address(const uint8_t *&aIp6AddrBufPtr) {
|
||||
otError ReadIp6Address(const uint8_t *&aIp6AddrBufPtr)
|
||||
{
|
||||
return ReadItem(&aIp6AddrBufPtr, sizeof(spinel_ipv6addr_t));
|
||||
}
|
||||
|
||||
@@ -335,7 +337,8 @@ public:
|
||||
* @retval OT_ERROR_PARSE Failed to parse/decode the value.
|
||||
*
|
||||
*/
|
||||
otError ReadEui64(const spinel_eui64_t *&aEui64Ptr) {
|
||||
otError ReadEui64(const spinel_eui64_t *&aEui64Ptr)
|
||||
{
|
||||
return ReadItem(reinterpret_cast<const uint8_t **>(&aEui64Ptr), sizeof(spinel_eui64_t));
|
||||
}
|
||||
|
||||
@@ -351,7 +354,8 @@ public:
|
||||
* @retval OT_ERROR_PARSE Failed to parse/decode the value.
|
||||
*
|
||||
*/
|
||||
otError ReadEui64(const otExtAddress *&aEui64Ptr) {
|
||||
otError ReadEui64(const otExtAddress *&aEui64Ptr)
|
||||
{
|
||||
return ReadItem(reinterpret_cast<const uint8_t **>(&aEui64Ptr), sizeof(spinel_eui64_t));
|
||||
}
|
||||
|
||||
@@ -367,9 +371,7 @@ public:
|
||||
* @retval OT_ERROR_PARSE Failed to parse/decode the value.
|
||||
*
|
||||
*/
|
||||
otError ReadEui64(const uint8_t *&aEui64BufPtr) {
|
||||
return ReadItem(&aEui64BufPtr, sizeof(spinel_eui64_t));
|
||||
}
|
||||
otError ReadEui64(const uint8_t *&aEui64BufPtr) { return ReadItem(&aEui64BufPtr, sizeof(spinel_eui64_t)); }
|
||||
|
||||
/**
|
||||
* This method decodes and reads an EUI64 value form the frame.
|
||||
@@ -411,7 +413,8 @@ public:
|
||||
* @retval OT_ERROR_PARSE Failed to parse/decode the value.
|
||||
*
|
||||
*/
|
||||
otError ReadEui48(const spinel_eui48_t *&aEui48Ptr) {
|
||||
otError ReadEui48(const spinel_eui48_t *&aEui48Ptr)
|
||||
{
|
||||
return ReadItem(reinterpret_cast<const uint8_t **>(&aEui48Ptr), sizeof(spinel_eui48_t));
|
||||
}
|
||||
|
||||
@@ -427,9 +430,7 @@ public:
|
||||
* @retval OT_ERROR_PARSE Failed to parse/decode the value.
|
||||
*
|
||||
*/
|
||||
otError ReadEui48(const uint8_t *&aEui48BufPtr) {
|
||||
return ReadItem(&aEui48BufPtr, sizeof(spinel_eui48_t));
|
||||
}
|
||||
otError ReadEui48(const uint8_t *&aEui48BufPtr) { return ReadItem(&aEui48BufPtr, sizeof(spinel_eui48_t)); }
|
||||
|
||||
/**
|
||||
* This method decodes and reads an EUI48 value form the frame.
|
||||
@@ -459,7 +460,7 @@ public:
|
||||
*/
|
||||
otError ReadUtf8(const char *&aUt8);
|
||||
|
||||
/**
|
||||
/**
|
||||
* This method decodes and reads a data blob (sequence of bytes) form the frame.
|
||||
*
|
||||
* On success, the read position gets updated.
|
||||
@@ -549,7 +550,7 @@ public:
|
||||
*/
|
||||
void SavePosition(void);
|
||||
|
||||
/**
|
||||
/**
|
||||
* This method resets/moves the read position to a previously saved position.
|
||||
*
|
||||
* The saved position remembers its enclosing structure. When `ResetToSaved()` is called, the current open
|
||||
@@ -564,28 +565,28 @@ public:
|
||||
|
||||
private:
|
||||
otError ReadItem(const uint8_t **aPtr, size_t aSize);
|
||||
void ClearSavedPosition(void) { mSavedIndex = mLength; }
|
||||
bool IsSavedPositionValid(void) const { return (mSavedIndex < mLength); }
|
||||
void ClearSavedPosition(void) { mSavedIndex = mLength; }
|
||||
bool IsSavedPositionValid(void) const { return (mSavedIndex < mLength); }
|
||||
|
||||
enum
|
||||
{
|
||||
kMaxNestedStructs = 4, ///< Maximum number of nested structs.
|
||||
kMaxNestedStructs = 4, ///< Maximum number of nested structs.
|
||||
};
|
||||
|
||||
const uint8_t *mFrame; // Frame buffer
|
||||
uint16_t mLength; // Total length of the buffer.
|
||||
uint16_t mIndex; // Current read index.
|
||||
uint16_t mEnd; // Current end index (end of struct if in a struct, or end of buffer otherwise).
|
||||
uint8_t mNumOpenStructs; // Number of open structs.
|
||||
const uint8_t *mFrame; // Frame buffer
|
||||
uint16_t mLength; // Total length of the buffer.
|
||||
uint16_t mIndex; // Current read index.
|
||||
uint16_t mEnd; // Current end index (end of struct if in a struct, or end of buffer otherwise).
|
||||
uint8_t mNumOpenStructs; // Number of open structs.
|
||||
|
||||
uint8_t mSavedNumOpenStructs; // Number of open structs when read position was saved.
|
||||
uint16_t mSavedIndex; // Read index when position was saved.
|
||||
uint16_t mSavedEnd; // End index when position was saved.
|
||||
uint8_t mSavedNumOpenStructs; // Number of open structs when read position was saved.
|
||||
uint16_t mSavedIndex; // Read index when position was saved.
|
||||
uint16_t mSavedEnd; // End index when position was saved.
|
||||
|
||||
uint16_t mPrevEnd[kMaxNestedStructs];
|
||||
};
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
#endif // SPINEL_DECODER_HPP_
|
||||
#endif // SPINEL_DECODER_HPP_
|
||||
|
||||
+16
-16
@@ -126,8 +126,8 @@ otError SpinelEncoder::WriteUint32(uint32_t aUint32)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint32 >> 0) & 0xff));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint32 >> 8) & 0xff));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint32 >> 0) & 0xff));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint32 >> 8) & 0xff));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint32 >> 16) & 0xff));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint32 >> 24) & 0xff));
|
||||
|
||||
@@ -139,8 +139,8 @@ otError SpinelEncoder::WriteUint64(uint64_t aUint64)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint64 >> 0) & 0xff));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint64 >> 8) & 0xff));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint64 >> 0) & 0xff));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint64 >> 8) & 0xff));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint64 >> 16) & 0xff));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint64 >> 24) & 0xff));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameFeedByte((aUint64 >> 32) & 0xff));
|
||||
@@ -154,7 +154,7 @@ exit:
|
||||
|
||||
otError SpinelEncoder::WriteUintPacked(unsigned int aUint)
|
||||
{
|
||||
uint8_t buffer[6];
|
||||
uint8_t buffer[6];
|
||||
spinel_ssize_t len;
|
||||
|
||||
len = spinel_packed_uint_encode(buffer, sizeof(buffer), aUint);
|
||||
@@ -176,7 +176,7 @@ exit:
|
||||
otError SpinelEncoder::WriteUtf8(const char *aUtf8)
|
||||
{
|
||||
otError error;
|
||||
size_t len = strlen(aUtf8);
|
||||
size_t len = strlen(aUtf8);
|
||||
|
||||
if (len >= 0xffff)
|
||||
{
|
||||
@@ -209,9 +209,9 @@ exit:
|
||||
|
||||
otError SpinelEncoder::CloseStruct(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t len;
|
||||
uint8_t buffer[sizeof(uint16_t)];
|
||||
uint8_t buffer[sizeof(uint16_t)];
|
||||
|
||||
VerifyOrExit(mNumOpenStructs > 0, error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
@@ -246,7 +246,7 @@ otError SpinelEncoder::ResetToSaved(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameReset(mSavedPosition));
|
||||
SuccessOrExit(error = mNcpBuffer.InFrameReset(mSavedPosition));
|
||||
mNumOpenStructs = mSavedNumOpenStructs;
|
||||
|
||||
exit:
|
||||
@@ -255,10 +255,10 @@ exit:
|
||||
|
||||
otError SpinelEncoder::WritePacked(const char *aPackFormat, ...)
|
||||
{
|
||||
uint8_t buf[kPackFormatBufferSize];
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t buf[kPackFormatBufferSize];
|
||||
otError error = OT_ERROR_NONE;
|
||||
spinel_ssize_t packedLen;
|
||||
va_list args;
|
||||
va_list args;
|
||||
|
||||
va_start(args, aPackFormat);
|
||||
|
||||
@@ -275,8 +275,8 @@ exit:
|
||||
|
||||
otError SpinelEncoder::WriteVPacked(const char *aPackFormat, va_list aArgs)
|
||||
{
|
||||
uint8_t buf[kPackFormatBufferSize];
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t buf[kPackFormatBufferSize];
|
||||
otError error = OT_ERROR_NONE;
|
||||
spinel_ssize_t packedLen;
|
||||
|
||||
packedLen = spinel_datatype_vpack(buf, sizeof(buf), aPackFormat, aArgs);
|
||||
@@ -288,5 +288,5 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
+21
-16
@@ -40,8 +40,8 @@
|
||||
#include <openthread/types.h>
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
#include "ncp/spinel.h"
|
||||
#include "ncp/ncp_buffer.hpp"
|
||||
#include "ncp/spinel.h"
|
||||
|
||||
namespace ot {
|
||||
namespace Ncp {
|
||||
@@ -59,8 +59,13 @@ public:
|
||||
* @param[in] aNcpBuffer A reference to a `NcpFrameBuffer` where the frames are written.
|
||||
*
|
||||
*/
|
||||
SpinelEncoder(NcpFrameBuffer &aNcpBuffer):
|
||||
mNcpBuffer(aNcpBuffer), mNumOpenStructs(0), mSavedNumOpenStructs(0), mSavedPosition() { }
|
||||
SpinelEncoder(NcpFrameBuffer &aNcpBuffer)
|
||||
: mNcpBuffer(aNcpBuffer)
|
||||
, mNumOpenStructs(0)
|
||||
, mSavedNumOpenStructs(0)
|
||||
, mSavedPosition()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method begins a new frame to be added/written to the frame buffer.
|
||||
@@ -169,7 +174,7 @@ public:
|
||||
* @retval OT_ERROR_INVALID_STATE `BeginFrame()` has not been called earlier to start the frame.
|
||||
*
|
||||
*/
|
||||
otError WriteBool(bool aBool) { return mNcpBuffer.InFrameFeedByte( aBool ? 0x01: 0x00); }
|
||||
otError WriteBool(bool aBool) { return mNcpBuffer.InFrameFeedByte(aBool ? 0x01 : 0x00); }
|
||||
|
||||
/**
|
||||
* This method encodes and writes a `uint8_t` value to current input frame.
|
||||
@@ -546,10 +551,10 @@ public:
|
||||
* `OT_ERROR_NO_BUFS`.
|
||||
*
|
||||
* The ownership of the passed-in message @p aMessage changes to underlying `NcpFrameBuffer` ONLY when the entire
|
||||
* frame is successfully finished (i.e., with a successful call to `EndFrame()` for the current frame being written),
|
||||
* and in this case the `otMessage` instance will be freed once the frame is removed from the `NcpFrameBuffer`.
|
||||
* However, if the frame gets discarded before it is finished (e.g., running out of buffer space), the `otMessage`
|
||||
* instance remains unchanged.
|
||||
* frame is successfully finished (i.e., with a successful call to `EndFrame()` for the current frame being
|
||||
* written), and in this case the `otMessage` instance will be freed once the frame is removed from the
|
||||
* `NcpFrameBuffer`. However, if the frame gets discarded before it is finished (e.g., running out of buffer space),
|
||||
* the `otMessage` instance remains unchanged.
|
||||
*
|
||||
* @param[in] aMessage A message to be added to current frame.
|
||||
*
|
||||
@@ -674,19 +679,19 @@ public:
|
||||
private:
|
||||
enum
|
||||
{
|
||||
kPackFormatBufferSize = 96, ///< Size of buffer used when encoding using `WritePacked()` or `WriteVPacked()`.
|
||||
kMaxNestedStructs = 4, ///< Maximum number of nested structs.
|
||||
kPackFormatBufferSize = 96, ///< Size of buffer used when encoding using `WritePacked()` or `WriteVPacked()`.
|
||||
kMaxNestedStructs = 4, ///< Maximum number of nested structs.
|
||||
};
|
||||
|
||||
NcpFrameBuffer &mNcpBuffer;
|
||||
NcpFrameBuffer & mNcpBuffer;
|
||||
NcpFrameBuffer::WritePosition mStructPosition[kMaxNestedStructs];
|
||||
uint8_t mNumOpenStructs;
|
||||
uint8_t mNumOpenStructs;
|
||||
|
||||
uint8_t mSavedNumOpenStructs;
|
||||
uint8_t mSavedNumOpenStructs;
|
||||
NcpFrameBuffer::WritePosition mSavedPosition;
|
||||
};
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
#endif // SPINEL_ENCODER_HPP_
|
||||
#endif // SPINEL_ENCODER_HPP_
|
||||
|
||||
@@ -52,10 +52,10 @@
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "utils/wrap_stdbool.h"
|
||||
#include "utils/wrap_stdint.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "utils/wrap_stdbool.h"
|
||||
#include "utils/wrap_stdint.h"
|
||||
#include "utils/wrap_string.h"
|
||||
|
||||
#endif // SPINEL_PLATFORM_OPENTHREAD_H_
|
||||
|
||||
Reference in New Issue
Block a user