nRF5 SDK for Mesh v1.0.1
scanner.h
1 /* Copyright (c) 2010 - 2017, 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 "radio_config.h"
44 #include "packet.h"
45 #include "bearer_event.h"
46 
59 #define SCANNER_CHANNELS_MAX (3)
60 #define SCANNER_ACCESS_ADDR_INVALID (0x00000000)
61 #define SCANNER_CHANNELS_DEFAULT {37, 38, 39}
62 
64 typedef struct
65 {
67  packet_t packet;
69 
71 typedef struct
72 {
74  uint32_t crc_failures;
77 
84 typedef void (*scanner_rx_callback_t)(const scanner_packet_t * p_packet);
85 
91 void scanner_init(bearer_event_flag_callback_t packet_process_cb);
92 
105 
109 void scanner_enable(void);
110 
114 void scanner_disable(void);
115 
121 bool scanner_is_enabled(void);
122 
130 const scanner_packet_t * scanner_rx(void);
131 
137 bool scanner_rx_pending(void);
138 
144 void scanner_packet_release(const scanner_packet_t * p_packet);
145 
151 const scanner_stats_t * scanner_stats_get(void);
152 
158 void scanner_config_radio_mode_set(radio_mode_t radio_mode);
159 
166 void scanner_config_scan_time_set(uint32_t scan_interval_us, uint32_t scan_window_us);
167 
174 void scanner_config_channels_set(const uint8_t * p_channels, uint8_t channel_count);
175 
186 void scanner_config_access_addresses_set(const uint32_t * p_access_addresses, uint8_t address_count);
187 
191 void scanner_config_reset(void);
192 
205 void scanner_radio_start(void);
206 
212 void scanner_radio_stop(void);
213 
219 void scanner_radio_irq_handler(void);
220 
225 #endif /* SCANNER_H__ */
const scanner_packet_t * scanner_rx(void)
Returns the next packet that has been received by the scanner.
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:73
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:75
Content of a packet received by the scanner.
Definition: scanner.h:64
void scanner_enable(void)
Enables the scanner module.
void scanner_radio_stop(void)
Stop scanner radio.
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:66
Scanner statistics structure.
Definition: scanner.h:71
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:74
bool scanner_is_enabled(void)
Checks if the scanner module is enabled.
bool scanner_rx_pending(void)
Checks if any received packets are pending.
void scanner_radio_start(void)
Start scanner radio.
Metadata structure for packets received with the scanner.
Definition: nrf_mesh.h:92
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_rx_callback_t)(const scanner_packet_t *p_packet)
Scanner packet callback hook, called on every successfully received packet before committing it to th...
Definition: scanner.h:84
void scanner_disable(void)
Disables the scanner module.
packet_t packet
Packet content.
Definition: scanner.h:67

Documentation feedback | Developer Zone | Subscribe | Updated