Skip to content

Commit

Permalink
[genio] several bug fixes for multiple devices and interop (#22951)
Browse files Browse the repository at this point in the history
* 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 <anthony.liu@mediatek.com>
  • Loading branch information
2 people authored and pull[bot] committed Apr 3, 2023
1 parent 03290ab commit 5217425
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/lighting-app/genio/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 10 additions & 3 deletions src/platform/mt793x/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#undef BT_ENABLE_HCI_SNOOP_LOG

#include <platform/CommissionableDataProvider.h>
#include <platform/internal/BLEManager.h>

#include "FreeRTOS.h"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<uint32_t>(discriminator));

gatts_device_name[kMaxDeviceNameLength] = 0;
}
Expand Down
11 changes: 11 additions & 0 deletions src/platform/mt793x/ConnectivityManagerImpl_WIFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <lwip/nd6.h>
#include <lwip/netif.h>

#include "mdns.h"

#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
#include <platform/internal/GenericConnectivityManagerImpl_BLE.ipp>
#endif
Expand Down Expand Up @@ -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;

Expand Down
24 changes: 21 additions & 3 deletions src/platform/mt793x/MT793XConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
* platforms based on the MediaTek SDK.
*/
/* this file behaves like a config.h, comes first */
#include <functional>

#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <platform/PlatformManager.h>
#include <platform/mt793x/MT793XConfig.h>

#include <lib/core/CHIPEncoding.h>
Expand Down Expand Up @@ -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<uint32_t *>(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;
Expand Down
2 changes: 1 addition & 1 deletion third_party/mt793x_sdk/lwip

0 comments on commit 5217425

Please sign in to comment.