Skip to content

Commit

Permalink
Fix ethernet commissioning with Apple/Google Home
Browse files Browse the repository at this point in the history
  • Loading branch information
PSONALl committed Mar 28, 2023
1 parent 379cde1 commit 915edd7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/platform/esp32/common/Esp32AppServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ app::Clusters::NetworkCommissioning::Instance
sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::ESPWiFiDriver::GetInstance()));
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
static app::Clusters::NetworkCommissioning::Instance
sEthernetNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::ESPEthernetDriver::GetInstance()));
#endif

#if CONFIG_TEST_EVENT_TRIGGER_ENABLED
static uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb,
Expand Down Expand Up @@ -109,6 +114,9 @@ void Esp32AppServer::Init(AppDelegate * sAppDelegate)
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
sWiFiNetworkCommissioningInstance.Init();
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
sEthernetNetworkCommissioningInstance.Init();
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
if (chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned() &&
(chip::Server::GetInstance().GetFabricTable().FabricCount() != 0))
Expand Down
29 changes: 29 additions & 0 deletions src/platform/ESP32/NetworkCommissioningDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,35 @@ class ESPWiFiDriver final : public WiFiDriver
uint16_t mLastDisconnectedReason;
};

class ESPEthernetDriver final : public EthernetDriver
{
public:
class EthernetNetworkIterator final : public NetworkIterator
{
public:
EthernetNetworkIterator(ESPEthernetDriver * aDriver) : mDriver(aDriver) {}
size_t Count() { return 1; }
bool Next(Network & item) { return true; }
void Release() override { delete this; }
~EthernetNetworkIterator() = default;

private:
ESPEthernetDriver * mDriver;
};

// BaseDriver
NetworkIterator * GetNetworks() override { return new EthernetNetworkIterator(this); }
uint8_t GetMaxNetworks() { return 1; }
CHIP_ERROR Init(NetworkStatusChangeCallback * networkStatusChangeCallback) {return CHIP_NO_ERROR;}
void Shutdown() {}

static ESPEthernetDriver & GetInstance()
{
static ESPEthernetDriver instance;
return instance;
}
};

} // namespace NetworkCommissioning
} // namespace DeviceLayer
} // namespace chip

0 comments on commit 915edd7

Please sign in to comment.