From 8ccf1386debe1ee0b0d395dca585fe3b50957e2d Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Fri, 29 Jun 2018 00:26:31 +0800 Subject: [PATCH] [ncp] adjust defining NCP handlers (#2829) --- .../libopenthread-ncp-spi.vcxproj | 1 + .../libopenthread-ncp-spi.vcxproj.filters | 3 + .../libopenthread-ncp-uart.vcxproj | 1 + .../libopenthread-ncp-uart.vcxproj.filters | 3 + src/ncp/Makefile.am | 1 + src/ncp/ncp_base.cpp | 521 +-------- src/ncp/ncp_base.hpp | 361 +------ src/ncp/ncp_base_dispatcher.cpp | 992 ++++++++++++++++++ src/ncp/ncp_base_ftd.cpp | 114 +- src/ncp/ncp_base_mtd.cpp | 340 +++--- src/ncp/ncp_base_radio.cpp | 22 +- 11 files changed, 1294 insertions(+), 1065 deletions(-) create mode 100644 src/ncp/ncp_base_dispatcher.cpp diff --git a/etc/visual-studio/libopenthread-ncp-spi.vcxproj b/etc/visual-studio/libopenthread-ncp-spi.vcxproj index 5d1ea4b36..3770cd51a 100644 --- a/etc/visual-studio/libopenthread-ncp-spi.vcxproj +++ b/etc/visual-studio/libopenthread-ncp-spi.vcxproj @@ -63,6 +63,7 @@ + diff --git a/etc/visual-studio/libopenthread-ncp-spi.vcxproj.filters b/etc/visual-studio/libopenthread-ncp-spi.vcxproj.filters index 5b94a7cdb..7082eee17 100644 --- a/etc/visual-studio/libopenthread-ncp-spi.vcxproj.filters +++ b/etc/visual-studio/libopenthread-ncp-spi.vcxproj.filters @@ -30,6 +30,9 @@ Source Files + + Source Files + Source Files diff --git a/etc/visual-studio/libopenthread-ncp-uart.vcxproj b/etc/visual-studio/libopenthread-ncp-uart.vcxproj index aadb336dc..61d63a766 100644 --- a/etc/visual-studio/libopenthread-ncp-uart.vcxproj +++ b/etc/visual-studio/libopenthread-ncp-uart.vcxproj @@ -64,6 +64,7 @@ + diff --git a/etc/visual-studio/libopenthread-ncp-uart.vcxproj.filters b/etc/visual-studio/libopenthread-ncp-uart.vcxproj.filters index 544d4c8ea..ab01236f6 100644 --- a/etc/visual-studio/libopenthread-ncp-uart.vcxproj.filters +++ b/etc/visual-studio/libopenthread-ncp-uart.vcxproj.filters @@ -33,6 +33,9 @@ Source Files + + Source Files + Source Files diff --git a/src/ncp/Makefile.am b/src/ncp/Makefile.am index 0c3bf38da..0519c4141 100644 --- a/src/ncp/Makefile.am +++ b/src/ncp/Makefile.am @@ -76,6 +76,7 @@ COMMON_SOURCES = \ ncp_base_ftd.cpp \ ncp_base_mtd.cpp \ ncp_base_radio.cpp \ + ncp_base_dispatcher.cpp \ ncp_buffer.cpp \ ncp_buffer.hpp \ ncp_spi.cpp \ diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index 4b0ddb4b4..56bd55fad 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -49,395 +49,6 @@ namespace ot { namespace Ncp { -// ---------------------------------------------------------------------------- -// MARK: Property Handler Jump Tables and Methods -// ---------------------------------------------------------------------------- - -#define NCP_GET_PROP_HANDLER_ENTRY(name) \ - { \ - SPINEL_PROP_##name, &NcpBase::GetPropertyHandler_##name \ - } - -const NcpBase::PropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] = { - NCP_GET_PROP_HANDLER_ENTRY(CAPS), - NCP_GET_PROP_HANDLER_ENTRY(DEBUG_TEST_ASSERT), - NCP_GET_PROP_HANDLER_ENTRY(DEBUG_TEST_WATCHDOG), - NCP_GET_PROP_HANDLER_ENTRY(DEBUG_NCP_LOG_LEVEL), - NCP_GET_PROP_HANDLER_ENTRY(HWADDR), - NCP_GET_PROP_HANDLER_ENTRY(HOST_POWER_STATE), - NCP_GET_PROP_HANDLER_ENTRY(INTERFACE_COUNT), - NCP_GET_PROP_HANDLER_ENTRY(INTERFACE_TYPE), - NCP_GET_PROP_HANDLER_ENTRY(LAST_STATUS), - NCP_GET_PROP_HANDLER_ENTRY(LOCK), - NCP_GET_PROP_HANDLER_ENTRY(PHY_ENABLED), - NCP_GET_PROP_HANDLER_ENTRY(PHY_CHAN), - NCP_GET_PROP_HANDLER_ENTRY(PHY_RX_SENSITIVITY), - NCP_GET_PROP_HANDLER_ENTRY(PHY_TX_POWER), - NCP_GET_PROP_HANDLER_ENTRY(POWER_STATE), - NCP_GET_PROP_HANDLER_ENTRY(MCU_POWER_STATE), - NCP_GET_PROP_HANDLER_ENTRY(PROTOCOL_VERSION), - NCP_GET_PROP_HANDLER_ENTRY(MAC_15_4_PANID), - NCP_GET_PROP_HANDLER_ENTRY(MAC_15_4_LADDR), - NCP_GET_PROP_HANDLER_ENTRY(MAC_15_4_SADDR), - NCP_GET_PROP_HANDLER_ENTRY(MAC_RAW_STREAM_ENABLED), - NCP_GET_PROP_HANDLER_ENTRY(MAC_PROMISCUOUS_MODE), - NCP_GET_PROP_HANDLER_ENTRY(NCP_VERSION), - NCP_GET_PROP_HANDLER_ENTRY(UNSOL_UPDATE_FILTER), - NCP_GET_PROP_HANDLER_ENTRY(UNSOL_UPDATE_LIST), - NCP_GET_PROP_HANDLER_ENTRY(VENDOR_ID), -#if OPENTHREAD_MTD || OPENTHREAD_FTD - NCP_GET_PROP_HANDLER_ENTRY(MAC_DATA_POLL_PERIOD), - NCP_GET_PROP_HANDLER_ENTRY(MAC_EXTENDED_ADDR), - NCP_GET_PROP_HANDLER_ENTRY(MAC_SCAN_STATE), - NCP_GET_PROP_HANDLER_ENTRY(MAC_SCAN_MASK), - NCP_GET_PROP_HANDLER_ENTRY(MAC_SCAN_PERIOD), - NCP_GET_PROP_HANDLER_ENTRY(MAC_CCA_FAILURE_RATE), -#if OPENTHREAD_ENABLE_MAC_FILTER - NCP_GET_PROP_HANDLER_ENTRY(MAC_BLACKLIST), - NCP_GET_PROP_HANDLER_ENTRY(MAC_BLACKLIST_ENABLED), - NCP_GET_PROP_HANDLER_ENTRY(MAC_FIXED_RSS), - NCP_GET_PROP_HANDLER_ENTRY(MAC_WHITELIST), - NCP_GET_PROP_HANDLER_ENTRY(MAC_WHITELIST_ENABLED), -#endif - NCP_GET_PROP_HANDLER_ENTRY(MSG_BUFFER_COUNTERS), - NCP_GET_PROP_HANDLER_ENTRY(PHY_CHAN_SUPPORTED), - NCP_GET_PROP_HANDLER_ENTRY(PHY_FREQ), - NCP_GET_PROP_HANDLER_ENTRY(PHY_RSSI), - NCP_GET_PROP_HANDLER_ENTRY(NET_IF_UP), - NCP_GET_PROP_HANDLER_ENTRY(NET_KEY_SEQUENCE_COUNTER), - NCP_GET_PROP_HANDLER_ENTRY(NET_KEY_SWITCH_GUARDTIME), - NCP_GET_PROP_HANDLER_ENTRY(NET_MASTER_KEY), - NCP_GET_PROP_HANDLER_ENTRY(NET_NETWORK_NAME), - NCP_GET_PROP_HANDLER_ENTRY(NET_PARTITION_ID), - NCP_GET_PROP_HANDLER_ENTRY(NET_REQUIRE_JOIN_EXISTING), - NCP_GET_PROP_HANDLER_ENTRY(NET_ROLE), - NCP_GET_PROP_HANDLER_ENTRY(NET_SAVED), - NCP_GET_PROP_HANDLER_ENTRY(NET_STACK_UP), - NCP_GET_PROP_HANDLER_ENTRY(NET_XPANID), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_ALLOW_LOCAL_NET_DATA_CHANGE), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_ASSISTING_PORTS), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_CHILD_TIMEOUT), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_DISCOVERY_SCAN_JOINER_FLAG), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_DISCOVERY_SCAN_ENABLE_FILTERING), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_DISCOVERY_SCAN_PANID), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_LEADER_ADDR), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_LEADER_NETWORK_DATA), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_LEADER_RID), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_MODE), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_NEIGHBOR_TABLE), -#if OPENTHREAD_CONFIG_ENABLE_TX_ERROR_RATE_TRACKING - NCP_GET_PROP_HANDLER_ENTRY(THREAD_NEIGHBOR_TABLE_ERROR_RATES), -#endif - NCP_GET_PROP_HANDLER_ENTRY(THREAD_NETWORK_DATA_VERSION), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_OFF_MESH_ROUTES), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_ON_MESH_NETS), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_PARENT), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_RLOC16), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_RLOC16_DEBUG_PASSTHRU), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_STABLE_LEADER_NETWORK_DATA), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_STABLE_NETWORK_DATA_VERSION), -#if OPENTHREAD_ENABLE_BORDER_ROUTER - NCP_GET_PROP_HANDLER_ENTRY(THREAD_NETWORK_DATA), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_STABLE_NETWORK_DATA), -#endif - NCP_GET_PROP_HANDLER_ENTRY(THREAD_ACTIVE_DATASET), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_PENDING_DATASET), - NCP_GET_PROP_HANDLER_ENTRY(IPV6_ADDRESS_TABLE), - NCP_GET_PROP_HANDLER_ENTRY(IPV6_ICMP_PING_OFFLOAD), - NCP_GET_PROP_HANDLER_ENTRY(IPV6_ICMP_PING_OFFLOAD_MODE), - NCP_GET_PROP_HANDLER_ENTRY(IPV6_LL_ADDR), - NCP_GET_PROP_HANDLER_ENTRY(IPV6_ML_PREFIX), - NCP_GET_PROP_HANDLER_ENTRY(IPV6_ML_ADDR), - NCP_GET_PROP_HANDLER_ENTRY(IPV6_MULTICAST_ADDRESS_TABLE), - NCP_GET_PROP_HANDLER_ENTRY(IPV6_ROUTE_TABLE), -#if OPENTHREAD_ENABLE_JAM_DETECTION - NCP_GET_PROP_HANDLER_ENTRY(JAM_DETECT_ENABLE), - NCP_GET_PROP_HANDLER_ENTRY(JAM_DETECTED), - NCP_GET_PROP_HANDLER_ENTRY(JAM_DETECT_RSSI_THRESHOLD), - NCP_GET_PROP_HANDLER_ENTRY(JAM_DETECT_WINDOW), - NCP_GET_PROP_HANDLER_ENTRY(JAM_DETECT_BUSY), - NCP_GET_PROP_HANDLER_ENTRY(JAM_DETECT_HISTORY_BITMAP), -#endif -#if OPENTHREAD_ENABLE_CHANNEL_MONITOR - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MONITOR_SAMPLE_INTERVAL), - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MONITOR_RSSI_THRESHOLD), - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MONITOR_SAMPLE_WINDOW), - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MONITOR_SAMPLE_COUNT), - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MONITOR_CHANNEL_OCCUPANCY), -#endif -#if OPENTHREAD_ENABLE_LEGACY - NCP_GET_PROP_HANDLER_ENTRY(NEST_LEGACY_ULA_PREFIX), - NCP_GET_PROP_HANDLER_ENTRY(NEST_LEGACY_LAST_NODE_JOINED), -#endif - // MAC counters - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_TOTAL), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_ACK_REQ), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_ACKED), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_NO_ACK_REQ), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_DATA), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_DATA_POLL), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_BEACON), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_BEACON_REQ), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_OTHER), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_RETRY), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_UNICAST), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_PKT_BROADCAST), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_ERR_CCA), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_ERR_ABORT), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_TOTAL), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_DATA), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_DATA_POLL), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_BEACON), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_BEACON_REQ), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_OTHER), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_FILT_WL), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_FILT_DA), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_UNICAST), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_BROADCAST), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_ERR_EMPTY), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_ERR_UKWN_NBR), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_ERR_NVLD_SADDR), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_ERR_SECURITY), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_ERR_BAD_FCS), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_ERR_OTHER), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_DUP), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_ALL_MAC_COUNTERS), - // NCP counters - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_IP_SEC_TOTAL), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_IP_INSEC_TOTAL), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_IP_DROPPED), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_IP_SEC_TOTAL), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_IP_INSEC_TOTAL), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_IP_DROPPED), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_SPINEL_TOTAL), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_SPINEL_TOTAL), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_SPINEL_ERR), - // IP counters - NCP_GET_PROP_HANDLER_ENTRY(CNTR_IP_TX_SUCCESS), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_IP_RX_SUCCESS), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_IP_TX_FAILURE), - NCP_GET_PROP_HANDLER_ENTRY(CNTR_IP_RX_FAILURE), -#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC - NCP_GET_PROP_HANDLER_ENTRY(THREAD_NETWORK_TIME), -#endif -#endif // OPENTHREAD_MTD || OPENTHREAD_FTD - -#if OPENTHREAD_FTD - NCP_GET_PROP_HANDLER_ENTRY(NET_PSKC), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_LEADER_WEIGHT), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_CHILD_TABLE), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_CHILD_TABLE_ADDRESSES), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_ROUTER_TABLE), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_LOCAL_LEADER_WEIGHT), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_ROUTER_ROLE_ENABLED), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_CHILD_COUNT_MAX), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_ROUTER_UPGRADE_THRESHOLD), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_ROUTER_DOWNGRADE_THRESHOLD), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_CONTEXT_REUSE_DELAY), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_NETWORK_ID_TIMEOUT), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_ROUTER_SELECTION_JITTER), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_PREFERRED_ROUTER_ID), - NCP_GET_PROP_HANDLER_ENTRY(THREAD_ADDRESS_CACHE_TABLE), -#if OPENTHREAD_ENABLE_COMMISSIONER - NCP_GET_PROP_HANDLER_ENTRY(THREAD_COMMISSIONER_ENABLED), -#endif -#if OPENTHREAD_ENABLE_TMF_PROXY - NCP_GET_PROP_HANDLER_ENTRY(THREAD_TMF_PROXY_ENABLED), -#endif -#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB - NCP_GET_PROP_HANDLER_ENTRY(THREAD_STEERING_DATA), -#endif -#if OPENTHREAD_ENABLE_CHANNEL_MANAGER - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_NEW_CHANNEL), - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_DELAY), - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_SUPPORTED_CHANNELS), - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_FAVORED_CHANNELS), - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_CHANNEL_SELECT), - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_AUTO_SELECT_ENABLED), - NCP_GET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_AUTO_SELECT_INTERVAL), -#endif -#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC - NCP_GET_PROP_HANDLER_ENTRY(TIME_SYNC_PERIOD), - NCP_GET_PROP_HANDLER_ENTRY(TIME_SYNC_XTAL_THRESHOLD), -#endif - -#endif // OPENTHREAD_FTD - -#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API - NCP_GET_PROP_HANDLER_ENTRY(MAC_SRC_MATCH_ENABLED), -#endif -}; - -#define NCP_SET_PROP_HANDLER_ENTRY(name) \ - { \ - SPINEL_PROP_##name, &NcpBase::SetPropertyHandler_##name \ - } - -const NcpBase::PropertyHandlerEntry NcpBase::mSetPropertyHandlerTable[] = { -#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API - NCP_SET_PROP_HANDLER_ENTRY(MAC_15_4_SADDR), - NCP_SET_PROP_HANDLER_ENTRY(MAC_SRC_MATCH_ENABLED), - NCP_SET_PROP_HANDLER_ENTRY(MAC_SRC_MATCH_SHORT_ADDRESSES), - NCP_SET_PROP_HANDLER_ENTRY(MAC_SRC_MATCH_EXTENDED_ADDRESSES), - NCP_SET_PROP_HANDLER_ENTRY(PHY_ENABLED), -#endif // OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API - NCP_SET_PROP_HANDLER_ENTRY(POWER_STATE), - NCP_SET_PROP_HANDLER_ENTRY(MCU_POWER_STATE), - NCP_SET_PROP_HANDLER_ENTRY(UNSOL_UPDATE_FILTER), - NCP_SET_PROP_HANDLER_ENTRY(PHY_TX_POWER), - NCP_SET_PROP_HANDLER_ENTRY(PHY_CHAN), - NCP_SET_PROP_HANDLER_ENTRY(MAC_PROMISCUOUS_MODE), - NCP_SET_PROP_HANDLER_ENTRY(MAC_15_4_PANID), - NCP_SET_PROP_HANDLER_ENTRY(MAC_15_4_LADDR), - NCP_SET_PROP_HANDLER_ENTRY(MAC_RAW_STREAM_ENABLED), -#if OPENTHREAD_MTD || OPENTHREAD_FTD - NCP_SET_PROP_HANDLER_ENTRY(MAC_DATA_POLL_PERIOD), - NCP_SET_PROP_HANDLER_ENTRY(MAC_SCAN_MASK), - NCP_SET_PROP_HANDLER_ENTRY(MAC_SCAN_STATE), - NCP_SET_PROP_HANDLER_ENTRY(MAC_SCAN_PERIOD), - NCP_SET_PROP_HANDLER_ENTRY(NET_IF_UP), - NCP_SET_PROP_HANDLER_ENTRY(NET_STACK_UP), - NCP_SET_PROP_HANDLER_ENTRY(NET_ROLE), - NCP_SET_PROP_HANDLER_ENTRY(NET_NETWORK_NAME), - NCP_SET_PROP_HANDLER_ENTRY(NET_XPANID), - NCP_SET_PROP_HANDLER_ENTRY(NET_MASTER_KEY), - NCP_SET_PROP_HANDLER_ENTRY(NET_KEY_SEQUENCE_COUNTER), - NCP_SET_PROP_HANDLER_ENTRY(NET_KEY_SWITCH_GUARDTIME), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_ASSISTING_PORTS), - NCP_SET_PROP_HANDLER_ENTRY(STREAM_NET_INSECURE), - NCP_SET_PROP_HANDLER_ENTRY(STREAM_NET), - NCP_SET_PROP_HANDLER_ENTRY(IPV6_ML_PREFIX), - NCP_SET_PROP_HANDLER_ENTRY(IPV6_ICMP_PING_OFFLOAD), - NCP_SET_PROP_HANDLER_ENTRY(IPV6_ICMP_PING_OFFLOAD_MODE), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_RLOC16_DEBUG_PASSTHRU), -#if OPENTHREAD_ENABLE_MAC_FILTER - NCP_SET_PROP_HANDLER_ENTRY(MAC_WHITELIST), - NCP_SET_PROP_HANDLER_ENTRY(MAC_WHITELIST_ENABLED), - NCP_SET_PROP_HANDLER_ENTRY(MAC_BLACKLIST), - NCP_SET_PROP_HANDLER_ENTRY(MAC_BLACKLIST_ENABLED), - NCP_SET_PROP_HANDLER_ENTRY(MAC_FIXED_RSS), -#endif - NCP_SET_PROP_HANDLER_ENTRY(THREAD_MODE), - NCP_SET_PROP_HANDLER_ENTRY(NET_REQUIRE_JOIN_EXISTING), - NCP_SET_PROP_HANDLER_ENTRY(DEBUG_NCP_LOG_LEVEL), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_DISCOVERY_SCAN_JOINER_FLAG), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_DISCOVERY_SCAN_ENABLE_FILTERING), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_DISCOVERY_SCAN_PANID), -#if OPENTHREAD_ENABLE_BORDER_ROUTER - NCP_SET_PROP_HANDLER_ENTRY(THREAD_ALLOW_LOCAL_NET_DATA_CHANGE), -#endif -#if OPENTHREAD_ENABLE_JAM_DETECTION - NCP_SET_PROP_HANDLER_ENTRY(JAM_DETECT_ENABLE), - NCP_SET_PROP_HANDLER_ENTRY(JAM_DETECT_RSSI_THRESHOLD), - NCP_SET_PROP_HANDLER_ENTRY(JAM_DETECT_WINDOW), - NCP_SET_PROP_HANDLER_ENTRY(JAM_DETECT_BUSY), -#endif -#if OPENTHREAD_ENABLE_LEGACY - NCP_SET_PROP_HANDLER_ENTRY(NEST_LEGACY_ULA_PREFIX), -#endif - NCP_SET_PROP_HANDLER_ENTRY(CNTR_RESET), -#endif // OPENTHREAD_MTD || OPENTHREAD_FTD -#if OPENTHREAD_FTD - NCP_SET_PROP_HANDLER_ENTRY(NET_PSKC), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_CHILD_TIMEOUT), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_NETWORK_ID_TIMEOUT), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_LOCAL_LEADER_WEIGHT), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_ROUTER_ROLE_ENABLED), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_CHILD_COUNT_MAX), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_ROUTER_UPGRADE_THRESHOLD), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_ROUTER_DOWNGRADE_THRESHOLD), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_CONTEXT_REUSE_DELAY), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_ROUTER_SELECTION_JITTER), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_PREFERRED_ROUTER_ID), -#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB - NCP_SET_PROP_HANDLER_ENTRY(THREAD_STEERING_DATA), -#endif -#if OPENTHREAD_ENABLE_TMF_PROXY - NCP_SET_PROP_HANDLER_ENTRY(THREAD_TMF_PROXY_ENABLED), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_TMF_PROXY_STREAM), -#endif - NCP_SET_PROP_HANDLER_ENTRY(THREAD_ACTIVE_DATASET), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_PENDING_DATASET), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_MGMT_ACTIVE_DATASET), - NCP_SET_PROP_HANDLER_ENTRY(THREAD_MGMT_PENDING_DATASET), -#if OPENTHREAD_ENABLE_CHANNEL_MANAGER - NCP_SET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_NEW_CHANNEL), - NCP_SET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_DELAY), - NCP_SET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_SUPPORTED_CHANNELS), - NCP_SET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_FAVORED_CHANNELS), - NCP_SET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_CHANNEL_SELECT), - NCP_SET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_AUTO_SELECT_ENABLED), - NCP_SET_PROP_HANDLER_ENTRY(CHANNEL_MANAGER_AUTO_SELECT_INTERVAL), -#endif -#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC - NCP_SET_PROP_HANDLER_ENTRY(TIME_SYNC_PERIOD), - NCP_SET_PROP_HANDLER_ENTRY(TIME_SYNC_XTAL_THRESHOLD), -#endif -#endif // #if OPENTHREAD_FTD -}; - -#define NCP_INSERT_PROP_HANDLER_ENTRY(name) \ - { \ - SPINEL_PROP_##name, &NcpBase::InsertPropertyHandler_##name \ - } - -const NcpBase::PropertyHandlerEntry NcpBase::mInsertPropertyHandlerTable[] = { - NCP_INSERT_PROP_HANDLER_ENTRY(UNSOL_UPDATE_FILTER), -#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API - NCP_INSERT_PROP_HANDLER_ENTRY(MAC_SRC_MATCH_SHORT_ADDRESSES), - NCP_INSERT_PROP_HANDLER_ENTRY(MAC_SRC_MATCH_EXTENDED_ADDRESSES), -#endif -#if OPENTHREAD_MTD || OPENTHREAD_FTD - NCP_INSERT_PROP_HANDLER_ENTRY(IPV6_ADDRESS_TABLE), - NCP_INSERT_PROP_HANDLER_ENTRY(IPV6_MULTICAST_ADDRESS_TABLE), - NCP_INSERT_PROP_HANDLER_ENTRY(THREAD_ASSISTING_PORTS), -#if OPENTHREAD_ENABLE_BORDER_ROUTER - NCP_INSERT_PROP_HANDLER_ENTRY(THREAD_OFF_MESH_ROUTES), - NCP_INSERT_PROP_HANDLER_ENTRY(THREAD_ON_MESH_NETS), -#endif -#if OPENTHREAD_ENABLE_MAC_FILTER - NCP_INSERT_PROP_HANDLER_ENTRY(MAC_WHITELIST), - NCP_INSERT_PROP_HANDLER_ENTRY(MAC_BLACKLIST), - NCP_INSERT_PROP_HANDLER_ENTRY(MAC_FIXED_RSS), -#endif -#endif // OPENTHREAD_MTD || OPENTHREAD_FTD -#if OPENTHREAD_FTD -#if OPENTHREAD_ENABLE_COMMISSIONER - NCP_INSERT_PROP_HANDLER_ENTRY(THREAD_JOINERS), -#endif -#endif // OPENTHREAD_FTD -}; - -#define NCP_REMOVE_PROP_HANDLER_ENTRY(name) \ - { \ - SPINEL_PROP_##name, &NcpBase::RemovePropertyHandler_##name \ - } - -const NcpBase::PropertyHandlerEntry NcpBase::mRemovePropertyHandlerTable[] = { - NCP_REMOVE_PROP_HANDLER_ENTRY(UNSOL_UPDATE_FILTER), -#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API - NCP_REMOVE_PROP_HANDLER_ENTRY(MAC_SRC_MATCH_SHORT_ADDRESSES), - NCP_REMOVE_PROP_HANDLER_ENTRY(MAC_SRC_MATCH_EXTENDED_ADDRESSES), -#endif -#if OPENTHREAD_MTD || OPENTHREAD_FTD - NCP_REMOVE_PROP_HANDLER_ENTRY(IPV6_ADDRESS_TABLE), - NCP_REMOVE_PROP_HANDLER_ENTRY(IPV6_MULTICAST_ADDRESS_TABLE), -#if OPENTHREAD_ENABLE_BORDER_ROUTER - NCP_REMOVE_PROP_HANDLER_ENTRY(THREAD_OFF_MESH_ROUTES), - NCP_REMOVE_PROP_HANDLER_ENTRY(THREAD_ON_MESH_NETS), -#endif - NCP_REMOVE_PROP_HANDLER_ENTRY(THREAD_ASSISTING_PORTS), -#if OPENTHREAD_ENABLE_MAC_FILTER - NCP_REMOVE_PROP_HANDLER_ENTRY(MAC_WHITELIST), - NCP_REMOVE_PROP_HANDLER_ENTRY(MAC_BLACKLIST), - NCP_REMOVE_PROP_HANDLER_ENTRY(MAC_FIXED_RSS), -#endif -#endif // OPENTHREAD_MTD || OPENTHREAD_FTD -#if OPENTHREAD_FTD - NCP_REMOVE_PROP_HANDLER_ENTRY(THREAD_ACTIVE_ROUTER_IDS), -#endif -}; - // ---------------------------------------------------------------------------- // MARK: Utility Functions // ---------------------------------------------------------------------------- @@ -1320,46 +931,6 @@ exit: // MARK: Property Get/Set/Insert/Remove Commands // ---------------------------------------------------------------------------- -NcpBase::PropertyHandler NcpBase::FindPropertyHandler(spinel_prop_key_t aKey, - const PropertyHandlerEntry *aTableEntry, - size_t aTableLen) -{ - PropertyHandler handler = NULL; - - while (aTableLen--) - { - if (aTableEntry->mPropKey == aKey) - { - handler = aTableEntry->mHandler; - break; - } - - aTableEntry++; - } - - return handler; -} - -NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey) -{ - return FindPropertyHandler(aKey, mGetPropertyHandlerTable, OT_ARRAY_LENGTH(mGetPropertyHandlerTable)); -} - -NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey) -{ - return FindPropertyHandler(aKey, mSetPropertyHandlerTable, OT_ARRAY_LENGTH(mSetPropertyHandlerTable)); -} - -NcpBase::PropertyHandler NcpBase::FindInsertPropertyHandler(spinel_prop_key_t aKey) -{ - return FindPropertyHandler(aKey, mInsertPropertyHandlerTable, OT_ARRAY_LENGTH(mInsertPropertyHandlerTable)); -} - -NcpBase::PropertyHandler NcpBase::FindRemovePropertyHandler(spinel_prop_key_t aKey) -{ - return FindPropertyHandler(aKey, mRemovePropertyHandlerTable, OT_ARRAY_LENGTH(mRemovePropertyHandlerTable)); -} - // Returns `true` and updates the `aError` on success. bool NcpBase::HandlePropertySetForSpecialProperties(uint8_t aHeader, spinel_prop_key_t aKey, otError &aError) { @@ -1372,21 +943,21 @@ bool NcpBase::HandlePropertySetForSpecialProperties(uint8_t aHeader, spinel_prop switch (aKey) { case SPINEL_PROP_HOST_POWER_STATE: - ExitNow(aError = SetPropertyHandler_HOST_POWER_STATE(aHeader)); + ExitNow(aError = HandlePropertySet_SPINEL_PROP_HOST_POWER_STATE(aHeader)); #if OPENTHREAD_ENABLE_DIAG case SPINEL_PROP_NEST_STREAM_MFG: - ExitNow(aError = SetPropertyHandler_NEST_STREAM_MFG(aHeader)); + ExitNow(aError = HandlePropertySet_SPINEL_PROP_NEST_STREAM_MFG(aHeader)); #endif #if OPENTHREAD_FTD && OPENTHREAD_ENABLE_COMMISSIONER case SPINEL_PROP_THREAD_COMMISSIONER_ENABLED: - ExitNow(aError = SetPropertyHandler_THREAD_COMMISSIONER_ENABLED(aHeader)); + ExitNow(aError = HandlePropertySet_SPINEL_PROP_THREAD_COMMISSIONER_ENABLED(aHeader)); #endif #if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API case SPINEL_PROP_STREAM_RAW: - ExitNow(aError = SetPropertyHandler_STREAM_RAW(aHeader)); + ExitNow(aError = HandlePropertySet_SPINEL_PROP_STREAM_RAW(aHeader)); #endif default: @@ -1732,7 +1303,7 @@ exit: #if OPENTHREAD_ENABLE_DIAG -otError NcpBase::SetPropertyHandler_NEST_STREAM_MFG(uint8_t aHeader) +otError NcpBase::HandlePropertySet_SPINEL_PROP_NEST_STREAM_MFG(uint8_t aHeader) { const char *string = NULL; const char *output = NULL; @@ -1755,7 +1326,7 @@ exit: #endif // OPENTHREAD_ENABLE_DIAG -otError NcpBase::GetPropertyHandler_PHY_ENABLED(void) +template <> otError NcpBase::HandlePropertyGet(void) { #if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API return mEncoder.WriteBool(otLinkRawIsEnabled(mInstance)); @@ -1764,12 +1335,12 @@ otError NcpBase::GetPropertyHandler_PHY_ENABLED(void) #endif } -otError NcpBase::GetPropertyHandler_PHY_CHAN(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otLinkGetChannel(mInstance)); } -otError NcpBase::SetPropertyHandler_PHY_CHAN(void) +template <> otError NcpBase::HandlePropertySet(void) { unsigned int channel = 0; otError error = OT_ERROR_NONE; @@ -1795,13 +1366,13 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_MAC_PROMISCUOUS_MODE(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otPlatRadioGetPromiscuous(mInstance) ? SPINEL_MAC_PROMISCUOUS_MODE_FULL : SPINEL_MAC_PROMISCUOUS_MODE_OFF); } -otError NcpBase::SetPropertyHandler_MAC_PROMISCUOUS_MODE(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t mode = 0; otError error = OT_ERROR_NONE; @@ -1828,12 +1399,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_MAC_15_4_PANID(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint16(otLinkGetPanId(mInstance)); } -otError NcpBase::SetPropertyHandler_MAC_15_4_PANID(void) +template <> otError NcpBase::HandlePropertySet(void) { uint16_t panid; otError error = OT_ERROR_NONE; @@ -1846,12 +1417,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_MAC_15_4_LADDR(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteEui64(*otLinkGetExtendedAddress(mInstance)); } -otError NcpBase::SetPropertyHandler_MAC_15_4_LADDR(void) +template <> otError NcpBase::HandlePropertySet(void) { const otExtAddress *extAddress; otError error = OT_ERROR_NONE; @@ -1864,17 +1435,17 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_MAC_15_4_SADDR(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint16(otLinkGetShortAddress(mInstance)); } -otError NcpBase::GetPropertyHandler_MAC_RAW_STREAM_ENABLED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(mIsRawStreamEnabled); } -otError NcpBase::SetPropertyHandler_MAC_RAW_STREAM_ENABLED(void) +template <> otError NcpBase::HandlePropertySet(void) { bool enabled = false; otError error = OT_ERROR_NONE; @@ -1903,7 +1474,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_UNSOL_UPDATE_FILTER(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; uint8_t numEntries; @@ -1923,7 +1494,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_UNSOL_UPDATE_FILTER(void) +template <> otError NcpBase::HandlePropertySet(void) { unsigned int propKey; otError error = OT_ERROR_NONE; @@ -1952,7 +1523,7 @@ exit: return error; } -otError NcpBase::InsertPropertyHandler_UNSOL_UPDATE_FILTER(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; unsigned int propKey; @@ -1965,7 +1536,7 @@ exit: return error; } -otError NcpBase::RemovePropertyHandler_UNSOL_UPDATE_FILTER(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; unsigned int propKey; @@ -1978,12 +1549,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_LAST_STATUS(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUintPacked(mLastStatus); } -otError NcpBase::GetPropertyHandler_PROTOCOL_VERSION(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; @@ -1994,17 +1565,17 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_INTERFACE_TYPE(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUintPacked(SPINEL_PROTOCOL_TYPE_THREAD); } -otError NcpBase::GetPropertyHandler_VENDOR_ID(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUintPacked(0); // Vendor ID. Zero for unknown. } -otError NcpBase::GetPropertyHandler_CAPS(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; @@ -2081,19 +1652,19 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_NCP_VERSION(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUtf8(otGetVersionString()); } -otError NcpBase::GetPropertyHandler_INTERFACE_COUNT(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(1); // Only one interface for now } #if OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL -otError NcpBase::GetPropertyHandler_MCU_POWER_STATE(void) +template <> otError NcpBase::HandlePropertyGet(void) { spinel_mcu_power_state_t state = SPINEL_MCU_POWER_STATE_ON; @@ -2115,7 +1686,7 @@ otError NcpBase::GetPropertyHandler_MCU_POWER_STATE(void) return mEncoder.WriteUint8(state); } -otError NcpBase::SetPropertyHandler_MCU_POWER_STATE(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; otPlatMcuPowerState powerState; @@ -2170,29 +1741,29 @@ exit: #else // OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL -otError NcpBase::GetPropertyHandler_MCU_POWER_STATE(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(SPINEL_MCU_POWER_STATE_ON); } -otError NcpBase::SetPropertyHandler_MCU_POWER_STATE(void) +template <> otError NcpBase::HandlePropertySet(void) { return OT_ERROR_DISABLED_FEATURE; } #endif // OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL -otError NcpBase::GetPropertyHandler_POWER_STATE(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(SPINEL_POWER_STATE_ONLINE); } -otError NcpBase::SetPropertyHandler_POWER_STATE(void) +template <> otError NcpBase::HandlePropertySet(void) { return OT_ERROR_NOT_IMPLEMENTED; } -otError NcpBase::GetPropertyHandler_HWADDR(void) +template <> otError NcpBase::HandlePropertyGet(void) { otExtAddress hwAddr; otPlatRadioGetIeeeEui64(mInstance, hwAddr.m8); @@ -2200,13 +1771,13 @@ otError NcpBase::GetPropertyHandler_HWADDR(void) return mEncoder.WriteEui64(hwAddr); } -otError NcpBase::GetPropertyHandler_LOCK(void) +template <> otError NcpBase::HandlePropertyGet(void) { // TODO: Implement property lock (Needs API!) return mEncoder.OverwriteWithLastStatusError(SPINEL_STATUS_UNIMPLEMENTED); } -otError NcpBase::GetPropertyHandler_HOST_POWER_STATE(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(mHostPowerState); } @@ -2217,7 +1788,7 @@ otError NcpBase::GetPropertyHandler_HOST_POWER_STATE(void) // that host is sleep (b) the response is critical so if there is no spinel // buffer to prepare the response, the current spinel header is saved to // prepare and send the response as soon as buffer space becomes available. -otError NcpBase::SetPropertyHandler_HOST_POWER_STATE(uint8_t aHeader) +otError NcpBase::HandlePropertySet_SPINEL_PROP_HOST_POWER_STATE(uint8_t aHeader) { uint8_t powerState; otError error = OT_ERROR_NONE; @@ -2284,7 +1855,7 @@ otError NcpBase::SetPropertyHandler_HOST_POWER_STATE(uint8_t aHeader) return error; } -otError NcpBase::GetPropertyHandler_UNSOL_UPDATE_LIST(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; uint8_t numEntries; @@ -2304,12 +1875,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_PHY_RX_SENSITIVITY(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteInt8(otPlatRadioGetReceiveSensitivity(mInstance)); } -otError NcpBase::GetPropertyHandler_PHY_TX_POWER(void) +template <> otError NcpBase::HandlePropertyGet(void) { int8_t power; otError error; @@ -2328,7 +1899,7 @@ otError NcpBase::GetPropertyHandler_PHY_TX_POWER(void) return error; } -otError NcpBase::SetPropertyHandler_PHY_TX_POWER(void) +template <> otError NcpBase::HandlePropertySet(void) { int8_t txPower = 0; otError error = OT_ERROR_NONE; @@ -2340,7 +1911,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_DEBUG_TEST_ASSERT(void) +template <> otError NcpBase::HandlePropertyGet(void) { assert(false); @@ -2352,7 +1923,7 @@ otError NcpBase::GetPropertyHandler_DEBUG_TEST_ASSERT(void) OT_UNREACHABLE_CODE(return mEncoder.WriteBool(false);) } -otError NcpBase::GetPropertyHandler_DEBUG_TEST_WATCHDOG(void) +template <> otError NcpBase::HandlePropertyGet(void) { while (true) ; @@ -2360,12 +1931,12 @@ otError NcpBase::GetPropertyHandler_DEBUG_TEST_WATCHDOG(void) OT_UNREACHABLE_CODE(return OT_ERROR_NONE;) } -otError NcpBase::GetPropertyHandler_DEBUG_NCP_LOG_LEVEL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(ConvertLogLevel(otGetDynamicLogLevel(mInstance))); } -otError NcpBase::SetPropertyHandler_DEBUG_NCP_LOG_LEVEL(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t spinelNcpLogLevel = 0; otLogLevel logLevel; diff --git a/src/ncp/ncp_base.hpp b/src/ncp/ncp_base.hpp index d174ba4b7..73f9a22e8 100644 --- a/src/ncp/ncp_base.hpp +++ b/src/ncp/ncp_base.hpp @@ -60,11 +60,6 @@ namespace ot { namespace Ncp { -#define NCP_GET_PROP_HANDLER(name) otError GetPropertyHandler_##name(void) -#define NCP_SET_PROP_HANDLER(name) otError SetPropertyHandler_##name(void) -#define NCP_INSERT_PROP_HANDLER(name) otError InsertPropertyHandler_##name(void) -#define NCP_REMOVE_PROP_HANDLER(name) otError RemovePropertyHandler_##name(void) - class NcpBase { public: @@ -180,11 +175,15 @@ public: protected: typedef otError (NcpBase::*PropertyHandler)(void); - struct PropertyHandlerEntry - { - spinel_prop_key_t mPropKey; - PropertyHandler mHandler; - }; + template otError HandlePropertyGet(void); + template otError HandlePropertySet(void); + template otError HandlePropertyInsert(void); + template otError HandlePropertyRemove(void); + + otError HandlePropertySet_SPINEL_PROP_NEST_STREAM_MFG(uint8_t aHeader); + otError HandlePropertySet_SPINEL_PROP_HOST_POWER_STATE(uint8_t aHeader); + otError HandlePropertySet_SPINEL_PROP_STREAM_RAW(uint8_t aHeader); + otError HandlePropertySet_SPINEL_PROP_THREAD_COMMISSIONER_ENABLED(uint8_t aHeader); /** * This struct represents a spinel response entry. @@ -206,7 +205,6 @@ protected: otError HandleCommand(uint8_t aHeader); - PropertyHandler FindPropertyHandler(spinel_prop_key_t aKey, const PropertyHandlerEntry *aTable, size_t aTableLen); PropertyHandler FindGetPropertyHandler(spinel_prop_key_t aKey); PropertyHandler FindSetPropertyHandler(spinel_prop_key_t aKey); PropertyHandler FindInsertPropertyHandler(spinel_prop_key_t aKey); @@ -365,350 +363,15 @@ protected: // -------------------------------------------------------------------------- // Common Properties - NCP_GET_PROP_HANDLER(LAST_STATUS); - NCP_GET_PROP_HANDLER(PROTOCOL_VERSION); - NCP_GET_PROP_HANDLER(INTERFACE_TYPE); - NCP_GET_PROP_HANDLER(VENDOR_ID); - NCP_GET_PROP_HANDLER(CAPS); - NCP_GET_PROP_HANDLER(DEBUG_TEST_ASSERT); - NCP_GET_PROP_HANDLER(DEBUG_TEST_WATCHDOG); - NCP_GET_PROP_HANDLER(DEBUG_NCP_LOG_LEVEL); - NCP_SET_PROP_HANDLER(DEBUG_NCP_LOG_LEVEL); - NCP_GET_PROP_HANDLER(NCP_VERSION); - NCP_GET_PROP_HANDLER(INTERFACE_COUNT); - NCP_GET_PROP_HANDLER(POWER_STATE); - NCP_SET_PROP_HANDLER(POWER_STATE); - NCP_GET_PROP_HANDLER(MCU_POWER_STATE); - NCP_SET_PROP_HANDLER(MCU_POWER_STATE); - NCP_GET_PROP_HANDLER(HWADDR); - NCP_GET_PROP_HANDLER(LOCK); - NCP_GET_PROP_HANDLER(HOST_POWER_STATE); - NCP_GET_PROP_HANDLER(UNSOL_UPDATE_FILTER); - NCP_SET_PROP_HANDLER(UNSOL_UPDATE_FILTER); - NCP_INSERT_PROP_HANDLER(UNSOL_UPDATE_FILTER); - NCP_REMOVE_PROP_HANDLER(UNSOL_UPDATE_FILTER); - NCP_GET_PROP_HANDLER(UNSOL_UPDATE_LIST); - - NCP_GET_PROP_HANDLER(PHY_RX_SENSITIVITY); - NCP_GET_PROP_HANDLER(PHY_TX_POWER); - NCP_SET_PROP_HANDLER(PHY_TX_POWER); - NCP_GET_PROP_HANDLER(PHY_ENABLED); - NCP_SET_PROP_HANDLER(PHY_CHAN); - NCP_GET_PROP_HANDLER(PHY_CHAN); - - NCP_GET_PROP_HANDLER(MAC_15_4_PANID); - NCP_SET_PROP_HANDLER(MAC_15_4_PANID); - NCP_GET_PROP_HANDLER(MAC_15_4_LADDR); - NCP_SET_PROP_HANDLER(MAC_15_4_LADDR); - NCP_GET_PROP_HANDLER(MAC_15_4_SADDR); - NCP_GET_PROP_HANDLER(MAC_PROMISCUOUS_MODE); - NCP_SET_PROP_HANDLER(MAC_PROMISCUOUS_MODE); - NCP_GET_PROP_HANDLER(MAC_RAW_STREAM_ENABLED); - NCP_SET_PROP_HANDLER(MAC_RAW_STREAM_ENABLED); - NCP_GET_PROP_HANDLER(MAC_DATA_POLL_PERIOD); - NCP_SET_PROP_HANDLER(MAC_DATA_POLL_PERIOD); - // -------------------------------------------------------------------------- // Raw Link API Properties -#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API - - NCP_SET_PROP_HANDLER(PHY_ENABLED); - - NCP_SET_PROP_HANDLER(MAC_15_4_SADDR); - NCP_GET_PROP_HANDLER(MAC_SRC_MATCH_ENABLED); - NCP_SET_PROP_HANDLER(MAC_SRC_MATCH_ENABLED); - NCP_SET_PROP_HANDLER(MAC_SRC_MATCH_SHORT_ADDRESSES); - NCP_INSERT_PROP_HANDLER(MAC_SRC_MATCH_SHORT_ADDRESSES); - NCP_REMOVE_PROP_HANDLER(MAC_SRC_MATCH_SHORT_ADDRESSES); - NCP_SET_PROP_HANDLER(MAC_SRC_MATCH_EXTENDED_ADDRESSES); - NCP_INSERT_PROP_HANDLER(MAC_SRC_MATCH_EXTENDED_ADDRESSES); - NCP_REMOVE_PROP_HANDLER(MAC_SRC_MATCH_EXTENDED_ADDRESSES); - -#endif // OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API - // -------------------------------------------------------------------------- // MTD (or FTD) Properties -#if OPENTHREAD_MTD || OPENTHREAD_FTD - - NCP_SET_PROP_HANDLER(STREAM_NET); - NCP_SET_PROP_HANDLER(STREAM_NET_INSECURE); - - NCP_GET_PROP_HANDLER(PHY_FREQ); - NCP_GET_PROP_HANDLER(PHY_CHAN_SUPPORTED); - NCP_GET_PROP_HANDLER(PHY_RSSI); - - NCP_GET_PROP_HANDLER(MAC_EXTENDED_ADDR); - NCP_GET_PROP_HANDLER(MAC_SCAN_MASK); - NCP_SET_PROP_HANDLER(MAC_SCAN_MASK); - NCP_GET_PROP_HANDLER(MAC_SCAN_PERIOD); - NCP_SET_PROP_HANDLER(MAC_SCAN_PERIOD); - NCP_GET_PROP_HANDLER(MAC_SCAN_STATE); - NCP_SET_PROP_HANDLER(MAC_SCAN_STATE); - NCP_GET_PROP_HANDLER(MAC_CCA_FAILURE_RATE); -#if OPENTHREAD_ENABLE_MAC_FILTER - NCP_GET_PROP_HANDLER(MAC_WHITELIST_ENABLED); - NCP_SET_PROP_HANDLER(MAC_WHITELIST_ENABLED); - NCP_GET_PROP_HANDLER(MAC_WHITELIST); - NCP_SET_PROP_HANDLER(MAC_WHITELIST); - NCP_INSERT_PROP_HANDLER(MAC_WHITELIST); - NCP_REMOVE_PROP_HANDLER(MAC_WHITELIST); - NCP_GET_PROP_HANDLER(MAC_BLACKLIST_ENABLED); - NCP_SET_PROP_HANDLER(MAC_BLACKLIST_ENABLED); - NCP_GET_PROP_HANDLER(MAC_BLACKLIST); - NCP_SET_PROP_HANDLER(MAC_BLACKLIST); - NCP_INSERT_PROP_HANDLER(MAC_BLACKLIST); - NCP_REMOVE_PROP_HANDLER(MAC_BLACKLIST); - NCP_GET_PROP_HANDLER(MAC_FIXED_RSS); - NCP_SET_PROP_HANDLER(MAC_FIXED_RSS); - NCP_INSERT_PROP_HANDLER(MAC_FIXED_RSS); - NCP_REMOVE_PROP_HANDLER(MAC_FIXED_RSS); -#endif - - NCP_GET_PROP_HANDLER(NET_SAVED); - NCP_GET_PROP_HANDLER(NET_IF_UP); - NCP_SET_PROP_HANDLER(NET_IF_UP); - NCP_GET_PROP_HANDLER(NET_STACK_UP); - NCP_SET_PROP_HANDLER(NET_STACK_UP); - NCP_GET_PROP_HANDLER(NET_ROLE); - NCP_SET_PROP_HANDLER(NET_ROLE); - NCP_GET_PROP_HANDLER(NET_NETWORK_NAME); - NCP_SET_PROP_HANDLER(NET_NETWORK_NAME); - NCP_GET_PROP_HANDLER(NET_XPANID); - NCP_SET_PROP_HANDLER(NET_XPANID); - NCP_GET_PROP_HANDLER(NET_MASTER_KEY); - NCP_SET_PROP_HANDLER(NET_MASTER_KEY); - NCP_GET_PROP_HANDLER(NET_KEY_SEQUENCE_COUNTER); - NCP_SET_PROP_HANDLER(NET_KEY_SEQUENCE_COUNTER); - NCP_GET_PROP_HANDLER(NET_PARTITION_ID); - NCP_GET_PROP_HANDLER(NET_KEY_SWITCH_GUARDTIME); - NCP_SET_PROP_HANDLER(NET_KEY_SWITCH_GUARDTIME); - - NCP_GET_PROP_HANDLER(IPV6_ML_PREFIX); - NCP_SET_PROP_HANDLER(IPV6_ML_PREFIX); - NCP_GET_PROP_HANDLER(IPV6_ML_ADDR); - NCP_GET_PROP_HANDLER(IPV6_LL_ADDR); - NCP_GET_PROP_HANDLER(IPV6_ADDRESS_TABLE); - NCP_INSERT_PROP_HANDLER(IPV6_ADDRESS_TABLE); - NCP_REMOVE_PROP_HANDLER(IPV6_ADDRESS_TABLE); - NCP_GET_PROP_HANDLER(IPV6_ROUTE_TABLE); - NCP_GET_PROP_HANDLER(IPV6_ICMP_PING_OFFLOAD); - NCP_SET_PROP_HANDLER(IPV6_ICMP_PING_OFFLOAD); - NCP_GET_PROP_HANDLER(IPV6_MULTICAST_ADDRESS_TABLE); - NCP_INSERT_PROP_HANDLER(IPV6_MULTICAST_ADDRESS_TABLE); - NCP_REMOVE_PROP_HANDLER(IPV6_MULTICAST_ADDRESS_TABLE); - NCP_GET_PROP_HANDLER(IPV6_ICMP_PING_OFFLOAD_MODE); - NCP_SET_PROP_HANDLER(IPV6_ICMP_PING_OFFLOAD_MODE); - - NCP_GET_PROP_HANDLER(THREAD_LEADER); - NCP_GET_PROP_HANDLER(THREAD_RLOC16_DEBUG_PASSTHRU); - NCP_SET_PROP_HANDLER(THREAD_RLOC16_DEBUG_PASSTHRU); - NCP_GET_PROP_HANDLER(THREAD_OFF_MESH_ROUTES); -#if OPENTHREAD_ENABLE_BORDER_ROUTER - NCP_INSERT_PROP_HANDLER(THREAD_OFF_MESH_ROUTES); - NCP_REMOVE_PROP_HANDLER(THREAD_OFF_MESH_ROUTES); -#endif - NCP_GET_PROP_HANDLER(THREAD_ON_MESH_NETS); -#if OPENTHREAD_ENABLE_BORDER_ROUTER - NCP_INSERT_PROP_HANDLER(THREAD_ON_MESH_NETS); - NCP_REMOVE_PROP_HANDLER(THREAD_ON_MESH_NETS); -#endif - NCP_GET_PROP_HANDLER(THREAD_LEADER_ADDR); - NCP_GET_PROP_HANDLER(THREAD_PARENT); - NCP_GET_PROP_HANDLER(THREAD_NEIGHBOR_TABLE); -#if OPENTHREAD_CONFIG_ENABLE_TX_ERROR_RATE_TRACKING - NCP_GET_PROP_HANDLER(THREAD_NEIGHBOR_TABLE_ERROR_RATES); -#endif - NCP_GET_PROP_HANDLER(THREAD_LEADER_RID); - NCP_GET_PROP_HANDLER(THREAD_LEADER_WEIGHT); -#if OPENTHREAD_ENABLE_BORDER_ROUTER - NCP_GET_PROP_HANDLER(THREAD_NETWORK_DATA); - NCP_GET_PROP_HANDLER(THREAD_STABLE_NETWORK_DATA); -#endif - NCP_GET_PROP_HANDLER(THREAD_NETWORK_DATA_VERSION); - NCP_GET_PROP_HANDLER(THREAD_STABLE_NETWORK_DATA_VERSION); - NCP_GET_PROP_HANDLER(THREAD_LEADER_NETWORK_DATA); - NCP_GET_PROP_HANDLER(THREAD_STABLE_LEADER_NETWORK_DATA); - NCP_GET_PROP_HANDLER(THREAD_ASSISTING_PORTS); - NCP_SET_PROP_HANDLER(THREAD_ASSISTING_PORTS); - NCP_INSERT_PROP_HANDLER(THREAD_ASSISTING_PORTS); - NCP_REMOVE_PROP_HANDLER(THREAD_ASSISTING_PORTS); - NCP_GET_PROP_HANDLER(THREAD_ALLOW_LOCAL_NET_DATA_CHANGE); -#if OPENTHREAD_ENABLE_BORDER_ROUTER - NCP_SET_PROP_HANDLER(THREAD_ALLOW_LOCAL_NET_DATA_CHANGE); -#endif - NCP_GET_PROP_HANDLER(THREAD_MODE); - NCP_SET_PROP_HANDLER(THREAD_MODE); - NCP_GET_PROP_HANDLER(THREAD_CHILD_TIMEOUT); - NCP_GET_PROP_HANDLER(THREAD_RLOC16); - NCP_GET_PROP_HANDLER(NET_REQUIRE_JOIN_EXISTING); - NCP_SET_PROP_HANDLER(NET_REQUIRE_JOIN_EXISTING); - NCP_GET_PROP_HANDLER(THREAD_DISCOVERY_SCAN_JOINER_FLAG); - NCP_SET_PROP_HANDLER(THREAD_DISCOVERY_SCAN_JOINER_FLAG); - NCP_GET_PROP_HANDLER(THREAD_DISCOVERY_SCAN_ENABLE_FILTERING); - NCP_SET_PROP_HANDLER(THREAD_DISCOVERY_SCAN_ENABLE_FILTERING); - NCP_GET_PROP_HANDLER(THREAD_DISCOVERY_SCAN_PANID); - NCP_SET_PROP_HANDLER(THREAD_DISCOVERY_SCAN_PANID); - NCP_GET_PROP_HANDLER(THREAD_ACTIVE_DATASET); - NCP_GET_PROP_HANDLER(THREAD_PENDING_DATASET); - - NCP_GET_PROP_HANDLER(CNTR_ALL_MAC_COUNTERS); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_TOTAL); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_ACK_REQ); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_ACKED); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_NO_ACK_REQ); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_DATA); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_DATA_POLL); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_BEACON); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_BEACON_REQ); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_OTHER); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_RETRY); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_UNICAST); - NCP_GET_PROP_HANDLER(CNTR_TX_PKT_BROADCAST); - NCP_GET_PROP_HANDLER(CNTR_TX_ERR_CCA); - NCP_GET_PROP_HANDLER(CNTR_TX_ERR_ABORT); - NCP_GET_PROP_HANDLER(CNTR_RX_PKT_TOTAL); - NCP_GET_PROP_HANDLER(CNTR_RX_PKT_DATA); - NCP_GET_PROP_HANDLER(CNTR_RX_PKT_DATA_POLL); - NCP_GET_PROP_HANDLER(CNTR_RX_PKT_BEACON); - NCP_GET_PROP_HANDLER(CNTR_RX_PKT_BEACON_REQ); - NCP_GET_PROP_HANDLER(CNTR_RX_PKT_OTHER); - NCP_GET_PROP_HANDLER(CNTR_RX_PKT_FILT_WL); - NCP_GET_PROP_HANDLER(CNTR_RX_PKT_FILT_DA); - NCP_GET_PROP_HANDLER(CNTR_RX_PKT_UNICAST); - NCP_GET_PROP_HANDLER(CNTR_RX_PKT_BROADCAST); - NCP_GET_PROP_HANDLER(CNTR_RX_ERR_EMPTY); - NCP_GET_PROP_HANDLER(CNTR_RX_ERR_UKWN_NBR); - NCP_GET_PROP_HANDLER(CNTR_RX_ERR_NVLD_SADDR); - NCP_GET_PROP_HANDLER(CNTR_RX_ERR_SECURITY); - NCP_GET_PROP_HANDLER(CNTR_RX_ERR_BAD_FCS); - NCP_GET_PROP_HANDLER(CNTR_RX_ERR_OTHER); - NCP_GET_PROP_HANDLER(CNTR_RX_PKT_DUP); - NCP_GET_PROP_HANDLER(CNTR_TX_IP_SEC_TOTAL); - NCP_GET_PROP_HANDLER(CNTR_TX_IP_INSEC_TOTAL); - NCP_GET_PROP_HANDLER(CNTR_TX_IP_DROPPED); - NCP_GET_PROP_HANDLER(CNTR_RX_IP_SEC_TOTAL); - NCP_GET_PROP_HANDLER(CNTR_RX_IP_INSEC_TOTAL); - NCP_GET_PROP_HANDLER(CNTR_RX_IP_DROPPED); - NCP_GET_PROP_HANDLER(CNTR_TX_SPINEL_TOTAL); - NCP_GET_PROP_HANDLER(CNTR_RX_SPINEL_TOTAL); - NCP_GET_PROP_HANDLER(CNTR_RX_SPINEL_OUT_OF_ORDER_TID); - NCP_GET_PROP_HANDLER(CNTR_RX_SPINEL_ERR); - NCP_GET_PROP_HANDLER(CNTR_IP_TX_SUCCESS); - NCP_GET_PROP_HANDLER(CNTR_IP_RX_SUCCESS); - NCP_GET_PROP_HANDLER(CNTR_IP_TX_FAILURE); - NCP_GET_PROP_HANDLER(CNTR_IP_RX_FAILURE); - NCP_SET_PROP_HANDLER(CNTR_RESET); - NCP_GET_PROP_HANDLER(MSG_BUFFER_COUNTERS); - -#if OPENTHREAD_ENABLE_JAM_DETECTION - NCP_GET_PROP_HANDLER(JAM_DETECTED); - NCP_GET_PROP_HANDLER(JAM_DETECT_ENABLE); - NCP_SET_PROP_HANDLER(JAM_DETECT_ENABLE); - NCP_GET_PROP_HANDLER(JAM_DETECT_RSSI_THRESHOLD); - NCP_SET_PROP_HANDLER(JAM_DETECT_RSSI_THRESHOLD); - NCP_GET_PROP_HANDLER(JAM_DETECT_WINDOW); - NCP_SET_PROP_HANDLER(JAM_DETECT_WINDOW); - NCP_GET_PROP_HANDLER(JAM_DETECT_BUSY); - NCP_SET_PROP_HANDLER(JAM_DETECT_BUSY); - NCP_GET_PROP_HANDLER(JAM_DETECT_HISTORY_BITMAP); -#endif - -#if OPENTHREAD_ENABLE_CHANNEL_MONITOR - NCP_GET_PROP_HANDLER(CHANNEL_MONITOR_SAMPLE_INTERVAL); - NCP_GET_PROP_HANDLER(CHANNEL_MONITOR_RSSI_THRESHOLD); - NCP_GET_PROP_HANDLER(CHANNEL_MONITOR_SAMPLE_WINDOW); - NCP_GET_PROP_HANDLER(CHANNEL_MONITOR_SAMPLE_COUNT); - NCP_GET_PROP_HANDLER(CHANNEL_MONITOR_CHANNEL_OCCUPANCY); -#endif - -#if OPENTHREAD_ENABLE_LEGACY - NCP_GET_PROP_HANDLER(NEST_LEGACY_ULA_PREFIX); - NCP_SET_PROP_HANDLER(NEST_LEGACY_ULA_PREFIX); - NCP_GET_PROP_HANDLER(NEST_LEGACY_LAST_NODE_JOINED); -#endif - -#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC - NCP_GET_PROP_HANDLER(THREAD_NETWORK_TIME); -#endif - -#endif // OPENTHREAD_MTD || OPENTHREAD_FTD - // -------------------------------------------------------------------------- // FTD Only Properties -#if OPENTHREAD_FTD - - NCP_GET_PROP_HANDLER(NET_PSKC); - NCP_SET_PROP_HANDLER(NET_PSKC); - - NCP_GET_PROP_HANDLER(THREAD_CHILD_TABLE); - NCP_GET_PROP_HANDLER(THREAD_CHILD_TABLE_ADDRESSES); - NCP_GET_PROP_HANDLER(THREAD_ROUTER_TABLE); - NCP_GET_PROP_HANDLER(THREAD_CHILD_COUNT_MAX); - NCP_SET_PROP_HANDLER(THREAD_CHILD_COUNT_MAX); - NCP_SET_PROP_HANDLER(THREAD_CHILD_TIMEOUT); - NCP_GET_PROP_HANDLER(THREAD_CONTEXT_REUSE_DELAY); - NCP_SET_PROP_HANDLER(THREAD_CONTEXT_REUSE_DELAY); - NCP_GET_PROP_HANDLER(THREAD_LOCAL_LEADER_WEIGHT); - NCP_SET_PROP_HANDLER(THREAD_LOCAL_LEADER_WEIGHT); - NCP_GET_PROP_HANDLER(THREAD_NETWORK_ID_TIMEOUT); - NCP_SET_PROP_HANDLER(THREAD_NETWORK_ID_TIMEOUT); - NCP_GET_PROP_HANDLER(THREAD_ROUTER_ROLE_ENABLED); - NCP_SET_PROP_HANDLER(THREAD_ROUTER_ROLE_ENABLED); - NCP_GET_PROP_HANDLER(THREAD_ROUTER_UPGRADE_THRESHOLD); - NCP_SET_PROP_HANDLER(THREAD_ROUTER_UPGRADE_THRESHOLD); - NCP_GET_PROP_HANDLER(THREAD_ROUTER_DOWNGRADE_THRESHOLD); - NCP_SET_PROP_HANDLER(THREAD_ROUTER_DOWNGRADE_THRESHOLD); - NCP_GET_PROP_HANDLER(THREAD_ROUTER_SELECTION_JITTER); - NCP_SET_PROP_HANDLER(THREAD_ROUTER_SELECTION_JITTER); - NCP_GET_PROP_HANDLER(THREAD_PREFERRED_ROUTER_ID); - NCP_SET_PROP_HANDLER(THREAD_PREFERRED_ROUTER_ID); -#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB - NCP_GET_PROP_HANDLER(THREAD_STEERING_DATA); - NCP_SET_PROP_HANDLER(THREAD_STEERING_DATA); -#endif -#if OPENTHREAD_ENABLE_COMMISSIONER - NCP_GET_PROP_HANDLER(THREAD_COMMISSIONER_ENABLED); - NCP_INSERT_PROP_HANDLER(THREAD_JOINERS); -#endif -#if OPENTHREAD_ENABLE_TMF_PROXY - NCP_GET_PROP_HANDLER(THREAD_TMF_PROXY_ENABLED); - NCP_SET_PROP_HANDLER(THREAD_TMF_PROXY_ENABLED); - NCP_SET_PROP_HANDLER(THREAD_TMF_PROXY_STREAM); -#endif - NCP_REMOVE_PROP_HANDLER(THREAD_ACTIVE_ROUTER_IDS); - NCP_SET_PROP_HANDLER(THREAD_ACTIVE_DATASET); - NCP_SET_PROP_HANDLER(THREAD_PENDING_DATASET); - NCP_SET_PROP_HANDLER(THREAD_MGMT_ACTIVE_DATASET); - NCP_SET_PROP_HANDLER(THREAD_MGMT_PENDING_DATASET); - NCP_GET_PROP_HANDLER(THREAD_ADDRESS_CACHE_TABLE); -#if OPENTHREAD_ENABLE_CHANNEL_MANAGER - NCP_GET_PROP_HANDLER(CHANNEL_MANAGER_NEW_CHANNEL); - NCP_SET_PROP_HANDLER(CHANNEL_MANAGER_NEW_CHANNEL); - NCP_GET_PROP_HANDLER(CHANNEL_MANAGER_DELAY); - NCP_SET_PROP_HANDLER(CHANNEL_MANAGER_DELAY); - NCP_GET_PROP_HANDLER(CHANNEL_MANAGER_SUPPORTED_CHANNELS); - NCP_SET_PROP_HANDLER(CHANNEL_MANAGER_SUPPORTED_CHANNELS); - NCP_GET_PROP_HANDLER(CHANNEL_MANAGER_FAVORED_CHANNELS); - NCP_SET_PROP_HANDLER(CHANNEL_MANAGER_FAVORED_CHANNELS); - NCP_GET_PROP_HANDLER(CHANNEL_MANAGER_CHANNEL_SELECT); - NCP_SET_PROP_HANDLER(CHANNEL_MANAGER_CHANNEL_SELECT); - NCP_GET_PROP_HANDLER(CHANNEL_MANAGER_AUTO_SELECT_ENABLED); - NCP_SET_PROP_HANDLER(CHANNEL_MANAGER_AUTO_SELECT_ENABLED); - NCP_GET_PROP_HANDLER(CHANNEL_MANAGER_AUTO_SELECT_INTERVAL); - NCP_SET_PROP_HANDLER(CHANNEL_MANAGER_AUTO_SELECT_INTERVAL); -#endif -#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC - NCP_GET_PROP_HANDLER(TIME_SYNC_PERIOD); - NCP_SET_PROP_HANDLER(TIME_SYNC_PERIOD); - NCP_GET_PROP_HANDLER(TIME_SYNC_XTAL_THRESHOLD); - NCP_SET_PROP_HANDLER(TIME_SYNC_XTAL_THRESHOLD); -#endif - -#endif // OPENTHREAD_FTD - // -------------------------------------------------------------------------- // Property "set" handlers for special properties for which the spinel // response needs to be created from within the set handler. @@ -824,12 +487,6 @@ protected: kInvalidScanChannel = -1, // Invalid scan channel. }; - // Command Handlers - static const PropertyHandlerEntry mGetPropertyHandlerTable[]; - static const PropertyHandlerEntry mSetPropertyHandlerTable[]; - static const PropertyHandlerEntry mInsertPropertyHandlerTable[]; - static const PropertyHandlerEntry mRemovePropertyHandlerTable[]; - spinel_status_t mLastStatus; uint32_t mSupportedChannelMask; uint32_t mChannelMask; diff --git a/src/ncp/ncp_base_dispatcher.cpp b/src/ncp/ncp_base_dispatcher.cpp new file mode 100644 index 000000000..538946674 --- /dev/null +++ b/src/ncp/ncp_base_dispatcher.cpp @@ -0,0 +1,992 @@ +/* + * Copyright (c) 2018, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * This file implements general thread device required Spinel interface to the OpenThread stack. + */ + +#include "ncp_base.hpp" + +namespace ot { +namespace Ncp { + +// ---------------------------------------------------------------------------- +// MARK: Property Handler Jump Tables and Methods +// ---------------------------------------------------------------------------- +NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey) +{ + NcpBase::PropertyHandler handler; + + switch (aKey) + { + case SPINEL_PROP_CAPS: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_DEBUG_TEST_ASSERT: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_DEBUG_TEST_WATCHDOG: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_DEBUG_NCP_LOG_LEVEL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_HWADDR: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_HOST_POWER_STATE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_INTERFACE_COUNT: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_INTERFACE_TYPE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_LAST_STATUS: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_LOCK: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_PHY_ENABLED: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_PHY_CHAN: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_PHY_RX_SENSITIVITY: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_PHY_TX_POWER: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_POWER_STATE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MCU_POWER_STATE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_PROTOCOL_VERSION: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_15_4_PANID: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_15_4_LADDR: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_15_4_SADDR: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_RAW_STREAM_ENABLED: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_PROMISCUOUS_MODE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NCP_VERSION: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_UNSOL_UPDATE_FILTER: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_UNSOL_UPDATE_LIST: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_VENDOR_ID: + handler = &NcpBase::HandlePropertyGet; + break; +#if OPENTHREAD_MTD || OPENTHREAD_FTD + case SPINEL_PROP_MAC_DATA_POLL_PERIOD: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_EXTENDED_ADDR: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_SCAN_STATE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_SCAN_MASK: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_SCAN_PERIOD: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_CCA_FAILURE_RATE: + handler = &NcpBase::HandlePropertyGet; + break; +#if OPENTHREAD_ENABLE_MAC_FILTER + case SPINEL_PROP_MAC_BLACKLIST: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_BLACKLIST_ENABLED: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_FIXED_RSS: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_WHITELIST: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_MAC_WHITELIST_ENABLED: + handler = &NcpBase::HandlePropertyGet; + break; +#endif + case SPINEL_PROP_MSG_BUFFER_COUNTERS: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_PHY_CHAN_SUPPORTED: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_PHY_FREQ: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_PHY_RSSI: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NET_IF_UP: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NET_KEY_SEQUENCE_COUNTER: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NET_KEY_SWITCH_GUARDTIME: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NET_MASTER_KEY: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NET_NETWORK_NAME: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NET_PARTITION_ID: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NET_REQUIRE_JOIN_EXISTING: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NET_ROLE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NET_SAVED: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NET_STACK_UP: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NET_XPANID: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_ALLOW_LOCAL_NET_DATA_CHANGE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_ASSISTING_PORTS: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_CHILD_TIMEOUT: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_DISCOVERY_SCAN_JOINER_FLAG: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_DISCOVERY_SCAN_ENABLE_FILTERING: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_DISCOVERY_SCAN_PANID: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_LEADER_ADDR: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_LEADER_NETWORK_DATA: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_LEADER_RID: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_MODE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_NEIGHBOR_TABLE: + handler = &NcpBase::HandlePropertyGet; + break; +#if OPENTHREAD_CONFIG_ENABLE_TX_ERROR_RATE_TRACKING + case SPINEL_PROP_THREAD_NEIGHBOR_TABLE_ERROR_RATES: + handler = &NcpBase::HandlePropertyGet; + break; +#endif + case SPINEL_PROP_THREAD_NETWORK_DATA_VERSION: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_OFF_MESH_ROUTES: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_ON_MESH_NETS: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_PARENT: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_RLOC16: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_RLOC16_DEBUG_PASSTHRU: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_STABLE_LEADER_NETWORK_DATA: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_STABLE_NETWORK_DATA_VERSION: + handler = &NcpBase::HandlePropertyGet; + break; +#if OPENTHREAD_ENABLE_BORDER_ROUTER + case SPINEL_PROP_THREAD_NETWORK_DATA: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_STABLE_NETWORK_DATA: + handler = &NcpBase::HandlePropertyGet; + break; +#endif + case SPINEL_PROP_THREAD_ACTIVE_DATASET: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_PENDING_DATASET: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_IPV6_ADDRESS_TABLE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_IPV6_ICMP_PING_OFFLOAD: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_IPV6_ICMP_PING_OFFLOAD_MODE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_IPV6_LL_ADDR: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_IPV6_ML_PREFIX: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_IPV6_ML_ADDR: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_IPV6_MULTICAST_ADDRESS_TABLE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_IPV6_ROUTE_TABLE: + handler = &NcpBase::HandlePropertyGet; + break; +#if OPENTHREAD_ENABLE_JAM_DETECTION + case SPINEL_PROP_JAM_DETECT_ENABLE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_JAM_DETECTED: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_JAM_DETECT_RSSI_THRESHOLD: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_JAM_DETECT_WINDOW: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_JAM_DETECT_BUSY: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_JAM_DETECT_HISTORY_BITMAP: + handler = &NcpBase::HandlePropertyGet; + break; +#endif +#if OPENTHREAD_ENABLE_CHANNEL_MONITOR + case SPINEL_PROP_CHANNEL_MONITOR_SAMPLE_INTERVAL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CHANNEL_MONITOR_RSSI_THRESHOLD: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CHANNEL_MONITOR_SAMPLE_WINDOW: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CHANNEL_MONITOR_SAMPLE_COUNT: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CHANNEL_MONITOR_CHANNEL_OCCUPANCY: + handler = &NcpBase::HandlePropertyGet; + break; +#endif +#if OPENTHREAD_ENABLE_LEGACY + case SPINEL_PROP_NEST_LEGACY_ULA_PREFIX: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_NEST_LEGACY_LAST_NODE_JOINED: + handler = &NcpBase::HandlePropertyGet; + break; +#endif + // MAC counters + case SPINEL_PROP_CNTR_TX_PKT_TOTAL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_PKT_ACK_REQ: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_PKT_ACKED: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_PKT_NO_ACK_REQ: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_PKT_DATA: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_PKT_DATA_POLL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_PKT_BEACON: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_PKT_BEACON_REQ: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_PKT_OTHER: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_PKT_RETRY: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_PKT_UNICAST: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_PKT_BROADCAST: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_ERR_CCA: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_ERR_ABORT: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_PKT_TOTAL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_PKT_DATA: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_PKT_DATA_POLL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_PKT_BEACON: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_PKT_BEACON_REQ: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_PKT_OTHER: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_PKT_FILT_WL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_PKT_FILT_DA: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_PKT_UNICAST: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_PKT_BROADCAST: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_ERR_EMPTY: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_ERR_UKWN_NBR: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_ERR_NVLD_SADDR: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_ERR_SECURITY: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_ERR_BAD_FCS: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_ERR_OTHER: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_PKT_DUP: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_ALL_MAC_COUNTERS: + handler = &NcpBase::HandlePropertyGet; + break; + // NCP counters + case SPINEL_PROP_CNTR_TX_IP_SEC_TOTAL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_IP_INSEC_TOTAL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_IP_DROPPED: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_IP_SEC_TOTAL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_IP_INSEC_TOTAL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_IP_DROPPED: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_TX_SPINEL_TOTAL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_SPINEL_TOTAL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_RX_SPINEL_ERR: + handler = &NcpBase::HandlePropertyGet; + break; + // IP counters + case SPINEL_PROP_CNTR_IP_TX_SUCCESS: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_IP_RX_SUCCESS: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_IP_TX_FAILURE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CNTR_IP_RX_FAILURE: + handler = &NcpBase::HandlePropertyGet; + break; +#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC + case SPINEL_PROP_THREAD_NETWORK_TIME: + handler = &NcpBase::HandlePropertyGet; + break; +#endif +#endif // OPENTHREAD_MTD || OPENTHREAD_FTD + +#if OPENTHREAD_FTD + case SPINEL_PROP_NET_PSKC: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_LEADER_WEIGHT: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_CHILD_TABLE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_CHILD_TABLE_ADDRESSES: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_ROUTER_TABLE: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_LOCAL_LEADER_WEIGHT: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_ROUTER_ROLE_ENABLED: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_CHILD_COUNT_MAX: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_ROUTER_UPGRADE_THRESHOLD: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_ROUTER_DOWNGRADE_THRESHOLD: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_CONTEXT_REUSE_DELAY: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_NETWORK_ID_TIMEOUT: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_ROUTER_SELECTION_JITTER: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_PREFERRED_ROUTER_ID: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_THREAD_ADDRESS_CACHE_TABLE: + handler = &NcpBase::HandlePropertyGet; + break; +#if OPENTHREAD_ENABLE_COMMISSIONER + case SPINEL_PROP_THREAD_COMMISSIONER_ENABLED: + handler = &NcpBase::HandlePropertyGet; + break; +#endif +#if OPENTHREAD_ENABLE_TMF_PROXY + case SPINEL_PROP_THREAD_TMF_PROXY_ENABLED: + handler = &NcpBase::HandlePropertyGet; + break; +#endif +#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB + case SPINEL_PROP_THREAD_STEERING_DATA: + handler = &NcpBase::HandlePropertyGet; + break; +#endif +#if OPENTHREAD_ENABLE_CHANNEL_MANAGER + case SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_DELAY: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_SUPPORTED_CHANNELS: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_FAVORED_CHANNELS: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_CHANNEL_SELECT: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_AUTO_SELECT_ENABLED: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_AUTO_SELECT_INTERVAL: + handler = &NcpBase::HandlePropertyGet; + break; +#endif +#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC + case SPINEL_PROP_TIME_SYNC_PERIOD: + handler = &NcpBase::HandlePropertyGet; + break; + case SPINEL_PROP_TIME_SYNC_XTAL_THRESHOLD: + handler = &NcpBase::HandlePropertyGet; + break; +#endif // OPENTHREAD_CONFIG_ENABLE_TIME_SYNC +#endif // OPENTHREAD_FTD + +#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API + case SPINEL_PROP_MAC_SRC_MATCH_ENABLED: + handler = &NcpBase::HandlePropertyGet; + break; +#endif + default: + handler = NULL; + } + + return handler; +} + +NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey) +{ + NcpBase::PropertyHandler handler; + + switch (aKey) + { +#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API + case SPINEL_PROP_MAC_15_4_SADDR: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_SRC_MATCH_ENABLED: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_PHY_ENABLED: + handler = &NcpBase::HandlePropertySet; + break; +#endif // OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API + case SPINEL_PROP_POWER_STATE: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MCU_POWER_STATE: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_UNSOL_UPDATE_FILTER: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_PHY_TX_POWER: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_PHY_CHAN: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_PROMISCUOUS_MODE: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_15_4_PANID: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_15_4_LADDR: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_RAW_STREAM_ENABLED: + handler = &NcpBase::HandlePropertySet; + break; +#if OPENTHREAD_MTD || OPENTHREAD_FTD + case SPINEL_PROP_MAC_DATA_POLL_PERIOD: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_SCAN_MASK: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_SCAN_STATE: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_SCAN_PERIOD: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_NET_IF_UP: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_NET_STACK_UP: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_NET_ROLE: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_NET_NETWORK_NAME: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_NET_XPANID: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_NET_MASTER_KEY: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_NET_KEY_SEQUENCE_COUNTER: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_NET_KEY_SWITCH_GUARDTIME: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_ASSISTING_PORTS: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_STREAM_NET_INSECURE: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_STREAM_NET: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_IPV6_ML_PREFIX: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_IPV6_ICMP_PING_OFFLOAD: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_IPV6_ICMP_PING_OFFLOAD_MODE: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_RLOC16_DEBUG_PASSTHRU: + handler = &NcpBase::HandlePropertySet; + break; +#if OPENTHREAD_ENABLE_MAC_FILTER + case SPINEL_PROP_MAC_WHITELIST: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_WHITELIST_ENABLED: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_BLACKLIST: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_BLACKLIST_ENABLED: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_MAC_FIXED_RSS: + handler = &NcpBase::HandlePropertySet; + break; +#endif + case SPINEL_PROP_THREAD_MODE: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_NET_REQUIRE_JOIN_EXISTING: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_DEBUG_NCP_LOG_LEVEL: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_DISCOVERY_SCAN_JOINER_FLAG: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_DISCOVERY_SCAN_ENABLE_FILTERING: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_DISCOVERY_SCAN_PANID: + handler = &NcpBase::HandlePropertySet; + break; +#if OPENTHREAD_ENABLE_BORDER_ROUTER + case SPINEL_PROP_THREAD_ALLOW_LOCAL_NET_DATA_CHANGE: + handler = &NcpBase::HandlePropertySet; + break; +#endif +#if OPENTHREAD_ENABLE_JAM_DETECTION + case SPINEL_PROP_JAM_DETECT_ENABLE: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_JAM_DETECT_RSSI_THRESHOLD: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_JAM_DETECT_WINDOW: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_JAM_DETECT_BUSY: + handler = &NcpBase::HandlePropertySet; + break; +#endif +#if OPENTHREAD_ENABLE_LEGACY + case SPINEL_PROP_NEST_LEGACY_ULA_PREFIX: + handler = &NcpBase::HandlePropertySet; + break; +#endif + case SPINEL_PROP_CNTR_RESET: + handler = &NcpBase::HandlePropertySet; + break; +#endif // OPENTHREAD_MTD || OPENTHREAD_FTD +#if OPENTHREAD_FTD + case SPINEL_PROP_NET_PSKC: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_CHILD_TIMEOUT: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_NETWORK_ID_TIMEOUT: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_LOCAL_LEADER_WEIGHT: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_ROUTER_ROLE_ENABLED: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_CHILD_COUNT_MAX: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_ROUTER_UPGRADE_THRESHOLD: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_ROUTER_DOWNGRADE_THRESHOLD: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_CONTEXT_REUSE_DELAY: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_ROUTER_SELECTION_JITTER: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_PREFERRED_ROUTER_ID: + handler = &NcpBase::HandlePropertySet; + break; +#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB + case SPINEL_PROP_THREAD_STEERING_DATA: + handler = &NcpBase::HandlePropertySet; + break; +#endif +#if OPENTHREAD_ENABLE_TMF_PROXY + case SPINEL_PROP_THREAD_TMF_PROXY_ENABLED: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_TMF_PROXY_STREAM: + handler = &NcpBase::HandlePropertySet; + break; +#endif + case SPINEL_PROP_THREAD_ACTIVE_DATASET: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_PENDING_DATASET: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_MGMT_ACTIVE_DATASET: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_THREAD_MGMT_PENDING_DATASET: + handler = &NcpBase::HandlePropertySet; + break; +#if OPENTHREAD_ENABLE_CHANNEL_MANAGER + case SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_DELAY: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_SUPPORTED_CHANNELS: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_FAVORED_CHANNELS: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_CHANNEL_SELECT: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_AUTO_SELECT_ENABLED: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_CHANNEL_MANAGER_AUTO_SELECT_INTERVAL: + handler = &NcpBase::HandlePropertySet; + break; +#endif +#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC + case SPINEL_PROP_TIME_SYNC_PERIOD: + handler = &NcpBase::HandlePropertySet; + break; + case SPINEL_PROP_TIME_SYNC_XTAL_THRESHOLD: + handler = &NcpBase::HandlePropertySet; + break; +#endif +#endif // #if OPENTHREAD_FTD + default: + handler = NULL; + } + + return handler; +} + +NcpBase::PropertyHandler NcpBase::FindInsertPropertyHandler(spinel_prop_key_t aKey) +{ + NcpBase::PropertyHandler handler; + + switch (aKey) + { + case SPINEL_PROP_UNSOL_UPDATE_FILTER: + handler = &NcpBase::HandlePropertyInsert; + break; +#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API + case SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES: + handler = &NcpBase::HandlePropertyInsert; + break; + case SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES: + handler = &NcpBase::HandlePropertyInsert; + break; +#endif +#if OPENTHREAD_MTD || OPENTHREAD_FTD + case SPINEL_PROP_IPV6_ADDRESS_TABLE: + handler = &NcpBase::HandlePropertyInsert; + break; + case SPINEL_PROP_IPV6_MULTICAST_ADDRESS_TABLE: + handler = &NcpBase::HandlePropertyInsert; + break; + case SPINEL_PROP_THREAD_ASSISTING_PORTS: + handler = &NcpBase::HandlePropertyInsert; + break; +#if OPENTHREAD_ENABLE_BORDER_ROUTER + case SPINEL_PROP_THREAD_OFF_MESH_ROUTES: + handler = &NcpBase::HandlePropertyInsert; + break; + case SPINEL_PROP_THREAD_ON_MESH_NETS: + handler = &NcpBase::HandlePropertyInsert; + break; +#endif +#if OPENTHREAD_ENABLE_MAC_FILTER + case SPINEL_PROP_MAC_WHITELIST: + handler = &NcpBase::HandlePropertyInsert; + break; + case SPINEL_PROP_MAC_BLACKLIST: + handler = &NcpBase::HandlePropertyInsert; + break; + case SPINEL_PROP_MAC_FIXED_RSS: + handler = &NcpBase::HandlePropertyInsert; + break; +#endif +#endif // OPENTHREAD_MTD || OPENTHREAD_FTD +#if OPENTHREAD_FTD +#if OPENTHREAD_ENABLE_COMMISSIONER + case SPINEL_PROP_THREAD_JOINERS: + handler = &NcpBase::HandlePropertyInsert; + break; +#endif +#endif // OPENTHREAD_FTD + default: + handler = NULL; + } + + return handler; +} + +NcpBase::PropertyHandler NcpBase::FindRemovePropertyHandler(spinel_prop_key_t aKey) +{ + NcpBase::PropertyHandler handler; + + switch (aKey) + { + case SPINEL_PROP_UNSOL_UPDATE_FILTER: + handler = &NcpBase::HandlePropertyRemove; + break; +#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API + case SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES: + handler = &NcpBase::HandlePropertyRemove; + break; + case SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES: + handler = &NcpBase::HandlePropertyRemove; + break; +#endif +#if OPENTHREAD_MTD || OPENTHREAD_FTD + case SPINEL_PROP_IPV6_ADDRESS_TABLE: + handler = &NcpBase::HandlePropertyRemove; + break; + case SPINEL_PROP_IPV6_MULTICAST_ADDRESS_TABLE: + handler = &NcpBase::HandlePropertyRemove; + break; +#if OPENTHREAD_ENABLE_BORDER_ROUTER + case SPINEL_PROP_THREAD_OFF_MESH_ROUTES: + handler = &NcpBase::HandlePropertyRemove; + break; + case SPINEL_PROP_THREAD_ON_MESH_NETS: + handler = &NcpBase::HandlePropertyRemove; + break; +#endif + case SPINEL_PROP_THREAD_ASSISTING_PORTS: + handler = &NcpBase::HandlePropertyRemove; + break; +#if OPENTHREAD_ENABLE_MAC_FILTER + case SPINEL_PROP_MAC_WHITELIST: + handler = &NcpBase::HandlePropertyRemove; + break; + case SPINEL_PROP_MAC_BLACKLIST: + handler = &NcpBase::HandlePropertyRemove; + break; + case SPINEL_PROP_MAC_FIXED_RSS: + handler = &NcpBase::HandlePropertyRemove; + break; +#endif +#endif // OPENTHREAD_MTD || OPENTHREAD_FTD +#if OPENTHREAD_FTD + case SPINEL_PROP_THREAD_ACTIVE_ROUTER_IDS: + handler = &NcpBase::HandlePropertyRemove; + break; +#endif + default: + handler = NULL; + } + + return handler; +} + +} // namespace Ncp +} // namespace ot diff --git a/src/ncp/ncp_base_ftd.cpp b/src/ncp/ncp_base_ftd.cpp index da6cc727f..03815da92 100644 --- a/src/ncp/ncp_base_ftd.cpp +++ b/src/ncp/ncp_base_ftd.cpp @@ -139,17 +139,17 @@ exit: // MARK: Individual Property Handlers // ---------------------------------------------------------------------------- -otError NcpBase::GetPropertyHandler_THREAD_LOCAL_LEADER_WEIGHT(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otThreadGetLocalLeaderWeight(mInstance)); } -otError NcpBase::GetPropertyHandler_THREAD_LEADER_WEIGHT(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otThreadGetLeaderWeight(mInstance)); } -otError NcpBase::GetPropertyHandler_THREAD_CHILD_TABLE(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; otChildInfo childInfo; @@ -173,7 +173,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_ROUTER_TABLE(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; otRouterInfo routerInfo; @@ -207,7 +207,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_CHILD_TABLE_ADDRESSES(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; otChildInfo childInfo; @@ -244,12 +244,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_ROUTER_ROLE_ENABLED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otThreadIsRouterRoleEnabled(mInstance)); } -otError NcpBase::SetPropertyHandler_THREAD_ROUTER_ROLE_ENABLED(void) +template <> otError NcpBase::HandlePropertySet(void) { bool enabled; otError error = OT_ERROR_NONE; @@ -262,12 +262,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_NET_PSKC(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteData(otThreadGetPSKc(mInstance), sizeof(spinel_net_pskc_t)); } -otError NcpBase::SetPropertyHandler_NET_PSKC(void) +template <> otError NcpBase::HandlePropertySet(void) { const uint8_t *ptr = NULL; uint16_t len; @@ -283,12 +283,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_CHILD_COUNT_MAX(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otThreadGetMaxAllowedChildren(mInstance)); } -otError NcpBase::SetPropertyHandler_THREAD_CHILD_COUNT_MAX(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t maxChildren = 0; otError error = OT_ERROR_NONE; @@ -301,12 +301,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_ROUTER_UPGRADE_THRESHOLD(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otThreadGetRouterUpgradeThreshold(mInstance)); } -otError NcpBase::SetPropertyHandler_THREAD_ROUTER_UPGRADE_THRESHOLD(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t threshold = 0; otError error = OT_ERROR_NONE; @@ -319,12 +319,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_ROUTER_DOWNGRADE_THRESHOLD(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otThreadGetRouterDowngradeThreshold(mInstance)); } -otError NcpBase::SetPropertyHandler_THREAD_ROUTER_DOWNGRADE_THRESHOLD(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t threshold = 0; otError error = OT_ERROR_NONE; @@ -337,12 +337,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_ROUTER_SELECTION_JITTER(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otThreadGetRouterSelectionJitter(mInstance)); } -otError NcpBase::SetPropertyHandler_THREAD_ROUTER_SELECTION_JITTER(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t jitter = 0; otError error = OT_ERROR_NONE; @@ -355,12 +355,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_CONTEXT_REUSE_DELAY(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otThreadGetContextIdReuseDelay(mInstance)); } -otError NcpBase::SetPropertyHandler_THREAD_CONTEXT_REUSE_DELAY(void) +template <> otError NcpBase::HandlePropertySet(void) { uint32_t delay = 0; otError error = OT_ERROR_NONE; @@ -373,12 +373,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_NETWORK_ID_TIMEOUT(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otThreadGetNetworkIdTimeout(mInstance)); } -otError NcpBase::SetPropertyHandler_THREAD_NETWORK_ID_TIMEOUT(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t timeout = 0; otError error = OT_ERROR_NONE; @@ -392,12 +392,12 @@ exit: } #if OPENTHREAD_ENABLE_COMMISSIONER -otError NcpBase::GetPropertyHandler_THREAD_COMMISSIONER_ENABLED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otCommissionerGetState(mInstance) == OT_COMMISSIONER_STATE_ACTIVE); } -otError NcpBase::SetPropertyHandler_THREAD_COMMISSIONER_ENABLED(uint8_t aHeader) +otError NcpBase::HandlePropertySet_SPINEL_PROP_THREAD_COMMISSIONER_ENABLED(uint8_t aHeader) { bool enabled = false; otError error = OT_ERROR_NONE; @@ -417,7 +417,7 @@ exit: return PrepareLastStatusResponse(aHeader, ThreadErrorToSpinelStatus(error)); } -otError NcpBase::InsertPropertyHandler_THREAD_JOINERS(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; const otExtAddress *eui64 = NULL; @@ -439,7 +439,7 @@ exit: } #endif // OPENTHREAD_ENABLE_COMMISSIONER -otError NcpBase::SetPropertyHandler_THREAD_LOCAL_LEADER_WEIGHT(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t weight; otError error = OT_ERROR_NONE; @@ -454,12 +454,12 @@ exit: #if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB -otError NcpBase::GetPropertyHandler_THREAD_STEERING_DATA(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteEui64(mSteeringDataAddress); } -otError NcpBase::SetPropertyHandler_THREAD_STEERING_DATA(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; @@ -472,7 +472,7 @@ exit: } #endif // #if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB -otError NcpBase::SetPropertyHandler_THREAD_CHILD_TIMEOUT(void) +template <> otError NcpBase::HandlePropertySet(void) { uint32_t timeout = 0; otError error = OT_ERROR_NONE; @@ -485,12 +485,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_PREFERRED_ROUTER_ID(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(mPreferredRouteId); } -otError NcpBase::SetPropertyHandler_THREAD_PREFERRED_ROUTER_ID(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; @@ -502,7 +502,7 @@ exit: return error; } -otError NcpBase::RemovePropertyHandler_THREAD_ACTIVE_ROUTER_IDS(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; uint8_t routerId; @@ -523,7 +523,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_ADDRESS_CACHE_TABLE(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; otEidCacheEntry entry; @@ -549,12 +549,12 @@ exit: } #if OPENTHREAD_ENABLE_TMF_PROXY -otError NcpBase::GetPropertyHandler_THREAD_TMF_PROXY_ENABLED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otTmfProxyIsEnabled(mInstance)); } -otError NcpBase::SetPropertyHandler_THREAD_TMF_PROXY_STREAM(void) +template <> otError NcpBase::HandlePropertySet(void) { const uint8_t *framePtr = NULL; uint16_t frameLen = 0; @@ -589,7 +589,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_THREAD_TMF_PROXY_ENABLED(void) +template <> otError NcpBase::HandlePropertySet(void) { bool enabled; otError error = OT_ERROR_NONE; @@ -821,7 +821,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_THREAD_ACTIVE_DATASET(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; otOperationalDataset dataset; @@ -833,7 +833,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_THREAD_PENDING_DATASET(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; otOperationalDataset dataset; @@ -845,7 +845,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_THREAD_MGMT_ACTIVE_DATASET(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; otOperationalDataset dataset; @@ -859,7 +859,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_THREAD_MGMT_PENDING_DATASET(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; otOperationalDataset dataset; @@ -875,12 +875,12 @@ exit: #if OPENTHREAD_ENABLE_CHANNEL_MANAGER -otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_NEW_CHANNEL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otChannelManagerGetRequestedChannel(mInstance)); } -otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_NEW_CHANNEL(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t channel; otError error = OT_ERROR_NONE; @@ -893,12 +893,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_DELAY(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint16(otChannelManagerGetDelay(mInstance)); } -otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_DELAY(void) +template <> otError NcpBase::HandlePropertySet(void) { uint16_t delay; otError error = OT_ERROR_NONE; @@ -911,12 +911,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_SUPPORTED_CHANNELS(void) +template <> otError NcpBase::HandlePropertyGet(void) { return EncodeChannelMask(otChannelManagerGetSupportedChannels(mInstance)); } -otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_SUPPORTED_CHANNELS(void) +template <> otError NcpBase::HandlePropertySet(void) { uint32_t channelMask = 0; otError error = OT_ERROR_NONE; @@ -928,12 +928,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_FAVORED_CHANNELS(void) +template <> otError NcpBase::HandlePropertyGet(void) { return EncodeChannelMask(otChannelManagerGetFavoredChannels(mInstance)); } -otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_FAVORED_CHANNELS(void) +template <> otError NcpBase::HandlePropertySet(void) { uint32_t channelMask = 0; otError error = OT_ERROR_NONE; @@ -945,12 +945,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_CHANNEL_SELECT(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(false); } -otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_CHANNEL_SELECT(void) +template <> otError NcpBase::HandlePropertySet(void) { bool skipQualityCheck = false; otError error = OT_ERROR_NONE; @@ -962,12 +962,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_AUTO_SELECT_ENABLED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otChannelManagerGetAutoChannelSelectionEnabled(mInstance)); } -otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_AUTO_SELECT_ENABLED(void) +template <> otError NcpBase::HandlePropertySet(void) { bool enabled = false; otError error = OT_ERROR_NONE; @@ -979,12 +979,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_CHANNEL_MANAGER_AUTO_SELECT_INTERVAL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otChannelManagerGetAutoChannelSelectionInterval(mInstance)); } -otError NcpBase::SetPropertyHandler_CHANNEL_MANAGER_AUTO_SELECT_INTERVAL(void) +template <> otError NcpBase::HandlePropertySet(void) { uint32_t interval; otError error = OT_ERROR_NONE; @@ -999,12 +999,12 @@ exit: #endif // OPENTHREAD_ENABLE_CHANNEL_MANAGER #if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC -otError NcpBase::GetPropertyHandler_TIME_SYNC_PERIOD(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint16(otNetworkTimeGetSyncPeriod(mInstance)); } -otError NcpBase::SetPropertyHandler_TIME_SYNC_PERIOD(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; uint16_t timeSyncPeriod; @@ -1017,12 +1017,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_TIME_SYNC_XTAL_THRESHOLD(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint16(otNetworkTimeGetXtalThreshold(mInstance)); } -otError NcpBase::SetPropertyHandler_TIME_SYNC_XTAL_THRESHOLD(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; uint16_t xtalThreshold; diff --git a/src/ncp/ncp_base_mtd.cpp b/src/ncp/ncp_base_mtd.cpp index 605e8c50f..994f040e2 100644 --- a/src/ncp/ncp_base_mtd.cpp +++ b/src/ncp/ncp_base_mtd.cpp @@ -179,12 +179,12 @@ uint8_t NcpBase::LinkFlagsToFlagByte(bool aRxOnWhenIdle, bool aSecureDataRequest return flags; } -otError NcpBase::GetPropertyHandler_MAC_DATA_POLL_PERIOD(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetPollPeriod(mInstance)); } -otError NcpBase::SetPropertyHandler_MAC_DATA_POLL_PERIOD(void) +template <> otError NcpBase::HandlePropertySet(void) { uint32_t pollPeriod; otError error = OT_ERROR_NONE; @@ -197,12 +197,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_MAC_EXTENDED_ADDR(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteEui64(*otLinkGetExtendedAddress(mInstance)); } -otError NcpBase::GetPropertyHandler_PHY_FREQ(void) +template <> otError NcpBase::HandlePropertyGet(void) { uint32_t freq_khz(0); const uint8_t chan(otLinkGetChannel(mInstance)); @@ -223,12 +223,12 @@ otError NcpBase::GetPropertyHandler_PHY_FREQ(void) return mEncoder.WriteUint32(freq_khz); } -otError NcpBase::GetPropertyHandler_PHY_CHAN_SUPPORTED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return EncodeChannelMask(mSupportedChannelMask); } -otError NcpBase::GetPropertyHandler_PHY_RSSI(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteInt8(otPlatRadioGetRssi(mInstance)); } @@ -248,17 +248,17 @@ otError NcpBase::CommandHandler_NET_RECALL(uint8_t aHeader) return PrepareLastStatusResponse(aHeader, SPINEL_STATUS_UNIMPLEMENTED); } -otError NcpBase::GetPropertyHandler_NET_SAVED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otDatasetIsCommissioned(mInstance)); } -otError NcpBase::GetPropertyHandler_NET_IF_UP(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otIp6IsEnabled(mInstance)); } -otError NcpBase::SetPropertyHandler_NET_IF_UP(void) +template <> otError NcpBase::HandlePropertySet(void) { bool enabled = false; otError error = OT_ERROR_NONE; @@ -271,12 +271,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_NET_STACK_UP(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otThreadGetDeviceRole(mInstance) != OT_DEVICE_ROLE_DISABLED); } -otError NcpBase::SetPropertyHandler_NET_STACK_UP(void) +template <> otError NcpBase::HandlePropertySet(void) { bool enabled = false; otError error = OT_ERROR_NONE; @@ -302,7 +302,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_NET_ROLE(void) +template <> otError NcpBase::HandlePropertyGet(void) { spinel_net_role_t role(SPINEL_NET_ROLE_DETACHED); @@ -329,7 +329,7 @@ otError NcpBase::GetPropertyHandler_NET_ROLE(void) return mEncoder.WriteUint8(role); } -otError NcpBase::SetPropertyHandler_NET_ROLE(void) +template <> otError NcpBase::HandlePropertySet(void) { unsigned int role = 0; otError error = OT_ERROR_NONE; @@ -361,12 +361,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_NET_NETWORK_NAME(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUtf8(otThreadGetNetworkName(mInstance)); } -otError NcpBase::SetPropertyHandler_NET_NETWORK_NAME(void) +template <> otError NcpBase::HandlePropertySet(void) { const char *string = NULL; otError error = OT_ERROR_NONE; @@ -379,12 +379,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_NET_XPANID(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteData(otThreadGetExtendedPanId(mInstance), sizeof(spinel_net_xpanid_t)); } -otError NcpBase::SetPropertyHandler_NET_XPANID(void) +template <> otError NcpBase::HandlePropertySet(void) { const uint8_t *ptr = NULL; uint16_t len; @@ -400,12 +400,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_NET_MASTER_KEY(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteData(otThreadGetMasterKey(mInstance)->m8, OT_MASTER_KEY_SIZE); } -otError NcpBase::SetPropertyHandler_NET_MASTER_KEY(void) +template <> otError NcpBase::HandlePropertySet(void) { const uint8_t *ptr = NULL; uint16_t len; @@ -421,12 +421,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_NET_KEY_SEQUENCE_COUNTER(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otThreadGetKeySequenceCounter(mInstance)); } -otError NcpBase::SetPropertyHandler_NET_KEY_SEQUENCE_COUNTER(void) +template <> otError NcpBase::HandlePropertySet(void) { uint32_t keySeqCounter; otError error = OT_ERROR_NONE; @@ -439,17 +439,17 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_NET_PARTITION_ID(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otThreadGetPartitionId(mInstance)); } -otError NcpBase::GetPropertyHandler_NET_KEY_SWITCH_GUARDTIME(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otThreadGetKeySwitchGuardTime(mInstance)); } -otError NcpBase::SetPropertyHandler_NET_KEY_SWITCH_GUARDTIME(void) +template <> otError NcpBase::HandlePropertySet(void) { uint32_t keyGuardTime; otError error = OT_ERROR_NONE; @@ -462,18 +462,18 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_NETWORK_DATA_VERSION(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otNetDataGetVersion(mInstance)); } -otError NcpBase::GetPropertyHandler_THREAD_STABLE_NETWORK_DATA_VERSION(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otNetDataGetStableVersion(mInstance)); } #if OPENTHREAD_ENABLE_BORDER_ROUTER -otError NcpBase::GetPropertyHandler_THREAD_NETWORK_DATA(void) +template <> otError NcpBase::HandlePropertyGet(void) { uint8_t networkData[255]; uint8_t networkDataLen = 255; @@ -485,7 +485,7 @@ otError NcpBase::GetPropertyHandler_THREAD_NETWORK_DATA(void) return mEncoder.WriteData(networkData, networkDataLen); } -otError NcpBase::GetPropertyHandler_THREAD_STABLE_NETWORK_DATA(void) +template <> otError NcpBase::HandlePropertyGet(void) { uint8_t networkData[255]; uint8_t networkDataLen = 255; @@ -498,7 +498,7 @@ otError NcpBase::GetPropertyHandler_THREAD_STABLE_NETWORK_DATA(void) } #endif // OPENTHREAD_ENABLE_BORDER_ROUTER -otError NcpBase::GetPropertyHandler_THREAD_LEADER_NETWORK_DATA(void) +template <> otError NcpBase::HandlePropertyGet(void) { uint8_t networkData[255]; uint8_t networkDataLen = 255; @@ -510,7 +510,7 @@ otError NcpBase::GetPropertyHandler_THREAD_LEADER_NETWORK_DATA(void) return mEncoder.WriteData(networkData, networkDataLen); } -otError NcpBase::GetPropertyHandler_THREAD_STABLE_LEADER_NETWORK_DATA(void) +template <> otError NcpBase::HandlePropertyGet(void) { uint8_t networkData[255]; uint8_t networkDataLen = 255; @@ -522,12 +522,12 @@ otError NcpBase::GetPropertyHandler_THREAD_STABLE_LEADER_NETWORK_DATA(void) return mEncoder.WriteData(networkData, networkDataLen); } -otError NcpBase::GetPropertyHandler_THREAD_LEADER_RID(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otThreadGetLeaderRouterId(mInstance)); } -otError NcpBase::GetPropertyHandler_THREAD_LEADER_ADDR(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; otIp6Address address; @@ -546,7 +546,7 @@ otError NcpBase::GetPropertyHandler_THREAD_LEADER_ADDR(void) return error; } -otError NcpBase::GetPropertyHandler_THREAD_PARENT(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; @@ -568,7 +568,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_NEIGHBOR_TABLE(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; otNeighborInfoIterator iter = OT_NEIGHBOR_INFO_ITERATOR_INIT; @@ -602,7 +602,7 @@ exit: #if OPENTHREAD_CONFIG_ENABLE_TX_ERROR_RATE_TRACKING -otError NcpBase::GetPropertyHandler_THREAD_NEIGHBOR_TABLE_ERROR_RATES(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; otNeighborInfoIterator iter = OT_NEIGHBOR_INFO_ITERATOR_INIT; @@ -628,7 +628,7 @@ exit: #endif // OPENTHREAD_CONFIG_ENABLE_TX_ERROR_RATE_TRACKING -otError NcpBase::GetPropertyHandler_THREAD_ASSISTING_PORTS(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; uint8_t numEntries = 0; @@ -643,7 +643,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_THREAD_ASSISTING_PORTS(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t numEntries = 0; const uint16_t *ports = otIp6GetUnsecurePorts(mInstance, &numEntries); @@ -678,13 +678,13 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_ALLOW_LOCAL_NET_DATA_CHANGE(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(mAllowLocalNetworkDataChange); } #if OPENTHREAD_ENABLE_BORDER_ROUTER -otError NcpBase::SetPropertyHandler_THREAD_ALLOW_LOCAL_NET_DATA_CHANGE(void) +template <> otError NcpBase::HandlePropertySet(void) { bool value = false; otError error = OT_ERROR_NONE; @@ -708,7 +708,7 @@ exit: } #endif // OPENTHREAD_ENABLE_BORDER_ROUTER -otError NcpBase::GetPropertyHandler_THREAD_ON_MESH_NETS(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; otBorderRouterConfig borderRouterConfig; @@ -754,7 +754,7 @@ exit: } #if OPENTHREAD_ENABLE_BORDER_ROUTER -otError NcpBase::InsertPropertyHandler_THREAD_ON_MESH_NETS(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; otBorderRouterConfig borderRouterConfig; @@ -787,7 +787,7 @@ exit: return error; } -otError NcpBase::RemovePropertyHandler_THREAD_ON_MESH_NETS(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; otIp6Prefix ip6Prefix; @@ -817,32 +817,32 @@ exit: } #endif // OPENTHREAD_ENABLE_BORDER_ROUTER -otError NcpBase::GetPropertyHandler_THREAD_DISCOVERY_SCAN_JOINER_FLAG(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(mDiscoveryScanJoinerFlag); } -otError NcpBase::SetPropertyHandler_THREAD_DISCOVERY_SCAN_JOINER_FLAG(void) +template <> otError NcpBase::HandlePropertySet(void) { return mDecoder.ReadBool(mDiscoveryScanJoinerFlag); } -otError NcpBase::GetPropertyHandler_THREAD_DISCOVERY_SCAN_ENABLE_FILTERING(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(mDiscoveryScanEnableFiltering); } -otError NcpBase::SetPropertyHandler_THREAD_DISCOVERY_SCAN_ENABLE_FILTERING(void) +template <> otError NcpBase::HandlePropertySet(void) { return mDecoder.ReadBool(mDiscoveryScanEnableFiltering); } -otError NcpBase::GetPropertyHandler_THREAD_DISCOVERY_SCAN_PANID(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint16(mDiscoveryScanPanId); } -otError NcpBase::SetPropertyHandler_THREAD_DISCOVERY_SCAN_PANID(void) +template <> otError NcpBase::HandlePropertySet(void) { return mDecoder.ReadUint16(mDiscoveryScanPanId); } @@ -964,7 +964,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_ACTIVE_DATASET(void) +template <> otError NcpBase::HandlePropertyGet(void) { otOperationalDataset dataset; @@ -972,7 +972,7 @@ otError NcpBase::GetPropertyHandler_THREAD_ACTIVE_DATASET(void) return EncodeOperationalDataset(dataset); } -otError NcpBase::GetPropertyHandler_THREAD_PENDING_DATASET(void) +template <> otError NcpBase::HandlePropertyGet(void) { otOperationalDataset dataset; @@ -980,7 +980,7 @@ otError NcpBase::GetPropertyHandler_THREAD_PENDING_DATASET(void) return EncodeOperationalDataset(dataset); } -otError NcpBase::GetPropertyHandler_IPV6_ML_PREFIX(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; const uint8_t *mlPrefix = otThreadGetMeshLocalPrefix(mInstance); @@ -1000,7 +1000,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_IPV6_ML_PREFIX(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; const uint8_t *meshLocalPrefix; @@ -1016,7 +1016,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_IPV6_ML_ADDR(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; const otIp6Address *ml64 = otThreadGetMeshLocalEid(mInstance); @@ -1028,7 +1028,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_IPV6_LL_ADDR(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; const otIp6Address *address = otThreadGetLinkLocalIp6Address(mInstance); @@ -1040,7 +1040,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_IPV6_ADDRESS_TABLE(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; @@ -1060,7 +1060,7 @@ exit: return error; } -otError NcpBase::InsertPropertyHandler_IPV6_ADDRESS_TABLE(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; otNetifAddress netifAddr; @@ -1081,7 +1081,7 @@ exit: return error; } -otError NcpBase::RemovePropertyHandler_IPV6_ADDRESS_TABLE(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; const otIp6Address *addrPtr; @@ -1100,18 +1100,18 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_IPV6_ROUTE_TABLE(void) +template <> otError NcpBase::HandlePropertyGet(void) { // TODO: Implement get route table return mEncoder.OverwriteWithLastStatusError(SPINEL_STATUS_UNIMPLEMENTED); } -otError NcpBase::GetPropertyHandler_IPV6_ICMP_PING_OFFLOAD(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otIcmp6GetEchoMode(mInstance) != OT_ICMP6_ECHO_HANDLER_DISABLED); } -otError NcpBase::SetPropertyHandler_IPV6_ICMP_PING_OFFLOAD(void) +template <> otError NcpBase::HandlePropertySet(void) { bool enabled = false; otError error = OT_ERROR_NONE; @@ -1124,7 +1124,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_IPV6_MULTICAST_ADDRESS_TABLE(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; const otNetifMulticastAddress *address; @@ -1140,7 +1140,7 @@ exit: return error; } -otError NcpBase::InsertPropertyHandler_IPV6_MULTICAST_ADDRESS_TABLE(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; const otIp6Address *addrPtr; @@ -1158,7 +1158,7 @@ exit: return error; } -otError NcpBase::RemovePropertyHandler_IPV6_MULTICAST_ADDRESS_TABLE(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; const otIp6Address *addrPtr; @@ -1178,7 +1178,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_IPV6_ICMP_PING_OFFLOAD_MODE(void) +template <> otError NcpBase::HandlePropertyGet(void) { spinel_ipv6_icmp_ping_offload_mode_t mode = SPINEL_IPV6_ICMP_PING_OFFLOAD_DISABLED; @@ -1201,7 +1201,7 @@ otError NcpBase::GetPropertyHandler_IPV6_ICMP_PING_OFFLOAD_MODE(void) return mEncoder.WriteUint8(mode); } -otError NcpBase::SetPropertyHandler_IPV6_ICMP_PING_OFFLOAD_MODE(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; otIcmp6EchoMode mode = OT_ICMP6_ECHO_HANDLER_DISABLED; @@ -1231,13 +1231,13 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_RLOC16_DEBUG_PASSTHRU(void) +template <> otError NcpBase::HandlePropertyGet(void) { // Note reverse logic: passthru enabled = filter disabled return mEncoder.WriteBool(!otIp6IsReceiveFilterEnabled(mInstance)); } -otError NcpBase::SetPropertyHandler_THREAD_RLOC16_DEBUG_PASSTHRU(void) +template <> otError NcpBase::HandlePropertySet(void) { bool enabled = false; otError error = OT_ERROR_NONE; @@ -1251,7 +1251,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_OFF_MESH_ROUTES(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; otExternalRouteConfig routeConfig; @@ -1319,7 +1319,7 @@ static int FlagByteToExternalRoutePreference(uint8_t aFlags) return route_preference; } -otError NcpBase::InsertPropertyHandler_THREAD_OFF_MESH_ROUTES(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; otExternalRouteConfig routeConfig; @@ -1346,7 +1346,7 @@ exit: return error; } -otError NcpBase::RemovePropertyHandler_THREAD_OFF_MESH_ROUTES(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; otIp6Prefix ip6Prefix; @@ -1374,7 +1374,7 @@ exit: } #endif // OPENTHREAD_ENABLE_BORDER_ROUTER -otError NcpBase::SetPropertyHandler_STREAM_NET(void) +template <> otError NcpBase::HandlePropertySet(void) { const uint8_t *framePtr = NULL; uint16_t frameLen = 0; @@ -1425,37 +1425,37 @@ exit: #if OPENTHREAD_ENABLE_JAM_DETECTION -otError NcpBase::GetPropertyHandler_JAM_DETECT_ENABLE(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otJamDetectionIsEnabled(mInstance)); } -otError NcpBase::GetPropertyHandler_JAM_DETECTED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otJamDetectionGetState(mInstance)); } -otError NcpBase::GetPropertyHandler_JAM_DETECT_RSSI_THRESHOLD(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteInt8(otJamDetectionGetRssiThreshold(mInstance)); } -otError NcpBase::GetPropertyHandler_JAM_DETECT_WINDOW(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otJamDetectionGetWindow(mInstance)); } -otError NcpBase::GetPropertyHandler_JAM_DETECT_BUSY(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint8(otJamDetectionGetBusyPeriod(mInstance)); } -otError NcpBase::GetPropertyHandler_JAM_DETECT_HISTORY_BITMAP(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint64(otJamDetectionGetHistoryBitmap(mInstance)); } -otError NcpBase::SetPropertyHandler_JAM_DETECT_ENABLE(void) +template <> otError NcpBase::HandlePropertySet(void) { bool enabled; otError error = OT_ERROR_NONE; @@ -1475,7 +1475,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_JAM_DETECT_RSSI_THRESHOLD(void) +template <> otError NcpBase::HandlePropertySet(void) { int8_t threshold = 0; otError error = OT_ERROR_NONE; @@ -1488,7 +1488,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_JAM_DETECT_WINDOW(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t window = 0; otError error = OT_ERROR_NONE; @@ -1501,7 +1501,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_JAM_DETECT_BUSY(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t busy = 0; otError error = OT_ERROR_NONE; @@ -1531,27 +1531,27 @@ void NcpBase::HandleJamStateChange(bool aJamState) #if OPENTHREAD_ENABLE_CHANNEL_MONITOR -otError NcpBase::GetPropertyHandler_CHANNEL_MONITOR_SAMPLE_INTERVAL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otChannelMonitorGetSampleInterval(mInstance)); } -otError NcpBase::GetPropertyHandler_CHANNEL_MONITOR_RSSI_THRESHOLD(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteInt8(otChannelMonitorGetRssiThreshold(mInstance)); } -otError NcpBase::GetPropertyHandler_CHANNEL_MONITOR_SAMPLE_WINDOW(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otChannelMonitorGetSampleWindow(mInstance)); } -otError NcpBase::GetPropertyHandler_CHANNEL_MONITOR_SAMPLE_COUNT(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otChannelMonitorGetSampleCount(mInstance)); } -otError NcpBase::GetPropertyHandler_CHANNEL_MONITOR_CHANNEL_OCCUPANCY(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; @@ -1571,237 +1571,237 @@ exit: #endif // OPENTHREAD_ENABLE_CHANNEL_MONITOR -otError NcpBase::GetPropertyHandler_MAC_CCA_FAILURE_RATE(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint16(otLinkGetCcaFailureRate(mInstance)); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_TOTAL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxTotal); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_ACK_REQ(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxAckRequested); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_ACKED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxAcked); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_NO_ACK_REQ(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxNoAckRequested); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_DATA(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxData); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_DATA_POLL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxDataPoll); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_BEACON(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxBeacon); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_BEACON_REQ(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxBeaconRequest); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_OTHER(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxOther); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_RETRY(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxRetry); } -otError NcpBase::GetPropertyHandler_CNTR_TX_ERR_CCA(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxErrCca); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_UNICAST(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxUnicast); } -otError NcpBase::GetPropertyHandler_CNTR_TX_PKT_BROADCAST(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxBroadcast); } -otError NcpBase::GetPropertyHandler_CNTR_TX_ERR_ABORT(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mTxErrAbort); } -otError NcpBase::GetPropertyHandler_CNTR_RX_PKT_TOTAL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxTotal); } -otError NcpBase::GetPropertyHandler_CNTR_RX_PKT_DATA(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxData); } -otError NcpBase::GetPropertyHandler_CNTR_RX_PKT_DATA_POLL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxDataPoll); } -otError NcpBase::GetPropertyHandler_CNTR_RX_PKT_BEACON(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxBeacon); } -otError NcpBase::GetPropertyHandler_CNTR_RX_PKT_BEACON_REQ(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxBeaconRequest); } -otError NcpBase::GetPropertyHandler_CNTR_RX_PKT_OTHER(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxOther); } -otError NcpBase::GetPropertyHandler_CNTR_RX_PKT_FILT_WL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxAddressFiltered); } -otError NcpBase::GetPropertyHandler_CNTR_RX_PKT_FILT_DA(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxDestAddrFiltered); } -otError NcpBase::GetPropertyHandler_CNTR_RX_PKT_DUP(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxDuplicated); } -otError NcpBase::GetPropertyHandler_CNTR_RX_PKT_UNICAST(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxUnicast); } -otError NcpBase::GetPropertyHandler_CNTR_RX_PKT_BROADCAST(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxBroadcast); } -otError NcpBase::GetPropertyHandler_CNTR_RX_ERR_EMPTY(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxErrNoFrame); } -otError NcpBase::GetPropertyHandler_CNTR_RX_ERR_UKWN_NBR(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxErrUnknownNeighbor); } -otError NcpBase::GetPropertyHandler_CNTR_RX_ERR_NVLD_SADDR(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxErrInvalidSrcAddr); } -otError NcpBase::GetPropertyHandler_CNTR_RX_ERR_SECURITY(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxErrSec); } -otError NcpBase::GetPropertyHandler_CNTR_RX_ERR_BAD_FCS(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxErrFcs); } -otError NcpBase::GetPropertyHandler_CNTR_RX_ERR_OTHER(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otLinkGetCounters(mInstance)->mRxErrOther); } -otError NcpBase::GetPropertyHandler_CNTR_TX_IP_SEC_TOTAL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(mInboundSecureIpFrameCounter); } -otError NcpBase::GetPropertyHandler_CNTR_TX_IP_INSEC_TOTAL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(mInboundInsecureIpFrameCounter); } -otError NcpBase::GetPropertyHandler_CNTR_TX_IP_DROPPED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(mDroppedInboundIpFrameCounter); } -otError NcpBase::GetPropertyHandler_CNTR_RX_IP_SEC_TOTAL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(mOutboundSecureIpFrameCounter); } -otError NcpBase::GetPropertyHandler_CNTR_RX_IP_INSEC_TOTAL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(mOutboundInsecureIpFrameCounter); } -otError NcpBase::GetPropertyHandler_CNTR_RX_IP_DROPPED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(mDroppedOutboundIpFrameCounter); } -otError NcpBase::GetPropertyHandler_CNTR_TX_SPINEL_TOTAL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(mTxSpinelFrameCounter); } -otError NcpBase::GetPropertyHandler_CNTR_RX_SPINEL_TOTAL(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(mRxSpinelFrameCounter); } -otError NcpBase::GetPropertyHandler_CNTR_RX_SPINEL_OUT_OF_ORDER_TID(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(mRxSpinelOutOfOrderTidCounter); } -otError NcpBase::GetPropertyHandler_CNTR_RX_SPINEL_ERR(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(mFramingErrorCounter); } -otError NcpBase::GetPropertyHandler_CNTR_IP_TX_SUCCESS(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otThreadGetIp6Counters(mInstance)->mTxSuccess); } -otError NcpBase::GetPropertyHandler_CNTR_IP_RX_SUCCESS(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otThreadGetIp6Counters(mInstance)->mRxSuccess); } -otError NcpBase::GetPropertyHandler_CNTR_IP_TX_FAILURE(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otThreadGetIp6Counters(mInstance)->mTxFailure); } -otError NcpBase::GetPropertyHandler_CNTR_IP_RX_FAILURE(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otThreadGetIp6Counters(mInstance)->mRxFailure); } -otError NcpBase::GetPropertyHandler_MSG_BUFFER_COUNTERS(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; otBufferInfo bufferInfo; @@ -1829,7 +1829,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_CNTR_ALL_MAC_COUNTERS(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; const otMacCounters *counters = otLinkGetCounters(mInstance); @@ -1886,7 +1886,7 @@ exit: #if OPENTHREAD_ENABLE_MAC_FILTER -otError NcpBase::GetPropertyHandler_MAC_WHITELIST(void) +template <> otError NcpBase::HandlePropertyGet(void) { otMacFilterEntry entry; otMacFilterIterator iterator = OT_MAC_FILTER_ITERATOR_INIT; @@ -1906,12 +1906,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_MAC_WHITELIST_ENABLED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otLinkFilterGetAddressMode(mInstance) == OT_MAC_FILTER_ADDRESS_MODE_WHITELIST); } -otError NcpBase::GetPropertyHandler_MAC_BLACKLIST(void) +template <> otError NcpBase::HandlePropertyGet(void) { otMacFilterEntry entry; otMacFilterIterator iterator = OT_MAC_FILTER_ITERATOR_INIT; @@ -1928,12 +1928,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_MAC_BLACKLIST_ENABLED(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(otLinkFilterGetAddressMode(mInstance) == OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST); } -otError NcpBase::GetPropertyHandler_MAC_FIXED_RSS(void) +template <> otError NcpBase::HandlePropertyGet(void) { otMacFilterEntry entry; otMacFilterIterator iterator = OT_MAC_FILTER_ITERATOR_INIT; @@ -1953,7 +1953,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_MAC_WHITELIST(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; @@ -2008,7 +2008,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_MAC_WHITELIST_ENABLED(void) +template <> otError NcpBase::HandlePropertySet(void) { bool enabled; otError error = OT_ERROR_NONE; @@ -2027,7 +2027,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_MAC_BLACKLIST(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; @@ -2066,7 +2066,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_MAC_BLACKLIST_ENABLED(void) +template <> otError NcpBase::HandlePropertySet(void) { bool enabled; otError error = OT_ERROR_NONE; @@ -2085,7 +2085,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_MAC_FIXED_RSS(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; @@ -2130,7 +2130,7 @@ exit: } #endif // OPENTHREAD_ENABLE_MAC_FILTER -otError NcpBase::GetPropertyHandler_THREAD_MODE(void) +template <> otError NcpBase::HandlePropertyGet(void) { uint8_t numericMode; otLinkModeConfig modeConfig = otThreadGetLinkMode(mInstance); @@ -2141,7 +2141,7 @@ otError NcpBase::GetPropertyHandler_THREAD_MODE(void) return mEncoder.WriteUint8(numericMode); } -otError NcpBase::SetPropertyHandler_THREAD_MODE(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t numericMode = 0; otLinkModeConfig modeConfig; @@ -2164,27 +2164,27 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_THREAD_CHILD_TIMEOUT(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint32(otThreadGetChildTimeout(mInstance)); } -otError NcpBase::GetPropertyHandler_THREAD_RLOC16(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint16(otThreadGetRloc16(mInstance)); } -otError NcpBase::GetPropertyHandler_NET_REQUIRE_JOIN_EXISTING(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteBool(mRequireJoinExistingNetwork); } -otError NcpBase::SetPropertyHandler_NET_REQUIRE_JOIN_EXISTING(void) +template <> otError NcpBase::HandlePropertySet(void) { return mDecoder.ReadBool(mRequireJoinExistingNetwork); } -otError NcpBase::SetPropertyHandler_STREAM_NET_INSECURE(void) +template <> otError NcpBase::HandlePropertySet(void) { const uint8_t *framePtr = NULL; uint16_t frameLen = 0; @@ -2235,7 +2235,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_CNTR_RESET(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t value = 0; otError error = OT_ERROR_NONE; @@ -2251,7 +2251,7 @@ exit: return error; } -otError NcpBase::InsertPropertyHandler_THREAD_ASSISTING_PORTS(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; uint16_t port; @@ -2265,7 +2265,7 @@ exit: #if OPENTHREAD_ENABLE_MAC_FILTER -otError NcpBase::InsertPropertyHandler_MAC_WHITELIST(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; const otExtAddress *extAddress = NULL; @@ -2296,7 +2296,7 @@ exit: return error; } -otError NcpBase::InsertPropertyHandler_MAC_BLACKLIST(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; const otExtAddress *extAddress = NULL; @@ -2314,7 +2314,7 @@ exit: return error; } -otError NcpBase::InsertPropertyHandler_MAC_FIXED_RSS(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; const otExtAddress *extAddress = NULL; @@ -2335,7 +2335,7 @@ exit: #endif // OPENTHREAD_ENABLE_MAC_FILTER -otError NcpBase::RemovePropertyHandler_THREAD_ASSISTING_PORTS(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; uint16_t port; @@ -2356,7 +2356,7 @@ exit: #if OPENTHREAD_ENABLE_MAC_FILTER -otError NcpBase::RemovePropertyHandler_MAC_WHITELIST(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; const otExtAddress *extAddress = NULL; @@ -2374,7 +2374,7 @@ exit: return error; } -otError NcpBase::RemovePropertyHandler_MAC_BLACKLIST(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; const otExtAddress *extAddress = NULL; @@ -2392,7 +2392,7 @@ exit: return error; } -otError NcpBase::RemovePropertyHandler_MAC_FIXED_RSS(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; const otExtAddress *extAddress = NULL; @@ -2465,12 +2465,12 @@ void NcpBase::HandleLegacyNodeDidJoin(const otExtAddress *aExtAddr) mUpdateChangedPropsTask.Post(); } -otError NcpBase::GetPropertyHandler_NEST_LEGACY_ULA_PREFIX(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteData(mLegacyUlaPrefix, sizeof(mLegacyUlaPrefix)); } -otError NcpBase::SetPropertyHandler_NEST_LEGACY_ULA_PREFIX(void) +template <> otError NcpBase::HandlePropertySet(void) { const uint8_t *ptr = NULL; uint16_t len; @@ -2492,7 +2492,7 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_NEST_LEGACY_LAST_NODE_JOINED(void) +template <> otError NcpBase::HandlePropertyGet(void) { if (!mLegacyNodeDidJoin) { @@ -2525,7 +2525,7 @@ void NcpBase::StopLegacy(void) #endif // OPENTHREAD_ENABLE_LEGACY #if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC -otError NcpBase::GetPropertyHandler_THREAD_NETWORK_TIME(void) +template <> otError NcpBase::HandlePropertyGet(void) { otError error = OT_ERROR_NONE; otNetworkTimeStatus networkTimeStatus; @@ -2575,12 +2575,12 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_MAC_SCAN_MASK(void) +template <> otError NcpBase::HandlePropertyGet(void) { return EncodeChannelMask(mChannelMask); } -otError NcpBase::SetPropertyHandler_MAC_SCAN_MASK(void) +template <> otError NcpBase::HandlePropertySet(void) { uint32_t newMask = 0; otError error = OT_ERROR_NONE; @@ -2594,17 +2594,17 @@ exit: return error; } -otError NcpBase::GetPropertyHandler_MAC_SCAN_PERIOD(void) +template <> otError NcpBase::HandlePropertyGet(void) { return mEncoder.WriteUint16(mScanPeriod); } -otError NcpBase::SetPropertyHandler_MAC_SCAN_PERIOD(void) +template <> otError NcpBase::HandlePropertySet(void) { return mDecoder.ReadUint16(mScanPeriod); } -otError NcpBase::GetPropertyHandler_MAC_SCAN_STATE(void) +template <> otError NcpBase::HandlePropertyGet(void) { uint8_t scanState = SPINEL_SCAN_STATE_IDLE; @@ -2640,7 +2640,7 @@ otError NcpBase::GetPropertyHandler_MAC_SCAN_STATE(void) return mEncoder.WriteUint8(scanState); } -otError NcpBase::SetPropertyHandler_MAC_SCAN_STATE(void) +template <> otError NcpBase::HandlePropertySet(void) { uint8_t state = 0; otError error = OT_ERROR_NONE; diff --git a/src/ncp/ncp_base_radio.cpp b/src/ncp/ncp_base_radio.cpp index 1882ddef8..fd43f9bb1 100644 --- a/src/ncp/ncp_base_radio.cpp +++ b/src/ncp/ncp_base_radio.cpp @@ -178,13 +178,13 @@ exit: return; } -otError NcpBase::GetPropertyHandler_MAC_SRC_MATCH_ENABLED(void) +template <> otError NcpBase::HandlePropertyGet(void) { // TODO: Would be good to add an `otLinkRaw` API to give the the status of source match. return mEncoder.WriteBool(mSrcMatchEnabled); } -otError NcpBase::SetPropertyHandler_MAC_SRC_MATCH_ENABLED(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; @@ -196,7 +196,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_MAC_SRC_MATCH_SHORT_ADDRESSES(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; @@ -217,7 +217,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_MAC_SRC_MATCH_EXTENDED_ADDRESSES(void) +template <> otError NcpBase::HandlePropertySet(void) { otError error = OT_ERROR_NONE; @@ -238,7 +238,7 @@ exit: return error; } -otError NcpBase::RemovePropertyHandler_MAC_SRC_MATCH_SHORT_ADDRESSES(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; uint16_t shortAddress; @@ -251,7 +251,7 @@ exit: return error; } -otError NcpBase::RemovePropertyHandler_MAC_SRC_MATCH_EXTENDED_ADDRESSES(void) +template <> otError NcpBase::HandlePropertyRemove(void) { otError error = OT_ERROR_NONE; const otExtAddress *extAddress; @@ -265,7 +265,7 @@ exit: return error; } -otError NcpBase::InsertPropertyHandler_MAC_SRC_MATCH_SHORT_ADDRESSES(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; uint16_t shortAddress; @@ -278,7 +278,7 @@ exit: return error; } -otError NcpBase::InsertPropertyHandler_MAC_SRC_MATCH_EXTENDED_ADDRESSES(void) +template <> otError NcpBase::HandlePropertyInsert(void) { otError error = OT_ERROR_NONE; const otExtAddress *extAddress = NULL; @@ -291,7 +291,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_PHY_ENABLED(void) +template <> otError NcpBase::HandlePropertySet(void) { bool value = false; otError error = OT_ERROR_NONE; @@ -323,7 +323,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_MAC_15_4_SADDR(void) +template <> otError NcpBase::HandlePropertySet(void) { uint16_t shortAddress; otError error = OT_ERROR_NONE; @@ -336,7 +336,7 @@ exit: return error; } -otError NcpBase::SetPropertyHandler_STREAM_RAW(uint8_t aHeader) +otError NcpBase::HandlePropertySet_SPINEL_PROP_STREAM_RAW(uint8_t aHeader) { const uint8_t *frameBuffer = NULL; otRadioFrame * frame;