nRF5 SDK for Mesh v3.0.0
internal_event.h
1 /* Copyright (c) 2010 - 2018, Nordic Semiconductor ASA
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form, except as embedded into a Nordic
11  * Semiconductor ASA integrated circuit in a product or a software update for
12  * such product, must reproduce the above copyright notice, this list of
13  * conditions and the following disclaimer in the documentation and/or other
14  * materials provided with the distribution.
15  *
16  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
17  * contributors may be used to endorse or promote products derived from this
18  * software without specific prior written permission.
19  *
20  * 4. This software, with or without modification, must only be used with a
21  * Nordic Semiconductor ASA integrated circuit.
22  *
23  * 5. Any software provided in binary form under this license must not be reverse
24  * engineered, decompiled, modified and/or disassembled.
25  *
26  * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
29  * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
30  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
35  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef INTERNAL_EVENT_H__
39 #define INTERNAL_EVENT_H__
40 
41 #include "nrf_mesh_config_core.h"
42 #include "nrf_mesh_assert.h"
43 
44 #include <nrf_error.h>
45 #include "log.h"
46 #include "utils.h"
47 
56 typedef enum
57 {
73  INTERNAL_EVENT__LAST
75 
77 typedef enum
78 {
91 
93 typedef struct
94 {
97 
99  union
100  {
104  uint8_t value;
105  } state;
107  uint8_t packet_size;
109  uint8_t * p_packet;
111 
121 typedef uint32_t (*internal_event_report_cb_t) (internal_event_t * p_event);
122 
131 
141 uint32_t internal_event_push(internal_event_t * p_event);
142 
152 uint32_t internal_event_pop(internal_event_t * p_event);
153 
165 #if INTERNAL_EVT_ENABLE
166 #define __INTERNAL_EVENT_PUSH(EVENT_TYPE, ADDATA, PACKET_SIZE, P_PACKET) \
167  do { \
168  internal_event_t EVT = \
169  { \
170  .type = (EVENT_TYPE), \
171  .state.value = (ADDATA), \
172  .packet_size = (PACKET_SIZE), \
173  .p_packet = (uint8_t *) (P_PACKET) \
174  }; \
175  uint32_t RESULT = internal_event_push(&EVT); \
176  if (RESULT != NRF_SUCCESS) \
177  { \
178  __LOG(LOG_SRC_INTERNAL, LOG_LEVEL_WARN, "Unable to push to internal event queue [er%d]", RESULT); \
179  } \
180  } while (0)
181 #else
182 #define __INTERNAL_EVENT_PUSH(...)
183 
184 #endif /* defined(INTERNAL_EVT_ENABLE) */
185 
186 #endif /* INTERNAL_EVENT_H__ */
internal_event_type_t
Internal event types.
Network layer packet data used for PTS.
Internal event structure.
internal_event_packet_dropped_t reason
Packet dropped reason.
Dropped due to invalid AD type.
Dropped due to unknown address.
Dropped due to invalid network key.
Flash Manager Defrag Completed.
Dropped due to network decrypt failed.
uint8_t * p_packet
Packet pointer.
Network queued packet in bearer for TX.
uint32_t(* internal_event_report_cb_t)(internal_event_t *p_event)
Callback function for inline handling of internal events.
Transport layer decrypted packet segment.
Dropped due to invalid packet length.
Dropped due to no more memory.
Dropped due to packet already in network cache.
internal_event_packet_dropped_t
Internal event packet dropped reasons.
Dropped due to invalid address.
internal_event_type_t type
Type of internal event.
Transport layer decrypted packet.
ACK for transport SAR queued in bearer.
Packet dropped with reason internal_event_packet_dropped_t.
uint32_t internal_event_pop(internal_event_t *p_event)
Pops an internal event.
void internal_event_init(internal_event_report_cb_t report_cb)
Initializes the internal event FIFO.
SAR transaction cancelled.
uint8_t value
Raw value of the packet dropped reason (used for the serial_evt_device_internal_event_t).
uint8_t packet_size
Size of the packet dropped.
Flash Manager Action Completed.
SAR transaction cancelled.
Dropped due to invalid application key.
uint32_t internal_event_push(internal_event_t *p_event)
Pushes an internal event.
Dropped due to invalid device key.
Packet was relayed by the network layer.
Dropped due to packet already in replay cache.
ACK for transport SAR segment received.

Documentation feedback | Developer Zone | Subscribe | Updated