Contiki-NG
rf-ble.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Texas Instruments Incorporated - http://www.ti.com/
3 * Copyright (c) 2017, University of Bristol - http://www.bristol.ac.uk/
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the copyright holder nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 * OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31/*---------------------------------------------------------------------------*/
32/**
33 * \addtogroup rf-core
34 * @{
35 *
36 * \defgroup rf-core-ble CC13xx/CC26xx BLE driver
37 *
38 * @{
39 *
40 * \file
41 * Header file for the CC13xx/CC26xx BLE driver
42 */
43/*---------------------------------------------------------------------------*/
44#ifndef RF_BLE_H_
45#define RF_BLE_H_
46/*---------------------------------------------------------------------------*/
47#include "contiki.h"
48#include "rf-core/rf-core.h"
49#include "radio.h"
50
51#include <stdint.h>
52/*---------------------------------------------------------------------------*/
53#ifdef RF_BLE_CONF_ENABLED
54#define RF_BLE_ENABLED RF_BLE_CONF_ENABLED
55#else
56#define RF_BLE_ENABLED 1
57#endif
58/*---------------------------------------------------------------------------*/
59#define RF_BLE_IDLE 0
60#define RF_BLE_ACTIVE 1
61/*---------------------------------------------------------------------------*/
62/* Memory address of BLE MAC address. Can be overwritten by the user by defining BLE_ADDRESS_PTR. */
63#ifndef BLE_ADDRESS_PTR
64#define BLE_ADDRESS_PTR (0x500012E8)
65#endif
66/*---------------------------------------------------------------------------*/
67/* BLE Advertisement channels. Not to be changed by the user. */
68#define BLE_ADV_CHANNEL_MASK 0x07
69
70#define BLE_ADV_CHANNEL_37 0x01
71#define BLE_ADV_CHANNEL_38 0x02
72#define BLE_ADV_CHANNEL_39 0x04
73
74#define BLE_ADV_CHANNEL_ALL (BLE_ADV_CHANNEL_37 | BLE_ADV_CHANNEL_38 | BLE_ADV_CHANNEL_39)
75/*---------------------------------------------------------------------------*/
76/* Maximum BLE advertisement size. Not to be changed by the user. */
77#define BLE_ADV_MAX_SIZE 31
78/*---------------------------------------------------------------------------*/
79/**
80 * \brief Set the device name to use with the BLE advertisement/beacon daemon
81 * \param interval The interval (ticks) between two consecutive beacon bursts
82 * \param name The device name to advertise
83 *
84 * If name is NULL it will be ignored. If interval==0 it will be ignored. Thus,
85 * this function can be used to configure a single parameter at a time if so
86 * desired.
87 */
88void rf_ble_beacond_config(clock_time_t interval, const char *name);
89
90/**
91 * \brief Start the BLE advertisement/beacon daemon
92 * \return RF_CORE_CMD_OK: Success, RF_CORE_CMD_ERROR: Failure
93 *
94 * Before calling this function, the name to advertise must first be set by
95 * calling rf_ble_beacond_config(). Otherwise, this function will return an
96 * error.
97 */
98uint8_t rf_ble_beacond_start(void);
99
100/**
101 * \brief Stop the BLE advertisement/beacon daemon
102 */
103void rf_ble_beacond_stop(void);
104
105/**
106 * \brief Check whether the BLE beacond is currently active
107 * \retval 1 The radio is in BLE mode
108 * \retval 0 The BLE daemon is not active, or disabled
109 */
110uint8_t rf_ble_is_active(void);
111
112/**
113 * \brief Set TX power for BLE advertisements
114 * \param power The 'at least' TX power in dBm, values avove 5 dBm will be ignored
115 *
116 * Set TX power to 'at least' power dBm.
117 * This works with a lookup table. If the value of 'power' does not exist in
118 * the lookup table, TXPOWER will be set to the immediately higher available
119 * value
120 */
122
123/**
124 * \brief Get TX power for BLE advertisements
125 * \return The TX power for BLE advertisements
126 */
128
129/**
130 * \brief Transmit a single BLE advertisement in one or more advertisement channels
131 * \param channel Bitmask of advertisement channels to be used: use
132 * BLE_ADV_CHANNEL_37 for channel 37, BLE_ADV_CHANNEL_38 for channel 38,
133 * BLE_ADV_CHANNEL_39 for channel 39, or any 'or' combination of those
134 * \param data A pointer to the advertisement data buffer
135 * \param len The length of the advertisement data. If more than BLE_ADV_MAX_SIZE,
136 * the first BLE_ADV_MAX_SIZE bytes will be used.
137 *
138 * Transmits a given advertisement payload once in one or any arbitrary combination
139 * of advertisement channels.
140 */
141void rf_ble_beacon_single(uint8_t channel, uint8_t *data, uint8_t len);
142/*---------------------------------------------------------------------------*/
143#endif /* RF_BLE_H_ */
144/*---------------------------------------------------------------------------*/
145/**
146 * @}
147 * @}
148 */
int radio_value_t
Each radio has a set of parameters that designate the current configuration and state of the radio.
Definition: radio.h:88
void rf_ble_beacond_stop()
Stop the BLE advertisement/beacon daemon.
Definition: rf-ble.c:268
uint8_t rf_ble_beacond_start()
Start the BLE advertisement/beacon daemon.
Definition: rf-ble.c:240
void rf_ble_beacond_config(clock_time_t interval, const char *name)
Set the device name to use with the BLE advertisement/beacon daemon.
Definition: rf-ble.c:219
void rf_ble_set_tx_power(radio_value_t power)
Set TX power for BLE advertisements.
Definition: rf-ble.c:205
uint8_t rf_ble_is_active()
Check whether the BLE beacond is currently active.
Definition: rf-ble.c:262
radio_value_t rf_ble_get_tx_power(void)
Get TX power for BLE advertisements.
Definition: rf-ble.c:193
void rf_ble_beacon_single(uint8_t channel, uint8_t *data, uint8_t len)
Transmit a single BLE advertisement in one or more advertisement channels.
Definition: rf-ble.c:308
Header file for the radio API.
Header file for the CC13xx/CC26xx RF core driver.