mirror of
https://github.com/espressif/openthread.git
synced 2026-08-09 12:17:47 +00:00
[spinel] add interface identifier of the Thread Domain Unicast Address (#6200)
This commit adds new spinel property to configure Interface Identifier of the Thread Domain Unicast Address.
This commit is contained in:
@@ -1187,6 +1187,7 @@ enum
|
||||
SPINEL_CAP_MAC_RETRY_HISTOGRAM = (SPINEL_CAP_OPENTHREAD__BEGIN + 12),
|
||||
SPINEL_CAP_MULTI_RADIO = (SPINEL_CAP_OPENTHREAD__BEGIN + 13),
|
||||
SPINEL_CAP_SRP_CLIENT = (SPINEL_CAP_OPENTHREAD__BEGIN + 14),
|
||||
SPINEL_CAP_DUA = (SPINEL_CAP_OPENTHREAD__BEGIN + 15),
|
||||
SPINEL_CAP_OPENTHREAD__END = 640,
|
||||
|
||||
SPINEL_CAP_THREAD__BEGIN = 1024,
|
||||
@@ -2944,6 +2945,21 @@ enum
|
||||
*/
|
||||
SPINEL_PROP_THREAD_DOMAIN_NAME = SPINEL_PROP_THREAD_EXT__BEGIN + 44,
|
||||
|
||||
/// Interface Identifier specified for Thread Domain Unicast Address.
|
||||
/** Format: `A(C)` - Read-write
|
||||
*
|
||||
* `A(C)`: Interface Identifier (8 bytes).
|
||||
*
|
||||
* Required capability: SPINEL_CAP_DUA
|
||||
*
|
||||
* If write to this property is performed without specified parameter
|
||||
* the Interface Identifier of the Thread Domain Unicast Address will be cleared.
|
||||
* If the DUA Interface Identifier is cleared on the NCP device,
|
||||
* the get spinel property command will be returned successfully without specified parameter.
|
||||
*
|
||||
*/
|
||||
SPINEL_PROP_THREAD_DUA_ID = SPINEL_PROP_THREAD_EXT__BEGIN + 54,
|
||||
|
||||
SPINEL_PROP_THREAD_EXT__END = 0x1600,
|
||||
|
||||
SPINEL_PROP_IPV6__BEGIN = 0x60,
|
||||
|
||||
@@ -1931,6 +1931,10 @@ template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CAPS>(void)
|
||||
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_SRP_CLIENT));
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_DUA_ENABLE
|
||||
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_DUA));
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
|
||||
exit:
|
||||
|
||||
@@ -310,6 +310,9 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey)
|
||||
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
|
||||
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_THREAD_DOMAIN_NAME),
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_DUA_ENABLE
|
||||
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_THREAD_DUA_ID),
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE
|
||||
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL),
|
||||
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_CHANNEL_MANAGER_DELAY),
|
||||
@@ -541,6 +544,9 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
|
||||
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_THREAD_DOMAIN_NAME),
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_DUA_ENABLE
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_THREAD_DUA_ID),
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_MESHCOP_COMMISSIONER_ANNOUNCE_BEGIN),
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_MESHCOP_COMMISSIONER_ENERGY_SCAN),
|
||||
|
||||
@@ -351,6 +351,53 @@ exit:
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_DUA_ENABLE
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_THREAD_DUA_ID>(void)
|
||||
{
|
||||
const otIp6InterfaceIdentifier *iid = otThreadGetFixedDuaInterfaceIdentifier(mInstance);
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (iid == nullptr)
|
||||
{
|
||||
// send empty response
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(otIp6InterfaceIdentifier); i++)
|
||||
{
|
||||
SuccessOrExit(error = mEncoder.WriteUint8(iid->mFields.m8[i]));
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_DUA_ID>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (mDecoder.GetRemainingLength() == 0)
|
||||
{
|
||||
SuccessOrExit(error = otThreadSetFixedDuaInterfaceIdentifier(mInstance, nullptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
otIp6InterfaceIdentifier iid;
|
||||
|
||||
for (size_t i = 0; i < sizeof(otIp6InterfaceIdentifier); i++)
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(iid.mFields.m8[i]));
|
||||
}
|
||||
|
||||
SuccessOrExit(error = otThreadSetFixedDuaInterfaceIdentifier(mInstance, &iid));
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_DUA_ENABLE
|
||||
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_NET_PSKC>(void)
|
||||
{
|
||||
return mEncoder.WriteData(otThreadGetPskc(mInstance)->m8, sizeof(spinel_net_pskc_t));
|
||||
|
||||
Reference in New Issue
Block a user