Skip to content

Commit

Permalink
make BindingManager instance optional
Browse files Browse the repository at this point in the history
  • Loading branch information
gjc13 committed Jan 20, 2022
1 parent 3a752b8 commit 9ad1478
Show file tree
Hide file tree
Showing 6 changed files with 759 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ using chip::Shell::streamer_printf;
#endif // defined(ENABLE_CHIP_SHELL)

static bool sSwitchOnOffState = false;
static chip::BindingManager sBindingManager;

#if defined(ENABLE_CHIP_SHELL)
static void ToggleSwitchOnOff(bool newState)
{
sSwitchOnOffState = newState;
chip::BindingManager::GetInstance().NotifyBoundClusterChanged(1, chip::app::Clusters::OnOff::Id, nullptr);
chip::GetBindingManagerInstance()->NotifyBoundClusterChanged(1, chip::app::Clusters::OnOff::Id, nullptr);
}

static CHIP_ERROR SwitchCommandHandler(int argc, char ** argv)
Expand Down Expand Up @@ -104,8 +105,9 @@ static void BoundDeviceChangedHandler(const EmberBindingTableEntry * binding, ch

CHIP_ERROR InitBindingHandlers()
{
chip::BindingManager::GetInstance().SetAppServer(&chip::Server::GetInstance());
chip::BindingManager::GetInstance().RegisterBoundDeviceChangedHandler(BoundDeviceChangedHandler);
sBindingManager.SetAppServer(&chip::Server::GetInstance());
sBindingManager.RegisterBoundDeviceChangedHandler(BoundDeviceChangedHandler);
chip::SetBindingManagerInstance(&sBindingManager);
#if defined(ENABLE_CHIP_SHELL)
RegisterSwitchCommands();
#endif
Expand Down
Loading

0 comments on commit 9ad1478

Please sign in to comment.