Contiki-NG
Loading...
Searching...
No Matches
rf-ble-cmd.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017, Graz University of Technology
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/**
32 * \file
33 * BLE commands for the TI CC26xx BLE radio.
34 * These functions are specific to the TI CC26xx and cannot be
35 * reused by other BLE radios.
36 *
37 * \author
38 * Michael Spoerk <michael.spoerk@tugraz.at>
39 */
40/*---------------------------------------------------------------------------*/
41
42#ifndef RF_BLE_CMD_H_
43#define RF_BLE_CMD_H_
44
45#include "os/dev/ble-hal.h"
46#include "../../ble-addr.h"
47#include "rf_common_cmd.h"
48#include <stdint.h>
49
50#define RF_BLE_CMD_OK 1
51#define RF_BLE_CMD_ERROR 0
52
53/*---------------------------------------------------------------------------*/
54/**
55 * \brief Sends a BLE radio command to the radio
56 * \param cmd A pointer to the command to be send
57 * \return RF_CORE_CMD_OK or RF_CORE_CMD_ERROR
58 */
59unsigned short rf_ble_cmd_send(uint8_t *cmd);
60
61/*---------------------------------------------------------------------------*/
62/**
63 * \brief Waits for a running BLE radio command to be finished
64 * \param cmd A pointer to the running command
65 * \return RF_CORE_CMD_OK or RF_CORE_CMD_ERROR
66 */
67unsigned short rf_ble_cmd_wait(uint8_t *cmd);
68
69/*---------------------------------------------------------------------------*/
70/**
71 * \brief Initializes the radio core to be used as a BLE radio
72 * \return RF_CORE_CMD_OK or RF_CORE_CMD_ERROR
73 */
74unsigned short rf_ble_cmd_setup_ble_mode(void);
75
76/*---------------------------------------------------------------------------*/
77/**
78 * \brief Creates a BLE radio command structure that enables
79 * BLE advertisement when sent to the radio core
80 * \param command A pointer to command that is created
81 * \param channel The BLE advertisement channel used for advertisement
82 * \param param A pointer to the radio command parameters
83 * \param output A pointer to the radio command output
84 */
85void rf_ble_cmd_create_adv_cmd(uint8_t *command, uint8_t channel,
86 uint8_t *param, uint8_t *output);
87
88/*---------------------------------------------------------------------------*/
89/**
90 * \brief Creates BLE radio command parameters that are used to enable
91 * BLE advertisement on the radio core
92 * \param param A pointer to parameter structure that is created
93 * \param rx_queue A pointer to the RX queue that is used
94 * \param adv_data_len
95 * The length of the advertisement data
96 * \param adv_data A pointer to the advertisement data that is advertised
97 * \param scan_resp_data_len
98 * The length of the scan response data
99 * \param scan_resp_data
100 * A pointer to the scan response data
101 * \param own_addr_type
102 * Either BLE_ADDR_TYPE_PUBLIC or BLE_ADDR_TYPE_RANDOM
103 * \param own_addr A pointer to the device address that is used as own address
104 */
105void rf_ble_cmd_create_adv_params(uint8_t *param, dataQueue_t *rx_queue,
106 uint8_t adv_data_len, uint8_t *adv_data,
107 uint8_t scan_resp_data_len, uint8_t *scan_resp_data,
108 ble_addr_type_t own_addr_type, uint8_t *own_addr);
109
110/*---------------------------------------------------------------------------*/
111/**
112 * \brief Creates a BLE radio command structure that sets up
113 * BLE initiation event when sent to the radio core
114 * \param cmd A pointer to command that is created
115 * \param channel The BLE data channel used for the connection event
116 * \param params A pointer to the radio command parameters
117 * \param output A pointer to the radio command output
118 * \param start_time
119 * The time in rf_core_ticks when the connection event will start
120 */
121void rf_ble_cmd_create_initiator_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
122 uint8_t *output, uint32_t start_time);
123
124/*---------------------------------------------------------------------------*/
125/**
126 * \brief Creates BLE radio command parameters that are used to set up
127 * BLE initiation event on the radio core
128 * \param param A pointer to parameter structure that is created
129 * \param rx_queue A pointer to the RX queue that is used
130 * \param initiator_window
131 * T
132 * \param own_addr_type
133 * Either BLE_ADDR_TYPE_PUBLIC or BLE_ADDR_TYPE_RANDOM
134 * \param own_addr A pointer to the device address that is used as own address
135 * \param peer_addr_type
136 * Either BLE_ADDR_TYPE_PUBLIC or BLE_ADDR_TYPE_RANDOM
137 * \param peer_addr A pointer to the device address that is used as peer address
138 * \param connect_time
139 The first possible start time of the first connection event
140 * \param conn_req_data A pointer to the connect request data
141 */
142void rf_ble_cmd_create_initiator_params(uint8_t *param, dataQueue_t *rx_queue,
143 uint32_t initiator_window,
144 ble_addr_type_t own_addr_type, uint8_t *own_addr,
145 ble_addr_type_t peer_addr_type, uint8_t *peer_addr,
146 uint32_t connect_time,
147 uint8_t *conn_req_data);
148
149/*---------------------------------------------------------------------------*/
150/**
151 * \brief Creates a BLE radio command structure that sets up a single
152 * BLE connection event when sent to the radio core
153 * \param cmd A pointer to command that is created
154 * \param channel The BLE data channel used for the connection event
155 * \param param A pointer to the radio command parameters
156 * \param output A pointer to the radio command output
157 * \param start_time
158 * The time in rf_core_ticks when the connection event will start
159 */
160void rf_ble_cmd_create_slave_cmd(uint8_t *cmd, uint8_t channel, uint8_t *param,
161 uint8_t *output, uint32_t start_time);
162
163/*---------------------------------------------------------------------------*/
164/**
165 * \brief Creates BLE radio command parameters that are used to setup a single
166 * BLE connection event on the radio core
167 * \param param A pointer to parameter structure that is created
168 * \param rx_queue A pointer to the RX queue that is used
169 * \param tx_queue A pointer to the TX queue that is used
170 * \param access_address
171 * The access address of the used BLE connection
172 * \param crc_init_0
173 * Part of the initialization of the CRC checksum
174 * \param crc_init_1
175 * Part of the initialization of the CRC checksum
176 * \param crc_init_2
177 * Part of the initialization of the CRC checksum
178 * \param win_size The window size parameter of the BLE connection event
179 * \param window_widening
180 * The window widening parameter used for this connection event
181 * \param first_packet
182 * 1 for the first packet of the BLE connection so that the
183 * connection is properly initialized
184 */
185void rf_ble_cmd_create_slave_params(uint8_t *param, dataQueue_t *rx_queue,
186 dataQueue_t *tx_queue, uint32_t access_address,
187 uint8_t crc_init_0, uint8_t crc_init_1,
188 uint8_t crc_init_2, uint32_t win_size,
189 uint32_t window_widening, uint8_t first_packet);
190
191/*---------------------------------------------------------------------------*/
192/**
193 * \brief Creates a BLE radio command structure that sets up
194 * BLE connection event when sent to the radio core
195 * \param cmd A pointer to command that is created
196 * \param channel The BLE data channel used for the connection event
197 * \param params A pointer to the radio command parameters
198 * \param output A pointer to the radio command output
199 * \param start_time
200 * The time in rf_core_ticks when the connection event will start
201 */
202void rf_ble_cmd_create_master_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
203 uint8_t *output, uint32_t start_time);
204
205/*---------------------------------------------------------------------------*/
206/**
207 * \brief Creates BLE radio command parameters that are used to set up
208 * BLE connection event on the radio core
209 * \param params A pointer to parameter structure that is created
210 * \param rx_queue A pointer to the RX queue that is used
211 * \param tx_queue A pointer to the TX queue that is used
212 * \param access_address
213 * The access address of the used BLE connection
214 * \param crc_init_0
215 * Part of the initialization of the CRC checksum
216 * \param crc_init_1
217 * Part of the initialization of the CRC checksum
218 * \param crc_init_2
219 * Part of the initialization of the CRC checksum
220 * \param first_packet
221 * 1 for the first packet of the BLE connection so that the
222 * connection is properly initialized
223 */
224void rf_ble_cmd_create_master_params(uint8_t *params, dataQueue_t *rx_queue,
225 dataQueue_t *tx_queue, uint32_t access_address,
226 uint8_t crc_init_0, uint8_t crc_init_1,
227 uint8_t crc_init_2, uint8_t first_packet);
228
229/*---------------------------------------------------------------------------*/
230/**
231 * \brief Adds a data buffer to a BLE transmission queue
232 * \param q A pointer to BLE transmission queue where the buffer
233 * should be added
234 * \param e A pointer to the data buffer that is added
235 */
236unsigned short rf_ble_cmd_add_data_queue_entry(dataQueue_t *q, uint8_t *e);
237
238#endif /* RF_BLE_CMD_H_ */
hardware abstraction for a BLE controller
Driver for the retrieval of an BLE address from flash.
void rf_ble_cmd_create_adv_cmd(uint8_t *command, uint8_t channel, uint8_t *param, uint8_t *output)
Creates a BLE radio command structure that enables BLE advertisement when sent to the radio core.
Definition rf-ble-cmd.c:196
unsigned short rf_ble_cmd_send(uint8_t *cmd)
Sends a BLE radio command to the radio.
Definition rf-ble-cmd.c:132
void rf_ble_cmd_create_master_params(uint8_t *params, dataQueue_t *rx_queue, dataQueue_t *tx_queue, uint32_t access_address, uint8_t crc_init_0, uint8_t crc_init_1, uint8_t crc_init_2, uint8_t first_packet)
Creates BLE radio command parameters that are used to set up BLE connection event on the radio core.
Definition rf-ble-cmd.c:468
void rf_ble_cmd_create_adv_params(uint8_t *param, dataQueue_t *rx_queue, uint8_t adv_data_len, uint8_t *adv_data, uint8_t scan_resp_data_len, uint8_t *scan_resp_data, ble_addr_type_t own_addr_type, uint8_t *own_addr)
Creates BLE radio command parameters that are used to enable BLE advertisement on the radio core.
Definition rf-ble-cmd.c:223
void rf_ble_cmd_create_initiator_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params, uint8_t *output, uint32_t start_time)
Creates a BLE radio command structure that sets up BLE initiation event when sent to the radio core.
Definition rf-ble-cmd.c:255
void rf_ble_cmd_create_master_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params, uint8_t *output, uint32_t start_time)
Creates a BLE radio command structure that sets up BLE connection event when sent to the radio core.
Definition rf-ble-cmd.c:430
unsigned short rf_ble_cmd_wait(uint8_t *cmd)
Waits for a running BLE radio command to be finished.
Definition rf-ble-cmd.c:146
void rf_ble_cmd_create_initiator_params(uint8_t *param, dataQueue_t *rx_queue, uint32_t initiator_window, ble_addr_type_t own_addr_type, uint8_t *own_addr, ble_addr_type_t peer_addr_type, uint8_t *peer_addr, uint32_t connect_time, uint8_t *conn_req_data)
Creates BLE radio command parameters that are used to set up BLE initiation event on the radio core.
Definition rf-ble-cmd.c:291
void rf_ble_cmd_create_slave_params(uint8_t *param, dataQueue_t *rx_queue, dataQueue_t *tx_queue, uint32_t access_address, uint8_t crc_init_0, uint8_t crc_init_1, uint8_t crc_init_2, uint32_t win_size, uint32_t window_widening, uint8_t first_packet)
Creates BLE radio command parameters that are used to setup a single BLE connection event on the radi...
Definition rf-ble-cmd.c:376
unsigned short rf_ble_cmd_setup_ble_mode(void)
Initializes the radio core to be used as a BLE radio.
Definition rf-ble-cmd.c:158
unsigned short rf_ble_cmd_add_data_queue_entry(dataQueue_t *q, uint8_t *e)
Adds a data buffer to a BLE transmission queue.
Definition rf-ble-cmd.c:515
void rf_ble_cmd_create_slave_cmd(uint8_t *cmd, uint8_t channel, uint8_t *param, uint8_t *output, uint32_t start_time)
Creates a BLE radio command structure that sets up a single BLE connection event when sent to the rad...
Definition rf-ble-cmd.c:337