1 /* 2 * Copyright (c) 2024 Alexandre Bailon 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef COAP_BUTTON_H 8 #define COAP_BUTTON_H 9 10 #include <zephyr/drivers/gpio.h> 11 #include <zephyr/data/json.h> 12 13 #define BTN_URI "sw" 14 15 #define BTN_MSG_STATE_OFF 0 16 #define BTN_MSG_STATE_ON 1 17 18 #define JSON_MAX_BTN 4 19 20 struct json_btn_state { 21 int btn_id; 22 int state; 23 }; 24 25 struct json_btn_get { 26 const char *device_id; 27 struct json_btn_state btns[JSON_MAX_BTN]; 28 int count; 29 }; 30 31 int button_init(const struct gpio_dt_spec *gpio); 32 int coap_btn_get_state(const char *addr, int led_id, int *state); 33 34 #ifdef CONFIG_OT_COAP_SAMPLE_SERVER 35 void coap_btn_reg_rsc(void); 36 #endif 37 38 #endif /* COAP_BUTTON_H */ 39