Skip to content

Commit

Permalink
Set DeviceInstanceInfoProvider to the platform implementation.
Browse files Browse the repository at this point in the history
In the project-chip#19514 there was a mistake made.
Within some platforms, the DeviceInstanceInfoProvider was set to
a generic one instead of the platform implementation.

To resolve this issue, the DeviceInstanceInfoProvider has been
set to the proper one in PlatformManager implementation for
Android, Darwin, Linux, Tizen, and WebOS.
  • Loading branch information
ArekBalysNordic committed Jul 14, 2022
1 parent a903f59 commit 11e9eef
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 21 deletions.
10 changes: 6 additions & 4 deletions src/platform/Darwin/DeviceInstanceInfoProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include <platform/Linux/ConfigurationManagerImpl.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.h>

namespace chip {
Expand All @@ -29,14 +30,15 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf
CHIP_ERROR GetVendorId(uint16_t & vendorId) override;
CHIP_ERROR GetProductId(uint16_t & productId) override;

private:
friend DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl();
static DeviceInstanceInfoProviderImpl sInstance;
DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) :
Internal::GenericDeviceInstanceInfoProvider<Internal::PosixConfig>(configManager)
{}
};

inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl()
{
return DeviceInstanceInfoProviderImpl::sInstance;
static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance());
return sInstance;
}
} // namespace DeviceLayer
} // namespace chip
3 changes: 3 additions & 0 deletions src/platform/Darwin/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <platform/Darwin/DeviceInstanceInfoProviderImpl.h>
#include <platform/Darwin/DiagnosticDataProviderImpl.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/PlatformManager.h>

// Include the non-inline definitions for the GenericPlatformManagerImpl<> template,
Expand All @@ -48,6 +50,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
#endif // CHIP_DISABLE_PLATFORM_KVS
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance());
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

mRunLoopSem = dispatch_semaphore_create(0);

Expand Down
10 changes: 6 additions & 4 deletions src/platform/Linux/DeviceInstanceInfoProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include <platform/Linux/ConfigurationManagerImpl.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.h>

namespace chip {
Expand All @@ -29,14 +30,15 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf
CHIP_ERROR GetVendorId(uint16_t & vendorId) override;
CHIP_ERROR GetProductId(uint16_t & productId) override;

private:
friend DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl();
static DeviceInstanceInfoProviderImpl sInstance;
DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) :
Internal::GenericDeviceInstanceInfoProvider<Internal::PosixConfig>(configManager)
{}
};

inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl()
{
return DeviceInstanceInfoProviderImpl::sInstance;
static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance());
return sInstance;
}
} // namespace DeviceLayer
} // namespace chip
3 changes: 3 additions & 0 deletions src/platform/Linux/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <lib/support/CHIPMem.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/DeviceControlServer.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/Linux/DeviceInstanceInfoProviderImpl.h>
#include <platform/Linux/DiagnosticDataProviderImpl.h>
#include <platform/PlatformManager.h>
#include <platform/internal/GenericPlatformManagerImpl_POSIX.ipp>
Expand Down Expand Up @@ -175,6 +177,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
ReturnErrorOnFailure(Internal::PosixConfig::Init());
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance());
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

// Call _InitChipStack() on the generic implementation base class
// to finish the initialization process.
Expand Down
10 changes: 6 additions & 4 deletions src/platform/Tizen/DeviceInstanceInfoProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include <platform/Linux/ConfigurationManagerImpl.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.h>

namespace chip {
Expand All @@ -29,14 +30,15 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf
CHIP_ERROR GetVendorId(uint16_t & vendorId) override;
CHIP_ERROR GetProductId(uint16_t & productId) override;

private:
friend DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl();
static DeviceInstanceInfoProviderImpl sInstance;
DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) :
Internal::GenericDeviceInstanceInfoProvider<Internal::PosixConfig>(configManager)
{}
};

inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl()
{
return DeviceInstanceInfoProviderImpl::sInstance;
static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance());
return sInstance;
}
} // namespace DeviceLayer
} // namespace chip
3 changes: 3 additions & 0 deletions src/platform/Tizen/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/PlatformManager.h>
#include <platform/Tizen/DeviceInstanceInfoProviderImpl.h>
#include <platform/Tizen/DiagnosticDataProviderImpl.h>
#include <platform/internal/GenericPlatformManagerImpl_POSIX.ipp>

Expand All @@ -39,6 +41,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
ReturnErrorOnFailure(Internal::PosixConfig::Init());
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance());
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

return Internal::GenericPlatformManagerImpl_POSIX<PlatformManagerImpl>::_InitChipStack();
}
Expand Down
11 changes: 6 additions & 5 deletions src/platform/android/DeviceInstanceInfoProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include <platform/Linux/ConfigurationManagerImpl.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.h>

namespace chip {
Expand All @@ -30,15 +31,15 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf
CHIP_ERROR GetProductId(uint16_t & productId) override;
CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override;

private:
friend DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl();
static DeviceInstanceInfoProviderImpl sInstance;
DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) :
Internal::GenericDeviceInstanceInfoProvider<Internal::AndroidConfig>(configManager)
{}
};

inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl()
{
return DeviceInstanceInfoProviderImpl::sInstance;
static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance());
return sInstance;
}

} // namespace DeviceLayer
} // namespace chip
3 changes: 3 additions & 0 deletions src/platform/android/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

#include <lib/support/CHIPMem.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/PlatformManager.h>
#include <platform/android/DeviceInstanceInfoProviderImpl.h>
#include <platform/android/DiagnosticDataProviderImpl.h>
#include <platform/internal/GenericPlatformManagerImpl_POSIX.ipp>

Expand All @@ -46,6 +48,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
SuccessOrExit(err);
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance());
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

// Call _InitChipStack() on the generic implementation base class
// to finish the initialization process.
Expand Down
10 changes: 6 additions & 4 deletions src/platform/webos/DeviceInstanceInfoProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include <platform/Linux/ConfigurationManagerImpl.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.h>

namespace chip {
Expand All @@ -29,14 +30,15 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf
CHIP_ERROR GetVendorId(uint16_t & vendorId) override;
CHIP_ERROR GetProductId(uint16_t & productId) override;

private:
friend DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl();
static DeviceInstanceInfoProviderImpl sInstance;
DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) :
Internal::GenericDeviceInstanceInfoProvider<Internal::PosixConfig>(configManager)
{}
};

inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl()
{
return DeviceInstanceInfoProviderImpl::sInstance;
static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance());
return sInstance;
}
} // namespace DeviceLayer
} // namespace chip
3 changes: 3 additions & 0 deletions src/platform/webos/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
#include <lib/support/CHIPMem.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/DeviceControlServer.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/PlatformManager.h>
#include <platform/internal/GenericPlatformManagerImpl_POSIX.ipp>
#include <platform/webos/DeviceInfoProviderImpl.h>
#include <platform/webos/DeviceInstanceInfoProviderImpl.h>
#include <platform/webos/DiagnosticDataProviderImpl.h>

#include <thread>
Expand Down Expand Up @@ -166,6 +168,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance());
SetDeviceInfoProvider(&DeviceInfoProviderImpl::GetDefaultInstance());
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

// Call _InitChipStack() on the generic implementation base class
// to finish the initialization process.
Expand Down

0 comments on commit 11e9eef

Please sign in to comment.