From f189cafcc725bec9d807ec11232b03f516719c06 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Fri, 7 Dec 2018 09:02:05 -0800 Subject: [PATCH] [spinel] add capability definitions for FTD, MTD, RADIO configuration (#3357) This commit adds new spinel capability definitions to specify the FTD, MTD or RADIO build configurations. Depending on the OpenThread build configurations the corresponding capability is included in `SPINEL_PROP_CAPS` list. --- src/ncp/ncp_base.cpp | 8 ++++++++ src/ncp/spinel.c | 12 ++++++++++++ src/ncp/spinel.h | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index 987955dfc..532f09359 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -1724,6 +1724,14 @@ template <> otError NcpBase::HandlePropertyGet(void) SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_MCU_POWER_STATE)); #endif +#if OPENTHREAD_FTD + SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_CONFIG_FTD)); +#elif OPENTHREAD_MTD + SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_CONFIG_MTD)); +#elif OPENTHREAD_RADIO + SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_CONFIG_RADIO)); +#endif + #if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_MAC_RAW)); #endif diff --git a/src/ncp/spinel.c b/src/ncp/spinel.c index ef1d51720..33875b1c1 100644 --- a/src/ncp/spinel.c +++ b/src/ncp/spinel.c @@ -2411,6 +2411,18 @@ const char *spinel_capability_to_cstr(unsigned int capability) ret = "802_15_4_868MHZ_ASK"; break; + case SPINEL_CAP_CONFIG_FTD: + ret = "CONFIG_FTD"; + break; + + case SPINEL_CAP_CONFIG_MTD: + ret = "CONFIG_MTD"; + break; + + case SPINEL_CAP_CONFIG_RADIO: + ret = "CONFIG_RADIO"; + break; + case SPINEL_CAP_ROLE_ROUTER: ret = "ROLE_ROUTER"; break; diff --git a/src/ncp/spinel.h b/src/ncp/spinel.h index 80abf99bf..5ea98f904 100644 --- a/src/ncp/spinel.h +++ b/src/ncp/spinel.h @@ -740,6 +740,12 @@ enum SPINEL_CAP_802_15_4_868MHZ_ASK = (SPINEL_CAP_802_15_4__BEGIN + 14), SPINEL_CAP_802_15_4__END = 32, + SPINEL_CAP_CONFIG__BEGIN = 32, + SPINEL_CAP_CONFIG_FTD = (SPINEL_CAP_CONFIG__BEGIN + 0), + SPINEL_CAP_CONFIG_MTD = (SPINEL_CAP_CONFIG__BEGIN + 1), + SPINEL_CAP_CONFIG_RADIO = (SPINEL_CAP_CONFIG__BEGIN + 2), + SPINEL_CAP_CONFIG__END = 40, + SPINEL_CAP_ROLE__BEGIN = 48, SPINEL_CAP_ROLE_ROUTER = (SPINEL_CAP_ROLE__BEGIN + 0), SPINEL_CAP_ROLE_SLEEPY = (SPINEL_CAP_ROLE__BEGIN + 1),