mirror of
https://github.com/espressif/openthread.git
synced 2026-08-13 06:07:48 +00:00
ncp: Add support for allowing leader to remove an active router id. (#440)
This commit defines a new property, `PROP_THREAD_ACTIVE_ROUTER_IDS`. While this property is theoretically a list of router-ids, `CMD_VALUE_GET` is not currently implemented for this property. `CMD_VALUE_REMOVE`, however, is implemented by this commit and maps directly to `otReleaseRouterId()`.
This commit is contained in:
committed by
Jonathan Hui
parent
ff3aa0c0f7
commit
106fc26834
@@ -1616,6 +1616,14 @@ Used when operating in the Child role.
|
||||
Allows you to get or set the Thread `NETWORK_ID_TIMEOUT` constant, as
|
||||
defined by the Thread specification.
|
||||
|
||||
#### D.4.21. PROP 5381: `PROP_THREAD_ACTIVE_ROUTER_IDS`
|
||||
* Type: Read-Write/Write-Only
|
||||
* Packed-Encoding: `A(C)` (List of active thread router ids)
|
||||
|
||||
Note that some implementations may not support `CMD_GET_VALUE`
|
||||
routerids, but may support `CMD_REMOVE_VALUE` when the node is
|
||||
a leader.
|
||||
|
||||
### D.5. IPv6 Properties
|
||||
|
||||
#### D.5.1. PROP 96: `PROP_IPV6_LL_ADDR`
|
||||
|
||||
@@ -241,6 +241,7 @@ const NcpBase::RemovePropertyHandlerEntry NcpBase::mRemovePropertyHandlerTable[]
|
||||
{ SPINEL_PROP_THREAD_ON_MESH_NETS, &NcpBase::NcpBase::RemovePropertyHandler_THREAD_ON_MESH_NETS },
|
||||
{ SPINEL_PROP_THREAD_ASSISTING_PORTS, &NcpBase::NcpBase::RemovePropertyHandler_THREAD_ASSISTING_PORTS },
|
||||
{ SPINEL_PROP_MAC_WHITELIST, &NcpBase::RemovePropertyHandler_MAC_WHITELIST },
|
||||
{ SPINEL_PROP_THREAD_ACTIVE_ROUTER_IDS, &NcpBase::RemovePropertyHandler_THREAD_ACTIVE_ROUTER_IDS },
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -3925,6 +3926,47 @@ ThreadError NcpBase::RemovePropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
ThreadError NcpBase::RemovePropertyHandler_THREAD_ACTIVE_ROUTER_IDS(uint8_t header, spinel_prop_key_t key,
|
||||
const uint8_t *value_ptr, uint16_t value_len)
|
||||
{
|
||||
spinel_ssize_t parsedLength;
|
||||
ThreadError errorCode = kThreadError_None;
|
||||
uint8_t router_id;
|
||||
|
||||
parsedLength = spinel_datatype_unpack(
|
||||
value_ptr,
|
||||
value_len,
|
||||
"C",
|
||||
&router_id
|
||||
);
|
||||
|
||||
if (parsedLength > 0)
|
||||
{
|
||||
errorCode = otReleaseRouterId(router_id);
|
||||
|
||||
if (errorCode == kThreadError_None)
|
||||
{
|
||||
errorCode = SendPropertyUpdate(
|
||||
header,
|
||||
SPINEL_CMD_PROP_VALUE_REMOVED,
|
||||
key,
|
||||
value_ptr,
|
||||
value_len
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorCode = SendLastStatus(header, ThreadErrorToSpinelStatus(errorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errorCode = SendLastStatus(header, SPINEL_STATUS_PARSE_ERROR);
|
||||
}
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
ThreadError NcpBase::RemovePropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len)
|
||||
{
|
||||
ThreadError errorCode = kThreadError_None;
|
||||
|
||||
@@ -388,6 +388,8 @@ private:
|
||||
const uint8_t *value_ptr,
|
||||
uint16_t value_len);
|
||||
ThreadError RemovePropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len);
|
||||
ThreadError RemovePropertyHandler_THREAD_ACTIVE_ROUTER_IDS(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr,
|
||||
uint16_t value_len);
|
||||
|
||||
private:
|
||||
enum
|
||||
|
||||
@@ -423,6 +423,16 @@ typedef enum
|
||||
SPINEL_PROP_THREAD_NETWORK_ID_TIMEOUT
|
||||
= SPINEL_PROP_THREAD_EXT__BEGIN + 4,
|
||||
|
||||
/// List of active thread router ids
|
||||
/** Format: `A(C)`
|
||||
*
|
||||
* Note that some implementations may not support CMD_GET_VALUE
|
||||
* routerids, but may support CMD_REMOVE_VALUE when the node is
|
||||
* a leader.
|
||||
*/
|
||||
SPINEL_PROP_THREAD_ACTIVE_ROUTER_IDS
|
||||
= SPINEL_PROP_THREAD_EXT__BEGIN + 5,
|
||||
|
||||
SPINEL_PROP_THREAD_EXT__END = 0x1600,
|
||||
|
||||
SPINEL_PROP_IPV6__BEGIN = 0x60,
|
||||
|
||||
Reference in New Issue
Block a user