Skip to content

Commit

Permalink
Set up a network commissioning cluster in linux lock-app. (#17663)
Browse files Browse the repository at this point in the history
* Set up a network commissioning cluster in linux lock-app.

If we have thread or wifi, use them to set up a network commissioning
cluster.

* Address review comments
  • Loading branch information
bzbarsky-apple authored Apr 25, 2022
1 parent 5ecc0b3 commit 736f4b3
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion examples/lock-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,46 @@
*/

#include "AppMain.h"
#include <app/clusters/network-commissioning/network-commissioning.h>
#include <platform/Linux/NetworkCommissioningDriver.h>

void ApplicationInit() {}
using namespace chip;
using namespace chip::app;

namespace {
// We support either thread or wi-fi commissioning, not both. Prefer thread if
// both are available.
#if CHIP_DEVICE_LAYER_TARGET_LINUX && CHIP_DEVICE_CONFIG_ENABLE_THREAD
DeviceLayer::NetworkCommissioning::LinuxThreadDriver sNetworkCommissioningDriver;
Clusters::NetworkCommissioning::Instance sNetworkCommissioningInstance(0, &sNetworkCommissioningDriver);

void InitNetworkCommissioning()
{
sNetworkCommissioningInstance.Init();
}

#elif CHIP_DEVICE_CONFIG_ENABLE_WPA

DeviceLayer::NetworkCommissioning::LinuxWiFiDriver sNetworkCommissioningDriver;
Clusters::NetworkCommissioning::Instance sNetworkCommissioningInstance(0, &sNetworkCommissioningDriver);

void InitNetworkCommissioning()
{
sNetworkCommissioningInstance.Init();
}

#else // !CHIP_DEVICE_CONFIG_ENABLE_WPA && !(CHIP_DEVICE_LAYER_TARGET_LINUX && CHIP_DEVICE_CONFIG_ENABLE_THREAD)

void InitNetworkCommissioning() {}

#endif // (CHIP_DEVICE_LAYER_TARGET_LINUX && CHIP_DEVICE_CONFIG_ENABLE_THREAD) || CHIP_DEVICE_CONFIG_ENABLE_WPA

} // anonymous namespace

void ApplicationInit()
{
InitNetworkCommissioning();
}

int main(int argc, char * argv[])
{
Expand Down

0 comments on commit 736f4b3

Please sign in to comment.