From 53478987916edb80fba3f2ea97a9766c5aca56cf Mon Sep 17 00:00:00 2001 From: Youngho Yoon <34558998+yhoyoon@users.noreply.github.com> Date: Wed, 11 Oct 2023 04:53:04 +0900 Subject: [PATCH] Update bridge app to init network commissioning (#29612) * Update bridge app to init network commissioning This change modifies the linux bridge app to initialize the Network Commissioning cluster, so that the FeatureMap of the cluster is set to ethernet. In other Linux example apps, the FeatureMap of the Network Commissioning cluster is set to ethernet, but in the bridge app, the cluster is not initialized, so the FeatureMap is set to thread. The default value of the FeatureMap is thread in zap file of example apps. Signed-off-by: Youngho Yoon <34558998+yhoyoon@users.noreply.github.com> * Move the setup code into ApplicationInit Signed-off-by: Youngho Yoon <34558998+yhoyoon@users.noreply.github.com> --------- Signed-off-by: Youngho Yoon <34558998+yhoyoon@users.noreply.github.com> --- examples/bridge-app/linux/main.cpp | 40 ++++++++---------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index 3d73688594c5a9..f9edf960ded512 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -739,10 +739,6 @@ bool emberAfActionsClusterInstantActionCallback(app::CommandHandler * commandObj return true; } -void ApplicationInit() {} - -void ApplicationShutdown() {} - const EmberAfDeviceType gBridgedOnOffDeviceTypes[] = { { DEVICE_TYPE_LO_ON_OFF_LIGHT, DEVICE_VERSION_DEFAULT }, { DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } }; @@ -891,7 +887,7 @@ void * bridge_polling_thread(void * context) return nullptr; } -int main(int argc, char * argv[]) +void ApplicationInit() { // Clear out the device database memset(gDevices, 0, sizeof(gDevices)); @@ -934,26 +930,6 @@ int main(int argc, char * argv[]) ComposedTempSensor2.SetChangeCallback(&HandleDeviceTempSensorStatusChanged); ComposedPowerSource.SetChangeCallback(&HandleDevicePowerSourceStatusChanged); - if (ChipLinuxAppInit(argc, argv) != 0) - { - return -1; - } - - // Init Data Model and CHIP App Server - static chip::CommonCaseDeviceServerInitParams initParams; - (void) initParams.InitializeStaticResourcesBeforeServerInit(); - -#if CHIP_DEVICE_ENABLE_PORT_PARAMS - // use a different service port to make testing possible with other sample devices running on same host - initParams.operationalServicePort = LinuxDeviceOptions::GetInstance().securedDevicePort; -#endif - - initParams.interfaceId = LinuxDeviceOptions::GetInstance().interfaceId; - chip::Server::GetInstance().Init(initParams); - - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); - // Set starting endpoint id where dynamic endpoints will be assigned, which // will be the next consecutive endpoint id after the last fixed endpoint. gFirstDynamicEndpointId = static_cast( @@ -1022,11 +998,17 @@ int main(int argc, char * argv[]) } } - // Run CHIP - - ApplicationInit(); registerAttributeAccessOverride(&gPowerAttrAccess); - chip::DeviceLayer::PlatformMgr().RunEventLoop(); +} +void ApplicationShutdown() {} + +int main(int argc, char * argv[]) +{ + if (ChipLinuxAppInit(argc, argv) != 0) + { + return -1; + } + ChipLinuxAppMainLoop(); return 0; }