Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the server to organize as a class #9200

Merged
merged 9 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/all-clusters-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class SetupListModel : public ListScreen::Model
if (i == 0)
{
ConnectivityMgr().ClearWiFiStationProvision();
OpenBasicCommissioningWindow(ResetFabrics::kYes);
chip::Server::GetInstance().GetCommissionManager().OpenBasicCommissioningWindow(ResetFabrics::kYes);
}
else if (i == 1)
{
Expand All @@ -355,7 +355,8 @@ class SetupListModel : public ListScreen::Model
else if (i == 2)
{
app::Mdns::AdvertiseCommissionableNode(app::Mdns::CommissioningMode::kEnabledBasic);
OpenBasicCommissioningWindow(ResetFabrics::kYes, kNoCommissioningTimeout, PairingWindowAdvertisement::kMdns);
chip::Server::GetInstance().GetCommissionManager().OpenBasicCommissioningWindow(
ResetFabrics::kYes, kNoCommissioningTimeout, CommissioningWindowAdvertisement::kMdns);
}
}

Expand Down Expand Up @@ -627,7 +628,7 @@ extern "C" void app_main()

// Init ZCL Data Model and CHIP App Server
AppCallbacks callbacks;
InitServer(&callbacks);
gjc13 marked this conversation as resolved.
Show resolved Hide resolved
chip::Server::GetInstance().Init(&callbacks);

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down
2 changes: 1 addition & 1 deletion examples/bridge-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ extern "C" void app_main()
return;
}

InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down
2 changes: 1 addition & 1 deletion examples/bridge-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ int main(int argc, char * argv[])
chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(true);

// Init ZCL Data Model and CHIP App Server
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ CHIP_ERROR AppTask::Init()
CHIP_ERROR err = CHIP_NO_ERROR;

// Init ZCL Data Model
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down
5 changes: 3 additions & 2 deletions examples/lighting-app/k32w/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ CHIP_ERROR AppTask::Init()
CHIP_ERROR err = CHIP_NO_ERROR;

// Init ZCL Data Model and start server
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down Expand Up @@ -489,7 +489,8 @@ void AppTask::BleHandler(AppEvent * aEvent)
{
ConnectivityMgr().SetBLEAdvertisingEnabled(true);

if (OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) == CHIP_NO_ERROR)
if (chip::Server::GetInstance().GetCommissionManager().OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) ==
CHIP_NO_ERROR)
{
K32W_LOG("Started BLE Advertising!");
}
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ target_sources(${APP_TARGET} PRIVATE
${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp
${CHIP_ROOT}/src/app/server/RendezvousServer.cpp
${CHIP_ROOT}/src/app/server/Server.cpp
${CHIP_ROOT}/src/app/server/CommissionManager.cpp
${CHIP_ROOT}/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/mbed/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int AppTask::Init()
chip::DeviceLayer::ConnectivityMgrImpl().StartWiFiManagement();

// Init ZCL Data Model and start server
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ target_sources(app PRIVATE
${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp
${CHIP_ROOT}/src/app/server/RendezvousServer.cpp
${CHIP_ROOT}/src/app/server/Server.cpp
${CHIP_ROOT}/src/app/server/CommissionManager.cpp
${CHIP_ROOT}/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
Expand Down
6 changes: 3 additions & 3 deletions examples/lighting-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int AppTask::Init()
LightingMgr().SetCallbacks(ActionInitiated, ActionCompleted);

// Init ZCL Data Model and start server
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down Expand Up @@ -352,7 +352,7 @@ void AppTask::StartThreadHandler(AppEvent * aEvent)
if (aEvent->ButtonEvent.PinNo != THREAD_START_BUTTON)
return;

if (AddTestCommissioning() != CHIP_NO_ERROR)
if (chip::Server::GetInstance().AddTestCommissioning() != CHIP_NO_ERROR)
{
LOG_ERR("Failed to add test pairing");
}
Expand Down Expand Up @@ -386,7 +386,7 @@ void AppTask::StartBLEAdvertisementHandler(AppEvent * aEvent)
return;
}

if (OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) != CHIP_NO_ERROR)
if (chip::Server::GetInstance().GetCommissionManager().OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) != CHIP_NO_ERROR)
{
LOG_ERR("OpenBasicCommissioningWindow() failed");
}
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/qpg/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ CHIP_ERROR AppTask::Init()
qvCHIP_SetBtnCallback(ButtonEventHandler);

// Init ZCL Data Model
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand All @@ -111,7 +111,7 @@ CHIP_ERROR AppTask::Init()
PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE));

// Enable BLE advertisements
OpenBasicCommissioningWindow(chip::ResetFabrics::kNo);
chip::Server::GetInstance().GetCommissionManager().OpenBasicCommissioningWindow(chip::ResetFabrics::kNo);
ChipLogProgress(NotSpecified, "BLE advertising started. Waiting for Pairing.");

return err;
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ target_sources(app PRIVATE
${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp
${CHIP_ROOT}/src/app/server/RendezvousServer.cpp
${CHIP_ROOT}/src/app/server/Server.cpp
${CHIP_ROOT}/src/app/server/CommissionManager.cpp
${CHIP_ROOT}/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ CHIP_ERROR AppTask::Init()
LightingMgr().SetCallbacks(ActionInitiated, ActionCompleted);

// Init ZCL Data Model and start server
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());

ConfigurationMgr().LogDeviceConfig();
PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE));

ret = AddTestCommissioning();
ret = chip::Server::GetInstance().AddTestCommissioning();
if (ret != CHIP_NO_ERROR)
{
LOG_ERR("Failed to add test pairing");
Expand Down
5 changes: 3 additions & 2 deletions examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ int AppTask::Init()

// Init ZCL Data Model and start server
PLAT_LOG("Initialize Server");
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down Expand Up @@ -333,7 +333,8 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
// Enable BLE advertisements
if (!ConnectivityMgr().IsBLEAdvertisingEnabled())
{
if (OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) == CHIP_NO_ERROR)
if (chip::Server::GetInstance().GetCommissionManager().OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) ==
CHIP_NO_ERROR)
{
PLAT_LOG("Enabled BLE Advertisement");
}
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ CHIP_ERROR AppTask::StartAppTask()
CHIP_ERROR AppTask::Init()
{
// Init ZCL Data Model
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extern "C" void app_main()
return;
}

InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down
5 changes: 3 additions & 2 deletions examples/lock-app/k32w/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ CHIP_ERROR AppTask::Init()
CHIP_ERROR err = CHIP_NO_ERROR;

// Init ZCL Data Model and start server
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down Expand Up @@ -528,7 +528,8 @@ void AppTask::BleHandler(void * aGenericEvent)
{
ConnectivityMgr().SetBLEAdvertisingEnabled(true);

if (OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) == CHIP_NO_ERROR)
if (chip::Server::GetInstance().GetCommissionManager().OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) ==
CHIP_NO_ERROR)
{
K32W_LOG("Started BLE Advertising!");
}
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ target_sources(${APP_TARGET} PRIVATE
${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp
${CHIP_ROOT}/src/app/server/RendezvousServer.cpp
${CHIP_ROOT}/src/app/server/Server.cpp
${CHIP_ROOT}/src/app/server/CommissionManager.cpp
${CHIP_ROOT}/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/mbed/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int AppTask::Init()
chip::DeviceLayer::ConnectivityMgrImpl().StartWiFiManagement();

// Init ZCL Data Model and start server
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ target_sources(app PRIVATE
${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp
${CHIP_ROOT}/src/app/server/RendezvousServer.cpp
${CHIP_ROOT}/src/app/server/Server.cpp
${CHIP_ROOT}/src/app/server/CommissionManager.cpp
${CHIP_ROOT}/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
Expand Down
6 changes: 3 additions & 3 deletions examples/lock-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int AppTask::Init()
BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted);

// Init ZCL Data Model and start server
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down Expand Up @@ -352,7 +352,7 @@ void AppTask::StartThreadHandler(AppEvent * aEvent)
if (aEvent->ButtonEvent.PinNo != THREAD_START_BUTTON)
return;

if (AddTestCommissioning() != CHIP_NO_ERROR)
if (chip::Server::GetInstance().AddTestCommissioning() != CHIP_NO_ERROR)
{
LOG_ERR("Failed to add test pairing");
}
Expand Down Expand Up @@ -386,7 +386,7 @@ void AppTask::StartBLEAdvertisementHandler(AppEvent * aEvent)
return;
}

if (OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) != CHIP_NO_ERROR)
if (chip::Server::GetInstance().GetCommissionManager().OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) != CHIP_NO_ERROR)
{
LOG_ERR("OpenBasicCommissioningWindow() failed");
}
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/p6/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ CHIP_ERROR AppTask::Init()
},
0);
// Init ZCL Data Model
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down
5 changes: 3 additions & 2 deletions examples/lock-app/qpg/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ CHIP_ERROR AppTask::Init()
qvCHIP_LedSet(LOCK_STATE_LED, !BoltLockMgr().IsUnlocked());

// Init ZCL Data Model
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down Expand Up @@ -350,7 +350,8 @@ void AppTask::FunctionHandler(AppEvent * aEvent)
if (!ConnectivityMgr().IsThreadProvisioned())
{
// Enable BLE advertisements and pairing window
if (OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) == CHIP_NO_ERROR)
if (chip::Server::GetInstance().GetCommissionManager().OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) ==
CHIP_NO_ERROR)
{
ChipLogProgress(NotSpecified, "BLE advertising started. Waiting for Pairing.");
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ota-provider-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ int main(int argc, char * argv[])
}

chip::DeviceLayer::ConfigurationMgr().LogDeviceConfig();
InitServer();
chip::Server::GetInstance().Init();

exchangeMgr = chip::ExchangeManager();
err = exchangeMgr->RegisterUnsolicitedMessageHandlerForProtocol(chip::Protocols::BDX::Id, &bdxServer);
Expand Down
10 changes: 5 additions & 5 deletions examples/platform/linux/AppMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,17 @@ void ChipLinuxAppMainLoop()
std::thread shellThread([]() { Engine::Root().RunMainLoop(); });
chip::Shell::RegisterCommissioneeCommands();
#endif
uint16_t securePort = CHIP_PORT;
uint16_t unsecurePort = CHIP_UDC_PORT;

#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
// use a different service port to make testing possible with other sample devices running on same host
ServerConfigParams params;
params.securedServicePort = LinuxDeviceOptions::GetInstance().securedDevicePort;
params.unsecuredServicePort = LinuxDeviceOptions::GetInstance().unsecuredCommissionerPort;
SetServerConfig(params);
securePort = LinuxDeviceOptions::GetInstance().securedDevicePort;
unsecurePort = LinuxDeviceOptions::GetInstance().unsecuredCommissionerPort;
#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE

// Init ZCL Data Model and CHIP App Server
InitServer();
chip::Server::GetInstance().Init(nullptr, securePort, unsecurePort);

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/linux/CommissioneeShellCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static CHIP_ERROR SendUDC(bool printHeader, chip::Transport::PeerAddress commiss
streamer_printf(sout, "SendUDC: ");
}

SendUserDirectedCommissioningRequest(commissioner);
Server::GetInstance().SendUserDirectedCommissioningRequest(commissioner);

streamer_printf(sout, "done\r\n");

Expand Down
5 changes: 3 additions & 2 deletions examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int AppTask::Init()

// Init ZCL Data Model and start server
PLAT_LOG("Initialize Server");
InitServer();
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down Expand Up @@ -335,7 +335,8 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
// Enable BLE advertisements
if (!ConnectivityMgr().IsBLEAdvertisingEnabled())
{
if (OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) == CHIP_NO_ERROR)
if (chip::Server::GetInstance().GetCommissionManager().OpenBasicCommissioningWindow(chip::ResetFabrics::kNo) ==
CHIP_NO_ERROR)
{
PLAT_LOG("Enabled BLE Advertisement");
}
Expand Down
1 change: 1 addition & 0 deletions examples/pump-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ target_sources(app PRIVATE
${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp
${CHIP_ROOT}/src/app/server/RendezvousServer.cpp
${CHIP_ROOT}/src/app/server/Server.cpp
${CHIP_ROOT}/src/app/server/CommissionManager.cpp
${CHIP_ROOT}/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
Expand Down
Loading