RDK Documentation (Open Sourced RDK Components)
sysMgr.c
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 
22 /**
23 * @defgroup iarmmgrs
24 * @{
25 * @defgroup sysmgr
26 * @{
27 **/
28 
29 
30 #include <stdio.h>
31 #include <string.h>
32 #include <unistd.h>
33 #include <fcntl.h>
34 #include <string.h>
35 #include <stdlib.h>
36 #include <time.h>
37 #include <pthread.h>
38 #include <sys/types.h>
39 #include <sys/stat.h>
40 #include "safec_lib.h"
41 #include "libIBus.h"
42 #include "iarmUtil.h"
43 #include "sysMgr.h"
44 #include "mfrMgr.h"
45 #include "sysMgrInternal.h"
46 #include <assert.h>
47 #ifdef ENABLE_SD_NOTIFY
48 #include <systemd/sd-daemon.h>
49 #endif
50 
51 
52 static pthread_mutex_t tMutexLock;
53 static IARM_Bus_SYSMgr_GetSystemStates_Param_t systemStates;
54 static void _sysEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);
55 static IARM_Result_t _GetSystemStates(void *arg);
56 static volatile int initialized = 0;
57 
58 
59 static char *ntp_filename ="/tmp/stt_received";
60 /*Support for HDCP Profile */
61 static char *profile_1_filename ="/opt/.hdcp_profile_1";
62 static int CheckHdcpProfile(void);
63 static void GetSerialNumber(void);
64 
65 static IARM_Result_t _SetHDCPProfile(void *arg);
66 static IARM_Result_t _GetHDCPProfile(void *arg);
67 
68 /* Functions added to get and set Key Code Logging status*/
69 static int keyLogStatus = 1;
70 static int getKeyCodeLoggingPref(void);
71 static void setKeyCodeLoggingPref(int logStatus);
72 static IARM_Result_t _GetKeyCodeLoggingPref(void *arg);
73 static IARM_Result_t _SetKeyCodeLoggingPref(void *arg);
74 
75 IARM_Result_t SYSMgr_Start()
76 {
77 
78  LOG("Entering [%s] - [%s] - disabling io redirect buf\r\n", __FUNCTION__, IARM_BUS_SYSMGR_NAME);
79  setvbuf(stdout, NULL, _IOLBF, 0);
80 
81  if (!initialized) {
82  LOG("I-ARM Sys Mgr: %d\r\n", __LINE__);
83  pthread_mutex_init (&tMutexLock, NULL);
84  // LOG("I-ARM Sys Mgr: %d\r\n", __LINE__);
85  pthread_mutex_lock(&tMutexLock);
86  // LOG("I-ARM Sys Mgr: %d\r\n", __LINE__);
88  // LOG("I-ARM Sys Mgr: %d\r\n", __LINE__);
90  // LOG("I-ARM Sys Mgr: %d\r\n", __LINE__);
92  // LOG("I-ARM Sys Mgr: %d\r\n", __LINE__);
94  // LOG("I-ARM Sys Mgr: %d\r\n", __LINE__);
95  IARM_Bus_RegisterEventHandler(IARM_BUS_SYSMGR_NAME, IARM_BUS_SYSMGR_EVENT_SYSTEMSTATE, _sysEventHandler);
96  // LOG("I-ARM Sys Mgr: %d\r\n", __LINE__);
97  initialized = 1;
98  #ifdef ENABLE_SD_NOTIFY
99  sd_notifyf(0, "READY=1\n"
100  "STATUS=sysMgr is Successfully Initialized\n"
101  "MAINPID=%lu",
102  (unsigned long) getpid());
103  #endif
104 
105 #ifdef PID_FILE_PATH
106 #define xstr(s) str(s)
107 #define str(s) #s
108  // write pidfile because sd_notify() does not work inside container
109  IARM_Bus_WritePIDFile(xstr(PID_FILE_PATH) "/sysmgr.pid");
110 #endif
111 
112  // LOG("I-ARM Sys Mgr: %d\r\n", __LINE__);
113 
114  /*HDCP Profile required for RNG 150*/
115  IARM_Bus_RegisterCall(IARM_BUS_SYSMGR_API_SetHDCPProfile,_SetHDCPProfile);
116  IARM_Bus_RegisterCall(IARM_BUS_SYSMGR_API_GetHDCPProfile,_GetHDCPProfile);
117 
118 
119  IARM_Bus_RegisterCall(IARM_BUS_SYSMGR_API_GetKeyCodeLoggingPref,_GetKeyCodeLoggingPref);
120  IARM_Bus_RegisterCall(IARM_BUS_SYSMGR_API_SetKeyCodeLoggingPref,_SetKeyCodeLoggingPref);
121  keyLogStatus = 1;
122 
123  systemStates.channel_map = {0};
124  systemStates.disconnect_mgr_state = {0};
125  systemStates.TuneReadyStatus = {0};
126  systemStates.exit_ok_key_sequence = {0};
127  systemStates.cmac = {0};
128  systemStates.card_moto_entitlements = {0};
129  systemStates.card_moto_hrv_rx = {0};
130  systemStates.dac_init_timestamp = {0};
131  systemStates.card_cisco_status = {0};
132  systemStates.video_presenting = {0};
133  systemStates.hdmi_out = {0};
134  systemStates.hdcp_enabled = {0};
135  systemStates.hdmi_edid_read = {0};
136  systemStates.firmware_download = {0};
137  systemStates.firmware_update_state = {0};
138  systemStates.time_source = {0};
139  systemStates.time_zone_available = {0};
140  systemStates.ca_system = {0};
141  systemStates.estb_ip = {0};
142  systemStates.ecm_ip = {0};
143  systemStates.lan_ip = {0};
144  systemStates.moca = {0};
145  systemStates.docsis = {0};
146  systemStates.dsg_broadcast_tunnel = {0};
147  systemStates.dsg_ca_tunnel = {0};
148  systemStates.cable_card = {0};
149  systemStates.cable_card_download = {0};
150  systemStates.cvr_subsystem = {0};
151  systemStates.download = {0};
152  systemStates.vod_ad = {0};
153  systemStates.card_serial_no ={0};
154  systemStates.ecm_mac ={0};
155  systemStates.dac_id = {0};
156  systemStates.plant_id = {0};
157  systemStates.stb_serial_no={0};
158  systemStates.bootup = {0};
159  systemStates.hdcp_enabled.state = 1; /*Default HDCP state is enabled.*/
160  systemStates.dst_offset = {0};
161  systemStates.ip_mode = {0};
162  systemStates.qam_ready_status = {0};
163  // LOG("I-ARM Sys Mgr: %d\r\n", __LINE__);
164  pthread_mutex_unlock(&tMutexLock);
165  LOG("I-ARM Sys Mgr: %d\r\n", __LINE__);
166  return IARM_RESULT_SUCCESS;
167  }
168  else {
169  LOG("VENU: I-ARM Sys Mgr Error case: %d\r\n", __LINE__);
170  return IARM_RESULT_INVALID_STATE;
171  }
172 }
173 
174 IARM_Result_t SYSMgr_Loop()
175 {
176  time_t curr = 0;
177  while(1)
178  {
179  time(&curr);
180  LOG("I-ARM Sys Mgr: HeartBeat at %s\r\n", ctime(&curr));
181  sleep(2000);
182  }
183  return IARM_RESULT_SUCCESS;
184 }
185 
186 
187 IARM_Result_t SYSMgr_Stop(void)
188 {
189  if (initialized) {
190  pthread_mutex_lock(&tMutexLock);
192  IARM_Bus_Term();
193  pthread_mutex_unlock(&tMutexLock);
194  pthread_mutex_destroy (&tMutexLock);
195  initialized = 0;
196  return IARM_RESULT_SUCCESS;
197  }
198  else {
199  return IARM_RESULT_INVALID_STATE;
200  }
201 }
202 
203 /**
204  * @brief This functions sets/updates the HDCP Profile
205  *
206  * @param callCtx: Context to the caller function
207  * @param methodID: Method to be invoke
208  * @param arg: Specifies the timeout to be set
209  * @param serial: Handshake code to share with
210  *
211  * @return None
212  */
213 static int CheckHdcpProfile(void)
214 {
215  struct stat st;
216  int ret = lstat(profile_1_filename, &st);
217 
218  if (ret >= 0) {
219  return 1;
220  }
221  else {
222  return 0;
223  }
224 }
225 
226 static IARM_Result_t _SetHDCPProfile(void *arg)
227 {
228 
230 int new_profile = 0;
231 
232  new_profile = param->HdcpProfile;
233 
234  if ((CheckHdcpProfile() != new_profile) && (new_profile == 0 || new_profile == 1)) {
235  int fd = -1;
236  if (new_profile == 0) {
237  unlink(profile_1_filename);
238  }
239  else {
240  fd = open(profile_1_filename, O_WRONLY|O_CREAT, 0666);
241  if (fd >= 0) {
242  close(fd);
243  }
244  }
245 
246  {
247  __TIMESTAMP(); printf ("The hdcp profile is set to %d\n", new_profile);
248  IARM_Bus_SYSMgr_EventData_t eventData;
249  eventData.data.hdcpProfileData.hdcpProfile = new_profile;
250  __TIMESTAMP(); printf("<<<<<<< Send HDCP Profile UPdate Event is %d>>>>>>>>",eventData.data.hdcpProfileData.hdcpProfile);
251  IARM_Bus_BroadcastEvent(IARM_BUS_SYSMGR_NAME, (IARM_EventId_t)IARM_BUS_SYSMGR_EVENT_HDCP_PROFILE_UPDATE,(void *)&eventData,sizeof(eventData));
252  }
253  }
254  return IARM_RESULT_SUCCESS;
255 }
256 
257 /**
258  * @brief This functions returns the HDCP Profile
259  *
260  * @param Get current Profile state
261  *
262  * @return None
263  */
264 static IARM_Result_t _GetHDCPProfile(void *arg)
265 {
267  param->HdcpProfile = CheckHdcpProfile();
268  __TIMESTAMP(); printf ("The hdcp profile is %d\n", param->HdcpProfile);
269  return IARM_RESULT_SUCCESS;
270 }
271 
272 
273 
274 /**
275  * @brief This functions returns the SYstem STates
276  *
277  * @param Data to return
278  *
279  * @return None
280  */
281 
282 
283 static IARM_Result_t _GetSystemStates(void *arg)
284 {
285 #ifdef USE_MFR_FOR_SERIAL
286  GetSerialNumber();
287 #endif
288  pthread_mutex_lock(&tMutexLock);
289  static int current_channel_map_state = 0;
291 
292  if(current_channel_map_state != systemStates.channel_map.state) {
293  __TIMESTAMP();LOG("_GetSystemStates return ChannelMapState = %d\r\n", systemStates.channel_map.state);
294  current_channel_map_state = systemStates.channel_map.state;
295  }
296 
297  #ifdef MEDIA_CLIENT
298  systemStates.channel_map.state=2;
299  systemStates.TuneReadyStatus.state=1;
300  if(systemStates.time_source.state==0) {
301  if( access( ntp_filename, F_OK ) != -1 ) {
302  systemStates.time_source.state=1;
303  }
304  }
305  #endif
306  *param = systemStates;
307  pthread_mutex_unlock(&tMutexLock);
308  return IARM_RESULT_SUCCESS;
309 }
310 
311 static void _sysEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
312 {
313  errno_t rc = -1;
314  /* Only handle state events */
315  if (eventId != IARM_BUS_SYSMGR_EVENT_SYSTEMSTATE) return;
316 
317  /*Handle only Sys Manager Events */
318  if (strcmp(owner, IARM_BUS_SYSMGR_NAME) == 0)
319  {
320 
321  //__TIMESTAMP();LOG("_sysEventHandler invoked ww\r\n");
322  pthread_mutex_lock(&tMutexLock);
324 
325  IARM_Bus_SYSMgr_SystemState_t stateId = sysEventData->data.systemStates.stateId;
326  int state = sysEventData->data.systemStates.state;
327  int error = sysEventData->data.systemStates.error;
328  char* payload=sysEventData->data.systemStates.payload;
329  __TIMESTAMP();LOG("_sysEventHandler invoked for stateid %d of state %d and error %d\r\n", stateId, state,error);
330  switch(stateId) {
331  case IARM_BUS_SYSMGR_SYSSTATE_CHANNELMAP:
332  systemStates.channel_map.state = state;
333  systemStates.channel_map.error = error;
334  /* memcpy can be replaced with strcpy once the RI is replaced with RMF */
335  rc = memcpy_s( systemStates.channel_map.payload,sizeof(systemStates.channel_map.payload), payload, sizeof( systemStates.channel_map.payload ) );
336  if(rc!=EOK)
337  {
338  ERR_CHK(rc);
339  }
340  memcpy( systemStates.channel_map.payload, payload, sizeof( systemStates.channel_map.payload ) );
341  systemStates.channel_map.payload[ sizeof( systemStates.channel_map.payload ) - 1] = 0;
342  LOG( "Got IARM_BUS_SYSMGR_SYSSTATE_CHANNELMAP ID = %s", systemStates.channel_map.payload );
343  break;
344  case IARM_BUS_SYSMGR_SYSSTATE_DISCONNECTMGR:
345  systemStates.disconnect_mgr_state.state = state;
346  systemStates.disconnect_mgr_state.error = error;
347  LOG( "Got IARM_BUS_SYSMGR_SYSSTATE_DISCONNECTMGR state = %d\n", state );
348  break;
349  case IARM_BUS_SYSMGR_SYSSTATE_TUNEREADY:
350  systemStates.TuneReadyStatus.state = state;
351  systemStates.TuneReadyStatus.error = error;
352  break;
353  case IARM_BUS_SYSMGR_SYSSTATE_EXIT_OK :
354  systemStates.exit_ok_key_sequence.state = state;
355  systemStates.exit_ok_key_sequence.error = error;
356  break;
357  case IARM_BUS_SYSMGR_SYSSTATE_CMAC :
358  systemStates.cmac.state = state;
359  systemStates.cmac.error = error;
360  break;
361  case IARM_BUS_SYSMGR_SYSSTATE_MOTO_ENTITLEMENT :
362  systemStates.card_moto_entitlements.state = state;
363  systemStates.card_moto_entitlements.error = error;
364  break;
365  case IARM_BUS_SYSMGR_SYSSTATE_MOTO_HRV_RX :
366  systemStates.card_moto_hrv_rx.state = state;
367  systemStates.card_moto_hrv_rx.error = error;
368  case IARM_BUS_SYSMGR_SYSSTATE_DAC_INIT_TIMESTAMP :
369  systemStates.dac_init_timestamp.state = state;
370  systemStates.dac_init_timestamp.error = error;
371  strncpy(systemStates.dac_init_timestamp.payload,payload,strlen(payload));
372  systemStates.dac_init_timestamp.payload[strlen(payload)]='\0';
373  printf("systemStates.dac_init_timestamp.payload=%s\n",systemStates.dac_init_timestamp.payload);
374  break;
375  case IARM_BUS_SYSMGR_SYSSTATE_CARD_CISCO_STATUS :
376  systemStates.card_cisco_status.state = state;
377  systemStates.card_cisco_status.error = error;
378  break;
379  case IARM_BUS_SYSMGR_SYSSTATE_VIDEO_PRESENTING :
380  systemStates.video_presenting.state = state;
381  systemStates.video_presenting.error = error;
382  break;
383  case IARM_BUS_SYSMGR_SYSSTATE_HDMI_OUT :
384  systemStates.hdmi_out.state = state;
385  systemStates.hdmi_out.error = error;
386  break;
387  case IARM_BUS_SYSMGR_SYSSTATE_HDCP_ENABLED :
388  systemStates.hdcp_enabled.state = state;
389  systemStates.hdcp_enabled.error = error;
390  break;
391  case IARM_BUS_SYSMGR_SYSSTATE_HDMI_EDID_READ :
392  systemStates.hdmi_edid_read.state = state;
393  systemStates.hdmi_edid_read.error = error;
394  break;
395  case IARM_BUS_SYSMGR_SYSSTATE_FIRMWARE_DWNLD :
396  systemStates.firmware_download.state = state;
397  systemStates.firmware_download.error = error;
398  break;
399  case IARM_BUS_SYSMGR_SYSSTATE_FIRMWARE_UPDATE_STATE :
400  systemStates.firmware_update_state.state = state;
401  systemStates.firmware_update_state.error = error;
402  break;
403  case IARM_BUS_SYSMGR_SYSSTATE_TIME_SOURCE :
404  systemStates.time_source.state = state;
405  systemStates.time_source.error = error;
406  break;
407  /*
408  payload contains any of the string below for various time zones
409  time zone = the string if no dst /if dst
410 
411  HST ="HST11" / "HST11HDT,M3.2.0,M11.1.0"
412  AKST="AKST" / "AKST09AKDT,M3.2.0,M11.1.0"
413  PST = "PST08" / "PST08PDT,M3.2.0,M11.1.0"
414  MST = "MST07" / "MST07MDT,M3.2.0,M11.1.0"
415  CST = "CST06" / "CST06CDT,M3.2.0,M11.1.0"
416  EST = "EST05" / "EST05EDT,M3.2.0,M11.1.0"
417  */
418  case IARM_BUS_SYSMGR_SYSSTATE_TIME_ZONE :
419  systemStates.time_zone_available.state = state;
420  systemStates.time_zone_available.error = error;
421  /* memcpy can be replaced with strcpy once the RI is replaced with RMF */
422  rc = memcpy_s( systemStates.time_zone_available.payload,sizeof(systemStates.time_zone_available.payload), payload, sizeof( systemStates.time_zone_available.payload ) );
423  if(rc!=EOK)
424  {
425  ERR_CHK(rc);
426  }
427  systemStates.time_zone_available.payload[ sizeof( systemStates.time_zone_available.payload ) - 1] = 0;
428  LOG( "Got IARM_BUS_SYSMGR_SYSSTATE_TIME_ZONE = %s\n", systemStates.time_zone_available.payload );
429  break;
430  case IARM_BUS_SYSMGR_SYSSTATE_CA_SYSTEM :
431  systemStates.ca_system.state = state;
432  systemStates.ca_system.error = error;
433  break;
434  case IARM_BUS_SYSMGR_SYSSTATE_ESTB_IP :
435  systemStates.estb_ip.state = state;
436  systemStates.estb_ip.error = error;
437  break;
438  case IARM_BUS_SYSMGR_SYSSTATE_ECM_IP :
439  systemStates.ecm_ip.state = state;
440  systemStates.ecm_ip.error = error;
441  break;
442  case IARM_BUS_SYSMGR_SYSSTATE_LAN_IP :
443  systemStates.lan_ip.state = state;
444  systemStates.lan_ip.error = error;
445  break;
446  case IARM_BUS_SYSMGR_SYSSTATE_MOCA :
447  systemStates.moca.state = state;
448  systemStates.moca.error = error;
449  break;
450  case IARM_BUS_SYSMGR_SYSSTATE_DOCSIS :
451  systemStates.docsis.state = state;
452  systemStates.docsis.error = error;
453  break;
454  case IARM_BUS_SYSMGR_SYSSTATE_DSG_BROADCAST_CHANNEL :
455  systemStates.dsg_broadcast_tunnel.state = state;
456  systemStates.dsg_broadcast_tunnel.error = error;
457  break;
458  case IARM_BUS_SYSMGR_SYSSTATE_DSG_CA_TUNNEL :
459  systemStates.dsg_ca_tunnel.state = state;
460  systemStates.dsg_ca_tunnel.error = error;
461  break;
462  case IARM_BUS_SYSMGR_SYSSTATE_CABLE_CARD :
463  systemStates.cable_card.state = state;
464  systemStates.cable_card.error = error;
465  break;
466  case IARM_BUS_SYSMGR_SYSSTATE_CABLE_CARD_DWNLD :
467  systemStates.cable_card_download.state = state;
468  systemStates.cable_card_download.error = error;
469  break;
470  case IARM_BUS_SYSMGR_SYSSTATE_CVR_SUBSYSTEM :
471  systemStates.cvr_subsystem.state = state;
472  systemStates.cvr_subsystem.error = error;
473  break;
474  case IARM_BUS_SYSMGR_SYSSTATE_DOWNLOAD :
475  systemStates.download.state = state;
476  systemStates.download.error = error;
477  break;
478  case IARM_BUS_SYSMGR_SYSSTATE_VOD_AD :
479  systemStates.vod_ad.state = state;
480  systemStates.vod_ad.error = error;
481  /* memcpy can be replaced with strcpy once the RI is replaced with RMF */
482  rc = memcpy_s( systemStates.vod_ad.payload,sizeof(systemStates.vod_ad.payload), payload, sizeof( systemStates.vod_ad.payload ) );
483  if(rc!=EOK)
484  {
485  ERR_CHK(rc);
486  }
487  systemStates.vod_ad.payload[ sizeof( systemStates.vod_ad.payload ) -1 ] =0;
488  LOG( "Got IARM_BUS_SYSMGR_SYSSTATE_VOD_AD = %s\n", systemStates.vod_ad.payload );
489  break;
490  case IARM_BUS_SYSMGR_SYSSTATE_CABLE_CARD_SERIAL_NO:
491  systemStates.card_serial_no.error =error;
492  strncpy(systemStates.card_serial_no.payload,payload,strlen(payload));
493  systemStates.card_serial_no.payload[strlen(payload)]='\0';
494  printf("systemStates.card.serial.no.payload=%s\n",systemStates.card_serial_no.payload);
495  break;
496  case IARM_BUS_SYSMGR_SYSSTATE_ECM_MAC:
497  systemStates.ecm_mac.error =error;
498  strncpy(systemStates.ecm_mac.payload,payload,strlen(payload));
499  systemStates.ecm_mac.payload[strlen(payload)]='\0';
500  printf("systemStates.ecm.mac.payload=%s\n",systemStates.ecm_mac.payload);
501  break;
502  case IARM_BUS_SYSMGR_SYSSTATE_DAC_ID :
503  systemStates.dac_id.state = state;
504  systemStates.dac_id.error = error;
505  assert ( ( sizeof(systemStates.dac_id.payload) -1 ) > strlen(payload) );
506  rc = strcpy_s( systemStates.dac_id.payload,sizeof(systemStates.dac_id.payload), payload );
507  if(rc!=EOK)
508  {
509  ERR_CHK(rc);
510  }
511  LOG( "Got IARM_BUS_SYSMGR_SYSSTATE_DAC_ID = %s\n", systemStates.dac_id.payload );
512  break;
513  case IARM_BUS_SYSMGR_SYSSTATE_PLANT_ID :
514  systemStates.plant_id.state = state;
515  systemStates.plant_id.error = error;
516  assert ( ( sizeof(systemStates.plant_id.payload) -1 ) > strlen(payload) );
517  rc = strcpy_s( systemStates.plant_id.payload,sizeof(systemStates.plant_id.payload), payload );
518  if(rc!=EOK)
519  {
520  ERR_CHK(rc);
521  }
522  LOG( "Got IARM_BUS_SYSMGR_SYSSTATE_PLANT_ID = %s\n", systemStates.plant_id.payload );
523  break;
524  case IARM_BUS_SYSMGR_SYSSTATE_STB_SERIAL_NO:
525  systemStates.stb_serial_no.error =error;
526  strncpy(systemStates.stb_serial_no.payload,payload,strlen(payload));
527  systemStates.stb_serial_no.payload[strlen(payload)]='\0';
528  printf("systemStates.stb.serial.payload=%s\n",systemStates.stb_serial_no.payload);
529  break;
530  case IARM_BUS_SYSMGR_SYSSTATE_BOOTUP :
531  systemStates.bootup.state = state;
532  systemStates.bootup.error = error;
533  break;
534  case IARM_BUS_SYSMGR_SYSSTATE_DST_OFFSET :
535  systemStates.dst_offset.state = state;
536  strncpy( systemStates.dst_offset.payload,payload,strlen(payload));
537  systemStates.dst_offset.payload[ strlen(payload) ] = '\0';
538  systemStates.dst_offset.error = error;
539  break;
540 
541  case IARM_BUS_SYSMGR_SYSSTATE_RF_CONNECTED :
542  systemStates.rf_connected.state = state;
543  systemStates.rf_connected.error = error;
544  LOG( "Got IARM_BUS_SYSMGR_SYSSTATE_RF_CONNECTED,State = %d, Error = %d\n", systemStates.rf_connected.state,systemStates.rf_connected.error );
545  break;
546  case IARM_BUS_SYSMGR_SYSSTATE_IP_MODE:
547  systemStates.ip_mode.state=state;
548  systemStates.ip_mode.error =error;
549  strncpy(systemStates.ip_mode.payload,payload,strlen(payload));
550  systemStates.ip_mode.payload[strlen(payload)]='\0';
551  printf("Got IARM_BUS_SYSMGR_SYSSTATE_IP_MODE systemStates.ip_mode.payload=%s\n",systemStates.ip_mode.payload);
552  break;
553  case IARM_BUS_SYSMGR_SYSSTATE_QAM_READY:
554  systemStates.qam_ready_status.state = state;
555  systemStates.qam_ready_status.error = error;
556  LOG( "Got IARM_BUS_SYSMGR_SYSSTATE_QAM_READY,State = %d, Error = %d\n", systemStates.qam_ready_status.state,systemStates.qam_ready_status.error );
557  break;
558  default:
559  break;
560  }
561  pthread_mutex_unlock(&tMutexLock);
562  }
563 }
564 
565 /**
566  * @brief This function executes a shell script and returns its value.
567  *
568  * @param script_name [in] Null terminated path name to the script.
569  *
570  * @param return_value [in] value returned by the system command executing the script.
571  *
572  * @return None
573  */
574 
575 void GetSerialNumber(void)
576 {
578  IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
579 
580  if(strlen(systemStates.stb_serial_no.payload) > 0)
581  {
582  return;
583  }
584 
585  param.type = mfrSERIALIZED_TYPE_SERIALNUMBER;
586  param.bufLen = 0;
588  param.buffer[param.bufLen] = '\0';
589 
590  pthread_mutex_lock(&tMutexLock);
591  if(iarm_ret == IARM_RESULT_SUCCESS)
592  {
593  memset(systemStates.stb_serial_no.payload, 0, sizeof(systemStates.stb_serial_no.payload));
594  strncpy(systemStates.stb_serial_no.payload, param.buffer, sizeof(systemStates.stb_serial_no.payload)-1); /*Limiting the size as that of destination*/
595  systemStates.stb_serial_no.error = 0;
596  }
597  else
598  {
599  systemStates.stb_serial_no.error = 1;
600  }
601  pthread_mutex_unlock(&tMutexLock);
602 }
603 
604 static int getKeyCodeLoggingPref(void)
605 {
606  int ret = 0;
607  ret = keyLogStatus;
608  return ret;
609 }
610 static void setKeyCodeLoggingPref(int logStatus)
611 {
612  int prevKeyLogStatus = keyLogStatus;
613 
614  if(0 == logStatus)
615  {
616  keyLogStatus = 0;
617  }
618  else if(1 == logStatus)
619  {
620  keyLogStatus = 1;
621  }
622  else
623  {
624  /*do nothing*/
625  }
626 
627  if(prevKeyLogStatus != keyLogStatus)
628  {
629  __TIMESTAMP(); printf ("The Key Code Logging Preference is set to %d\n", keyLogStatus);
630  IARM_Bus_SYSMgr_EventData_t eventData;
631  eventData.data.keyCodeLogData.logStatus = keyLogStatus;
632  __TIMESTAMP(); printf("<<<<<<< Send KEYCODE LOGGING CHANGED Event with log status %d>>>>>>>>", eventData.data.keyCodeLogData.logStatus);
633  IARM_Bus_BroadcastEvent(IARM_BUS_SYSMGR_NAME, (IARM_EventId_t)IARM_BUS_SYSMGR_EVENT_KEYCODE_LOGGING_CHANGED,(void *)&eventData,sizeof(eventData));
634  }
635  else
636  {
637  __TIMESTAMP(); printf ("Key Code Log status set to previous value itself!!\n");
638  }
639 
640  return;
641 }
642 
643 static IARM_Result_t _GetKeyCodeLoggingPref(void *arg)
644 {
646 
647  param->logStatus = getKeyCodeLoggingPref();
648 
649  __TIMESTAMP(); printf ("_GetKeyCodeLoggingPref : Key Code Log status is %d\n", param->logStatus);
650  return IARM_RESULT_SUCCESS;
651 
652 }
653 static IARM_Result_t _SetKeyCodeLoggingPref(void *arg)
654 {
656 
657  __TIMESTAMP(); printf ("_SetKeyCodeLoggingPref : Key Code Log status is %d\n", param->logStatus);
658  setKeyCodeLoggingPref(param->logStatus);
659 
660  return IARM_RESULT_SUCCESS;
661 }
662 
663 
664 
665 /** @} */
666 /** @} */
_IARM_BUS_SYSMGR_HDCPProfileInfo_Param_t
Definition: sysMgr.h:119
_IARM_BUS_SYSMGR_KEYCodeLoggingInfo_Param_t
Definition: sysMgr.h:123
IARM_Bus_Term
IARM_Result_t IARM_Bus_Term(void)
This API is used to terminate the IARM-Bus library.
_IARM_Bus_SYSMgr_GetSystemStates_Param_t::channel_map
state_property channel_map
Definition: sysMgr.h:300
sysMgr.h
IARM-Bus Sys Manager Public API.
IARM_BUS_SYSMGR_NAME
#define IARM_BUS_SYSMGR_NAME
Definition: sysMgr.h:110
_IARM_Bus_MFRLib_GetSerializedData_Param_t::buffer
char buffer[(1280)]
Definition: mfrMgr.h:120
IARM_Bus_WritePIDFile
void IARM_Bus_WritePIDFile(const char *path)
Write PID file.
IARM_Bus_Call
IARM_Result_t IARM_Bus_Call(const char *ownerName, const char *methodName, void *arg, size_t argLen)
This API is used to Invoke RPC method by its application name and method name.
Definition: iarm_bus.c:57
SYSMgr_Stop
IARM_Result_t SYSMgr_Stop(void)
Terminates the Sys manager.
Definition: sysMgr.c:187
_IARM_Bus_MFRLib_GetSerializedData_Param_t::bufLen
int bufLen
Definition: mfrMgr.h:121
IARM_Bus_RegisterEvent
IARM_Result_t IARM_Bus_RegisterEvent(IARM_EventId_t maxEventId)
This API is used to register all the events that are published by the application.
IARM_Bus_RegisterEventHandler
IARM_Result_t IARM_Bus_RegisterEventHandler(const char *ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler)
This API register to listen to event and provide the callback function for event notification....
Definition: iarmMgrMocks.cpp:43
_IARM_Bus_SYSMgr_GetSystemStates_Param_t
Definition: sysMgr.h:299
IARM_Bus_RegisterCall
IARM_Result_t IARM_Bus_RegisterCall(const char *methodName, IARM_BusCall_t handler)
This API is used to register an RPC method that can be invoked by other applications.
SYSMgr_Loop
IARM_Result_t SYSMgr_Loop()
Listens for component specific events from drivers.
Definition: sysMgr.c:174
IARM_Bus_Disconnect
IARM_Result_t IARM_Bus_Disconnect(void)
This API disconnect Application from IARM Bus so the application will not receive any IARM event or R...
_IARM_BUS_SYSMgr_EventData_t
Definition: sysMgr.h:229
IARM_Bus_BroadcastEvent
IARM_Result_t IARM_Bus_BroadcastEvent(const char *ownerName, IARM_EventId_t eventId, void *data, size_t len)
This API is used to publish an Asynchronous event to all IARM client registered for this perticular e...
libIBus.h
RDK IARM-Bus API Declarations.
IARM_BUS_SYSMGR_EVENT_MAX
@ IARM_BUS_SYSMGR_EVENT_MAX
Definition: sysMgr.h:141
GetSerialNumber
static void GetSerialNumber(void)
This function executes a shell script and returns its value.
Definition: sysMgr.c:575
IARM_BUS_MFRLIB_API_GetSerializedData
#define IARM_BUS_MFRLIB_API_GetSerializedData
Definition: mfrMgr.h:100
_GetSystemStates
static IARM_Result_t _GetSystemStates(void *arg)
This functions returns the SYstem STates.
Definition: sysMgr.c:283
IARM_BUS_MFRLIB_NAME
#define IARM_BUS_MFRLIB_NAME
Definition: mfrMgr.h:98
CheckHdcpProfile
static int CheckHdcpProfile(void)
This functions sets/updates the HDCP Profile
Definition: sysMgr.c:213
_IARM_Bus_MFRLib_GetSerializedData_Param_t
Definition: mfrMgr.h:118
_IARM_BUS_SYSMGR_KEYCodeLoggingInfo_Param_t::logStatus
int logStatus
Definition: sysMgr.h:124
_GetHDCPProfile
static IARM_Result_t _GetHDCPProfile(void *arg)
This functions returns the HDCP Profile.
Definition: sysMgr.c:264
sysMgrInternal.h
IARM-Bus Sys Manager Internal API.
_IARM_Bus_MFRLib_GetSerializedData_Param_t::type
mfrSerializedType_t type
Definition: mfrMgr.h:119
IARM_Bus_Connect
IARM_Result_t IARM_Bus_Connect(void)
This API is used to connect application to the IARM bus daemon. After connected, the application can ...
Definition: iarmMgrMocks.cpp:33
_IARM_BUS_SYSMGR_HDCPProfileInfo_Param_t::HdcpProfile
int HdcpProfile
Definition: sysMgr.h:120
IARM_Bus_Init
IARM_Result_t IARM_Bus_Init(const char *name)
This API is used to initialize the IARM-Bus library.
Definition: iarmMgrMocks.cpp:38
IARM_BUS_SYSMGR_EVENT_KEYCODE_LOGGING_CHANGED
@ IARM_BUS_SYSMGR_EVENT_KEYCODE_LOGGING_CHANGED
Definition: sysMgr.h:138
IARM_BUS_SYSMGR_EVENT_HDCP_PROFILE_UPDATE
@ IARM_BUS_SYSMGR_EVENT_HDCP_PROFILE_UPDATE
Definition: sysMgr.h:134
IARM_BUS_SYSMGR_API_GetSystemStates
#define IARM_BUS_SYSMGR_API_GetSystemStates
Definition: sysMgr.h:284