mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(openthread): support restoring vendor properties of rcp
This commit is contained in:
parent
d894253c48
commit
7d9b33408d
@ -189,7 +189,7 @@ menu "OpenThread"
|
|||||||
config OPENTHREAD_NCP_VENDOR_HOOK
|
config OPENTHREAD_NCP_VENDOR_HOOK
|
||||||
bool "Enable vendor command for RCP"
|
bool "Enable vendor command for RCP"
|
||||||
depends on OPENTHREAD_RADIO
|
depends on OPENTHREAD_RADIO
|
||||||
default n
|
default y
|
||||||
help
|
help
|
||||||
Select this to enable OpenThread NCP vendor commands.
|
Select this to enable OpenThread NCP vendor commands.
|
||||||
|
|
||||||
|
@ -42,9 +42,11 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT
|
#ifndef OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT
|
||||||
// TZ-567: Set OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT to 3 after adding rcp failure notification mechanism
|
// TZ-567: Set OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT to 3 after adding rcp failure notification mechanism
|
||||||
#define OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT 0
|
#define OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_SPINEL_CONFIG_RCP_CUSTOM_RESTORATION
|
* @def OPENTHREAD_SPINEL_CONFIG_RCP_CUSTOM_RESTORATION
|
||||||
*
|
*
|
||||||
|
@ -14,6 +14,12 @@
|
|||||||
#include "esp_radio_spinel_uart_interface.hpp"
|
#include "esp_radio_spinel_uart_interface.hpp"
|
||||||
#include "spinel_driver.hpp"
|
#include "spinel_driver.hpp"
|
||||||
|
|
||||||
|
#define SPINEL_VENDOR_PROPERTY_BIT_PENDINGMODE BIT(0)
|
||||||
|
#define SPINEL_VENDOR_PROPERTY_BIT_COORDINATOR BIT(1)
|
||||||
|
static esp_ieee802154_pending_mode_t s_spinel_vendor_property_pendingmode[ot::Spinel::kSpinelHeaderMaxNumIid] = {ESP_IEEE802154_AUTO_PENDING_DISABLE};
|
||||||
|
static bool s_spinel_vendor_property_coordinator[ot::Spinel::kSpinelHeaderMaxNumIid] = {false};
|
||||||
|
static uint64_t s_spinel_vendor_property_mask[ot::Spinel::kSpinelHeaderMaxNumIid] = {0};
|
||||||
|
|
||||||
using ot::Spinel::RadioSpinel;
|
using ot::Spinel::RadioSpinel;
|
||||||
using ot::Spinel::RadioSpinelCallbacks;
|
using ot::Spinel::RadioSpinelCallbacks;
|
||||||
using esp::radio_spinel::SpinelInterfaceAdapter;
|
using esp::radio_spinel::SpinelInterfaceAdapter;
|
||||||
@ -45,6 +51,22 @@ static otInstance* get_instance_from_index(esp_radio_spinel_idx_t idx)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void esp_radio_spinel_restore_vendor_properities(void *context)
|
||||||
|
{
|
||||||
|
esp_radio_spinel_idx_t idx = get_index_from_instance((otInstance*)context);
|
||||||
|
if (s_spinel_vendor_property_mask[idx] & SPINEL_VENDOR_PROPERTY_BIT_PENDINGMODE) {
|
||||||
|
if (esp_radio_spinel_set_pending_mode(s_spinel_vendor_property_pendingmode[idx], idx) != ESP_OK) {
|
||||||
|
ESP_LOGE(ESP_SPINEL_LOG_TAG, "Fail to restore pendingmode: %d", idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_spinel_vendor_property_mask[idx] & SPINEL_VENDOR_PROPERTY_BIT_COORDINATOR) {
|
||||||
|
if (esp_radio_spinel_set_pan_coord(s_spinel_vendor_property_coordinator[idx], idx) != ESP_OK) {
|
||||||
|
ESP_LOGE(ESP_SPINEL_LOG_TAG, "Fail to restore coordinator: %d", idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
|
void ReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
|
||||||
{
|
{
|
||||||
esp_radio_spinel_idx_t idx = get_index_from_instance(aInstance);
|
esp_radio_spinel_idx_t idx = get_index_from_instance(aInstance);
|
||||||
@ -225,6 +247,8 @@ void esp_radio_spinel_init(esp_radio_spinel_idx_t idx)
|
|||||||
iidList[0] = 0;
|
iidList[0] = 0;
|
||||||
s_spinel_driver[idx].Init(s_spinel_interface[idx].GetSpinelInterface(), true, iidList, ot::Spinel::kSpinelHeaderMaxNumIid);
|
s_spinel_driver[idx].Init(s_spinel_interface[idx].GetSpinelInterface(), true, iidList, ot::Spinel::kSpinelHeaderMaxNumIid);
|
||||||
s_radio[idx].Init(/*skip_rcp_compatibility_check=*/false, /*reset_radio=*/true, &s_spinel_driver[idx], s_radio_caps);
|
s_radio[idx].Init(/*skip_rcp_compatibility_check=*/false, /*reset_radio=*/true, &s_spinel_driver[idx], s_radio_caps);
|
||||||
|
otInstance *instance = get_instance_from_index(idx);
|
||||||
|
s_radio[idx].SetVendorRestorePropertiesCallback(esp_radio_spinel_restore_vendor_properities, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_radio_spinel_enable(esp_radio_spinel_idx_t idx)
|
esp_err_t esp_radio_spinel_enable(esp_radio_spinel_idx_t idx)
|
||||||
@ -233,11 +257,6 @@ esp_err_t esp_radio_spinel_enable(esp_radio_spinel_idx_t idx)
|
|||||||
return (s_radio[idx].Enable(instance) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
return (s_radio[idx].Enable(instance) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_radio_spinel_set_pending_mode(esp_ieee802154_pending_mode_t pending_mode, esp_radio_spinel_idx_t idx)
|
|
||||||
{
|
|
||||||
return (s_radio[idx].Set(SPINEL_PROP_VENDOR_ESP_SET_PENDINGMODE, SPINEL_DATATYPE_INT32_S, static_cast<int32_t>(pending_mode)) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t esp_radio_spinel_get_eui64(uint8_t *eui64, esp_radio_spinel_idx_t idx)
|
esp_err_t esp_radio_spinel_get_eui64(uint8_t *eui64, esp_radio_spinel_idx_t idx)
|
||||||
{
|
{
|
||||||
return (s_radio[idx].GetIeeeEui64(eui64) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
return (s_radio[idx].GetIeeeEui64(eui64) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
@ -260,11 +279,6 @@ esp_err_t esp_radio_spinel_set_extended_address(uint8_t *ext_address, esp_radio_
|
|||||||
return (s_radio[idx].SetExtendedAddress(aExtAddress) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
return (s_radio[idx].SetExtendedAddress(aExtAddress) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_radio_spinel_set_pan_coord(bool enable, esp_radio_spinel_idx_t idx)
|
|
||||||
{
|
|
||||||
return (s_radio[idx].Set(SPINEL_PROP_VENDOR_ESP_SET_COORDINATOR, SPINEL_DATATYPE_BOOL_S, enable) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t esp_radio_spinel_receive(uint8_t channel, esp_radio_spinel_idx_t idx)
|
esp_err_t esp_radio_spinel_receive(uint8_t channel, esp_radio_spinel_idx_t idx)
|
||||||
{
|
{
|
||||||
return (s_radio[idx].Receive(channel) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
return (s_radio[idx].Receive(channel) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
@ -313,6 +327,24 @@ esp_err_t esp_radio_spinel_set_promiscuous_mode(bool enable, esp_radio_spinel_id
|
|||||||
return (s_radio[idx].SetPromiscuous(enable) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
return (s_radio[idx].SetPromiscuous(enable) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------Vendor Property Set-------------------------------------------------------*/
|
||||||
|
esp_err_t esp_radio_spinel_set_pending_mode(esp_ieee802154_pending_mode_t pending_mode, esp_radio_spinel_idx_t idx)
|
||||||
|
{
|
||||||
|
s_spinel_vendor_property_pendingmode[idx] = pending_mode;
|
||||||
|
s_spinel_vendor_property_mask[idx] |= SPINEL_VENDOR_PROPERTY_BIT_PENDINGMODE;
|
||||||
|
return (s_radio[idx].Set(SPINEL_PROP_VENDOR_ESP_SET_PENDINGMODE, SPINEL_DATATYPE_INT32_S, static_cast<int32_t>(pending_mode)) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_radio_spinel_set_pan_coord(bool enable, esp_radio_spinel_idx_t idx)
|
||||||
|
{
|
||||||
|
s_spinel_vendor_property_coordinator[idx] = enable;
|
||||||
|
s_spinel_vendor_property_mask[idx] |= SPINEL_VENDOR_PROPERTY_BIT_COORDINATOR;
|
||||||
|
return (s_radio[idx].Set(SPINEL_PROP_VENDOR_ESP_SET_COORDINATOR, SPINEL_DATATYPE_BOOL_S, enable) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
void esp_radio_spinel_radio_update(esp_radio_spinel_mainloop_context_t *mainloop_context, esp_radio_spinel_idx_t idx)
|
void esp_radio_spinel_radio_update(esp_radio_spinel_mainloop_context_t *mainloop_context, esp_radio_spinel_idx_t idx)
|
||||||
{
|
{
|
||||||
s_spinel_interface[idx].GetSpinelInterface().UpdateFdSet(static_cast<void *>(mainloop_context));
|
s_spinel_interface[idx].GetSpinelInterface().UpdateFdSet(static_cast<void *>(mainloop_context));
|
||||||
@ -372,3 +404,23 @@ esp_err_t esp_radio_spinel_set_rcp_ready(esp_radio_spinel_idx_t idx)
|
|||||||
s_spinel_driver[idx].SetCoprocessorReady();
|
s_spinel_driver[idx].SetCoprocessorReady();
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ot {
|
||||||
|
namespace Spinel {
|
||||||
|
|
||||||
|
otError RadioSpinel::VendorHandleValueIs(spinel_prop_key_t aPropKey)
|
||||||
|
{
|
||||||
|
otError error = OT_ERROR_NONE;
|
||||||
|
|
||||||
|
switch (aPropKey)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
ESP_LOGW(ESP_SPINEL_LOG_TAG, "Not Implemented!");
|
||||||
|
error = OT_ERROR_NOT_FOUND;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Spinel
|
||||||
|
} // namespace ot
|
||||||
|
Loading…
Reference in New Issue
Block a user