From e6b3746123ea47c6d55548e3a1d7406b9a3a179c Mon Sep 17 00:00:00 2001 From: gugugu Date: Fri, 30 Sep 2022 04:17:13 +0800 Subject: [PATCH] [genio] several bug fixes for multiple devices and interop (#22951) * Report exchanged MTU size to core for BLE transaction * Add mdns refresh after IP address update * Migrate MatterPostAttributeChangeCallback() to current prototype * Discriminator as gatts device name * Get wifi mac address by filogic wifi opmode mode * Update submodule genio-matter-bsp, lwip Co-authored-by: Anthony Liu --- .../lighting-app/genio/src/ZclCallbacks.cpp | 4 ++-- src/platform/mt793x/BLEManagerImpl.cpp | 13 +++++++--- .../mt793x/ConnectivityManagerImpl_WIFI.cpp | 11 +++++++++ src/platform/mt793x/MT793XConfig.cpp | 24 ++++++++++++++++--- third_party/mt793x_sdk/filogic | 2 +- third_party/mt793x_sdk/lwip | 2 +- 6 files changed, 46 insertions(+), 10 deletions(-) diff --git a/examples/lighting-app/genio/src/ZclCallbacks.cpp b/examples/lighting-app/genio/src/ZclCallbacks.cpp index 6f18c3b622c602..2e0dfe3dd2c912 100644 --- a/examples/lighting-app/genio/src/ZclCallbacks.cpp +++ b/examples/lighting-app/genio/src/ZclCallbacks.cpp @@ -31,8 +31,8 @@ using namespace ::chip; using namespace ::chip::app::Clusters; -void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type, - uint16_t size, uint8_t * value) +void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, + uint8_t * value) { ClusterId clusterId = attributePath.mClusterId; AttributeId attributeId = attributePath.mAttributeId; diff --git a/src/platform/mt793x/BLEManagerImpl.cpp b/src/platform/mt793x/BLEManagerImpl.cpp index bdb16361277e31..a688807c2978c0 100644 --- a/src/platform/mt793x/BLEManagerImpl.cpp +++ b/src/platform/mt793x/BLEManagerImpl.cpp @@ -28,6 +28,7 @@ #undef BT_ENABLE_HCI_SNOOP_LOG +#include #include #include "FreeRTOS.h" @@ -328,8 +329,11 @@ bool BLEManagerImpl::CloseConnection(BLE_CONNECTION_OBJECT conId) uint16_t BLEManagerImpl::GetMTU(BLE_CONNECTION_OBJECT conId) const { - ChipLogProgress(DeviceLayer, "GetMTU (con %u), returning 247", conId); - return 247; + uint16_t mtu = (uint16_t) bt_gattc_get_mtu(conId); + + ChipLogProgress(DeviceLayer, "GetMTU (con %u), returning %u", conId, mtu); + + return mtu; } #define INDICATION_BUFFER_LENGTH (300) @@ -543,8 +547,11 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) if (!mFlags.Has(Flags::kDeviceNameSet)) { + uint16_t discriminator = 0; + err = GetCommissionableDataProvider()->GetSetupDiscriminator(discriminator); + snprintf(gatts_device_name, sizeof(gatts_device_name), "%s%04" PRIX32, CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, - (uint32_t) 0); + static_cast(discriminator)); gatts_device_name[kMaxDeviceNameLength] = 0; } diff --git a/src/platform/mt793x/ConnectivityManagerImpl_WIFI.cpp b/src/platform/mt793x/ConnectivityManagerImpl_WIFI.cpp index 24bd2f65a6717a..7b9ad8194d15d9 100644 --- a/src/platform/mt793x/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/mt793x/ConnectivityManagerImpl_WIFI.cpp @@ -31,6 +31,8 @@ #include #include +#include "mdns.h" + #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE #include #endif @@ -111,6 +113,15 @@ void ConnectivityManagerImpl::_OnWiFiPlatformEvent(const ChipDeviceEvent * event { ChipLogProgress(DeviceLayer, "%s", __func__); + if (event->Type == DeviceEventType::kInternetConnectivityChange) + { + if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established || + event->InternetConnectivityChange.IPv6 == kConnectivity_Established) + { + mdns_update_interface(); + } + } + if (event->Type != DeviceEventType::kMtkWiFiEvent) return; diff --git a/src/platform/mt793x/MT793XConfig.cpp b/src/platform/mt793x/MT793XConfig.cpp index 2d9efe1d4cf6fd..add3d95c013b81 100644 --- a/src/platform/mt793x/MT793XConfig.cpp +++ b/src/platform/mt793x/MT793XConfig.cpp @@ -22,8 +22,11 @@ * platforms based on the MediaTek SDK. */ /* this file behaves like a config.h, comes first */ +#include + #include +#include #include #include @@ -147,9 +150,24 @@ CHIP_ERROR MT793XConfig::ReadConfigValue(Key key, uint32_t & val) err = CHIP_ERROR_TIMEOUT; SuccessOrExit(err); } - // Get NVDM item - err = MapNvdmStatus(nvdm_read_data_item(key.Namespace, key.Name, (uint8_t *) &val, &len)); - SuccessOrExit(err); + + if (key.Namespace == MT793XConfig::kConfigKey_SetupDiscriminator.Namespace && + key.Name == MT793XConfig::kConfigKey_SetupDiscriminator.Name) + { + uint8_t mac_addr[WIFI_MAC_ADDRESS_LENGTH] = { 0 }; + auto mFilogicCtx = PlatformMgrImpl().mFilogicCtx; + + filogic_wifi_mac_addr_get_sync(mFilogicCtx, FILOGIC_WIFI_OPMODE_STA, mac_addr); + + val = (*(reinterpret_cast(mac_addr))) & 0xFFF; + err = CHIP_NO_ERROR; + } + else + { + // Get NVDM item + err = MapNvdmStatus(nvdm_read_data_item(key.Namespace, key.Name, (uint8_t *) &val, &len)); + SuccessOrExit(err); + } exit: OnExit(); return err; diff --git a/third_party/mt793x_sdk/filogic b/third_party/mt793x_sdk/filogic index 1201e7af8b4a2d..1d914894748858 160000 --- a/third_party/mt793x_sdk/filogic +++ b/third_party/mt793x_sdk/filogic @@ -1 +1 @@ -Subproject commit 1201e7af8b4a2d32c2b55bb98b76dd212a2e519e +Subproject commit 1d91489474885849967971a59eb2d6129c6977d5 diff --git a/third_party/mt793x_sdk/lwip b/third_party/mt793x_sdk/lwip index e9c4e9089e0390..23edc18878f11b 160000 --- a/third_party/mt793x_sdk/lwip +++ b/third_party/mt793x_sdk/lwip @@ -1 +1 @@ -Subproject commit e9c4e9089e0390770795543f33942b247dfeed51 +Subproject commit 23edc18878f11bbf93ec598bf19ede52e7328a4f