nRF5 SDK for Mesh v5.0.0
scanner.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 #ifndef SCANNER_H__
38 #define SCANNER_H__
39 
40 #include <stdint.h>
41 #include <stdbool.h>
42 #include "nrf_mesh.h"
43 #include "timeslot_timer.h"
44 #include "radio_config.h"
45 #include "packet.h"
46 #include "bearer_event.h"
47 
60 #define SCANNER_CHANNELS_MAX (3)
61 #define SCANNER_ACCESS_ADDR_INVALID (0x00000000)
62 #define SCANNER_CHANNELS_DEFAULT {37, 38, 39}
63 
65 typedef struct
66 {
68  packet_t packet;
70 
72 typedef struct
73 {
75  uint32_t crc_failures;
77  uint32_t out_of_memory;
79 
88 typedef void (*scanner_rx_callback_t)(const scanner_packet_t * p_packet, ts_timestamp_t rx_timestamp_ts);
89 
95 void scanner_init(bearer_event_flag_callback_t packet_process_cb);
96 
109 
113 void scanner_enable(void);
114 
118 void scanner_disable(void);
119 
125 bool scanner_is_enabled(void);
126 
134 const scanner_packet_t * scanner_rx(void);
135 
141 bool scanner_rx_pending(void);
142 
148 void scanner_packet_release(const scanner_packet_t * p_packet);
149 
155 const scanner_stats_t * scanner_stats_get(void);
156 
162 void scanner_config_radio_mode_set(radio_mode_t radio_mode);
163 
170 void scanner_config_scan_time_set(uint32_t scan_interval_us, uint32_t scan_window_us);
171 
178 void scanner_config_channels_set(const uint8_t * p_channels, uint8_t channel_count);
179 
190 void scanner_config_access_addresses_set(const uint32_t * p_access_addresses, uint8_t address_count);
191 
195 void scanner_config_reset(void);
196 
211 void scanner_radio_start(ts_timestamp_t start_time);
212 
218 void scanner_radio_stop(void);
219 
225 void scanner_radio_irq_handler(void);
226 
232 void scanner_timer_irq_handler(void);
233 
238 #endif /* SCANNER_H__ */
void(* scanner_rx_callback_t)(const scanner_packet_t *p_packet, ts_timestamp_t rx_timestamp_ts)
Scanner packet callback hook, called on every successfully received packet before committing it to th...
Definition: scanner.h:88
const scanner_packet_t * scanner_rx(void)
Returns the next packet that has been received by the scanner.
void scanner_radio_start(ts_timestamp_t start_time)
Start scanner radio.
void scanner_rx_callback_set(scanner_rx_callback_t callback)
Set the scanner rx callback function.
uint32_t successful_receives
Number of received packets.
Definition: scanner.h:74
void scanner_config_scan_time_set(uint32_t scan_interval_us, uint32_t scan_window_us)
Sets scanner timing parameters.
void scanner_config_reset(void)
Resets the scanner module.
void scanner_packet_release(const scanner_packet_t *p_packet)
Releases a packet that has previously been returned by scanner_rx().
uint32_t length_out_of_bounds
Number of packets with length out of bounds.
Definition: scanner.h:76
Content of a packet received by the scanner.
Definition: scanner.h:65
void scanner_timer_irq_handler(void)
Scanner timer IRQ handler.
void scanner_enable(void)
Enables the scanner module.
void scanner_radio_stop(void)
Stop scanner radio.
uint32_t out_of_memory
Number of times the scanner has ran out of memory.
Definition: scanner.h:77
void scanner_init(bearer_event_flag_callback_t packet_process_cb)
Initializes the scanner module.
nrf_mesh_rx_metadata_scanner_t metadata
Packet metadata.
Definition: scanner.h:67
Scanner statistics structure.
Definition: scanner.h:72
const scanner_stats_t * scanner_stats_get(void)
Returns statistics related to the scanner module.
uint32_t crc_failures
Number of CRC failures.
Definition: scanner.h:75
bool scanner_is_enabled(void)
Checks if the scanner module is enabled.
bool scanner_rx_pending(void)
Checks if any received packets are pending.
Metadata structure for packets received with the scanner.
Definition: nrf_mesh.h:117
void scanner_config_radio_mode_set(radio_mode_t radio_mode)
Sets scanner radio mode (data rate and modulation).
void scanner_config_access_addresses_set(const uint32_t *p_access_addresses, uint8_t address_count)
Sets access addresses to be used by the scanner, and corresponding logical address.
void scanner_radio_irq_handler(void)
Scanner radio IRQ handler.
void scanner_config_channels_set(const uint8_t *p_channels, uint8_t channel_count)
Sets which radio channels are to be used by the scanner.
void scanner_disable(void)
Disables the scanner module.
packet_t packet
Packet content.
Definition: scanner.h:68

Documentation feedback | Developer Zone | Subscribe | Updated