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

RDKTV-35484 Add deviceIdentification plugin details into deviceinfo #6108

Open
wants to merge 9 commits into
base: sprint/25Q1
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .github/workflows/L1-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ jobs:
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0001-DELIA-66976-SystemAudioPlayer-interface.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0002-DELIA-66976-specially-for-comcast-bring-back-the-old.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/DeviceInfo_brand.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/RDKTV-35484-DeviceIdentification2.patch
cd ..

- name: Build ThunderInterfaces
Expand Down
76 changes: 76 additions & 0 deletions DeviceInfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,26 @@
set(PLUGIN_NAME DeviceInfo)
set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME})

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

set(PLUGIN_DEVICEINFO_MODE "Off" CACHE STRING "Controls if the plugin should run in its own process, in process or remote")
set(PLUGIN_DEVICEINFO_STARTUPORDER "" CACHE STRING "Start-up order for DeviceInfo plugin")
set(PLUGIN_DEVICEIDENTIFICATION_INTERFACE_NAME "eth0" CACHE STRING "Ethernet Card name which has to be associated for the Raw Device Id creation")
option(PLUGIN_DEVICEIDENTIFICATION_USE_MFR "Get device identification details using MFR library" OFF)

if (DEVICE_IDENTIFICATION_CHIPSET_INFO)
add_definitions (-DDEVICE_IDENTIFICATION_CHIPSET_INFO=\"${DEVICE_IDENTIFICATION_CHIPSET_INFO}\")
endif (DEVICE_IDENTIFICATION_CHIPSET_INFO)

find_package(${NAMESPACE}Plugins REQUIRED)
find_package(${NAMESPACE}Definitions REQUIRED)
find_package(CompileSettingsDebug CONFIG REQUIRED)
find_package(RFC)
find_package(DS)
find_package(IARMBus)
find_package(NEXUS QUIET)
find_package(BCM_HOST QUIET)
find_package(MFRFWLibs QUIET)

add_library(${MODULE_NAME} SHARED
DeviceInfo.cpp
Expand All @@ -37,10 +48,75 @@ add_library(${MODULE_NAME} SHARED
Implementation/DeviceInfo.cpp
Module.cpp)

if (PLUGIN_DEVICEIDENTIFICATION_USE_MFR AND MFRFWLIBS_FOUND)
target_sources(${MODULE_NAME}
PRIVATE
Implementation/MFR/MFR.cpp)
target_link_libraries(${MODULE_NAME}
PRIVATE
MFRFWLibs::MFRFWLibs)
elseif (BUILD_BROADCOM)
target_sources(${MODULE_NAME}
PRIVATE
Implementation/Broadcom/Broadcom.cpp)
elseif (NEXUS_FOUND)
find_package(NXCLIENT REQUIRED)
target_link_libraries(${MODULE_NAME}
PRIVATE
NEXUS::NEXUS
NXCLIENT::NXCLIENT)
if (DEVICEIDENTIFICATION_IMPLEMENTATION_PATH)
target_sources(${MODULE_NAME}
PRIVATE
${DEVICEIDENTIFICATION_IMPLEMENTATION_PATH}/Nexus.cpp)
else()
include(GetExternalCode)
set(DEVICEIDENTIFICATION_IMPLEMENTATION_VERSION "master" CACHE STRING "DeviceIdentification implementation version")
set(DEVICEIDENTIFICATION_IMPLEMENTATION_REPOSITORY "https://code.rdkcentral.com/r/soc/broadcom/components/rdkcentral/thundernanoservices/DeviceIdentification" CACHE STRING "DeviceIdentification implementation repository")
GetExternalCode(
GIT_REPOSITORY ${DEVICEIDENTIFICATION_IMPLEMENTATION_REPOSITORY}
GIT_TAG ${DEVICEIDENTIFICATION_IMPLEMENTATION_VERSION}
SOURCE_DIR "Implementation/Nexus"
)
target_sources(${MODULE_NAME}
PRIVATE
Implementation/Nexus/Nexus.cpp)
endif()
elseif (BCM_HOST_FOUND)
target_sources(${MODULE_NAME}
PRIVATE
Implementation/RPI/RPI.cpp)
target_link_libraries(${MODULE_NAME}
PRIVATE
BCM_HOST::BCM_HOST)
elseif (BUILD_AMLOGIC)
target_sources(${MODULE_NAME}
PRIVATE
Implementation/Amlogic/Amlogic.cpp)
target_compile_definitions(${MODULE_NAME}
PRIVATE
DISABLE_DEVICEID_CONTROL=1)
elseif (BUILD_REALTEK)
target_sources(${MODULE_NAME}
PRIVATE
Implementation/Realtek/Realtek.cpp)
elseif(UNIX AND NOT APPLE)
target_sources(${MODULE_NAME}
PRIVATE
Implementation/Linux/Linux.cpp)
set(GENERIC_DEVICEIDENTIFIATION ON)
else ()
message(FATAL_ERROR "There is no platform backend for device identifier plugin")
endif()

set_target_properties(${MODULE_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES)

target_include_directories(${MODULE_NAME}
PRIVATE
${CMAKE_CURRENT_LIST_DIR})

target_include_directories(${MODULE_NAME} PRIVATE
${RFC_INCLUDE_DIRS}
${DS_INCLUDE_DIRS}
Expand Down
4 changes: 4 additions & 0 deletions DeviceInfo/DeviceInfo.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ startuporder = "@PLUGIN_DEVICEINFO_STARTUPORDER@"

configuration = JSON()

if boolean("@GENERIC_DEVICEIDENTIFIATION@"):
if boolean("@PLUGIN_DEVICEIDENTIFICATION_INTERFACE_NAME@"):
configuration.add("interface", @PLUGIN_DEVICEIDENTIFICATION_INTERFACE_NAME@)

rootobject = JSON()
rootobject.add("mode", "@PLUGIN_DEVICEINFO_MODE@")
configuration.add("root", rootobject)
6 changes: 6 additions & 0 deletions DeviceInfo/DeviceInfo.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ set (startuporder ${PLUGIN_DEVICEINFO_STARTUPORDER})
endif()

map()
if(GENERIC_DEVICEIDENTIFIATION)
if(PLUGIN_DEVICEIDENTIFICATION_INTERFACE_NAME)
kv(interface ${PLUGIN_DEVICEIDENTIFICATION_INTERFACE_NAME})
endif()
endif()

key(root)
map()
kv(mode ${PLUGIN_DEVICEINFO_MODE})
Expand Down
121 changes: 120 additions & 1 deletion DeviceInfo/DeviceInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
*/

#include "DeviceInfo.h"
#include <interfaces/IConfiguration.h>
#include <interfaces/IDeviceIdentification2.h>
#include "tracing/Logging.h"
#include "UtilsJsonRpc.h"
#include "UtilsController.h"
#include <time.h>


#define API_VERSION_NUMBER_MAJOR 1
#define API_VERSION_NUMBER_MINOR 1
#define API_VERSION_NUMBER_PATCH 0
Expand All @@ -30,11 +36,19 @@ namespace {
// Version (Major, Minor, Patch)
API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH,
// Preconditions
#ifdef DISABLE_DEVICEID_CONTROL
{ PluginHost::ISubSystem::IDENTIFIER },
#else
{},
#endif
// Terminations
{},
// Controls
#ifdef DISABLE_DEVICEID_CONTROL
{}
#else
{ PluginHost::ISubSystem::IDENTIFIER }
#endif
);
}

Expand All @@ -48,7 +62,7 @@ namespace Plugin {
{
ASSERT(_service == nullptr);
ASSERT(service != nullptr);

ASSERT(_identifier == nullptr);
ASSERT(_subSystem == nullptr);

_skipURL = static_cast<uint8_t>(service->WebPrefix().length());
Expand All @@ -61,18 +75,42 @@ namespace Plugin {
_deviceAudioCapabilities = service->Root<Exchange::IDeviceAudioCapabilities>(_connectionId, 2000, _T("DeviceAudioCapabilities"));
_deviceVideoCapabilities = service->Root<Exchange::IDeviceVideoCapabilities>(_connectionId, 2000, _T("DeviceVideoCapabilities"));
_firmwareVersion = service->Root<Exchange::IFirmwareVersion>(_connectionId, 2000, _T("FirmwareVersion"));
_device = service->Root<Exchange::IDeviceIdentification2>(_connectionId, 2000, _T("DeviceImplementation"));
if (_device != nullptr) {

Exchange::IConfiguration* configure = _device->QueryInterface<Exchange::IConfiguration>();
if (configure != nullptr) {
configure->Configure(service);
configure->Release();
}

_identifier = _device->QueryInterface<PluginHost::ISubSystem::IIdentifier>();
if (_identifier == nullptr) {

_device->Release();
_device = nullptr;
} else {
_deviceId = GetDeviceId();
if (_deviceId.empty() != true) {
#ifndef DISABLE_DEVICEID_CONTROL
service->SubSystems()->Set(PluginHost::ISubSystem::IDENTIFIER, _identifier);
#endif
}
}
}
ASSERT(_deviceInfo != nullptr);
ASSERT(_deviceAudioCapabilities != nullptr);
ASSERT(_deviceVideoCapabilities != nullptr);
ASSERT(_firmwareVersion != nullptr);
ASSERT(_device != nullptr);

// On success return empty, to indicate there is no error text.

return ((_subSystem != nullptr)
&& (_deviceInfo != nullptr)
&& (_deviceAudioCapabilities != nullptr)
&& (_deviceVideoCapabilities != nullptr)
&& (_device != nullptr)
&& (_firmwareVersion != nullptr))
? EMPTY_STRING
: _T("Could not retrieve System Information.");
Expand All @@ -82,10 +120,22 @@ namespace Plugin {
{
ASSERT(_service == service);

if (_identifier != nullptr) {
if (_deviceId.empty() != true) {
#ifndef DISABLE_DEVICEID_CONTROL
service->SubSystems()->Set(PluginHost::ISubSystem::IDENTIFIER, nullptr);
#endif
_deviceId.clear();
}
_identifier->Release();
_identifier = nullptr;
}

_deviceInfo->Release();
_deviceAudioCapabilities->Release();
_deviceVideoCapabilities->Release();
_firmwareVersion->Release();
_device->Release();

if (_subSystem != nullptr) {
_subSystem->Release();
Expand Down Expand Up @@ -221,5 +271,74 @@ namespace Plugin {
socketPortInfo.Runs = Core::ResourceMonitor::Instance().Runs();
}

string DeviceInfo::RetrieveSerialNumberThroughCOMRPC() const
{
std::string Number;
if (_service)
{
if(_deviceInfo)
{
_deviceInfo->SerialNumber(Number);
}
else
{
LOGERR("Failed to create DeviceInfo object\n");
}
}
return Number;
}
string DeviceInfo::GetDeviceId() const
{
string result;
string serial;
#ifndef DISABLE_DEVICEID_CONTROL
ASSERT(_identifier != nullptr);

if (_identifier != nullptr) {
uint8_t myBuffer[64];

myBuffer[0] = _identifier->Identifier(sizeof(myBuffer) - 1, &(myBuffer[1]));

if (myBuffer[0] != 0) {
result = Core::SystemInfo::Instance().Id(myBuffer, ~0);
}
else
{
serial = RetrieveSerialNumberThroughCOMRPC();

if (!serial.empty()) {
uint8_t ret = serial.length();

if (ret > (sizeof(myBuffer) - 1)){
ret = sizeof(myBuffer) - 1;
}
myBuffer[0] = ret;
::memcpy(&(myBuffer[1]), serial.c_str(), ret);

if(myBuffer[0] != 0){
result = Core::SystemInfo::Instance().Id(myBuffer, ~0);
}
}
}

}
#else
// extract DeviceId set by Thunder
if (_service->SubSystems()->IsActive(PluginHost::ISubSystem::IDENTIFIER) == true) {

const PluginHost::ISubSystem::IIdentifier* identifier(_service->SubSystems()->Get<PluginHost::ISubSystem::IIdentifier>());

if (identifier != nullptr) {
uint8_t myBuffer[64];

if ((myBuffer[0] = identifier->Identifier(sizeof(myBuffer) - 1, &(myBuffer[1]))) != 0) {
result = Core::SystemInfo::Instance().Id(myBuffer, ~0);
}
identifier->Release();
}
}
#endif
return result;
}
} // namespace Plugin
} // namespace WPEFramework
12 changes: 12 additions & 0 deletions DeviceInfo/DeviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <interfaces/IDeviceInfo2.h>
#endif /* USE_THUNDER_R4 */
#include <interfaces/IFirmwareVersion.h>
#include <interfaces/IDeviceIdentification2.h>
#include <interfaces/json/JsonData_DeviceInfo.h>

namespace WPEFramework {
Expand Down Expand Up @@ -73,6 +74,9 @@ namespace Plugin {
, _deviceAudioCapabilities(nullptr)
, _deviceVideoCapabilities(nullptr)
, _firmwareVersion(nullptr)
, _deviceId()
, _identifier(nullptr)
, _device(nullptr)
{
RegisterAll();
}
Expand All @@ -90,6 +94,7 @@ namespace Plugin {
INTERFACE_AGGREGATE(Exchange::IDeviceAudioCapabilities, _deviceAudioCapabilities)
INTERFACE_AGGREGATE(Exchange::IDeviceVideoCapabilities, _deviceVideoCapabilities)
INTERFACE_AGGREGATE(Exchange::IFirmwareVersion, _firmwareVersion)
INTERFACE_AGGREGATE(Exchange::IDeviceIdentification2, _device)
END_INTERFACE_MAP

public:
Expand Down Expand Up @@ -123,6 +128,7 @@ namespace Plugin {
uint32_t get_supportedaudioports(JsonData::DeviceInfo::SupportedaudioportsData& response) const;
uint32_t get_supportedvideodisplays(JsonData::DeviceInfo::SupportedvideodisplaysData& response) const;
uint32_t get_hostedid(JsonData::DeviceInfo::HostedidData& response) const;
uint32_t get_chipset(JsonData::DeviceInfo::ChipsetData& response) const;
uint32_t endpoint_defaultresolution(const JsonData::DeviceInfo::SupportedresolutionsParamsInfo& params, JsonData::DeviceInfo::DefaultresolutionResultData& response) const;
uint32_t endpoint_supportedresolutions(const JsonData::DeviceInfo::SupportedresolutionsParamsInfo& params, JsonData::DeviceInfo::SupportedresolutionsResultData& response) const;
uint32_t endpoint_supportedhdcp(const JsonData::DeviceInfo::SupportedresolutionsParamsInfo& params, JsonData::DeviceInfo::SupportedhdcpResultData& response) const;
Expand All @@ -133,6 +139,8 @@ namespace Plugin {
void SysInfo(JsonData::DeviceInfo::SysteminfoData& systemInfo) const;
void AddressInfo(Core::JSON::ArrayType<JsonData::DeviceInfo::AddressesData>& addressInfo) const;
void SocketPortInfo(JsonData::DeviceInfo::SocketinfoData& socketPortInfo) const;
string GetDeviceId() const;
string RetrieveSerialNumberThroughCOMRPC() const;

private:
uint8_t _skipURL;
Expand All @@ -143,6 +151,10 @@ namespace Plugin {
Exchange::IDeviceAudioCapabilities* _deviceAudioCapabilities;
Exchange::IDeviceVideoCapabilities* _deviceVideoCapabilities;
Exchange::IFirmwareVersion* _firmwareVersion;
string _deviceId;
PluginHost::ISubSystem::IIdentifier* _identifier;
Exchange::IDeviceIdentification2* _device;

};

} // namespace Plugin
Expand Down
Loading
Loading