| /* |
| * wl led command module |
| * |
| * Broadcom Proprietary and Confidential. Copyright (C) 2017, |
| * All Rights Reserved. |
| * |
| * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom; |
| * the contents of this file may not be disclosed to third parties, copied |
| * or duplicated in any form, in whole or in part, without the prior |
| * written permission of Broadcom. |
| * |
| * |
| * <<Broadcom-WL-IPTag/Proprietary:>> |
| * |
| * $Id: wluc_led.c 458728 2014-02-27 18:15:25Z $ |
| */ |
| |
| #ifdef WIN32 |
| #include <windows.h> |
| #endif |
| |
| #include <wlioctl.h> |
| |
| #if defined(DONGLEBUILD) |
| #include <typedefs.h> |
| #include <osl.h> |
| #endif |
| |
| /* Because IL_BIGENDIAN was removed there are few warnings that need |
| * to be fixed. Windows was not compiled earlier with IL_BIGENDIAN. |
| * Hence these warnings were not seen earlier. |
| * For now ignore the following warnings |
| */ |
| #ifdef WIN32 |
| #pragma warning(push) |
| #pragma warning(disable : 4244) |
| #pragma warning(disable : 4761) |
| #endif |
| |
| #include <bcmutils.h> |
| #include <bcmendian.h> |
| #include "wlu_common.h" |
| #include "wlu.h" |
| |
| static cmd_func_t wl_ledbh; |
| static cmd_func_t wl_led_blink_sync; |
| |
| static cmd_t wl_led_cmds[] = { |
| { "ledbh", wl_ledbh, WLC_GET_VAR, WLC_SET_VAR, |
| "set/get led behavior\n" |
| "\tUsage: wl ledbh [0-3] [0-15]"}, |
| { "led_blink_sync", wl_led_blink_sync, WLC_GET_VAR, WLC_SET_VAR, "set/get led_blink_sync\n" |
| "\tUsage: wl led_blink_sync [0-3] [0/1]"}, |
| { NULL, NULL, 0, 0, NULL } |
| }; |
| |
| static char *buf; |
| |
| /* module initialization */ |
| void |
| wluc_led_module_init(void) |
| { |
| /* get the global buf */ |
| buf = wl_get_buf(); |
| |
| /* register led commands */ |
| wl_module_cmds_register(wl_led_cmds); |
| } |
| |
| static int |
| wl_ledbh(void *wl, cmd_t *cmd, char **argv) |
| { |
| int err; |
| wl_led_info_t led; |
| void *ptr = NULL; |
| |
| memset(&led, 0, sizeof(wl_led_info_t)); |
| if (*++argv == NULL) { |
| printf("Usage: ledbh [led#] [behavior#]\n"); |
| return BCME_USAGE_ERROR; |
| } |
| led.index = (int)strtoul(*argv, NULL, 10); |
| |
| if (led.index >= LED_MAX_INDEX) { |
| printf("only %d led supported\n", LED_MAX_INDEX); |
| return BCME_BADARG; |
| } |
| |
| if (*++argv) { /* set */ |
| /* Read the original back so we don't toggle the activehi */ |
| if ((err = wlu_var_getbuf(wl, cmd->name, (void*)&led, |
| sizeof(wl_led_info_t), &ptr)) < 0) { |
| printf("wl_ledbh: fail to get. code %x\n", err); |
| } |
| led.behavior = (int)strtoul(*argv, NULL, 10); |
| led.activehi = ((wl_led_info_t*)ptr)->activehi; |
| |
| if ((err = wlu_var_setbuf(wl, cmd->name, (void*)&led, |
| sizeof(wl_led_info_t))) < 0) { |
| printf("wl_ledbh: fail to set\n"); |
| } |
| } else { /* get */ |
| wl_led_info_t *ledo; |
| |
| if ((err = wlu_var_getbuf(wl, cmd->name, (void*)&led, |
| sizeof(wl_led_info_t), &ptr)) < 0) { |
| printf("wl_ledbh: fail to get\n"); |
| } |
| ledo = (wl_led_info_t*)ptr; |
| |
| printf("led %d behavior %d\n", ledo->index, ledo->behavior); |
| } |
| |
| return err; |
| } |
| |
| static int |
| wl_led_blink_sync(void *wl, cmd_t *cmd, char **argv) |
| { |
| int argc; |
| int err = 0; |
| int in_arg[2]; |
| void *ptr = NULL; |
| char *endptr; |
| |
| /* arg count */ |
| for (argc = 0; argv[argc]; argc++) |
| ; |
| |
| if (argc > 3 || argc < 2) |
| return BCME_USAGE_ERROR; |
| |
| in_arg[0] = htod32((uint32)(strtoul(argv[1], &endptr, 0))); |
| |
| if (in_arg[0] > 3) { |
| printf("only 4 led supported\n"); |
| return BCME_BADARG; |
| } |
| |
| if (argc == 2) { |
| err = wlu_var_getbuf(wl, cmd->name, (void*)in_arg, sizeof(int), &ptr); |
| if (err < 0) |
| return err; |
| printf("led%d, blink_sync is %s\n", in_arg[0], |
| (dtoh32(*(int*)ptr) != 0) ? "TRUE" : "FALSE"); |
| } |
| else if (argc == 3) { |
| in_arg[1] = htod32((uint32)(strtoul(argv[2], &endptr, 0))); |
| err = wlu_var_setbuf(wl, cmd->name, in_arg, sizeof(in_arg)); |
| } |
| |
| return err; |
| } |