Skip to content

Commit

Permalink
Adding config checks for fucntions specific to only wifi and thread i…
Browse files Browse the repository at this point in the history
…n NetworkCommissioning
  • Loading branch information
shripad621git committed May 2, 2024
1 parent f6b3594 commit 4e9dbc7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/app/clusters/network-commissioning/network-commissioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,21 @@ void Instance::InvokeCommand(HandlerContext & ctxt)
ctxt, [this](HandlerContext & ctx, const auto & req) { HandleScanNetworks(ctx, req); });
return;

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP
case Commands::AddOrUpdateWiFiNetwork::Id:
VerifyOrReturn(mFeatureFlags.Has(Feature::kWiFiNetworkInterface));
HandleCommand<Commands::AddOrUpdateWiFiNetwork::DecodableType>(
ctxt, [this](HandlerContext & ctx, const auto & req) { HandleAddOrUpdateWiFiNetwork(ctx, req); });
return;
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
case Commands::AddOrUpdateThreadNetwork::Id:
VerifyOrReturn(mFeatureFlags.Has(Feature::kThreadNetworkInterface));
HandleCommand<Commands::AddOrUpdateThreadNetwork::DecodableType>(
ctxt, [this](HandlerContext & ctx, const auto & req) { HandleAddOrUpdateThreadNetwork(ctx, req); });
return;
#endif

case Commands::RemoveNetwork::Id:
VerifyOrReturn(mFeatureFlags.Has(Feature::kWiFiNetworkInterface) || mFeatureFlags.Has(Feature::kThreadNetworkInterface));
Expand Down Expand Up @@ -543,6 +547,7 @@ bool CheckFailSafeArmed(CommandHandlerInterface::HandlerContext & ctx)

} // namespace

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP
void Instance::HandleAddOrUpdateWiFiNetwork(HandlerContext & ctx, const Commands::AddOrUpdateWiFiNetwork::DecodableType & req)
{
MATTER_TRACE_SCOPE("HandleAddOrUpdateWiFiNetwork", "NetworkCommissioning");
Expand Down Expand Up @@ -618,6 +623,7 @@ void Instance::HandleAddOrUpdateWiFiNetwork(HandlerContext & ctx, const Commands
ReportNetworksListChanged();
}
}
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC
void Instance::HandleAddOrUpdateWiFiNetworkWithPDC(HandlerContext & ctx,
Expand Down Expand Up @@ -725,6 +731,7 @@ void Instance::HandleAddOrUpdateWiFiNetworkWithPDC(HandlerContext & ctx,
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
void Instance::HandleAddOrUpdateThreadNetwork(HandlerContext & ctx, const Commands::AddOrUpdateThreadNetwork::DecodableType & req)
{
MATTER_TRACE_SCOPE("HandleAddOrUpdateThreadNetwork", "NetworkCommissioning");
Expand All @@ -745,6 +752,7 @@ void Instance::HandleAddOrUpdateThreadNetwork(HandlerContext & ctx, const Comman
UpdateBreadcrumb(req.breadcrumb);
}
}
#endif

void Instance::UpdateBreadcrumb(const Optional<uint64_t> & breadcrumb)
{
Expand Down Expand Up @@ -977,6 +985,7 @@ void Instance::OnResult(Status commissioningError, CharSpan debugText, int32_t i
}
}

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
void Instance::OnFinished(Status status, CharSpan debugText, ThreadScanResponseIterator * networks)
{
CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -1090,7 +1099,9 @@ void Instance::OnFinished(Status status, CharSpan debugText, ThreadScanResponseI
}
networks->Release();
}
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP
void Instance::OnFinished(Status status, CharSpan debugText, WiFiScanResponseIterator * networks)
{
CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -1170,6 +1181,7 @@ void Instance::OnFinished(Status status, CharSpan debugText, WiFiScanResponseIte
networks->Release();
}
}
#endif

void Instance::OnPlatformEventHandler(const DeviceLayer::ChipDeviceEvent * event, intptr_t arg)
{
Expand Down
12 changes: 12 additions & 0 deletions src/app/clusters/network-commissioning/network-commissioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,17 @@ class Instance : public CommandHandlerInterface,
void OnResult(DeviceLayer::NetworkCommissioning::Status commissioningError, CharSpan errorText,
int32_t interfaceStatus) override;

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP
// WiFiDriver::ScanCallback
void OnFinished(DeviceLayer::NetworkCommissioning::Status err, CharSpan debugText,
DeviceLayer::NetworkCommissioning::WiFiScanResponseIterator * networks) override;
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
// ThreadDriver::ScanCallback
void OnFinished(DeviceLayer::NetworkCommissioning::Status err, CharSpan debugText,
DeviceLayer::NetworkCommissioning::ThreadScanResponseIterator * networks) override;
#endif

private:
static void OnPlatformEventHandler(const DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
Expand Down Expand Up @@ -120,9 +124,17 @@ class Instance : public CommandHandlerInterface,

// Actual handlers of the commands
void HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetworks::DecodableType & req);

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP
void HandleAddOrUpdateWiFiNetwork(HandlerContext & ctx, const Commands::AddOrUpdateWiFiNetwork::DecodableType & req);
#endif

void HandleAddOrUpdateWiFiNetworkWithPDC(HandlerContext & ctx, const Commands::AddOrUpdateWiFiNetwork::DecodableType & req);

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
void HandleAddOrUpdateThreadNetwork(HandlerContext & ctx, const Commands::AddOrUpdateThreadNetwork::DecodableType & req);
#endif

void HandleRemoveNetwork(HandlerContext & ctx, const Commands::RemoveNetwork::DecodableType & req);
void HandleConnectNetwork(HandlerContext & ctx, const Commands::ConnectNetwork::DecodableType & req);
void HandleReorderNetwork(HandlerContext & ctx, const Commands::ReorderNetwork::DecodableType & req);
Expand Down
4 changes: 4 additions & 0 deletions src/include/platform/NetworkCommissioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ class WiFiDriver : public Internal::WirelessDriver
* iterator might be not fully consumed (i.e. There are too many networks scanned to fit in the buffer for scan response
* message.)
*/
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP
virtual void OnFinished(Status status, CharSpan debugText, WiFiScanResponseIterator * networks) = 0;
#endif

virtual ~ScanCallback() = default;
};
Expand Down Expand Up @@ -398,7 +400,9 @@ class ThreadDriver : public Internal::WirelessDriver
* iterator might be not fully consumed (i.e. There are too many networks scanned to fit in the buffer for scan response
* message.)
*/
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
virtual void OnFinished(Status err, CharSpan debugText, ThreadScanResponseIterator * networks) = 0;
#endif

virtual ~ScanCallback() = default;
};
Expand Down

0 comments on commit 4e9dbc7

Please sign in to comment.