Skip to content

Commit 9d0af9b

Browse files
Merge pull request rdkcentral#6 from rdkcentral/main
sync Main
2 parents bb5336d + 466d41f commit 9d0af9b

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

DeviceIdentification/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.
1616

1717
* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.
1818

19+
## [1.0.6] - 2024-12-30
20+
### Fixed
21+
- Added method for retrieving Serial number if existing implementation fails to retrive the serial number.
22+
1923
## [1.0.6] - 2024-05-28
2024
### Fixed
2125
- Added methods for retrieving Serial number, Chip Id and Firmware version for Broadcom Devices.

DeviceIdentification/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,5 @@ target_include_directories(${MODULE_NAME}
126126
install(TARGETS ${MODULE_NAME}
127127
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)
128128

129+
target_include_directories(${MODULE_NAME} PRIVATE ../helpers)
129130
write_config(${PLUGIN_NAME})

DeviceIdentification/DeviceIdentification.cpp

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@
2020
#include "DeviceIdentification.h"
2121
#include "IdentityProvider.h"
2222
#include <interfaces/IConfiguration.h>
23+
#include "tracing/Logging.h"
24+
#include "UtilsJsonRpc.h"
25+
#include "UtilsController.h"
26+
#ifdef USE_THUNDER_R4
27+
#include <interfaces/IDeviceInfo.h>
28+
#else
29+
#include <interfaces/IDeviceInfo2.h>
30+
#endif /* USE_THUNDER_R4 */
2331

2432
#define API_VERSION_NUMBER_MAJOR 1
2533
#define API_VERSION_NUMBER_MINOR 0
26-
#define API_VERSION_NUMBER_PATCH 6
34+
#define API_VERSION_NUMBER_PATCH 7
2735

2836
namespace WPEFramework {
2937
namespace {
@@ -154,6 +162,7 @@ namespace Plugin {
154162
string DeviceIdentification::GetDeviceId() const
155163
{
156164
string result;
165+
string serial;
157166
#ifndef DISABLE_DEVICEID_CONTROL
158167
ASSERT(_identifier != nullptr);
159168

@@ -165,6 +174,25 @@ namespace Plugin {
165174
if (myBuffer[0] != 0) {
166175
result = Core::SystemInfo::Instance().Id(myBuffer, ~0);
167176
}
177+
else
178+
{
179+
serial = RetrieveSerialNumberThroughCOMRPC();
180+
181+
if (!serial.empty()) {
182+
uint8_t ret = serial.length();
183+
184+
if (ret > (sizeof(myBuffer) - 1)){
185+
ret = sizeof(myBuffer) - 1;
186+
}
187+
myBuffer[0] = ret;
188+
::memcpy(&(myBuffer[1]), serial.c_str(), ret);
189+
190+
if(myBuffer[0] != 0){
191+
result = Core::SystemInfo::Instance().Id(myBuffer, ~0);
192+
}
193+
}
194+
}
195+
168196
}
169197
#else
170198
// extract DeviceId set by Thunder
@@ -184,7 +212,34 @@ namespace Plugin {
184212
#endif
185213
return result;
186214
}
187-
215+
string DeviceIdentification::RetrieveSerialNumberThroughCOMRPC() const
216+
{
217+
std::string Number;
218+
if (_service)
219+
{
220+
PluginHost::IShell::state state;
221+
222+
if ((Utils::getServiceState(_service, "DeviceInfo", state) == Core::ERROR_NONE) && (state != PluginHost::IShell::state::ACTIVATED))
223+
{
224+
Utils::activatePlugin(_service, "DeviceInfo");
225+
}
226+
if ((Utils::getServiceState(_service, "DeviceInfo", state) == Core::ERROR_NONE) && (state == PluginHost::IShell::state::ACTIVATED))
227+
{
228+
auto _remoteDeviceInfoObject = _service->QueryInterfaceByCallsign<Exchange::IDeviceInfo>("DeviceInfo");
229+
230+
if(_remoteDeviceInfoObject)
231+
{
232+
_remoteDeviceInfoObject->SerialNumber(Number);
233+
_remoteDeviceInfoObject->Release();
234+
}
235+
}
236+
else
237+
{
238+
LOGERR("Failed to create DeviceInfo object\n");
239+
}
240+
}
241+
return Number;
242+
}
188243
void DeviceIdentification::Info(JsonData::DeviceIdentification::DeviceidentificationData& deviceInfo) const
189244
{
190245
deviceInfo.Firmwareversion = _identifier->FirmwareVersion();

DeviceIdentification/DeviceIdentification.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ namespace Plugin {
9494
uint32_t get_deviceidentification(JsonData::DeviceIdentification::DeviceidentificationData& response) const;
9595

9696
string GetDeviceId() const;
97+
string RetrieveSerialNumberThroughCOMRPC() const;
9798
void Info(JsonData::DeviceIdentification::DeviceidentificationData&) const;
9899

99100
void Deactivated(RPC::IRemoteConnection* connection);

0 commit comments

Comments
 (0)