ONLP
Open Network Linux Platform APIs
led.h
Go to the documentation of this file.
1 /************************************************************
2  * <bsn.cl fy=2014 v=onl>
3  *
4  * Copyright 2014, 2015 Big Switch Networks, Inc.
5  *
6  * Licensed under the Eclipse Public License, Version 1.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.eclipse.org/legal/epl-v10.html
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific
16  * language governing permissions and limitations under the
17  * License.
18  *
19  * </bsn.cl>
20  ********************************************************/
28 #ifndef __ONLP_LED_H__
29 #define __ONLP_LED_H__
30 
31 #include <onlp/onlp.h>
32 #include <onlp/oids.h>
33 
34 /* <auto.start.enum(tag:led).define> */
36 typedef enum onlp_led_caps_e {
37  ONLP_LED_CAPS_OFF = (1 << 0),
38  ONLP_LED_CAPS_AUTO = (1 << 1),
39  ONLP_LED_CAPS_AUTO_BLINKING = (1 << 2),
40  ONLP_LED_CAPS_CHAR = (1 << 3),
41  ONLP_LED_CAPS_RED = (1 << 4),
42  ONLP_LED_CAPS_RED_BLINKING = (1 << 5),
43  ONLP_LED_CAPS_ORANGE = (1 << 6),
44  ONLP_LED_CAPS_ORANGE_BLINKING = (1 << 7),
45  ONLP_LED_CAPS_YELLOW = (1 << 8),
46  ONLP_LED_CAPS_YELLOW_BLINKING = (1 << 9),
47  ONLP_LED_CAPS_GREEN = (1 << 10),
48  ONLP_LED_CAPS_GREEN_BLINKING = (1 << 11),
49  ONLP_LED_CAPS_BLUE = (1 << 12),
50  ONLP_LED_CAPS_BLUE_BLINKING = (1 << 13),
51  ONLP_LED_CAPS_PURPLE = (1 << 14),
52  ONLP_LED_CAPS_PURPLE_BLINKING = (1 << 15),
54 
56 typedef enum onlp_led_mode_e {
57  ONLP_LED_MODE_OFF,
58  ONLP_LED_MODE_AUTO,
59  ONLP_LED_MODE_AUTO_BLINKING,
60  ONLP_LED_MODE_CHAR,
61  ONLP_LED_MODE_RED,
62  ONLP_LED_MODE_RED_BLINKING,
63  ONLP_LED_MODE_ORANGE,
64  ONLP_LED_MODE_ORANGE_BLINKING,
65  ONLP_LED_MODE_YELLOW,
66  ONLP_LED_MODE_YELLOW_BLINKING,
67  ONLP_LED_MODE_GREEN,
68  ONLP_LED_MODE_GREEN_BLINKING,
69  ONLP_LED_MODE_BLUE,
70  ONLP_LED_MODE_BLUE_BLINKING,
71  ONLP_LED_MODE_PURPLE,
72  ONLP_LED_MODE_PURPLE_BLINKING,
73  ONLP_LED_MODE_LAST = ONLP_LED_MODE_PURPLE_BLINKING,
74  ONLP_LED_MODE_COUNT,
75  ONLP_LED_MODE_INVALID = -1,
77 /* <auto.end.enum(tag:led).define> */
78 
79 
83 typedef struct onlp_led_info_s {
86 
88  uint32_t caps;
89 
92 
94  char character;
95 
97 
101 int onlp_led_sw_init(void);
102 
106 int onlp_led_hw_init(uint32_t flags);
107 
114 int onlp_led_sw_denit(void);
115 
122 
123 
130 
136 int onlp_led_caps_get(onlp_oid_t oid, uint32_t* caps);
137 
145 
146 
153 int onlp_led_char_set(onlp_oid_t oid, char c);
154 
161 int onlp_led_info_to_user_json(onlp_led_info_t* info, cJSON** cj, uint32_t flags);
162 
169 int onlp_led_info_to_json(onlp_led_info_t* info, cJSON** cj, uint32_t flags);
170 
176 int onlp_led_info_from_json(cJSON* cj, onlp_led_info_t* info);
177 
178 /******************************************************************************
179  *
180  * Enumeration Support Definitions.
181  *
182  * Please do not add additional code beyond this point.
183  *
184  *****************************************************************************/
185 /* <auto.start.enum(tag:led).supportheader> */
187 const char* onlp_led_caps_name(onlp_led_caps_t e);
188 
190 int onlp_led_caps_value(const char* str, onlp_led_caps_t* e, int substr);
191 
193 const char* onlp_led_caps_desc(onlp_led_caps_t e);
194 
197 
199 #define ONLP_LED_CAPS_VALID(_e) \
200  (onlp_led_caps_valid((_e)))
201 
203 extern aim_map_si_t onlp_led_caps_map[];
205 extern aim_map_si_t onlp_led_caps_desc_map[];
206 
208 #define ONLP_LED_MODE_STRINGS \
209 {\
210  "OFF", \
211  "AUTO", \
212  "AUTO_BLINKING", \
213  "CHAR", \
214  "RED", \
215  "RED_BLINKING", \
216  "ORANGE", \
217  "ORANGE_BLINKING", \
218  "YELLOW", \
219  "YELLOW_BLINKING", \
220  "GREEN", \
221  "GREEN_BLINKING", \
222  "BLUE", \
223  "BLUE_BLINKING", \
224  "PURPLE", \
225  "PURPLE_BLINKING", \
226 }
227 
228 const char* onlp_led_mode_name(onlp_led_mode_t e);
229 
231 int onlp_led_mode_value(const char* str, onlp_led_mode_t* e, int substr);
232 
234 const char* onlp_led_mode_desc(onlp_led_mode_t e);
235 
237 #define ONLP_LED_MODE_VALID(_e) \
238  ( (0 <= (_e)) && ((_e) <= ONLP_LED_MODE_PURPLE_BLINKING))
239 
241 extern aim_map_si_t onlp_led_mode_map[];
243 extern aim_map_si_t onlp_led_mode_desc_map[];
244 /* <auto.end.enum(tag:led).supportheader> */
245 
246 #endif /* __ONLP_LED_H__ */
247 /* @} */
onlp_led_mode_t mode
Definition: led.h:91
onlp_oid_hdr_t hdr
Definition: led.h:85
int onlp_led_hdr_get(onlp_oid_t oid, onlp_oid_hdr_t *rv)
Get the LED header.
int onlp_led_info_to_user_json(onlp_led_info_t *info, cJSON **cj, uint32_t flags)
Convert an LED info structure to user JSON.
const char * onlp_led_caps_desc(onlp_led_caps_t e)
int onlp_led_caps_get(onlp_oid_t oid, uint32_t *caps)
Get the LED caps.
int onlp_led_info_from_json(cJSON *cj, onlp_led_info_t *info)
Convert a JSON object to an LED info structure.
const char * onlp_led_mode_name(onlp_led_mode_t e)
Object Identifiers.
int onlp_led_sw_denit(void)
Deinitialize the led software module.
uint32_t onlp_oid_t
Definition: oids.h:52
const char * onlp_led_caps_name(onlp_led_caps_t e)
int onlp_led_info_get(onlp_oid_t oid, onlp_led_info_t *rv)
Get LED information.
uint32_t caps
Definition: led.h:88
const char * onlp_led_mode_desc(onlp_led_mode_t e)
aim_map_si_t onlp_led_caps_map[]
int onlp_led_char_set(onlp_oid_t oid, char c)
Set the LED char.
onlp_led_caps_e
Definition: led.h:36
aim_map_si_t onlp_led_caps_desc_map[]
int onlp_led_mode_set(onlp_oid_t oid, onlp_led_mode_t mode)
Set the LED mode.
int onlp_led_caps_value(const char *str, onlp_led_caps_t *e, int substr)
aim_map_si_t onlp_led_mode_map[]
char character
Definition: led.h:94
aim_map_si_t onlp_led_mode_desc_map[]
int onlp_led_mode_value(const char *str, onlp_led_mode_t *e, int substr)
enum onlp_led_mode_e onlp_led_mode_t
int onlp_led_caps_valid(onlp_led_caps_t e)
int onlp_led_sw_init(void)
Software initialization of the LED module.
Definition: led.h:83
int onlp_led_info_to_json(onlp_led_info_t *info, cJSON **cj, uint32_t flags)
Convert an LED info structure to JSON.
enum onlp_led_caps_e onlp_led_caps_t
struct onlp_led_info_s onlp_led_info_t
onlp_led_mode_e
Definition: led.h:56
Definition: oids.h:296
int onlp_led_hw_init(uint32_t flags)
Hardware initialization of the LED module.