1 /* 2 * Copyright (c) 2024 Analog Devices, Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef __DEVICE_H__ 8 #define __DEVICE_H__ 9 10 /** @brief Sensor sample structure */ 11 struct sensor_sample { 12 const char *unit; 13 int value; 14 }; 15 16 /** @brief Available board LEDs */ 17 enum led_id { 18 LED_NET, /* Network status LED*/ 19 LED_USER /* User LED */ 20 }; 21 22 /** @brief LED states */ 23 enum led_state { 24 LED_OFF, 25 LED_ON 26 }; 27 28 /** @brief Device command consisting of a command string 29 * and associated handler function pointer 30 */ 31 struct device_cmd { 32 const char *command; 33 void (*handler)(); 34 }; 35 36 /** 37 * @brief Check if all devices are ready 38 */ 39 bool devices_ready(void); 40 41 /** 42 * @brief Read sample from the sensor 43 */ 44 int device_read_sensor(struct sensor_sample *sample); 45 46 /** 47 * @brief Write to a board LED 48 */ 49 int device_write_led(enum led_id led_idx, enum led_state state); 50 51 /** 52 * @brief Handler function for commands received over MQTT 53 */ 54 void device_command_handler(uint8_t *command); 55 56 #endif /* __DEVICE_H__ */ 57