New spinel properties to get the "leader" network data (#1191)

- Adding two new spinel properties: `THREAD_LEADER_NETWORK_DATA`
  and `THREAD_STABLE_LEADER_NETWORK_DATA` (read-only)

- Add the corresponding `GetHandler` for the two new properties
  in `NcpBase`.

- When a `OT_THREAD_NETDATA_UPDATED` event is received in `NcpBase`
  in addition  to sending `HREAD_ON_MESH_NETS` we also send the
  full leader network data (this is mainly intended for debugging).
This commit is contained in:
Abtin Keshavarzian
2017-01-23 13:24:46 -08:00
committed by Jonathan Hui
parent 5a6f10d1e7
commit d309a9579d
4 changed files with 74 additions and 0 deletions
+52
View File
@@ -137,6 +137,8 @@ const NcpBase::GetPropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] =
{ SPINEL_PROP_THREAD_NETWORK_DATA_VERSION, &NcpBase::GetPropertyHandler_THREAD_NETWORK_DATA_VERSION },
{ SPINEL_PROP_THREAD_STABLE_NETWORK_DATA, &NcpBase::GetPropertyHandler_THREAD_STABLE_NETWORK_DATA },
{ SPINEL_PROP_THREAD_STABLE_NETWORK_DATA_VERSION, &NcpBase::GetPropertyHandler_THREAD_STABLE_NETWORK_DATA_VERSION },
{ SPINEL_PROP_THREAD_LEADER_NETWORK_DATA, &NcpBase::GetPropertyHandler_THREAD_LEADER_NETWORK_DATA },
{ SPINEL_PROP_THREAD_STABLE_LEADER_NETWORK_DATA, &NcpBase::GetPropertyHandler_THREAD_STABLE_LEADER_NETWORK_DATA },
{ SPINEL_PROP_THREAD_LOCAL_ROUTES, &NcpBase::NcpBase::GetPropertyHandler_THREAD_LOCAL_ROUTES },
{ SPINEL_PROP_THREAD_ASSISTING_PORTS, &NcpBase::NcpBase::GetPropertyHandler_THREAD_ASSISTING_PORTS },
{ SPINEL_PROP_THREAD_ALLOW_LOCAL_NET_DATA_CHANGE, &NcpBase::GetPropertyHandler_THREAD_ALLOW_LOCAL_NET_DATA_CHANGE },
@@ -882,6 +884,11 @@ void NcpBase::UpdateChangedProps(void)
SPINEL_PROP_THREAD_ON_MESH_NETS
));
SuccessOrExit(HandleCommandPropertyGet(
SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0,
SPINEL_PROP_THREAD_LEADER_NETWORK_DATA
));
mChangedFlags &= ~static_cast<uint32_t>(OT_THREAD_NETDATA_UPDATED);
}
else if ((mChangedFlags & (OT_IP6_RLOC_ADDED | OT_IP6_RLOC_REMOVED)) != 0)
@@ -1985,6 +1992,51 @@ exit:
return errorCode;
}
ThreadError NcpBase::GetPropertyHandler_THREAD_LEADER_NETWORK_DATA(uint8_t header, spinel_prop_key_t key)
{
ThreadError errorCode = kThreadError_None;
uint8_t network_data[255];
uint8_t network_data_len = 255;
SuccessOrExit(errorCode = OutboundFrameBegin());
SuccessOrExit(errorCode = OutboundFrameFeedPacked("Cii", header, SPINEL_CMD_PROP_VALUE_IS, key));
otGetNetworkDataLeader(
mInstance,
false, // Stable?
network_data,
&network_data_len
);
SuccessOrExit(errorCode = OutboundFrameFeedData(network_data, network_data_len));
SuccessOrExit(errorCode = OutboundFrameSend());
exit:
return errorCode;
}
ThreadError NcpBase::GetPropertyHandler_THREAD_STABLE_LEADER_NETWORK_DATA(uint8_t header, spinel_prop_key_t key)
{
ThreadError errorCode = kThreadError_None;
uint8_t network_data[255];
uint8_t network_data_len = 255;
SuccessOrExit(errorCode = OutboundFrameBegin());
SuccessOrExit(errorCode = OutboundFrameFeedPacked("Cii", header, SPINEL_CMD_PROP_VALUE_IS, key));
otGetNetworkDataLeader(
mInstance,
true, // Stable?
network_data,
&network_data_len
);
SuccessOrExit(errorCode = OutboundFrameFeedData(network_data, network_data_len));
SuccessOrExit(errorCode = OutboundFrameSend());
exit:
return errorCode;
}
ThreadError NcpBase::GetPropertyHandler_THREAD_LEADER_RID(uint8_t header, spinel_prop_key_t key)
{
return SendPropertyUpdate(
+2
View File
@@ -336,6 +336,8 @@ private:
ThreadError GetPropertyHandler_THREAD_NETWORK_DATA_VERSION(uint8_t header, spinel_prop_key_t key);
ThreadError GetPropertyHandler_THREAD_STABLE_NETWORK_DATA(uint8_t header, spinel_prop_key_t key);
ThreadError GetPropertyHandler_THREAD_STABLE_NETWORK_DATA_VERSION(uint8_t header, spinel_prop_key_t key);
ThreadError GetPropertyHandler_THREAD_LEADER_NETWORK_DATA(uint8_t header, spinel_prop_key_t key);
ThreadError GetPropertyHandler_THREAD_STABLE_LEADER_NETWORK_DATA(uint8_t header, spinel_prop_key_t key);
ThreadError GetPropertyHandler_MAC_PROMISCUOUS_MODE(uint8_t header, spinel_prop_key_t key);
ThreadError GetPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, spinel_prop_key_t key);
ThreadError GetPropertyHandler_THREAD_ALLOW_LOCAL_NET_DATA_CHANGE(uint8_t header, spinel_prop_key_t key);
+8
View File
@@ -1119,6 +1119,14 @@ spinel_prop_key_to_cstr(spinel_prop_key_t prop_key)
ret = "SPINEL_PROP_THREAD_STABLE_NETWORK_DATA";
break;
case SPINEL_PROP_THREAD_LEADER_NETWORK_DATA:
ret = "SPINEL_PROP_THREAD_LEADER_NETWORK_DATA";
break;
case SPINEL_PROP_THREAD_STABLE_LEADER_NETWORK_DATA:
ret = "SPINEL_PROP_THREAD_STABLE_LEADER_NETWORK_DATA";
break;
case SPINEL_PROP_THREAD_ON_MESH_NETS:
ret = "SPINEL_PROP_THREAD_ON_MESH_NETS";
break;
+12
View File
@@ -762,6 +762,18 @@ typedef enum
*/
SPINEL_PROP_THREAD_CHILD_COUNT_MAX = SPINEL_PROP_THREAD_EXT__BEGIN + 12,
/// Leader network data
/** Format: `D` - Read only
*/
SPINEL_PROP_THREAD_LEADER_NETWORK_DATA
= SPINEL_PROP_THREAD_EXT__BEGIN + 13,
/// Stable leader network data
/** Format: `D` - Read only
*/
SPINEL_PROP_THREAD_STABLE_LEADER_NETWORK_DATA
= SPINEL_PROP_THREAD_EXT__BEGIN + 14,
SPINEL_PROP_THREAD_EXT__END = 0x1600,
SPINEL_PROP_IPV6__BEGIN = 0x60,