20
20
#include " DeviceIdentification.h"
21
21
#include " IdentityProvider.h"
22
22
#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 */
23
31
24
32
#define API_VERSION_NUMBER_MAJOR 1
25
33
#define API_VERSION_NUMBER_MINOR 0
@@ -154,6 +162,7 @@ namespace Plugin {
154
162
string DeviceIdentification::GetDeviceId () const
155
163
{
156
164
string result;
165
+ string serial;
157
166
#ifndef DISABLE_DEVICEID_CONTROL
158
167
ASSERT (_identifier != nullptr );
159
168
@@ -165,6 +174,24 @@ namespace Plugin {
165
174
if (myBuffer[0 ] != 0 ) {
166
175
result = Core::SystemInfo::Instance ().Id (myBuffer, ~0 );
167
176
}
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
+ }
168
195
}
169
196
#else
170
197
// extract DeviceId set by Thunder
@@ -185,6 +212,35 @@ namespace Plugin {
185
212
return result;
186
213
}
187
214
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
+ if (_remoteDeviceInfoObject)
230
+ {
231
+ _remoteDeviceInfoObject->SerialNumber (Number);
232
+ _remoteDeviceInfoObject->Release ();
233
+ }
234
+ }
235
+ else
236
+ {
237
+ LOGERR (" Failed to create DeviceInfo object\n " );
238
+ }
239
+ }
240
+ return Number;
241
+ }
242
+
243
+
188
244
void DeviceIdentification::Info (JsonData::DeviceIdentification::DeviceidentificationData& deviceInfo) const
189
245
{
190
246
deviceInfo.Firmwareversion = _identifier->FirmwareVersion ();
0 commit comments