diff --git a/src/ncp/PROTOCOL.md b/src/ncp/PROTOCOL.md index dcb87f16e..a4130cd9f 100644 --- a/src/ncp/PROTOCOL.md +++ b/src/ncp/PROTOCOL.md @@ -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` diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index 13e96b43f..71587d9dc 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -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; diff --git a/src/ncp/ncp_base.hpp b/src/ncp/ncp_base.hpp index 6cd946dfc..630169ed2 100644 --- a/src/ncp/ncp_base.hpp +++ b/src/ncp/ncp_base.hpp @@ -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 diff --git a/src/ncp/spinel.h b/src/ncp/spinel.h index c1669dd9a..1512be912 100644 --- a/src/ncp/spinel.h +++ b/src/ncp/spinel.h @@ -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,