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 "dsFPD.h"
33 #include "dsRpc.h"
34 #include "dsMgr.h"
35 #include "dsclientlogger.h"
36 #include "iarmUtil.h"
37 #include "libIARM.h"
38 #include "libIBus.h"
39 
40 
41 
43 {
44  printf("<<<<< Front Panel is initialized in Multi-App Mode >>>>>>>>\r\n");
45 
46  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
47 
48  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
49  (char *)IARM_BUS_DSMGR_API_dsFPInit,
50  NULL,
51  0);
52 
53  if (IARM_RESULT_SUCCESS == rpcRet)
54  {
55  return dsERR_NONE;
56  }
57 
58  return dsERR_GENERAL;
59 }
60 
61 
63 {
64  _DEBUG_ENTER();
65 
66  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
67  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
68  (char *)IARM_BUS_DSMGR_API_dsFPTerm,
69  NULL,
70  0);
71 
72  if (IARM_RESULT_SUCCESS == rpcRet)
73  {
74  return dsERR_NONE;
75  }
76 
77  return dsERR_GENERAL ;
78 }
79 
80 dsError_t dsSetFPText(const char* pszChars)
81 {
82  _DEBUG_ENTER();
83  _RETURN_IF_ERROR(pszChars != NULL, dsERR_INVALID_PARAM);
84 
85  int len = strlen(pszChars),i=0;
86  unsigned char text[128]={'\0'};
87 
88  for (i=0;i<len ;i++ )
89  {
90  text[i] = pszChars[i];
91  }
92  text[i] = '\0';
93 
94  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
95 
96  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
97  (char *)IARM_BUS_DSMGR_API_dsSetFPText,
98  &text[0],
99  len+1);
100 
101  if (IARM_RESULT_SUCCESS == rpcRet)
102  {
103  return dsERR_NONE;
104  }
105 
106  return dsERR_GENERAL ;
107 
108  }
109 
110 dsError_t dsSetFPTime (dsFPDTimeFormat_t eTime, const unsigned int uHour, const unsigned int uMinutes)
111 {
112  _DEBUG_ENTER();
113 
114  dsFPDTimeParam_t param ;
115 
116  param.eTime = eTime;
117  param.nHours = uHour;
118  param.nMinutes = uMinutes;
119 
120 
121  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
122 
123  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
124  (char *)IARM_BUS_DSMGR_API_dsSetFPTime,
125  (void *)&param,
126  sizeof(param));
127 
128  if (IARM_RESULT_SUCCESS == rpcRet)
129  {
130  return dsERR_NONE;
131  }
132 return dsERR_GENERAL ;
133 }
134 
135 dsError_t dsSetFPScroll(unsigned int nScrollHoldOnDur, unsigned int nHorzScrollIterations, unsigned int nVertScrollIterations)
136 {
137  _DEBUG_ENTER();
138 
139  dsFPDScrollParam_t param ;
140 
141 
142  param.nScrollHoldOnDur = nScrollHoldOnDur;
143  param.nHorzScrollIterations = nHorzScrollIterations;
144  param.nVertScrollIterations = nVertScrollIterations;
145 
146  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
147 
148  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
149  (char *)IARM_BUS_DSMGR_API_dsSetFPScroll,
150  (void *)&param,
151  sizeof(param));
152 
153  if (IARM_RESULT_SUCCESS == rpcRet)
154  {
155  return dsERR_NONE;
156  }
157 
158  return dsERR_GENERAL ;
159 }
160 
161 dsError_t dsSetFPBlink (dsFPDIndicator_t eIndicator, unsigned int nBlinkDuration, unsigned int nBlinkIterations)
162 {
163  _DEBUG_ENTER();
164 
165  dsFPDBlinkParam_t param ;
166 
167 
168  param.eIndicator = eIndicator;
169  param.nBlinkDuration = nBlinkDuration;
170  param.nBlinkIterations = nBlinkIterations;
171 
172  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
173 
174  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
175  (char *)IARM_BUS_DSMGR_API_dsSetFPBlink,
176  (void *)&param,
177  sizeof(param));
178 
179  if (IARM_RESULT_SUCCESS == rpcRet)
180  {
181  return dsERR_NONE;
182  }
183 
184  return dsERR_GENERAL ;
185 }
186 
187 dsError_t dsGetFPBrightness (dsFPDIndicator_t eIndicator, dsFPDBrightness_t *pBrightness)
188 {
189  _DEBUG_ENTER();
190 
191  dsFPDBrightParam_t param ;
192 
193  param.eIndicator = eIndicator;
194  param.eBrightness = 0;
195 
196  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
197 
198  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
199  (char *)IARM_BUS_DSMGR_API_dsGetFPBrightness,
200  (void *)&param,
201  sizeof(param));
202 
203  if (IARM_RESULT_SUCCESS == rpcRet)
204  {
205  *pBrightness = param.eBrightness;
206  return dsERR_NONE;
207  }
208 
209  return dsERR_GENERAL ;
210 }
211 
212 
213 dsError_t dsSetFPBrightness (dsFPDIndicator_t eIndicator, dsFPDBrightness_t eBrightness)
214 {
215  _DEBUG_ENTER();
216  dsFPDBrightParam_t param ;
217 
218  if(eIndicator >= dsFPD_INDICATOR_MAX || eBrightness > 100)
219  {
220  return dsERR_INVALID_PARAM;
221  }
222  param.eIndicator = eIndicator;
223  param.eBrightness = eBrightness;
224  param.toPersist = true;
225 
226  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
227 
228  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
229  (char *)IARM_BUS_DSMGR_API_dsSetFPBrightness,
230  (void *)&param,
231  sizeof(param));
232 
233  if (IARM_RESULT_SUCCESS == rpcRet)
234  {
235  return dsERR_NONE;
236  }
237  return dsERR_GENERAL ;
238 }
239 
240 
241 
242 dsError_t dsSetFPDBrightness(dsFPDIndicator_t eIndicator, dsFPDBrightness_t eBrightness,bool toPersist)
243 {
244  _DEBUG_ENTER();
245  dsFPDBrightParam_t param ;
246 
247  if(eIndicator >= dsFPD_INDICATOR_MAX || eBrightness > 100)
248  {
249  return dsERR_INVALID_PARAM;
250  }
251 
252  param.eIndicator = eIndicator;
253  param.eBrightness = eBrightness;
254  param.toPersist = toPersist;
255 
256  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
257 
258  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
259  (char *)IARM_BUS_DSMGR_API_dsSetFPBrightness,
260  (void *)&param,
261  sizeof(param));
262 
263  if (IARM_RESULT_SUCCESS == rpcRet)
264  {
265  return dsERR_NONE;
266  }
267  return dsERR_GENERAL ;
268 }
269 
271 {
272  _DEBUG_ENTER();
273 
274  dsFPDTextBrightParam_t param ;
275 
276  param.eIndicator = eIndicator;
277  param.eBrightness = 0;
278 
279  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
280 
281  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
282  (char *)IARM_BUS_DSMGR_API_dsGetFPTextBrightness,
283  (void *)&param,
284  sizeof(param));
285 
286  if (IARM_RESULT_SUCCESS == rpcRet)
287  {
288  *pBrightness = param.eBrightness;
289  return dsERR_NONE;
290  }
291 
292  return dsERR_GENERAL ;
293 }
294 
296 {
297  _DEBUG_ENTER();
298  dsFPDTextBrightParam_t param ;
299 
300  param.eIndicator = eIndicator;
301  param.eBrightness = eBrightness;
302 
303  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
304 
305  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
306  (char *)IARM_BUS_DSMGR_API_dsSetFPTextBrightness,
307  (void *)&param,
308  sizeof(param));
309 
310  if (IARM_RESULT_SUCCESS == rpcRet)
311  {
312  return dsERR_NONE;
313  }
314  return dsERR_GENERAL ;
315 }
316 
317 dsError_t dsGetFPColor (dsFPDIndicator_t eIndicator, dsFPDColor_t *pColor)
318 {
319  _DEBUG_ENTER();
320  dsFPDColorParam_t param ;
321 
322  param.eIndicator = eIndicator;
323  param.eColor = 0;
324 
325 
326  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
327 
328  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
329  (char *)IARM_BUS_DSMGR_API_dsGetFPColor,
330  (void *)&param,
331  sizeof(param));
332 
333  if (IARM_RESULT_SUCCESS == rpcRet)
334  {
335  *pColor = param.eColor;
336  return dsERR_NONE;
337  }
338  return dsERR_GENERAL ;
339 }
340 
341 
342 
343 dsError_t dsSetFPColor (dsFPDIndicator_t eIndicator, dsFPDColor_t eColor)
344 {
345  _DEBUG_ENTER();
346  dsFPDColorParam_t param ;
347 
348  param.eIndicator = eIndicator;
349  param.eColor = eColor;
350  param.toPersist = true;
351 
352  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
353 
354  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
355  (char *)IARM_BUS_DSMGR_API_dsSetFPColor,
356  (void *)&param,
357  sizeof(param));
358 
359  if (IARM_RESULT_SUCCESS == rpcRet)
360  {
361  return dsERR_NONE;
362  }
363  return dsERR_GENERAL ;
364 }
365 
366 
367 dsError_t dsSetFPDColor (dsFPDIndicator_t eIndicator, dsFPDColor_t eColor,bool toPersist)
368 {
369  _DEBUG_ENTER();
370  dsFPDColorParam_t param ;
371 
372  param.eIndicator = eIndicator;
373  param.eColor = eColor;
374  param.toPersist = toPersist;
375 
376  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
377 
378  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
379  (char *)IARM_BUS_DSMGR_API_dsSetFPColor,
380  (void *)&param,
381  sizeof(param));
382 
383  if (IARM_RESULT_SUCCESS == rpcRet)
384  {
385  return dsERR_NONE;
386  }
387  return dsERR_GENERAL ;
388 }
389 
391 {
392  _DEBUG_ENTER();
393  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
394  int ienable = enable;
395 
396  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
397  (char *)IARM_BUS_DSMGR_API_dsFPEnableCLockDisplay,
398  (void *)&ienable,
399  sizeof(ienable));
400 
401  if (IARM_RESULT_SUCCESS == rpcRet)
402  {
403  return dsERR_NONE;
404  }
405  return dsERR_GENERAL ;
406 }
407 
408 
409 
410 dsError_t dsSetFPState (dsFPDIndicator_t eIndicator, dsFPDState_t state)
411 {
412  _DEBUG_ENTER();
413  dsFPDStateParam_t param ;
414 
415  param.eIndicator = eIndicator;
416  param.state = state;
417 
418  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
419 
420  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
421  (char *)IARM_BUS_DSMGR_API_dsSetFPState,
422  (void *)&param,
423  sizeof(param));
424 
425  if (IARM_RESULT_SUCCESS == rpcRet)
426  {
427  return dsERR_NONE;
428  }
429  return dsERR_GENERAL ;
430 }
431 
432 
433 
434 
436 {
437  _DEBUG_ENTER();
438  dsFPDTimeFormatParam_t param ;
439 
440  param.eTime = dsFPD_TIME_12_HOUR;
441 
442  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
443 
444  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
445  (char *)IARM_BUS_DSMGR_API_dsGetTimeFormat,
446  (void *)&param,
447  sizeof(param));
448 
449  if (IARM_RESULT_SUCCESS == rpcRet)
450  {
451  *pTimeFormat = param.eTime;
452  return dsERR_NONE;
453  }
454  return dsERR_GENERAL ;
455 }
456 
457 
459 {
460  _DEBUG_ENTER();
461  dsFPDTimeFormatParam_t param ;
462 
463  param.eTime = eTimeFormat;
464 
465  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
466 
467  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
468  (char *)IARM_BUS_DSMGR_API_dsSetTimeFormat,
469  (void *)&param,
470  sizeof(param));
471 
472  if (IARM_RESULT_SUCCESS == rpcRet)
473  {
474  return dsERR_NONE;
475  }
476  return dsERR_GENERAL ;
477 }
478 
479 
480 dsError_t dsGetFPState(dsFPDIndicator_t eIndicator, dsFPDState_t* state)
481 {
482  _DEBUG_ENTER();
483  dsFPDStateParam_t param ;
484 
485  param.eIndicator = eIndicator;
486  param.state = dsFPD_STATE_OFF;
487 
488  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
489 
490  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
491  (char *)IARM_BUS_DSMGR_API_dsGetFPState,
492  (void *)&param,
493  sizeof(param));
494 
495  if (IARM_RESULT_SUCCESS == rpcRet)
496  {
497  *state = param.state;
498  return dsERR_NONE;
499  }
500  return dsERR_GENERAL ;
501 }
502 
503 
505 {
506 #ifndef USE_WPE_THUNDER_PLUGIN
507  _DEBUG_ENTER();
508  dsFPDModeParam_t param ;
509 
510  param.eMode = eMode;
511 
512  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
513 
514  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
515  (char *)IARM_BUS_DSMGR_API_dsSetFPDMode,
516  (void *)&param,
517  sizeof(param));
518 
519  if (IARM_RESULT_SUCCESS == rpcRet)
520  {
521  return dsERR_NONE;
522  }
523 #else
524  printf("%s currently not supported in Thunder Framework\n",__FUNCTION__);
525 #endif
526  return dsERR_GENERAL ;
527 }
528 
529 /** @} */
530 /** @} */
_dsFPDColorParam
Definition: dsRpc.h:668
dsGetFPTimeFormat
dsError_t dsGetFPTimeFormat(dsFPDTimeFormat_t *pTimeFormat)
This function get the Current time zone format set on 7-segment display LEDs panel.
Definition: dsFPD.c:435
dsFPD.h
dsSetFPColor
dsError_t dsSetFPColor(dsFPDIndicator_t eIndicator, dsFPDColor_t eColor)
Set LED color.
Definition: dsFPD.c:343
dsSetFPDColor
dsError_t dsSetFPDColor(dsFPDIndicator_t eIndicator, dsFPDColor_t eColor, bool toPersist)
This function sets the color of the specified LED on the front panel in multi-app mode using iarmbus ...
Definition: dsFPD.c:367
dsSetFPDBrightness
dsError_t dsSetFPDBrightness(dsFPDIndicator_t eIndicator, dsFPDBrightness_t eBrightness, bool toPersist)
This function will set the brightness of the specified discrete LED on the front panel display to the...
Definition: dsFPD.c:242
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
dsFPDTimeFormat_t
enum __dsFPDTimeFormat_t dsFPDTimeFormat_t
dsFPDBrightness_t
uint32_t dsFPDBrightness_t
Definition: dsTypes.h:862
dsFPEnableCLockDisplay
dsError_t dsFPEnableCLockDisplay(int enable)
Use disable and enable display of clock.
Definition: dsFPD.c:390
dsGetFPState
dsError_t dsGetFPState(dsFPDIndicator_t eIndicator, dsFPDState_t *state)
This function will Get the ON or OFF state of Specified LEDs.
Definition: dsFPD.c:480
dsSetFPScroll
dsError_t dsSetFPScroll(unsigned int nScrollHoldOnDur, unsigned int nHorzScrollIterations, unsigned int nVertScrollIterations)
Scroll text on 7-Segment Display.
Definition: dsFPD.c:135
dsERR_GENERAL
@ dsERR_GENERAL
Definition: dsError.h:86
dsERR_NONE
@ dsERR_NONE
Definition: dsError.h:85
dsFPDTextDisplay_t
enum __dsFPDTextDisplay_t dsFPDTextDisplay_t
dsSetFPDMode
dsError_t dsSetFPDMode(dsFPDMode_t eMode)
This function sets the display mode of the FPD text display.
Definition: dsFPD.c:504
dsFPDState_t
enum __dsFPDState_t dsFPDState_t
_dsFPDScrollParam
Definition: dsRpc.h:633
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
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_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
dsGetFPColor
dsError_t dsGetFPColor(dsFPDIndicator_t eIndicator, dsFPDColor_t *pColor)
Get LED color.
Definition: dsFPD.c:317
dsGetFPBrightness
dsError_t dsGetFPBrightness(dsFPDIndicator_t eIndicator, dsFPDBrightness_t *pBrightness)
Get the brightness level for Front Panel Display LEDs.
Definition: dsFPD.c:187
dsSetFPState
dsError_t dsSetFPState(dsFPDIndicator_t eIndicator, dsFPDState_t state)
This function will enable or disable the specified discrete LED on the front panel display.
Definition: dsFPD.c:410
_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
dsGetFPTextBrightness
dsError_t dsGetFPTextBrightness(dsFPDTextDisplay_t eIndicator, dsFPDBrightness_t *pBrightness)
Get the brightness of 7-Segment Display LEDs.
Definition: dsFPD.c:270
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
_dsFPDTimeParam
Definition: dsRpc.h:620
dsSetFPTimeFormat
dsError_t dsSetFPTimeFormat(dsFPDTimeFormat_t eTimeFormat)
This function sets the 7-segment display LEDs to show the specified time in specified format.
Definition: dsFPD.c:458
_dsFPDBrightParam
Definition: dsRpc.h:647
dsERR_INVALID_PARAM
@ dsERR_INVALID_PARAM
Definition: dsError.h:87
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
dsFPD_STATE_OFF
@ dsFPD_STATE_OFF
Definition: dsTypes.h:820