nRF5 SDK for Mesh v2.1.1
instaburst_tx.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 #ifndef INSTABURST_TX_H__
38 #define INSTABURST_TX_H__
39 
67 #include "instaburst.h"
68 #include "broadcast.h"
69 #include "adv_ext_tx.h"
70 #include "bearer_event.h"
71 #include "packet_buffer.h"
72 #include "bearer_handler.h"
73 
77 #define INSTABURST_TX_BUFFER_MIN_SIZE \
78  (sizeof(packet_buffer_packet_t) + sizeof(adv_ext_tx_event_t) + \
79  (sizeof(adv_ext_tx_packet_t) + ADV_EXT_PACKET_LEN_MAX) * ADV_EXT_TX_CHAIN_MAX_COUNT)
80 
81 
82 typedef struct instaburst_tx instaburst_tx_t;
83 
90 typedef void (*instaburst_tx_complete_t)(struct instaburst_tx * p_tx, nrf_mesh_tx_token_t tx_token, uint32_t timestamp);
91 
94 typedef struct
95 {
97  uint8_t set_id;
99  const uint8_t * p_channels;
101  uint8_t channel_count;
103  radio_mode_t radio_mode;
105  radio_tx_power_t tx_power;
115  uint32_t interval_ms;
117 
118 #ifdef INSTABURST_TX_DEBUG
119 
120 typedef struct
121 {
122  uint32_t failed_allocs;
123  uint32_t tx_regular_packet;
124  uint32_t tx_adv_ext;
125  uint32_t tx_skipped;
126 } instaburst_tx_debug_t;
127 #endif
128 
134 {
135  instaburst_tx_config_t config;
136 
137  uint8_t channel_index;
138 
139  packet_buffer_t packet_buffer;
140 
141  uint8_t * p_next_alloc;
142  adv_ext_tx_packet_t * p_alloc_packet;
143  packet_buffer_packet_t * p_alloc_buf;
144  packet_buffer_packet_t * p_tx_buf;
146  broadcast_t broadcast;
147  adv_ext_tx_t adv_ext_tx;
148 
149  bearer_event_sequential_t tx_complete_event;
150  uint32_t prev_tx_timestamp;
151 
152  timer_event_t timer_event;
153 
154 #ifdef INSTABURST_TX_DEBUG
155  instaburst_tx_debug_t debug;
156 #endif
157 };
158 
164 void instaburst_tx_init(uint32_t lfclk_ppm);
165 
174 void instaburst_tx_instance_init(instaburst_tx_t * p_instaburst,
175  const instaburst_tx_config_t * p_config,
176  uint8_t * p_packet_buffer,
177  uint32_t packet_buffer_size);
178 
184 void instaburst_tx_enable(instaburst_tx_t * p_instaburst);
185 
191 void instaburst_tx_disable(instaburst_tx_t * p_instaburst);
192 
205 uint8_t * instaburst_tx_buffer_alloc(instaburst_tx_t * p_instaburst, uint32_t data_len, nrf_mesh_tx_token_t tx_token);
206 
213 void instaburst_tx_buffer_commit(instaburst_tx_t * p_instaburst, const uint8_t * p_buffer);
214 
221 void instaburst_tx_buffer_discard(instaburst_tx_t * p_instaburst, const uint8_t * p_buffer);
222 
236 bool instaburst_tx_finalize(instaburst_tx_t * p_instaburst);
237 
250 void instaburst_tx_buffer_lock(bool lock);
251 
259 void instaburst_tx_interval_set(instaburst_tx_t * p_instaburst, uint32_t interval_ms);
260 
267 void instaburst_tx_tx_power_set(instaburst_tx_t * p_instaburst, radio_tx_power_t tx_power);
268 
271 #endif /* INSTABURST_TX_H__ */
Instaburst TX configuration.
Definition: instaburst_tx.h:94
void instaburst_tx_enable(instaburst_tx_t *p_instaburst)
Enables the given Instaburst instance.
uint8_t channel_count
Number of channels in the p_channels array.
uint8_t * p_next_alloc
Pointer to the next location to allocate a buffer in.
radio_mode_t radio_mode
Radio mode to run auxiliary packets in.
bool instaburst_tx_finalize(instaburst_tx_t *p_instaburst)
Finalizes the TX event under construction, putting it up for transmission.
Instaburst instance structure.
const uint8_t * p_channels
Array of radio channels to send on.
Definition: instaburst_tx.h:99
radio_tx_power_t tx_power
TX power to transmit auxiliary packets at.
void instaburst_tx_tx_power_set(instaburst_tx_t *p_instaburst, radio_tx_power_t tx_power)
Sets the TX power for the given Instaburst instance.
void instaburst_tx_buffer_lock(bool lock)
Locks the current buffer to prevent it from being automatically transmitted on the next advertisement...
uint32_t nrf_mesh_tx_token_t
TX Token type, used as a context parameter to notify the application of ended transmissions.
Definition: nrf_mesh.h:88
void instaburst_tx_buffer_commit(instaburst_tx_t *p_instaburst, const uint8_t *p_buffer)
Commits the given buffer for transmission.
packet_buffer_packet_t * p_alloc_buf
Buffer currently being used for allocating new packets.
uint8_t set_id
Set ID for this Instaburst instance.
Definition: instaburst_tx.h:97
uint8_t * instaburst_tx_buffer_alloc(instaburst_tx_t *p_instaburst, uint32_t data_len, nrf_mesh_tx_token_t tx_token)
Allocates a buffer for transmission.
adv_ext_tx_packet_t * p_alloc_packet
Packet being built in the allocate stage.
void instaburst_tx_init(uint32_t lfclk_ppm)
Initializes the Instaburst TX module.
void instaburst_tx_disable(instaburst_tx_t *p_instaburst)
Disables the given Instaburst instance.
void instaburst_tx_buffer_discard(instaburst_tx_t *p_instaburst, const uint8_t *p_buffer)
Discards the given buffer, freeing any memory associated with it.
instaburst_tx_complete_t callback
Callback to call when the transmission was completed.
void instaburst_tx_instance_init(instaburst_tx_t *p_instaburst, const instaburst_tx_config_t *p_config, uint8_t *p_packet_buffer, uint32_t packet_buffer_size)
Initializes an Instaburst TX instance.
void instaburst_tx_interval_set(instaburst_tx_t *p_instaburst, uint32_t interval_ms)
Sets the TX interval for the given Instaburst instance.
packet_buffer_packet_t * p_tx_buf
Buffer currently in transmission.
uint32_t interval_ms
Transmission interval in milliseconds.
void(* instaburst_tx_complete_t)(struct instaburst_tx *p_tx, nrf_mesh_tx_token_t tx_token, uint32_t timestamp)
TX Complete callback to be called when all repeats of a buffer have been sent.
Definition: instaburst_tx.h:90

Documentation feedback | Developer Zone | Subscribe | Updated