Merge branch 'bugfix/binding_manager_initialize' into 'main'

binding: Call BindingManager::Init() after network connected

See merge request app-frameworks/esp-matter!238
This commit is contained in:
Shu Chen
2022-12-12 15:35:33 +08:00
3 changed files with 12 additions and 15 deletions
@@ -170,6 +170,7 @@ void binding_manager_init()
{
if (initialize_binding_manager) {
chip::DeviceLayer::PlatformMgr().ScheduleWork(__binding_manager_init);
initialize_binding_manager = false;
}
}
+6 -11
View File
@@ -788,15 +788,11 @@ static void esp_matter_chip_init_task(intptr_t context)
sWiFiNetworkCommissioningInstance.Init();
}
#endif
/* Initialize binding manager */
client::binding_manager_init();
xTaskNotifyGive(task_to_notify);
}
static void device_callback_internal(const ChipDeviceEvent * event, intptr_t arg)
{
// TODO: Use RemoveEventHandler() instead of the static is_ota_requestor_start
static bool is_ota_requestor_start = false;
switch (event->Type)
{
case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged:
@@ -812,19 +808,18 @@ static void device_callback_internal(const ChipDeviceEvent * event, intptr_t arg
// in esp_matter_ota_requestor_start(), so the device should be connected to the Wi-Fi network when calling
// esp_matter_ota_requestor_start(). IPv4 might be disabled on the Provider so we should call this function
// when the IPv6 address is assigned.
if (!is_ota_requestor_start) {
esp_matter_ota_requestor_start();
is_ota_requestor_start = true;
}
esp_matter_ota_requestor_start();
/* Initialize binding manager */
client::binding_manager_init();
}
break;
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
case chip::DeviceLayer::DeviceEventType::kThreadConnectivityChange:
if (!is_ota_requestor_start &&
event->ThreadConnectivityChange.Result == chip::DeviceLayer::ConnectivityChange::kConnectivity_Established) {
if (event->ThreadConnectivityChange.Result == chip::DeviceLayer::ConnectivityChange::kConnectivity_Established) {
esp_matter_ota_requestor_start();
is_ota_requestor_start = true;
/* Initialize binding manager */
client::binding_manager_init();
}
break;
#endif
+5 -4
View File
@@ -26,15 +26,15 @@
using chip::BDXDownloader;
using chip::DefaultOTARequestor;
using chip::DefaultOTARequestorStorage;
using chip::DeviceLayer::DefaultOTARequestorDriver;
using chip::OTAImageProcessorImpl;
using chip::Server;
using chip::DeviceLayer::DefaultOTARequestorDriver;
using namespace esp_matter;
using namespace esp_matter::endpoint;
using namespace esp_matter::cluster;
#if CONFIG_ENABLE_OTA_REQUESTOR
#if CONFIG_ENABLE_OTA_REQUESTOR
DefaultOTARequestor gRequestorCore;
DefaultOTARequestorStorage gRequestorStorage;
DefaultOTARequestorDriver gRequestorUser;
@@ -52,7 +52,7 @@ esp_err_t esp_matter_ota_requestor_init(void)
if (!root_node || !root_node_endpoint) {
return ESP_FAIL;
}
cluster_t *cluster_p = ota_provider::create(root_node_endpoint, NULL, CLUSTER_FLAG_CLIENT);
cluster_t *cluster_r = ota_requestor::create(root_node_endpoint, &config, CLUSTER_FLAG_SERVER);
@@ -68,7 +68,8 @@ esp_err_t esp_matter_ota_requestor_init(void)
void esp_matter_ota_requestor_start(void)
{
#if CONFIG_ENABLE_OTA_REQUESTOR
#if CONFIG_ENABLE_OTA_REQUESTOR
VerifyOrReturn(chip::GetRequestorInstance() == nullptr);
chip::SetRequestorInstance(&gRequestorCore);
gRequestorStorage.Init(Server::GetInstance().GetPersistentStorage());
gRequestorCore.Init(Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader);