mirror of
https://github.com/espressif/openthread.git
synced 2026-07-31 16:17:47 +00:00
[ncp] add support for child supervision in spinel/NcpBase (#2939)
This commit is contained in:
committed by
Jonathan Hui
parent
c551e30350
commit
1ca81fbb16
@@ -1606,6 +1606,10 @@ template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CAPS>(void)
|
||||
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_JAM_DETECT));
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_CHILD_SUPERVISION));
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_CHANNEL_MONITOR
|
||||
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_CHANNEL_MONITOR));
|
||||
#endif
|
||||
|
||||
@@ -495,6 +495,11 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey)
|
||||
handler = &NcpBase::HandlePropertyGet<SPINEL_PROP_THREAD_NETWORK_TIME>;
|
||||
break;
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
case SPINEL_PROP_CHILD_SUPERVISION_CHECK_TIMEOUT:
|
||||
handler = &NcpBase::HandlePropertyGet<SPINEL_PROP_CHILD_SUPERVISION_CHECK_TIMEOUT>;
|
||||
break;
|
||||
#endif
|
||||
#endif // OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -556,6 +561,11 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey)
|
||||
handler = &NcpBase::HandlePropertyGet<SPINEL_PROP_THREAD_STEERING_DATA>;
|
||||
break;
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
case SPINEL_PROP_CHILD_SUPERVISION_INTERVAL:
|
||||
handler = &NcpBase::HandlePropertyGet<SPINEL_PROP_CHILD_SUPERVISION_INTERVAL>;
|
||||
break;
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_CHANNEL_MANAGER
|
||||
case SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL:
|
||||
handler = &NcpBase::HandlePropertyGet<SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL>;
|
||||
@@ -771,6 +781,11 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
|
||||
case SPINEL_PROP_CNTR_RESET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_CNTR_RESET>;
|
||||
break;
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
case SPINEL_PROP_CHILD_SUPERVISION_CHECK_TIMEOUT:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_CHILD_SUPERVISION_CHECK_TIMEOUT>;
|
||||
break;
|
||||
#endif
|
||||
#endif // OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -835,6 +850,11 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
|
||||
case SPINEL_PROP_THREAD_MGMT_GET_PENDING_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_GET_PENDING_DATASET>;
|
||||
break;
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
case SPINEL_PROP_CHILD_SUPERVISION_INTERVAL:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_CHILD_SUPERVISION_INTERVAL>;
|
||||
break;
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_CHANNEL_MANAGER
|
||||
case SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL>;
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
#if OPENTHREAD_ENABLE_CHANNEL_MANAGER
|
||||
#include <openthread/channel_manager.h>
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
#include <openthread/child_supervision.h>
|
||||
#endif
|
||||
#include <openthread/dataset_ftd.h>
|
||||
#include <openthread/diag.h>
|
||||
#include <openthread/icmp6.h>
|
||||
@@ -857,6 +860,27 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CHILD_SUPERVISION_INTERVAL>(void)
|
||||
{
|
||||
return mEncoder.WriteUint16(otChildSupervisionGetInterval(mInstance));
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_CHILD_SUPERVISION_INTERVAL>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t interval;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint16(interval));
|
||||
otChildSupervisionSetInterval(mInstance, interval);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
|
||||
#if OPENTHREAD_ENABLE_CHANNEL_MANAGER
|
||||
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL>(void)
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
#if OPENTHREAD_ENABLE_CHANNEL_MONITOR
|
||||
#include <openthread/channel_monitor.h>
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
#include <openthread/child_supervision.h>
|
||||
#endif
|
||||
#include <openthread/diag.h>
|
||||
#include <openthread/icmp6.h>
|
||||
#if OPENTHREAD_ENABLE_JAM_DETECTION
|
||||
@@ -1559,6 +1562,27 @@ void NcpBase::HandleJamStateChange(bool aJamState)
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_JAM_DETECTION
|
||||
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CHILD_SUPERVISION_CHECK_TIMEOUT>(void)
|
||||
{
|
||||
return mEncoder.WriteUint16(otChildSupervisionGetCheckTimeout(mInstance));
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_CHILD_SUPERVISION_CHECK_TIMEOUT>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t timeout;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint16(timeout));
|
||||
otChildSupervisionSetCheckTimeout(mInstance, timeout);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
|
||||
#if OPENTHREAD_ENABLE_CHANNEL_MONITOR
|
||||
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CHANNEL_MONITOR_SAMPLE_INTERVAL>(void)
|
||||
|
||||
@@ -1669,6 +1669,14 @@ const char *spinel_prop_key_to_cstr(spinel_prop_key_t prop_key)
|
||||
ret = "PROP_TIME_SYNC_XTAL_THRESHOLD";
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_CHILD_SUPERVISION_INTERVAL:
|
||||
ret = "PROP_CHILD_SUPERVISION_INTERVAL";
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_CHILD_SUPERVISION_CHECK_TIMEOUT:
|
||||
ret = "PROP_CHILD_SUPERVISION_CHECK_TIMEOUT";
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_UART_BITRATE:
|
||||
ret = "PROP_UART_BITRATE";
|
||||
break;
|
||||
@@ -2258,6 +2266,10 @@ const char *spinel_capability_to_cstr(unsigned int capability)
|
||||
ret = "CAP_TIME_SYNC";
|
||||
break;
|
||||
|
||||
case SPINEL_CAP_CHILD_SUPERVISION:
|
||||
ret = "CAP_CHILD_SUPERVISION";
|
||||
break;
|
||||
|
||||
case SPINEL_CAP_ERROR_RATE_TRACKING:
|
||||
ret = "CAP_ERROR_RATE_TRACKING";
|
||||
break;
|
||||
|
||||
@@ -453,6 +453,7 @@ enum
|
||||
SPINEL_CAP_CHANNEL_MANAGER = (SPINEL_CAP_OPENTHREAD__BEGIN + 5),
|
||||
SPINEL_CAP_OPENTHREAD_LOG_METADATA = (SPINEL_CAP_OPENTHREAD__BEGIN + 6),
|
||||
SPINEL_CAP_TIME_SYNC = (SPINEL_CAP_OPENTHREAD__BEGIN + 7),
|
||||
SPINEL_CAP_CHILD_SUPERVISION = (SPINEL_CAP_OPENTHREAD__BEGIN + 8),
|
||||
SPINEL_CAP_OPENTHREAD__END = 640,
|
||||
|
||||
SPINEL_CAP_THREAD__BEGIN = 1024,
|
||||
@@ -1728,6 +1729,41 @@ typedef enum {
|
||||
*/
|
||||
SPINEL_PROP_TIME_SYNC_XTAL_THRESHOLD = SPINEL_PROP_OPENTHREAD__BEGIN + 9,
|
||||
|
||||
/// Child Supervision Interval
|
||||
/** Format: `S` - Read-Write
|
||||
* Units: Seconds
|
||||
*
|
||||
* Required capability: `SPINEL_CAP_CHILD_SUPERVISION`
|
||||
*
|
||||
* The child supervision interval (in seconds). Zero indicates that child supervision is disabled.
|
||||
*
|
||||
* When enabled, Child supervision feature ensures that at least one message is sent to every sleepy child within
|
||||
* the given supervision interval. If there is no other message, a supervision message (a data message with empty
|
||||
* payload) is enqueued and sent to the child.
|
||||
*
|
||||
* This property is available for FTD build only.
|
||||
*
|
||||
*/
|
||||
SPINEL_PROP_CHILD_SUPERVISION_INTERVAL = SPINEL_PROP_OPENTHREAD__BEGIN + 10,
|
||||
|
||||
/// Child Supervision Check Timeout
|
||||
/** Format: `S` - Read-Write
|
||||
* Units: Seconds
|
||||
*
|
||||
* Required capability: `SPINEL_CAP_CHILD_SUPERVISION`
|
||||
*
|
||||
* The child supervision check timeout interval (in seconds). Zero indicates supervision check on the child is
|
||||
* disabled.
|
||||
*
|
||||
* Supervision check is only applicable on a sleepy child. When enabled, if the child does not hear from its parent
|
||||
* within the specified check timeout, it initiates a re-attach process by starting an MLE Child Update
|
||||
* Request/Response exchange with the parent.
|
||||
*
|
||||
* This property is available for FTD and MTD builds.
|
||||
*
|
||||
*/
|
||||
SPINEL_PROP_CHILD_SUPERVISION_CHECK_TIMEOUT = SPINEL_PROP_OPENTHREAD__BEGIN + 11,
|
||||
|
||||
SPINEL_PROP_OPENTHREAD__END = 0x2000,
|
||||
|
||||
SPINEL_PROP_INTERFACE__BEGIN = 0x100,
|
||||
|
||||
Reference in New Issue
Block a user