This repository has been archived by the owner on Jan 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ledmgr.c
572 lines (510 loc) · 18.7 KB
/
ledmgr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
/*
##########################################################################
# If not stated otherwise in this file or this component's LICENSE
# file the following copyright and licenses apply:
#
# Copyright 2019 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################
*/
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include "ledmgrlogger.h"
#include "ledmgr.h"
#include "ledmgr_rtmsg.h"
#ifdef __cplusplus
extern "C"{
#endif
#include "sc_tool.h"
#include "PRO_file.h"
#include "conf_sec.h"
#include "sysUtils.h"
#ifdef __cplusplus
}
#endif
#define INVALID_TIME (-1)
#define LEDMGR_ASSERT_NOT_NULL(P) if ((P) == NULL) return LED_MGR_ERR_GENERAL
#define DEF_USER_ADMIN_NAME "administrator"
#define XW_INIT_MAX_RETRY 25
/* Telemetry 2.0 */
#include "telemetry_busmessage_sender.h"
typedef struct ledRGBColor{
ledMgrColor_t color;
uint8_t cR; /* Red color */
uint8_t bR; /* Brightness of Red color */
uint8_t cG; /* Green color */
uint8_t bG; /* Brightness of Green color */
uint8_t cB; /* Blue color */
uint8_t bB; /* Brightness of Blue color */
}ledRGBColor;
/* Array of all colors and default RGB values */
ledRGBColor g_ledColorVal[LED_MGR_COLOR_MAX] = {
{LED_MGR_COLOR_AMBER, 63, 255, 63, 153, 0, 0},
{LED_MGR_COLOR_WHITE, 65, 255, 85, 233, 85, 181},
{LED_MGR_COLOR_RED, 255, 115, 0, 0, 0, 0},
{LED_MGR_COLOR_GREEN, 0, 0, 255, 122, 0, 0},
{LED_MGR_COLOR_BLUE, 0, 0, 0, 0, 255, 150},
};
/*
ledRGBColor g_ledColorVal[LED_MGR_COLOR_MAX] = {
{LED_MGR_COLOR_WHITE, 255, 255, 255, 255, 255, 255},
{LED_MGR_COLOR_BLUE, 0, 0, 0, 0, 255, 255},
{LED_MGR_COLOR_AMBER, 255, 255, 194, 255, 0, 0},
{LED_MGR_COLOR_GREEN, 0, 0, 255, 255, 0, 0},
{LED_MGR_COLOR_RED, 255, 255, 0, 0, 0, 0}
};
*/
/* Array of all colors and default xw RGB values */
ledRGBColor g_xwledColorVal[LED_MGR_COLOR_MAX] = {
{LED_MGR_COLOR_AMBER, 63, 255, 63, 153, 0, 0},
{LED_MGR_COLOR_WHITE, 65, 255, 85, 233, 85, 181},
{LED_MGR_COLOR_RED, 255, 115, 0, 0, 0, 0},
{LED_MGR_COLOR_GREEN, 0, 0, 255, 122, 0, 0},
{LED_MGR_COLOR_BLUE, 0, 0, 0, 0, 255, 150},
};
typedef struct ledOp{
ledMgrOp_t op; /* operation */
int32_t ontime; /* on time in ms */
int32_t offtime; /* off time in ms */
int32_t longofftime; /* long off time in ms */
}ledOp;
/* Array of all operations and default on/off time values */
ledOp g_ledOpVal[LED_MGR_OP_MAX] = {
{LED_MGR_OP_SOLID_LIGHT, INVALID_TIME, INVALID_TIME, INVALID_TIME},
{LED_MGR_OP_BLINK, 500, 1000, INVALID_TIME},
{LED_MGR_OP_SLOW_BLINK, 200, 400, INVALID_TIME},
{LED_MGR_OP_DOUBLE_BLINK, 200, 100, 1000},
{LED_MGR_OP_FAST_BLINK, 100, 100, INVALID_TIME},
{LED_MGR_OP_NO_LIGHT, INVALID_TIME, INVALID_TIME, INVALID_TIME}
};
/* Static functions */
static const ledOp* getOpVal(ledMgrOp_t op);
static const ledRGBColor* getColorVal(ledMgrColor_t color);
static const ledRGBColor* getxwColorVal(ledMgrColor_t color);
static ledMgrErr_t led_xw_init(int retry);
static ledMgrErr_t led_xw_setOp(ledId_t id, ledMgrOp_t op, ledMgrColor_t color);
static pthread_mutex_t ledinitmutex = PTHREAD_MUTEX_INITIALIZER;
/* Function to get default RGB color values */
static const ledRGBColor* getColorVal(ledMgrColor_t color)
{
int i;
for(i = 0; i < LED_MGR_COLOR_MAX; i++){
if(g_ledColorVal[i].color == color)
break;
}
if(LED_MGR_COLOR_MAX != i)
return &g_ledColorVal[i];
else
return NULL;
}
/* Function to get default xw RGB color values */
static const ledRGBColor* getxwColorVal(ledMgrColor_t color)
{
int i;
for(i = 0; i < LED_MGR_COLOR_MAX; i++){
if(g_xwledColorVal[i].color == color)
break;
}
if(LED_MGR_COLOR_MAX != i)
return &g_xwledColorVal[i];
else
return NULL;
}
/* Function to get default values based on operation */
static const ledOp* getOpVal(ledMgrOp_t op)
{
int i;
for(i = 0; i < LED_MGR_OP_MAX; i++){
if(g_ledOpVal[i].op == op)
break;
}
if(LED_MGR_OP_MAX != i)
return &g_ledOpVal[i];
else
return NULL;
}
/* API to initialize xw ledmgr */
ledMgrErr_t led_xw_init(int retry)
{
//TODO find a clearner way to do this
int count = 1;
static bool led_xw_color_init = false;
if (led_xw_color_init)
return LED_MGR_ERR_NONE;
while (count <= retry)
{
/* To avoid reading xw system.conf on every boot, we store it locally */
if (access("/opt/usr_config/xwsystem.conf", F_OK) != 0)
{
int retval=0;
retval = xw_file_get();
if(retval != 1)
{
LEDMGR_LOG_INFO("system.conf not available check again count : %d", count);
count++;
continue;
}
if(retval ==1)
LEDMGR_LOG_INFO("\nsystem.conf copied from xw sucessfully ");
}
else
{
LEDMGR_LOG_INFO("Creating xw_led_conf");
exec_sys_command("grep -r led_color1 /opt/usr_config/xwsystem.conf | cut -d = -f2 > /tmp/xw_led_conf", NULL);
exec_sys_command("grep -r led_color2 /opt/usr_config/xwsystem.conf | cut -d = -f2 >> /tmp/xw_led_conf", NULL);
exec_sys_command("grep -r led_color3 /opt/usr_config/xwsystem.conf | cut -d = -f2 >> /tmp/xw_led_conf", NULL);
exec_sys_command("grep -r led_color4 /opt/usr_config/xwsystem.conf | cut -d = -f2 >> /tmp/xw_led_conf", NULL);
exec_sys_command("grep -r led_color5 /opt/usr_config/xwsystem.conf | cut -d = -f2 >> /tmp/xw_led_conf", NULL);
break;
}
}
FILE * fp;
int index = 0;
char content[50];
fp = fopen ("/tmp/xw_led_conf", "r");
if (fp != NULL)
{
while(index < LED_MGR_COLOR_MAX)
{
g_xwledColorVal[index].color = (ledMgrColor_t)index;
fgets(content, 50, fp);
//current R
LEDMGR_LOG_INFO("led_color from system.conf color %d, value %s\n", index, content);
char *col = strtok(content, ":");
LEDMGR_ASSERT_NOT_NULL(col);
g_xwledColorVal[index].cR = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d, ", g_xwledColorVal[index].cR);
//pwm R
col = strtok(NULL, ",");
LEDMGR_ASSERT_NOT_NULL(col);
g_xwledColorVal[index].bR = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d, ", g_xwledColorVal[index].bR);
//current G
col = strtok(NULL, ":");
LEDMGR_ASSERT_NOT_NULL(col);
g_xwledColorVal[index].cG = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d, ", g_xwledColorVal[index].cG);
//pwm G
col = strtok(NULL, ",");
LEDMGR_ASSERT_NOT_NULL(col);
g_xwledColorVal[index].bG = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d, ", g_xwledColorVal[index].bG);
//current B
col = strtok(NULL, ":");
LEDMGR_ASSERT_NOT_NULL(col);
g_xwledColorVal[index].cB = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d, ", g_xwledColorVal[index].cB);
//pwm B
col = strtok(NULL, ",");
LEDMGR_ASSERT_NOT_NULL(col);
g_xwledColorVal[index].bB = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d", g_xwledColorVal[index].bB);
index++;
}
fclose(fp);
}
else
{
/* use default values */
LEDMGR_LOG_ERROR("Unable to read led color values from xw system.conf.");
return LED_MGR_ERR_GENERAL;
}
led_xw_color_init = true;
return LED_MGR_ERR_NONE;
}
/* API to initialize ledmgr */
ledMgrErr_t ledmgr_init(void)
{
int ret = 0;
int led_mode = 0;
ret = PRO_SetInt(SEC_SYS, SYS_LED_MODE, led_mode, SYSTEM_CONF); // success return 0, others return value mean something error
if (ret != LED_ERR_NONE)
LEDMGR_LOG_INFO("Error setting led more");
SYS_INFO systeminfo;
int status = 0;
int index = 0;
/* Populate led current and pwm values from system.conf */
status = SYSINFO_ReadConfigData(&systeminfo);
/* systeminfo.led_color_val[0..5] contains current and pwm values of
* AMBER, WHITE, RED, GREEN and BLUE respectively */
if(status == SYSTEM_OK)
{
/* parse current and pwm values from systeminfo
* Example string. led_color1=39:255,10:204,0:0 */
while(index < LED_MGR_COLOR_MAX)
{
g_ledColorVal[index].color = (ledMgrColor_t)index;
//current R
LEDMGR_LOG_INFO("led_color from system.conf color %d, value %s\n", index, systeminfo.led_color_val[index]);
char *col = strtok(systeminfo.led_color_val[index], ":");
LEDMGR_ASSERT_NOT_NULL(col);
g_ledColorVal[index].cR = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d, ", g_ledColorVal[index].cR);
//pwm R
col = strtok(NULL, ",");
LEDMGR_ASSERT_NOT_NULL(col);
g_ledColorVal[index].bR = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d, ", g_ledColorVal[index].bR);
//current G
col = strtok(NULL, ":");
LEDMGR_ASSERT_NOT_NULL(col);
g_ledColorVal[index].cG = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d, ", g_ledColorVal[index].cG);
//pwm G
col = strtok(NULL, ",");
LEDMGR_ASSERT_NOT_NULL(col);
g_ledColorVal[index].bG = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d, ", g_ledColorVal[index].bG);
//current B
col = strtok(NULL, ":");
LEDMGR_ASSERT_NOT_NULL(col);
g_ledColorVal[index].cB = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d, ", g_ledColorVal[index].cB);
//pwm B
col = strtok(NULL, ",");
LEDMGR_ASSERT_NOT_NULL(col);
g_ledColorVal[index].bB = (uint8_t)atoi(col);
LEDMGR_LOG_DEBUG("%d", g_ledColorVal[index].bB);
index++;
}
led_xw_init(XW_INIT_MAX_RETRY);
}
else
{
/* use default values */
LEDMGR_LOG_ERROR("Unable to read led color values from system.conf.");
led_xw_init(XW_INIT_MAX_RETRY);
return LED_MGR_ERR_GENERAL;
}
return LED_MGR_ERR_NONE;
}
/* API to set led state */
ledMgrErr_t ledmgr_setState(ledMgrState_t state)
{
switch(state)
{
case LED_MGR_STATE_BOOT_UP:
/* boot up state */
LEDMGR_LOG_INFO("Led set white with ledHalApi during bootup");
//ledmgr_setOp(LED_ID_CAMERA_FRONT_PANEL, LED_MGR_OP_SOLID_LIGHT, LED_MGR_COLOR_WHITE);
//led_xw_setOp(LED_ID_XW_FRONT_PANEL, LED_MGR_OP_SOLID_LIGHT, LED_MGR_COLOR_WHITE);
LEDMGR_LOG_INFO("Led State = LED_MGR_STATE_BOOT_UP");
break;
case LED_MGR_STATE_INCORRECT_XW:
/* incompatible xw */
LEDMGR_LOG_INFO("Led State = LED_MGR_STATE_INCORRECT_XW");
while (true)
{
ledmgr_setOp(LED_ID_CAMERA_FRONT_PANEL, LED_MGR_OP_SOLID_LIGHT, LED_MGR_COLOR_AMBER);
led_xw_setOp(LED_ID_XW_FRONT_PANEL, LED_MGR_OP_SOLID_LIGHT, LED_MGR_COLOR_AMBER);
sleep (1);
ledmgr_setOp(LED_ID_CAMERA_FRONT_PANEL, LED_MGR_OP_SOLID_LIGHT, LED_MGR_COLOR_RED);
led_xw_setOp(LED_ID_XW_FRONT_PANEL, LED_MGR_OP_SOLID_LIGHT, LED_MGR_COLOR_RED);
sleep (1);
}
break;
case LED_MGR_STATE_READY_TO_PAIR:
/* ready to pair state */
ledmgr_setOp(LED_ID_CAMERA_FRONT_PANEL, LED_MGR_OP_BLINK, LED_MGR_COLOR_WHITE);
led_xw_setOp(LED_ID_XW_FRONT_PANEL, LED_MGR_OP_BLINK, LED_MGR_COLOR_WHITE);
LEDMGR_LOG_INFO("Led State = LED_MGR_STATE_READY_TO_PAIR");
break;
case LED_MGR_STATE_TROUBLE_CONNECTING:
/* trouble connecting state */
ledmgr_setOp(LED_ID_CAMERA_FRONT_PANEL, LED_MGR_OP_BLINK, LED_MGR_COLOR_AMBER);
led_xw_setOp(LED_ID_XW_FRONT_PANEL, LED_MGR_OP_BLINK, LED_MGR_COLOR_AMBER);
LEDMGR_LOG_INFO("Led State = LED_MGR_STATE_TROUBLE_CONNECTING");
t2_event_d("LED_INFO_CONNBad", 1);
break;
case LED_MGR_STATE_NOT_PROVISIONED:
/* camera not provisioned */
ledmgr_setOp(LED_ID_CAMERA_FRONT_PANEL, LED_MGR_OP_BLINK, LED_MGR_COLOR_AMBER);
led_xw_setOp(LED_ID_XW_FRONT_PANEL, LED_MGR_OP_BLINK, LED_MGR_COLOR_AMBER);
LEDMGR_LOG_INFO("Led State = LED_MGR_STATE_NOT_PROVISIONED");
break;
case LED_MGR_STATE_WORKING_NORMALLY:
/* working normally */
ledmgr_setOp(LED_ID_CAMERA_FRONT_PANEL, LED_MGR_OP_SOLID_LIGHT, LED_MGR_COLOR_BLUE);
led_xw_setOp(LED_ID_XW_FRONT_PANEL, LED_MGR_OP_SOLID_LIGHT, LED_MGR_COLOR_BLUE);
LEDMGR_LOG_INFO("Led State = LED_MGR_STATE_WORKING_NORMALLY");
t2_event_d("LED_INFO_CONNGood", 1);
break;
case LED_MGR_STATE_2_WAY_VOICE:
/* two way voice state */
ledmgr_setOp(LED_ID_CAMERA_FRONT_PANEL, LED_MGR_OP_BLINK, LED_MGR_COLOR_BLUE);
led_xw_setOp(LED_ID_XW_FRONT_PANEL, LED_MGR_OP_BLINK, LED_MGR_COLOR_BLUE);
LEDMGR_LOG_INFO("Led State = LED_MGR_STATE_2_WAY_VOICE");
break;
case LED_MGR_STATE_FACTORY_DOWNLOAD_MODE:
/* factory download mode state */
ledmgr_setOp(LED_ID_CAMERA_FRONT_PANEL, LED_MGR_OP_BLINK, LED_MGR_COLOR_GREEN);
led_xw_setOp(LED_ID_XW_FRONT_PANEL, LED_MGR_OP_BLINK, LED_MGR_COLOR_GREEN);
LEDMGR_LOG_INFO("Led State = LED_MGR_STATE_FACTORY_DOWNLOAD_MODE");
break;
case LED_MGR_STATE_UNKNOWN:
default:
/* invalid state */
LEDMGR_LOG_ERROR("Invalid state %d", state);
return LED_MGR_ERR_INVALID_PARAM;
break;
}
return LED_MGR_ERR_NONE;
}
/* API to set led operation and color */
ledMgrErr_t ledmgr_setOp(ledId_t id, ledMgrOp_t op, ledMgrColor_t color)
{
const ledRGBColor* pColor;
const ledOp* pOp;
int err = 0;
if (id == LED_ID_XW_FRONT_PANEL) {
return led_xw_setOp(id, op, color);
}
pOp = (ledOp*) getOpVal(op);
pColor = (ledRGBColor*) getColorVal(color);
if(pOp == NULL || pColor == NULL){
LEDMGR_LOG_ERROR("Unable to get color or operation %d %d", op, color);
return LED_MGR_ERR_INVALID_PARAM;
}
err = pthread_mutex_trylock(&ledinitmutex);
if(err != 0){
LEDMGR_LOG_ERROR("Unable to acquire mutex err: %s", strerror(err));
LEDMGR_LOG_ERROR("Led manager is busy. Try again later...");
return LED_MGR_ERR_BUSY;
}
/* initialize led hal */
led_init(id);
switch(op)
{
case LED_MGR_OP_SOLID_LIGHT:
led_reset(id);
led_setBrightness(id, pColor->bR, pColor->bG, pColor->bB);
led_setColor(id, pColor->cR, pColor->cG, pColor->cB);
led_setOnOff(id, "on");
break;
case LED_MGR_OP_BLINK:
led_reset(id);
led_setBrightness(id, pColor->bR, pColor->bG, pColor->bB);
led_setColor(id, pColor->cR, pColor->cG, pColor->cB);
led_setBlink(id, pOp->ontime, pOp->offtime);
break;
case LED_MGR_OP_SLOW_BLINK:
led_reset(id);
led_setBrightness(id, pColor->bR, pColor->bG, pColor->bB);
led_setColor(id, pColor->cR, pColor->cG, pColor->cB);
led_setBlink(id, pOp->ontime, pOp->offtime);
break;
case LED_MGR_OP_DOUBLE_BLINK:
led_reset(id);
led_setBrightness(id, pColor->bR, pColor->bG, pColor->bB);
led_setColor(id, pColor->cR, pColor->cG, pColor->cB);
led_setBlinkSequence(id, pOp->ontime, pOp->offtime, 2, pOp->longofftime);
break;
case LED_MGR_OP_FAST_BLINK:
led_reset(id);
led_setBrightness(id, pColor->bR, pColor->bG, pColor->bB);
led_setColor(id, pColor->cR, pColor->cG, pColor->cB);
led_setBlink(id, pOp->ontime, pOp->offtime);
break;
case LED_MGR_OP_NO_LIGHT:
led_setOnOff(id, "off");
break;
case LED_MGR_OP_MAX:
default:
LEDMGR_LOG_ERROR("Invalid operation %d", op);
err = LED_MGR_ERR_INVALID_PARAM;
break;
}
/* apply configuration */
if(err == LED_MGR_ERR_NONE)
led_applySettings(id);
err = pthread_mutex_unlock(&ledinitmutex);
if(err != 0){
LEDMGR_LOG_ERROR("Led manager unlock mutex failed with err: %s", strerror(err));
}
return (ledMgrErr_t)err;
}
/* API to set led operation and color */
static ledMgrErr_t led_xw_setOp(ledId_t id, ledMgrOp_t op, ledMgrColor_t color)
{
const ledRGBColor* pColor;
const ledOp* pOp;
int err = 0;
led_xw_init(1);
pOp = (ledOp*) getOpVal(op);
pColor = (ledRGBColor*) getxwColorVal(color);
if(pOp == NULL || pColor == NULL){
LEDMGR_LOG_ERROR("Unable to get color or operation %d %d", op, color);
return LED_MGR_ERR_INVALID_PARAM;
}
err = pthread_mutex_trylock(&ledinitmutex);
if(err != 0){
LEDMGR_LOG_ERROR("Unable to acquire mutex err: %s", strerror(err));
LEDMGR_LOG_ERROR("Led manager is busy. Try again later...");
return LED_MGR_ERR_BUSY;
}
/* initialize led hal */
xw_led_init(id);
switch(op)
{
case LED_MGR_OP_SOLID_LIGHT:
xw_led_reset(id);
xw_led_setBrightness(id, pColor->bR, pColor->bG, pColor->bB);
xw_led_setColor(id, pColor->cR, pColor->cG, pColor->cB);
break;
case LED_MGR_OP_BLINK:
xw_led_reset(id);
xw_led_setBrightness(id, pColor->bR, pColor->bG, pColor->bB);
xw_led_setColor(id, pColor->cR, pColor->cG, pColor->cB);
xw_led_setBlink(id, pOp->ontime, pOp->offtime);
break;
case LED_MGR_OP_SLOW_BLINK:
xw_led_reset(id);
xw_led_setBrightness(id, pColor->bR, pColor->bG, pColor->bB);
xw_led_setColor(id, pColor->cR, pColor->cG, pColor->cB);
xw_led_setBlink(id, pOp->ontime, pOp->offtime);
break;
case LED_MGR_OP_DOUBLE_BLINK:
xw_led_reset(id);
xw_led_setBrightness(id, pColor->bR, pColor->bG, pColor->bB);
xw_led_setColor(id, pColor->cR, pColor->cG, pColor->cB);
xw_led_setBlinkSequence(id, pOp->ontime, pOp->offtime, 2, pOp->longofftime);
break;
case LED_MGR_OP_FAST_BLINK:
xw_led_reset(id);
xw_led_setBrightness(id, pColor->bR, pColor->bG, pColor->bB);
xw_led_setColor(id, pColor->cR, pColor->cG, pColor->cB);
xw_led_setBlink(id, pOp->ontime, pOp->offtime);
break;
case LED_MGR_OP_NO_LIGHT:
xw_led_setOnOff(id, "off");
break;
case LED_MGR_OP_MAX:
default:
LEDMGR_LOG_ERROR("Invalid operation %d", op);
err = LED_MGR_ERR_INVALID_PARAM;
break;
}
/* apply configuration */
if(err == LED_MGR_ERR_NONE)
xw_led_applySettings(id);
err = pthread_mutex_unlock(&ledinitmutex);
if(err != 0){
LEDMGR_LOG_ERROR("Led manager unlock mutex failed with err: %s", strerror(err));
}
return (ledMgrErr_t)err;
}