Line data Source code
1 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 NET_MGMT_LAYER_CODE_COAP
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 {
44 : NET_EVENT_COAP_CMD_SERVICE_STARTED_VAL,
45 : NET_EVENT_COAP_CMD_SERVICE_STOPPED_VAL,
46 : NET_EVENT_COAP_CMD_OBSERVER_ADDED_VAL,
47 : NET_EVENT_COAP_CMD_OBSERVER_REMOVED_VAL,
48 :
49 : NET_EVENT_COAP_CMD_MAX
50 : };
51 :
52 : BUILD_ASSERT(NET_EVENT_COAP_CMD_MAX <= NET_MGMT_MAX_COMMANDS,
53 : "Number of events in net_event_coap_cmd exceeds the limit");
54 :
55 : enum net_event_coap_cmd {
56 : /* Service events */
57 : NET_MGMT_CMD(NET_EVENT_COAP_CMD_SERVICE_STARTED),
58 : NET_MGMT_CMD(NET_EVENT_COAP_CMD_SERVICE_STOPPED),
59 : /* Observer events */
60 : NET_MGMT_CMD(NET_EVENT_COAP_CMD_OBSERVER_ADDED),
61 : NET_MGMT_CMD(NET_EVENT_COAP_CMD_OBSERVER_REMOVED),
62 : };
63 :
64 : /** @endcond */
65 :
66 : /**
67 : * @brief coap_mgmt event raised when a service has started
68 : */
69 1 : #define NET_EVENT_COAP_SERVICE_STARTED \
70 : (NET_COAP_IF_BASE | NET_EVENT_COAP_CMD_SERVICE_STARTED)
71 :
72 : /**
73 : * @brief coap_mgmt event raised when a service has stopped
74 : */
75 1 : #define NET_EVENT_COAP_SERVICE_STOPPED \
76 : (NET_COAP_IF_BASE | NET_EVENT_COAP_CMD_SERVICE_STOPPED)
77 :
78 : /**
79 : * @brief coap_mgmt event raised when an observer has been added to a resource
80 : */
81 1 : #define NET_EVENT_COAP_OBSERVER_ADDED \
82 : (NET_COAP_IF_BASE | NET_EVENT_COAP_CMD_OBSERVER_ADDED)
83 :
84 : /**
85 : * @brief coap_mgmt event raised when an observer has been removed from a resource
86 : */
87 1 : #define NET_EVENT_COAP_OBSERVER_REMOVED \
88 : (NET_COAP_IF_BASE | NET_EVENT_COAP_CMD_OBSERVER_REMOVED)
89 :
90 : /**
91 : * @brief CoAP Service event structure.
92 : */
93 1 : struct net_event_coap_service {
94 : /** The CoAP service for which the event is emitted */
95 1 : const struct coap_service *service;
96 : };
97 :
98 : /**
99 : * @brief CoAP Observer event structure.
100 : */
101 1 : struct net_event_coap_observer {
102 : /** The CoAP resource for which the event is emitted */
103 1 : struct coap_resource *resource;
104 : /** The observer that is added/removed */
105 1 : struct coap_observer *observer;
106 : };
107 :
108 : #ifdef __cplusplus
109 : }
110 : #endif
111 :
112 : /**
113 : * @}
114 : */
115 :
116 : #endif /* ZEPHYR_INCLUDE_NET_COAP_MGMT_H_ */
|