nRF5 SDK for Mesh v5.0.0
internal_event.h
1 /* Copyright (c) 2010 - 2020, 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 {
76  INTERNAL_EVENT__LAST
78 
80 typedef enum
81 {
94 
96 typedef struct
97 {
100 
102  union
103  {
107  uint8_t value;
108  } state;
110  uint8_t packet_size;
112  uint8_t * p_packet;
114 
124 typedef uint32_t (*internal_event_report_cb_t) (internal_event_t * p_event);
125 
132 
141 uint32_t internal_event_push(internal_event_t * p_event);
142 
154 #if INTERNAL_EVT_ENABLE
155 #define __INTERNAL_EVENT_PUSH(EVENT_TYPE, ADDATA, PACKET_SIZE, P_PACKET) \
156  do { \
157  internal_event_t EVT = \
158  { \
159  .type = (EVENT_TYPE), \
160  .state.value = (ADDATA), \
161  .packet_size = (PACKET_SIZE), \
162  .p_packet = (uint8_t *) (P_PACKET) \
163  }; \
164  uint32_t RESULT = internal_event_push(&EVT); \
165  if (RESULT != NRF_SUCCESS) \
166  { \
167  __LOG(LOG_SRC_INTERNAL, LOG_LEVEL_WARN, "Unable to push the internal event to the callback function [er%d]", RESULT); \
168  } \
169  } while (0)
170 #else
171 #define __INTERNAL_EVENT_PUSH(...)
172 
173 #endif /* defined(INTERNAL_EVT_ENABLE) */
174 
175 #endif /* INTERNAL_EVENT_H__ */
internal_event_type_t
Internal event types.
Network layer packet data used for PTS.
Internal event structure.
Invalid provisioning PDU was ignored.
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.
Packet to LPN is queued on Friend node.
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.
void internal_event_init(internal_event_report_cb_t report_cb)
Initializes the internal event module.
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 to the callback function provided at the initialization. ...
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.
Network beacon is transmitted.

Documentation feedback | Developer Zone | Subscribe | Updated