RDK Documentation (Open Sourced RDK Components)
dsFPD.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 devicesettings
24 * @{
25 * @defgroup rpc
26 * @{
27 **/
28 
29 
30 #include <stdio.h>
31 #include <string.h>
32 #include <unistd.h>
33 #include <fcntl.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <pthread.h>
37 #include "dsFPD.h"
38 #include "dsRpc.h"
39 #include "dsTypes.h"
40 #include "dsserverlogger.h"
41 #include "dsMgr.h"
42 
43 #include "iarmUtil.h"
44 #include "libIARM.h"
45 #include "libIBus.h"
46 
47 #include <iostream>
48 #include "hostPersistence.hpp"
49 #include <sstream>
50 
51 
52 #define direct_list_top(list) ((list))
53 #define IARM_BUS_Lock(lock) pthread_mutex_lock(&fpLock)
54 #define IARM_BUS_Unlock(lock) pthread_mutex_unlock(&fpLock)
55 
56 /* Below block allows the default brightness of a device (after a reset) to be set from
57  * device-specific recipes. If recipes say nothing, it should use max brightness supported. */
58 #ifndef dsFPD_BRIGHTNESS_DEFAULT
59 #define dsFPD_BRIGHTNESS_DEFAULT dsFPD_BRIGHTNESS_MAX
60 #endif
61 
62 static int m_isInitialized = 0;
63 static int m_isPlatInitialized=0;
64 static pthread_mutex_t fpLock = PTHREAD_MUTEX_INITIALIZER;
65 
66 IARM_Result_t dsFPDMgr_init();
67 IARM_Result_t dsFPDMgr_term();
68 IARM_Result_t _dsFPInit(void *arg);
69 IARM_Result_t _dsFPTerm(void *arg);
70 IARM_Result_t _dsSetFPText(void *arg);
71 IARM_Result_t _dsSetFPTime(void *arg);
72 IARM_Result_t _dsSetFPScroll(void *arg);
73 IARM_Result_t _dsSetFPBlink(void *arg);
74 IARM_Result_t _dsGetFPBrightness(void *arg);
75 IARM_Result_t _dsSetFPBrightness(void *arg);
76 IARM_Result_t _dsSetFPState(void *arg);
77 IARM_Result_t _dsGetFPState(void *arg);
78 IARM_Result_t _dsSetFPColor(void *arg);
79 IARM_Result_t _dsGetFPColor(void *arg);
80 IARM_Result_t _dsSetFPTextBrightness(void *arg);
81 IARM_Result_t _dsGetFPTextBrightness(void *arg);
82 IARM_Result_t _dsFPEnableCLockDisplay(void *arg);
83 IARM_Result_t _dsGetTimeFormat(void *arg);
84 IARM_Result_t _dsSetTimeFormat(void *arg);
85 IARM_Result_t _dsSetFPDMode(void *arg);
86 
87 /*TBD - Only Text and Power Brigghtness settings for the time being
88  * Create an Array of all inidcator and test display
89 */
90 static dsFPDBrightness_t _dsPowerBrightness = dsFPD_BRIGHTNESS_MAX ;
91 static dsFPDBrightness_t _dsTextBrightness = dsFPD_BRIGHTNESS_MAX ;
92 static dsFPDColor_t _dsPowerLedColor = dsFPD_COLOR_BLUE;
93 static dsFPDTimeFormat_t _dsTextTimeFormat = dsFPD_TIME_12_HOUR;
94 static dsFPDMode_t _dsFPDMode = dsFPD_MODE_ANY;
95 
96 
97 
98 
99 /** Structure that defines internal data base for the FP */
100 typedef struct _dsFPDSettings_t_
101 {
102  dsFPDBrightness_t brightness;
103  dsFPDState_t state;
104  dsFPDColor_t color;
106 
107 /** Variable that stores the brightness and State for FP */
108 static _FPDSettings_t srvFPDSettings[dsFPD_INDICATOR_MAX];
109 
110 
111 
112 using namespace std;
113 
114 std::string numberToString (int number);
115 int stringToNumber (std::string text);
116 std::string enumToColor (dsFPDColor_t enumColor);
117 
118 std::string numberToString (int number)
119 {
120  stringstream convert;
121  convert << number;
122  return convert.str();
123 }
124 
125 
126 int stringToNumber (std::string text)
127 {
128  int number;
129  stringstream convert (text);
130 
131  if (!(convert >> number) )
132  number = 0;
133 
134  return number;
135 }
136 
137 std::string enumToColor (dsFPDColor_t enumColor)
138 {
139  std::string color;
140  stringstream convert;
141 
142  switch (enumColor)
143  {
144 
145  case dsFPD_COLOR_BLUE:
146  color = "BLUE";
147  break;
148 
149  case dsFPD_COLOR_GREEN:
150  color = "GREEN";
151  break;
152 
153  case dsFPD_COLOR_RED:
154  color = "RED";
155  break;
156 
157  case dsFPD_COLOR_YELLOW:
158  color = "YELLOW";
159  break;
160 
161  case dsFPD_COLOR_ORANGE:
162  color = "RED";
163  break;
164 
165  default:
166  convert << enumColor;
167  return convert.str();
168  }
169  return color;
170 }
171 
172 
173 IARM_Result_t dsFPDMgr_init()
174 {
175 
176 
177  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsFPInit,_dsFPInit);
178 
179  try
180  {
181  /* Init the Power and Clock Brightness */
182  string value;
183  int maxBrightness = dsFPD_BRIGHTNESS_DEFAULT;
184 
185  value = device::HostPersistence::getInstance().getProperty("Power.brightness", numberToString(maxBrightness));
186  _dsPowerBrightness = stringToNumber(value);
187 
188  value = device::HostPersistence::getInstance().getProperty("Text.brightness", numberToString(maxBrightness));
189  _dsTextBrightness = stringToNumber(value);
190 
191 #if(dsFPD_BRIGHTNESS_DEFAULT != dsFPD_BRIGHTNESS_MAX)
192  /* If we're applying a default brightness that's not MAX, check for currently persisted values. If any of them = MAX,
193  * update those to the current default. If the persisted values != MAX, leave them alone because they're likely to have been
194  * set by the user. */
195  if(dsFPD_BRIGHTNESS_MAX == _dsPowerBrightness)
196  {
197  INT_INFO("Applying new default brightness to power indicator. Changing from %d to %d.\n", _dsPowerBrightness, dsFPD_BRIGHTNESS_DEFAULT);
198  _dsPowerBrightness = dsFPD_BRIGHTNESS_DEFAULT;
199  }
200  if(dsFPD_BRIGHTNESS_MAX == _dsTextBrightness)
201  {
202  INT_INFO("Applying new default brightness to text indicator. Changing from %d to %d.\n", _dsTextBrightness, dsFPD_BRIGHTNESS_DEFAULT);
203  _dsTextBrightness = dsFPD_BRIGHTNESS_DEFAULT;
204  }
205 #endif
206 
207  INT_INFO("Power Brightness Read from Persistent is %d \r\n",_dsPowerBrightness);
208  INT_INFO("Text Brightness Read from Persistent is %d \r\n",_dsTextBrightness);
209 
210  #ifdef HAS_CLOCK_DISPLAY
211  string _TimeFormat("12_HOUR");
212  /* Get the Time Format from Persistence */
213  _TimeFormat = device::HostPersistence::getInstance().getProperty("Text.timeformat",_TimeFormat);
214  if (_TimeFormat.compare("12_HOUR") == 0)
215  {
216  _dsTextTimeFormat = dsFPD_TIME_12_HOUR;
217  device::HostPersistence::getInstance().persistHostProperty("Text.timeformat","12_HOUR");
218  }
219  else if (_TimeFormat.compare("24_HOUR") == 0)
220  {
221  _dsTextTimeFormat = dsFPD_TIME_24_HOUR;
222  device::HostPersistence::getInstance().persistHostProperty("Text.timeformat","24_HOUR");
223  }
224  INT_INFO("Clock Time Format Read from Persistent is %s \r\n",_TimeFormat.c_str());
225  #endif
226 
227  }
228  catch(...)
229  {
230  INT_ERROR("Error in Reading Brightness Value On Startup.. Use Default value \r\n");
231  }
232 
233  return IARM_RESULT_SUCCESS;
234 }
235 
236 IARM_Result_t dsFPDMgr_term()
237 {
238  return IARM_RESULT_SUCCESS;
239 }
240 
241 IARM_Result_t _dsFPInit(void *arg)
242 {
243  IARM_BUS_Lock(lock);
244 
245 
246  if (!m_isInitialized) {
247 
248  INT_INFO("<<<<< called _dsFPInit >>>>>>>>\r\n");
249 
250  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsFPTerm,_dsFPTerm);
251  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetFPText,_dsSetFPText);
252  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetFPTime,_dsSetFPTime);
253  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetFPScroll,_dsSetFPScroll);
254  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetFPBlink,_dsSetFPBlink);
255  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetFPBrightness,_dsGetFPBrightness);
256  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetFPState,_dsSetFPState);
257  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetFPState,_dsGetFPState);
258  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetFPBrightness,_dsSetFPBrightness);
259  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetFPColor,_dsSetFPColor);
260  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetFPColor,_dsGetFPColor);
261  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetFPTextBrightness,_dsGetFPTextBrightness);
262  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetFPTextBrightness,_dsSetFPTextBrightness);
263  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsFPEnableCLockDisplay,_dsFPEnableCLockDisplay);
264  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetTimeFormat,_dsGetTimeFormat);
265  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetTimeFormat,_dsSetTimeFormat);
266  IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsSetFPDMode,_dsSetFPDMode);
267 
268 
269  memset (srvFPDSettings, 0, sizeof (srvFPDSettings));
270 
271  for (int i = dsFPD_INDICATOR_MESSAGE; i < dsFPD_INDICATOR_MAX; i++)
272  {
273  srvFPDSettings[i].brightness = dsFPD_BRIGHTNESS_MAX;
274  srvFPDSettings[i].state = dsFPD_STATE_OFF;
275  srvFPDSettings[i].color = dsFPD_COLOR_BLUE;
276  }
277 
278  m_isInitialized = 1;
279  }
280 
281  if (!m_isPlatInitialized) {
282  dsFPInit();
283  m_isPlatInitialized = 1;
284  }
285 
286  IARM_BUS_Unlock(lock);
287 
288  return IARM_RESULT_SUCCESS;
289 }
290 IARM_Result_t _dsFPTerm(void *arg)
291 {
292  /*@TODO: Deregister the calls, if necessary */
293  _DEBUG_ENTER();
294 
295 
296  IARM_BUS_Lock(lock);
297 
298  if (m_isPlatInitialized) {
299  dsFPTerm();
300  m_isPlatInitialized = 0;
301  }
302 
303  IARM_BUS_Unlock(lock);
304 
305  return IARM_RESULT_SUCCESS;
306 }
307 
308 IARM_Result_t _dsSetFPText(void *arg)
309 {
310  _DEBUG_ENTER();
311 
312  IARM_Result_t ret = IARM_RESULT_SUCCESS;
313  #ifdef HAS_CLOCK_DISPLAY
314  IARM_BUS_Lock(lock);
315 
316  if ((_dsFPDMode == dsFPD_MODE_ANY) || (_dsFPDMode == dsFPD_MODE_TEXT)) {
317  dsError_t dsStatus = dsSetFPText((char *) arg);
318  if(dsStatus != dsERR_NONE)
319  {
320  ret = IARM_RESULT_INVALID_PARAM;
321  }
322  }
323  else {
324  INT_INFO("_dsSetFPText: Not setting Text, Clock mode enabled \r\n");
325  }
326 
327  IARM_BUS_Unlock(lock);
328  #endif
329 
330  return ret;
331 }
332 
333 IARM_Result_t _dsSetFPTime(void *arg)
334 {
335  _DEBUG_ENTER();
336 
337  IARM_Result_t ret = IARM_RESULT_SUCCESS;
338  #ifdef HAS_CLOCK_DISPLAY
339  IARM_BUS_Lock(lock);
340 
341  if ((_dsFPDMode == dsFPD_MODE_ANY) || (_dsFPDMode == dsFPD_MODE_CLOCK)) {
342  dsFPDTimeParam_t *param = (dsFPDTimeParam_t *)arg;
343  dsError_t dsStatus = dsSetFPTime(_dsTextTimeFormat, param->nHours, param->nMinutes);
344  if(dsStatus != dsERR_NONE)
345  {
346  ret = IARM_RESULT_INVALID_PARAM;
347  }
348  }
349  else {
350  INT_INFO("_dsSetFPTime: Not setting Clock, Text mode enabled \r\n");
351  }
352 
353  IARM_BUS_Unlock(lock);
354  #endif
355 
356  return ret;
357 }
358 
359 IARM_Result_t _dsSetFPScroll(void *arg)
360 {
361  _DEBUG_ENTER();
362 
363  IARM_Result_t ret = IARM_RESULT_SUCCESS;
364  #ifdef HAS_CLOCK_DISPLAY
365  IARM_BUS_Lock(lock);
366 
367  dsFPDScrollParam_t *param = (dsFPDScrollParam_t *)arg;
368  dsError_t dsStatus = dsSetFPScroll(param->nScrollHoldOnDur, param->nHorzScrollIterations, param->nVertScrollIterations);
369  if(dsStatus != dsERR_NONE)
370  {
371  ret = IARM_RESULT_INVALID_PARAM;
372  }
373 
374  IARM_BUS_Unlock(lock);
375  #endif
376 
377  return ret;
378 }
379 
380 IARM_Result_t _dsSetFPBlink(void *arg)
381 {
382  _DEBUG_ENTER();
383  IARM_Result_t ret = IARM_RESULT_SUCCESS;
384  IARM_BUS_Lock(lock);
385 
386  dsFPDBlinkParam_t *param = (dsFPDBlinkParam_t *)arg;
387  dsError_t dsStatus = dsSetFPBlink(param->eIndicator, param->nBlinkDuration, param->nBlinkIterations);
388  if(dsStatus != dsERR_NONE)
389  {
390  ret = IARM_RESULT_INVALID_PARAM;
391  }
392 
393  IARM_BUS_Unlock(lock);
394  return ret;
395 }
396 
397 IARM_Result_t _dsGetFPBrightness(void *arg)
398 {
399  _DEBUG_ENTER();
400  IARM_BUS_Lock(lock);
401 
402  dsFPDBrightParam_t *param = (dsFPDBrightParam_t *)arg;
403  //dsGetFPBrightness(param->eIndicator, &param->eBrightness);
404 
405  /*
406  * Power LED Indicator Brightness is the Global LED brightness
407  * for all indicators
408  */
409 
410  param->eBrightness = _dsPowerBrightness;
411 
412  INT_INFO("_dsGetFPBrightness Power Brightness is %d \r\n",param->eBrightness);
413 
414  IARM_BUS_Unlock(lock);
415  return IARM_RESULT_SUCCESS;
416 
417 }
418 
419 
420 
421 IARM_Result_t _dsSetFPBrightness(void *arg)
422 {
423  _DEBUG_ENTER();
424  IARM_Result_t ret = IARM_RESULT_SUCCESS;
425  IARM_BUS_Lock(lock);
426 
427  dsFPDBrightParam_t *param = (dsFPDBrightParam_t *)arg;
428 
429 
430  if (param->eBrightness <= dsFPD_BRIGHTNESS_MAX)
431  {
432  dsError_t dsStatus = dsSetFPBrightness(param->eIndicator, param->eBrightness);
433  if(dsStatus == dsERR_NONE)
434  {
435  srvFPDSettings[param->eIndicator].brightness = param->eBrightness;
436 
437  try{
438  switch (param->eIndicator)
439  {
441  {
442  INT_INFO("_dsSetFPBrightness Power Brightness From App is %d \r\n",param->eBrightness);
443 
444  if(param->toPersist)
445  {
446  _dsPowerBrightness = param->eBrightness;
447  device::HostPersistence::getInstance().persistHostProperty("Power.brightness", numberToString(_dsPowerBrightness));
448  }
449  break;
450  }
451 
456  default:
457  {
458  break;
459  }
460  }
461  }
462  catch(...)
463  {
464  INT_ERROR("Error in Persisting the Power Brightness Value \r\n");
465  }
466  }
467  else
468  {
469  ret = IARM_RESULT_INVALID_PARAM;
470  }
471 
472  }
473  else
474  {
475  ret = IARM_RESULT_INVALID_PARAM;
476  }
477  //printf("_dsSetFPBrightness Power Brighnes is %d \r\n",_dsPowerBrightness);
478  //printf("_dsSetFPBrightness Text Brighnes is %d \r\n",_dsTextBrightness);
479 
480  IARM_BUS_Unlock(lock);
481  return ret;
482 }
483 
484 
485 IARM_Result_t _dsGetFPTextBrightness(void *arg)
486 {
487  _DEBUG_ENTER();
488 
489  #ifdef HAS_CLOCK_DISPLAY
490  IARM_BUS_Lock(lock);
491 
493  /*
494  * Text Display Indicator Brightness
495  */
496  param->eBrightness = _dsTextBrightness;
497  INT_INFO("_dsGetFPTextBrightness Brightness is %d \r\n",param->eBrightness);
498 
499  IARM_BUS_Unlock(lock);
500  #endif
501  return IARM_RESULT_SUCCESS;
502 }
503 
504 IARM_Result_t _dsSetFPTextBrightness(void *arg)
505 {
506  _DEBUG_ENTER();
507  IARM_Result_t ret = IARM_RESULT_SUCCESS;
508  #ifdef HAS_CLOCK_DISPLAY
509  IARM_BUS_Lock(lock);
510 
512 
513 
514  if (param->eBrightness <= dsFPD_BRIGHTNESS_MAX)
515  {
516  dsError_t dsStatus = dsSetFPTextBrightness(param->eIndicator, param->eBrightness);
517  if(dsStatus == dsERR_NONE)
518  {
519  try
520  {
521  switch (param->eIndicator)
522  {
523  case dsFPD_TEXTDISP_TEXT:
524  {
525  INT_INFO("_dsSetFPTextBrightness Brightness frm App is %d \r\n",param->eBrightness);
526  _dsTextBrightness = param->eBrightness;
527  device::HostPersistence::getInstance().persistHostProperty("Text.brightness",numberToString(_dsTextBrightness));
528  break;
529  }
530  default:
531  {
532  break;
533  }
534  }
535  }
536  catch(...)
537  {
538  INT_ERROR("Error in Persisting the Text Brightness Value \r\n");
539  }
540  }
541  else
542  {
543  ret = IARM_RESULT_INVALID_PARAM;
544  }
545 
546  }
547  else
548  {
549  ret = IARM_RESULT_INVALID_PARAM;
550  }
551 
552  IARM_BUS_Unlock(lock);
553 
554  #endif
555  return ret;
556 }
557 
558 
559 IARM_Result_t _dsGetFPColor(void *arg)
560 {
561  _DEBUG_ENTER();
562  IARM_BUS_Lock(lock);
563 
564  dsFPDColorParam_t *param = (dsFPDColorParam_t *)arg;
565  param->eColor = srvFPDSettings[param->eIndicator].color;
566  IARM_BUS_Unlock(lock);
567  return IARM_RESULT_SUCCESS;
568 
569 }
570 
571 IARM_Result_t _dsSetFPColor(void *arg)
572 {
573  _DEBUG_ENTER();
574  IARM_Result_t ret = IARM_RESULT_SUCCESS;
575  IARM_BUS_Lock(lock);
576 
577  dsFPDColorParam_t *param = (dsFPDColorParam_t *)arg;
578  dsError_t dsStatus = dsSetFPColor(param->eIndicator, param->eColor);
579  if(dsStatus == dsERR_NONE)
580  {
581  param->eColor &= 0x00FFFFFF;
582  srvFPDSettings[param->eIndicator].color = param->eColor;
583  INT_INFO("_dsSetFPColor Value From App is %d for Indicator %d \r\n",param->eColor,param->eIndicator);
584  try{
585  switch (param->eIndicator)
586  {
588  {
589  if(param->toPersist)
590  {
591  _dsPowerLedColor = param->eColor;
592  device::HostPersistence::getInstance().persistHostProperty("Power.Color",enumToColor(param->eColor));
593  }
594  break;
595  }
600  default:
601  {
602  break;
603  }
604  }
605  }
606  catch(...)
607  {
608  INT_ERROR("Error in Persisting the Color Value \r\n");
609  }
610  }
611  else
612  {
613  INT_ERROR("Error in dsSetFPColor dsStatus:%d \r\n",dsStatus);
614  ret = IARM_RESULT_INVALID_PARAM;
615  }
616  IARM_BUS_Unlock(lock);
617  return ret;
618 }
619 
620 
621 
622 IARM_Result_t _dsFPEnableCLockDisplay(void *arg)
623 {
624 
625  IARM_Result_t ret = IARM_RESULT_SUCCESS;
626 #ifdef HAS_CLOCK_DISPLAY
627  IARM_BUS_Lock(lock);
628  int *enable = (int *)arg;
629  int lenable = *enable;
630  dsError_t dsStatus = dsFPEnableCLockDisplay(lenable);
631  if(dsStatus != dsERR_NONE)
632  {
633  ret = IARM_RESULT_INVALID_PARAM;
634  }
635  IARM_BUS_Unlock(lock);
636 #endif
637  return ret;
638 }
639 
640 
641 IARM_Result_t _dsSetFPState(void *arg)
642 {
643  _DEBUG_ENTER();
644  IARM_Result_t ret = IARM_RESULT_SUCCESS;
645  IARM_BUS_Lock(lock);
646 
647  dsFPDStateParam_t *param = (dsFPDStateParam_t *)arg;
648  dsError_t dsStatus = dsERR_NONE;
649 
650  if (param->state == dsFPD_STATE_ON)
651  {
652  /*
653  * Power LED Indicator Brightness is the Global LED brightness
654  * for all indicators
655  */
656  dsStatus = dsSetFPBrightness(param->eIndicator,_dsPowerBrightness);
657  if(dsStatus == dsERR_NONE)
658  {
659  if(param->eIndicator == dsFPD_INDICATOR_POWER)
660  INT_INFO("_dsSetFPState Setting Power LED to ON with Brightness %d \r\n",_dsPowerBrightness);
661 
662  srvFPDSettings[param->eIndicator].state = param->state;
663  }
664  else
665  {
666  ret = IARM_RESULT_INVALID_PARAM;
667  }
668  }
669  else if (param->state == dsFPD_STATE_OFF)
670  {
671  dsStatus = dsSetFPBrightness(param->eIndicator,0);
672  if(dsStatus == dsERR_NONE)
673  {
674  if(param->eIndicator == dsFPD_INDICATOR_POWER)
675  INT_INFO("_dsSetFPState Setting Power LED to OFF with Brightness 0 \r\n"); //CID:127891 - Print_args
676 
677  srvFPDSettings[param->eIndicator].state = param->state;
678  }
679  else
680  {
681  ret = IARM_RESULT_INVALID_PARAM;
682  }
683  }
684 
685  IARM_BUS_Unlock(lock);
686  return ret;
687 }
688 
689 
690 
691 
692 IARM_Result_t _dsGetTimeFormat(void *arg)
693 {
694  _DEBUG_ENTER();
695 
696 #ifdef HAS_CLOCK_DISPLAY
697  IARM_BUS_Lock(lock);
698 
700 
701  if( param == NULL)
702  {
703  INT_INFO("Error:_dsGetTimeFormat : NULL Param ... \r\n");
704  IARM_BUS_Unlock(lock);
705  return IARM_RESULT_INVALID_PARAM;
706  }
707 
708  param->eTime = _dsTextTimeFormat;
709 
710  IARM_BUS_Unlock(lock);
711  #endif
712  return IARM_RESULT_SUCCESS;
713 }
714 
715 IARM_Result_t _dsSetTimeFormat(void *arg)
716 {
717  _DEBUG_ENTER();
718 
719  #ifdef HAS_CLOCK_DISPLAY
720 
721  IARM_BUS_Lock(lock);
722 
724 
725  if( param == NULL)
726  {
727  INT_INFO("Error:_dsSetTimeFormat : NULL Param ... \r\n");
728  IARM_BUS_Unlock(lock);
729  return IARM_RESULT_INVALID_PARAM;
730  }
731 
732  if (param->eTime != _dsTextTimeFormat)
733  {
734  _dsTextTimeFormat = param->eTime;
735 
736  if (param->eTime == dsFPD_TIME_12_HOUR)
737  {
738  device::HostPersistence::getInstance().persistHostProperty("Text.timeformat","12_HOUR");
739  INT_INFO("Clock Time Format Updated to 12_HOUR ... \r\n");
740  }
741  else if (param->eTime == dsFPD_TIME_24_HOUR)
742  {
743  device::HostPersistence::getInstance().persistHostProperty("Text.timeformat","24_HOUR");
744  INT_INFO("Clock Time Format Updated to 24_HOUR ... \r\n");
745  }
746 
747  /* Send Time Format Event */
748  IARM_Bus_DSMgr_EventData_t _eventData;
749  IARM_Bus_DSMgr_EventId_t _eventId;
750 
751  _eventData.data.FPDTimeFormat.eTimeFormat = _dsTextTimeFormat;
753 
754  IARM_Bus_BroadcastEvent(IARM_BUS_DSMGR_NAME,(IARM_EventId_t)_eventId,(void *)&_eventData, sizeof(_eventData));
755 
756  INT_INFO("Sent Clock IARM_BUS_DSMGR_EVENT_TIME_FORMAT_CHANGE event ... \r\n");
757  }
758 
759  IARM_BUS_Unlock(lock);
760 
761  #endif
762 
763  return IARM_RESULT_SUCCESS;
764 }
765 
766 
767 IARM_Result_t _dsGetFPState(void *arg)
768 {
769  _DEBUG_ENTER();
770  IARM_BUS_Lock(lock);
771 
772  dsFPDStateParam_t *param = (dsFPDStateParam_t *)arg;
773 
774  if(param->eIndicator < dsFPD_INDICATOR_MAX)
775  {
776  param->state = srvFPDSettings[param->eIndicator].state;
777  }
778 
779  IARM_BUS_Unlock(lock);
780  return IARM_RESULT_SUCCESS;
781 }
782 
783 
784 IARM_Result_t _dsSetFPDMode(void *arg)
785 {
786  _DEBUG_ENTER();
787 
788  IARM_BUS_Lock(lock);
789 
790  dsFPDModeParam_t *param = (dsFPDModeParam_t *)arg;
791  if ((param->eMode == dsFPD_MODE_ANY) || (param->eMode == dsFPD_MODE_TEXT) || (param->eMode == dsFPD_MODE_CLOCK)) {
792  _dsFPDMode = param->eMode;
793  INT_INFO("_dsSetFPDMode: Mode set to %d \r\n",param->eMode);
794  }
795  else {
796  INT_INFO("Error:_dsSetFPDMode : Invalid Param ... \r\n");
797  IARM_BUS_Unlock(lock);
798  return IARM_RESULT_INVALID_PARAM;
799  }
800 
801  IARM_BUS_Unlock(lock);
802  return IARM_RESULT_SUCCESS;
803 }
804 
805 
806 /** @} */
807 /** @} */
_dsFPDColorParam
Definition: dsRpc.h:668
dsFPD.h
dsFPD_MODE_TEXT
@ dsFPD_MODE_TEXT
Definition: dsTypes.h:869
IARM_BUS_DSMGR_EVENT_TIME_FORMAT_CHANGE
@ IARM_BUS_DSMGR_EVENT_TIME_FORMAT_CHANGE
Definition: dsMgr.h:62
dsSetFPColor
dsError_t dsSetFPColor(dsFPDIndicator_t eIndicator, dsFPDColor_t eColor)
Set LED color.
Definition: dsFPD.c:343
dsTypes.h
Device Settings HAL types.
dsFPDTimeFormat_t
enum __dsFPDTimeFormat_t dsFPDTimeFormat_t
dsFPDBrightness_t
uint32_t dsFPDBrightness_t
Definition: dsTypes.h:862
dsFPD_MODE_CLOCK
@ dsFPD_MODE_CLOCK
Definition: dsTypes.h:870
dsFPEnableCLockDisplay
dsError_t dsFPEnableCLockDisplay(int enable)
Use disable and enable display of clock.
Definition: dsFPD.c:390
dsFPD_STATE_ON
@ dsFPD_STATE_ON
Definition: dsTypes.h:821
device::HostPersistence::persistHostProperty
void persistHostProperty(const std::string &key, const std::string &value)
Definition: hostPersistence.cpp:273
dsFPD_COLOR_BLUE
#define dsFPD_COLOR_BLUE
Definition: dsTypes.h:765
dsSetFPScroll
dsError_t dsSetFPScroll(unsigned int nScrollHoldOnDur, unsigned int nHorzScrollIterations, unsigned int nVertScrollIterations)
Scroll text on 7-Segment Display.
Definition: dsFPD.c:135
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.
dsFPD_COLOR_GREEN
#define dsFPD_COLOR_GREEN
Definition: dsTypes.h:766
dsERR_NONE
@ dsERR_NONE
Definition: dsError.h:85
dsFPD_INDICATOR_RECORD
#define dsFPD_INDICATOR_RECORD
Definition: dsTypes.h:791
dsFPD_INDICATOR_MESSAGE
#define dsFPD_INDICATOR_MESSAGE
Definition: dsTypes.h:789
dsFPDState_t
enum __dsFPDState_t dsFPDState_t
dsFPD_COLOR_YELLOW
#define dsFPD_COLOR_YELLOW
Definition: dsTypes.h:768
_dsFPDScrollParam
Definition: dsRpc.h:633
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...
dsFPD_BRIGHTNESS_MAX
#define dsFPD_BRIGHTNESS_MAX
Definition: dsTypes.h:856
dsFPInit
dsError_t dsFPInit(void)
This function is used to initialize the underlying front panel display sub-system.
Definition: dsFPD.c:42
libIBus.h
RDK IARM-Bus API Declarations.
_dsFPDStateParam
Definition: dsRpc.h:662
_dsFPDModeParam
Definition: dsRpc.h:675
dsFPD_TIME_24_HOUR
@ dsFPD_TIME_24_HOUR
Definition: dsTypes.h:848
_FPDSettings_t
struct _dsFPDSettings_t_ _FPDSettings_t
dsSetFPBrightness
dsError_t dsSetFPBrightness(dsFPDIndicator_t eIndicator, dsFPDBrightness_t eBrightness)
Set LED brightness level.
Definition: dsFPD.c:213
dsSetFPText
dsError_t dsSetFPText(const char *pszChars)
Set text on 7-Segment Display.
Definition: dsFPD.c:80
dsFPD_COLOR_ORANGE
#define dsFPD_COLOR_ORANGE
Definition: dsTypes.h:769
dsFPD_INDICATOR_REMOTE
#define dsFPD_INDICATOR_REMOTE
Definition: dsTypes.h:792
dsFPD_TIME_12_HOUR
@ dsFPD_TIME_12_HOUR
Definition: dsTypes.h:847
dsFPTerm
dsError_t dsFPTerm(void)
Terminate the the Front Panel Display sub-system.
Definition: dsFPD.c:62
_dsFPDTimeFormatParam
Definition: dsRpc.h:628
_dsFPDTextBrightParam
Definition: dsRpc.h:655
dsSetFPBlink
dsError_t dsSetFPBlink(dsFPDIndicator_t eIndicator, unsigned int nBlinkDuration, unsigned int nBlinkIterations)
Set LED blinking mode.
Definition: dsFPD.c:161
dsFPD_COLOR_RED
#define dsFPD_COLOR_RED
Definition: dsTypes.h:767
dsSetFPTextBrightness
dsError_t dsSetFPTextBrightness(dsFPDTextDisplay_t eIndicator, dsFPDBrightness_t eBrightness)
Set brightness level of 7-Segment Display.
Definition: dsFPD.c:295
dsFPDMode_t
enum __dsFPDMode_t dsFPDMode_t
dsFPD_TEXTDISP_TEXT
@ dsFPD_TEXTDISP_TEXT
Definition: dsTypes.h:805
_dsFPDTimeParam
Definition: dsRpc.h:620
_dsFPDSettings_t_
Definition: dsFPD.c:100
dsFPD_MODE_ANY
@ dsFPD_MODE_ANY
Definition: dsTypes.h:868
IARM_Bus_DSMgr_EventId_t
enum _DSMgr_EventId_t IARM_Bus_DSMgr_EventId_t
srvFPDSettings
static _FPDSettings_t srvFPDSettings[dsFPD_INDICATOR_MAX]
Definition: dsFPD.c:108
_dsFPDBrightParam
Definition: dsRpc.h:647
dsFPD_INDICATOR_RFBYPASS
#define dsFPD_INDICATOR_RFBYPASS
Definition: dsTypes.h:793
device::HostPersistence::getInstance
static HostPersistence & getInstance(void)
Definition: hostPersistence.cpp:122
dsError_t
dsError_t
Device Settings API Error return codes.
Definition: dsError.h:84
dsSetFPTime
dsError_t dsSetFPTime(dsFPDTimeFormat_t eTime, const unsigned int uHour, const unsigned int uMinutes)
Set time on 7-Segment Display.
Definition: dsFPD.c:110
_DSMgr_EventData_t
Definition: dsMgr.h:81
dsFPD_INDICATOR_POWER
#define dsFPD_INDICATOR_POWER
Definition: dsTypes.h:790
dsFPD_STATE_OFF
@ dsFPD_STATE_OFF
Definition: dsTypes.h:820