diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 426e3c686572c0..e4db190c507608 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -19,8 +19,10 @@ #include +#include #include #include +#include #include #include #include @@ -81,6 +83,33 @@ using chip::Transport::TcpListenParameters; namespace { +#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE +class DeviceTypeResolver : public chip::Access::AccessControl::DeviceTypeResolver +{ +public: + bool IsDeviceTypeOnEndpoint(chip::DeviceTypeId deviceType, chip::EndpointId endpoint) override + { + chip::app::DataModel::Provider * model = chip::app::InteractionModelEngine::GetInstance()->GetDataModelProvider(); + + for (auto type = model->FirstDeviceType(endpoint); type.has_value(); type = model->NextDeviceType(endpoint, *type)) + { + if (type->deviceTypeId == deviceType) + { +#if CHIP_CONFIG_USE_EMBER_DATA_MODEL + VerifyOrDie(chip::app::IsDeviceTypeOnEndpoint(deviceType, endpoint)); +#endif // CHIP_CONFIG_USE_EMBER_DATA_MODEL + return true; + } + } +#if CHIP_CONFIG_USE_EMBER_DATA_MODEL + VerifyOrDie(!chip::app::IsDeviceTypeOnEndpoint(deviceType, endpoint)); +#endif // CHIP_CONFIG_USE_EMBER_DATA_MODEL + return false; + } +} sDeviceTypeResolver; +#else // CHIP_CONFIG_USE_DATA_MODEL_INTERFACE + +// Ember implementation of the device type resolver class DeviceTypeResolver : public chip::Access::AccessControl::DeviceTypeResolver { public: @@ -89,6 +118,7 @@ class DeviceTypeResolver : public chip::Access::AccessControl::DeviceTypeResolve return chip::app::IsDeviceTypeOnEndpoint(deviceType, endpoint); } } sDeviceTypeResolver; +#endif } // namespace