Skip to content

Commit

Permalink
[NXP][third_party] Border router updates and fixes (project-chip#36118)
Browse files Browse the repository at this point in the history
* [NXP][third_party] Border router updates and fixes

Fixed selecting correct DnsSd implementation when Border Router is enabled.
Fix an issue with the SRP client starting even when the device is running
in Border Router mode.
Removed ChipDnssdShutdown function, there is no use for it.
Removed unused OpenThread define.

Signed-off-by: Marius Preda <[email protected]>

* Restyled by clang-format

---------

Signed-off-by: Marius Preda <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
marius-preda and restyled-commits authored Oct 17, 2024
1 parent d5886bc commit 190c5c8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,16 @@ void chip::NXP::App::CommonDeviceCallbacks::DeviceEventCallback(const ChipDevice
case DeviceEventType::kCommissioningComplete:
CommonDeviceCallbacks::OnComissioningComplete(event);
break;
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_WPA
case DeviceEventType::kThreadConnectivityChange:
if (!ConnectivityMgr().IsWiFiStationConnected() && (event->ThreadConnectivityChange.Result == kConnectivity_Established))
{
// Restart DnsSd service when operating as Matter over Thread
chip::app::DnssdServer::Instance().StartServer();
}
break;
#endif // CHIP_DEVICE_CONFIG_ENABLE_WPA
#endif // CHIP_ENABLE_OPENTHREAD
case DeviceLayer::DeviceEventType::kDnssdInitialized:
ChipLogProgress(DeviceLayer, "kDnssdInitialized");
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
Expand Down Expand Up @@ -158,20 +167,13 @@ void chip::NXP::App::CommonDeviceCallbacks::OnSessionEstablished(chip::DeviceLay
#if CHIP_ENABLE_OPENTHREAD
void chip::NXP::App::CommonDeviceCallbacks::OnComissioningComplete(const chip::DeviceLayer::ChipDeviceEvent * event)
{
#ifndef _NO_GENERIC_THREAD_NETWORK_COMMISSIONING_DRIVER_
#if CHIP_DEVICE_CONFIG_ENABLE_WPA
if (ConnectivityMgr().IsWiFiStationConnected())
{
// Disable thr nwk commissioining cluster
app::Clusters::NetworkCommissioning::Attributes::InterfaceEnabled::Set(CHIP_DEVICE_CONFIG_THREAD_NETWORK_ENDPOINT_ID, 0);
}
else if (ConnectivityMgr().IsThreadProvisioned())
if (!ConnectivityMgr().IsWiFiStationConnected() && ConnectivityMgr().IsThreadProvisioned())
{
// Set WIFI cluster interface attribute to disable.
app::Clusters::NetworkCommissioning::Attributes::InterfaceEnabled::Set(0, 0);
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_WPA
#endif // _NO_GENERIC_THREAD_NETWORK_COMMISSIONING_DRIVER_

#if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED
/*
Expand Down
16 changes: 13 additions & 3 deletions src/platform/nxp/common/DnssdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,25 @@ namespace Dnssd {

CHIP_ERROR ChipDnssdInit(DnssdAsyncReturnCallback initCallback, DnssdAsyncReturnCallback errorCallback, void * context)
{
NxpChipDnssdInit(initCallback, errorCallback, context);
OpenThreadDnssdInit(initCallback, errorCallback, context);
if (ConnectivityMgr().IsWiFiStationConnected())
{
ReturnErrorOnFailure(NxpChipDnssdInit(initCallback, errorCallback, context));
}
else if (ConnectivityMgr().IsThreadProvisioned())
{
ReturnErrorOnFailure(OpenThreadDnssdInit(initCallback, errorCallback, context));
}
else
{
initCallback(context, CHIP_ERROR_INCORRECT_STATE);
}

return CHIP_NO_ERROR;
}

void ChipDnssdShutdown()
{
NxpChipDnssdShutdown();
// Empty implementation. Intentionally left blank
}

CHIP_ERROR ChipDnssdPublishService(const DnssdService * service, DnssdPublishCallback callback, void * context)
Expand Down
14 changes: 4 additions & 10 deletions src/platform/nxp/common/DnssdImplBr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,17 @@ static uint32_t mServiceListFreeIndex;

CHIP_ERROR NxpChipDnssdInit(DnssdAsyncReturnCallback initCallback, DnssdAsyncReturnCallback errorCallback, void * context)
{
CHIP_ERROR error = CHIP_NO_ERROR;
otInstance * thrInstancePtr = ThreadStackMgrImpl().OTInstance();
struct netif * extNetif = (ConnectivityManagerImpl().GetExternalInterface()).GetPlatformInterface();

// Don't try to do anything until the mDNS server is started
VerifyOrExit(otMdnsIsEnabled(thrInstancePtr), error = CHIP_ERROR_INCORRECT_STATE);
struct netif * extNetif = (ConnectivityManagerImpl().GetExternalInterface()).GetPlatformInterface();

mNetifIndex = netif_get_index(extNetif);
initCallback(context, CHIP_NO_ERROR);

exit:
initCallback(context, error);
return error;
return CHIP_NO_ERROR;
}

void NxpChipDnssdShutdown()
{
otMdnsSetEnabled(ThreadStackMgrImpl().OTInstance(), false, 0);
// Empty implementation. Intentionally left blank
}
#if USE_MDNS_NEXT_SERVICE_API
CHIP_ERROR NxpChipDnssdRemoveServices()
Expand Down
1 change: 0 additions & 1 deletion src/platform/nxp/rt/rw61x/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ static_library("nxp_platform") {
if (chip_mdns == "platform") {
if (chip_enable_wifi) {
sources += [
"../../../OpenThread/DnssdImpl.cpp",
"../../../OpenThread/OpenThreadDnssdImpl.cpp",
"../../../OpenThread/OpenThreadDnssdImpl.h",
"../../common/DnssdImpl.cpp",
Expand Down
1 change: 0 additions & 1 deletion third_party/openthread/platforms/nxp/rt/rw61x/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ config("openthread_rw61x_config") {
"OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1",
"OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE=1",
"OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE=1",
"OPENTHREAD_CONFIG_GENERIC_TASKLET_ENABLE=1",
"OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE=1",
"OPENTHREAD_CONFIG_DNSSD_DISCOVERY_PROXY_ENABLE=1",
"OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE=1",
Expand Down

0 comments on commit 190c5c8

Please sign in to comment.