1 /* 2 * Copyright (c) 2023 Basalte bv 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file 9 * @brief CoAP Events code public header 10 */ 11 12 #ifndef ZEPHYR_INCLUDE_NET_COAP_MGMT_H_ 13 #define ZEPHYR_INCLUDE_NET_COAP_MGMT_H_ 14 15 #include <zephyr/net/net_mgmt.h> 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /** 22 * @brief CoAP Manager Events 23 * @defgroup coap_mgmt CoAP Manager Events 24 * @since 3.6 25 * @version 0.1.0 26 * @ingroup networking 27 * @{ 28 */ 29 30 /** @cond INTERNAL_HIDDEN */ 31 32 /* CoAP events */ 33 #define _NET_COAP_LAYER NET_MGMT_LAYER_L4 34 #define _NET_COAP_CODE 0x1c0 35 #define _NET_COAP_IF_BASE (NET_MGMT_EVENT_BIT | \ 36 NET_MGMT_LAYER(_NET_COAP_LAYER) | \ 37 NET_MGMT_LAYER_CODE(_NET_COAP_CODE)) 38 39 struct coap_service; 40 struct coap_resource; 41 struct coap_observer; 42 43 enum net_event_coap_cmd { 44 /* Service events */ 45 NET_EVENT_COAP_CMD_SERVICE_STARTED = 1, 46 NET_EVENT_COAP_CMD_SERVICE_STOPPED, 47 /* Observer events */ 48 NET_EVENT_COAP_CMD_OBSERVER_ADDED, 49 NET_EVENT_COAP_CMD_OBSERVER_REMOVED, 50 }; 51 52 /** @endcond */ 53 54 /** 55 * @brief coap_mgmt event raised when a service has started 56 */ 57 #define NET_EVENT_COAP_SERVICE_STARTED \ 58 (_NET_COAP_IF_BASE | NET_EVENT_COAP_CMD_SERVICE_STARTED) 59 60 /** 61 * @brief coap_mgmt event raised when a service has stopped 62 */ 63 #define NET_EVENT_COAP_SERVICE_STOPPED \ 64 (_NET_COAP_IF_BASE | NET_EVENT_COAP_CMD_SERVICE_STOPPED) 65 66 /** 67 * @brief coap_mgmt event raised when an observer has been added to a resource 68 */ 69 #define NET_EVENT_COAP_OBSERVER_ADDED \ 70 (_NET_COAP_IF_BASE | NET_EVENT_COAP_CMD_OBSERVER_ADDED) 71 72 /** 73 * @brief coap_mgmt event raised when an observer has been removed from a resource 74 */ 75 #define NET_EVENT_COAP_OBSERVER_REMOVED \ 76 (_NET_COAP_IF_BASE | NET_EVENT_COAP_CMD_OBSERVER_REMOVED) 77 78 /** 79 * @brief CoAP Service event structure. 80 */ 81 struct net_event_coap_service { 82 /** The CoAP service for which the event is emitted */ 83 const struct coap_service *service; 84 }; 85 86 /** 87 * @brief CoAP Observer event structure. 88 */ 89 struct net_event_coap_observer { 90 /** The CoAP resource for which the event is emitted */ 91 struct coap_resource *resource; 92 /** The observer that is added/removed */ 93 struct coap_observer *observer; 94 }; 95 96 #ifdef __cplusplus 97 } 98 #endif 99 100 /** 101 * @} 102 */ 103 104 #endif /* ZEPHYR_INCLUDE_NET_COAP_MGMT_H_ */ 105