Skip to content

Commit

Permalink
Add Network Commissioning cluster setup for Linux apps (#16222)
Browse files Browse the repository at this point in the history
* Add Network Commissioning cluster setup for lighting app Linux

For issue #15261 the Linux lighting app failed to be commission by
chip-tool pairing ble-wifi command.
Based on the message in #14751, the Linux platform intented to support
WiFi network by default instead Thread.

This patch add Network Commissioning cluster setup for WiFi device for
lighting-app.

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

* Add Network Commissioning cluster setup for thermostat app Linux

For issue #15261 the Linux lighting app failed to be commission by
chip-tool pairing ble-wifi command.
Based on the message in #14751, the Linux platform intented to
support
WiFi network by default instead Thread.

This patch add Network Commissioning cluster setup for WiFi device for
thermostat-app.

Signed-off-by: Haoran Wang <[email protected]>
  • Loading branch information
TE-N-ElvenWang authored and pull[bot] committed May 19, 2022
1 parent 79f43d5 commit 1628036
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
17 changes: 16 additions & 1 deletion examples/lighting-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,25 @@
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/ConcreteAttributePath.h>
#include <app/clusters/network-commissioning/network-commissioning.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/Linux/NetworkCommissioningDriver.h>

#if defined(PW_RPC_ENABLED)
#include "Rpc.h"
#endif // PW_RPC_ENABLED

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;

#if CHIP_DEVICE_CONFIG_ENABLE_WPA
namespace {
DeviceLayer::NetworkCommissioning::LinuxWiFiDriver sLinuxWiFiDriver;
Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0, &sLinuxWiFiDriver);
} // namespace
#endif

void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type,
uint16_t size, uint8_t * value)
{
Expand Down Expand Up @@ -60,7 +70,12 @@ void emberAfOnOffClusterInitCallback(EndpointId endpoint)
// TODO: implement any additional Cluster Server init actions
}

void ApplicationInit() {}
void ApplicationInit()
{
#if CHIP_DEVICE_CONFIG_ENABLE_WPA
sWiFiNetworkCommissioningInstance.Init();
#endif
}

int main(int argc, char * argv[])
{
Expand Down
16 changes: 15 additions & 1 deletion examples/thermostat/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,21 @@
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/CommandHandler.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/clusters/network-commissioning/network-commissioning.h>
#include <app/util/af.h>
#include <platform/Linux/NetworkCommissioningDriver.h>

using namespace chip;
using namespace chip::app;
// using namespace chip::app::Clusters;

#if CHIP_DEVICE_CONFIG_ENABLE_WPA
namespace {
DeviceLayer::NetworkCommissioning::LinuxWiFiDriver sLinuxWiFiDriver;
Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0, &sLinuxWiFiDriver);
} // namespace
#endif

bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj)
{
emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS);
Expand Down Expand Up @@ -87,7 +96,12 @@ static Identify gIdentify1 = {
chip::EndpointId{ 1 }, OnIdentifyStart, OnIdentifyStop, EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, OnTriggerEffect,
};

void ApplicationInit() {}
void ApplicationInit()
{
#if CHIP_DEVICE_CONFIG_ENABLE_WPA
sWiFiNetworkCommissioningInstance.Init();
#endif
}

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

0 comments on commit 1628036

Please sign in to comment.