Skip to content

Commit

Permalink
Add Network Commissioning cluster setup for bridge app Linux (#23906)
Browse files Browse the repository at this point in the history
Based on change #16222, the bridge app on Linux need support WiFi
network for commissioning.

Signed-off-by: Haoran Wang <[email protected]>

Signed-off-by: Haoran Wang <[email protected]>
  • Loading branch information
TE-N-ElvenWang authored and pull[bot] committed Oct 12, 2023
1 parent 67db1bd commit 1080760
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion examples/bridge-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <app/ConcreteAttributePath.h>
#include <app/EventLogging.h>
#include <app/chip-zcl-zpro-codec.h>
#include <app/clusters/network-commissioning/network-commissioning.h>
#include <app/reporting/reporting.h>
#include <app/util/af-types.h>
#include <app/util/af.h>
Expand All @@ -38,6 +39,7 @@
#include <lib/support/CHIPMem.h>
#include <lib/support/ZclString.h>
#include <platform/CommissionableDataProvider.h>
#include <platform/Linux/NetworkCommissioningDriver.h>
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
#include <setup_payload/SetupPayload.h>

Expand All @@ -54,6 +56,7 @@
#include <vector>

using namespace chip;
using namespace chip::app;
using namespace chip::Credentials;
using namespace chip::Inet;
using namespace chip::Transport;
Expand All @@ -71,6 +74,10 @@ EndpointId gFirstDynamicEndpointId;
Device * gDevices[CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT];
std::vector<Room *> gRooms;
std::vector<Action *> gActions;
#if defined(CHIP_DEVICE_CONFIG_ENABLE_WIFI) && defined(CHIP_DEVICE_LAYER_TARGET_LINUX)
DeviceLayer::NetworkCommissioning::LinuxWiFiDriver sLinuxWiFiDriver;
Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0, &sLinuxWiFiDriver);
#endif

const int16_t minMeasuredValue = -27315;
const int16_t maxMeasuredValue = 32766;
Expand Down Expand Up @@ -719,7 +726,12 @@ bool emberAfActionsClusterInstantActionCallback(app::CommandHandler * commandObj
return true;
}

void ApplicationInit() {}
void ApplicationInit()
{
#if defined(CHIP_DEVICE_CONFIG_ENABLE_WIFI) && defined(CHIP_DEVICE_LAYER_TARGET_LINUX)
sWiFiNetworkCommissioningInstance.Init();
#endif
}

const EmberAfDeviceType gBridgedOnOffDeviceTypes[] = { { DEVICE_TYPE_LO_ON_OFF_LIGHT, DEVICE_VERSION_DEFAULT },
{ DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } };
Expand Down Expand Up @@ -995,6 +1007,7 @@ int main(int argc, char * argv[])

// Run CHIP

ApplicationInit();
chip::DeviceLayer::PlatformMgr().RunEventLoop();

return 0;
Expand Down

0 comments on commit 1080760

Please sign in to comment.