Contiki-NG
ble-beacond.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
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  * \addtogroup cc13xx-cc26xx-rf
32  * @{
33  *
34  * \defgroup cc13xx-cc26xx-rf-ble CC13xx/CC26xx BLE Beacon Daemon
35  *
36  * @{
37  *
38  * \file
39  * Header file for the CC13xx/CC26xx BLE Beacon Daemon.
40  * \author
41  * Edvard Pettersen <e.pettersen@ti.com>
42  */
43 /*---------------------------------------------------------------------------*/
44 #ifndef RF_BLE_BEACOND_H_
45 #define RF_BLE_BEACOND_H_
46 /*---------------------------------------------------------------------------*/
47 #include "contiki.h"
48 /*---------------------------------------------------------------------------*/
49 #include <stdint.h>
50 /*---------------------------------------------------------------------------*/
51 typedef enum {
52  RF_BLE_BEACOND_OK,
53  RF_BLE_BEACOND_ERROR,
54  RF_BLE_BEACOND_DISABLED,
55 } rf_ble_beacond_result_t;
56 /*---------------------------------------------------------------------------*/
57 /**
58  * \brief Initialize the BLE advertisement/beacon daemon
59  */
60 rf_ble_beacond_result_t rf_ble_beacond_init(void);
61 
62 /**
63  * \brief Set the device name to use with the BLE advertisement/beacon daemon
64  * \param interval The interval (ticks) between two consecutive beacon bursts
65  * \param name The device name to advertise
66  *
67  * If name is NULL it will be ignored. If interval==0 it will be ignored. Thus,
68  * this function can be used to configure a single parameter at a time if so
69  * desired.
70  */
71 rf_ble_beacond_result_t rf_ble_beacond_config(clock_time_t interval, const char *name);
72 
73 /**
74  * \brief Start the BLE advertisement/beacon daemon
75  * \return RF_CORE_CMD_OK: Success, RF_CORE_CMD_ERROR: Failure
76  *
77  * Before calling this function, the name to advertise must first be set by
78  * calling rf_ble_beacond_config(). Otherwise, this function will return an
79  * error.
80  */
81 rf_ble_beacond_result_t rf_ble_beacond_start(void);
82 
83 /**
84  * \brief Stop the BLE advertisement/beacon daemon
85  */
86 rf_ble_beacond_result_t rf_ble_beacond_stop(void);
87 
88 /**
89  * \brief Check whether the BLE beacond is currently active
90  * \retval 1 BLE daemon is active
91  * \retval 0 BLE daemon is inactive
92  * \retval -1 BLE daemon is disabled
93  */
94 int8_t rf_ble_is_active(void);
95 
96 /**
97  * \brief Set TX power for BLE advertisements
98  * \param dbm The 'at least' TX power in dBm, values avove 5 dBm will be ignored
99  *
100  * Set TX power to 'at least' power dBm.
101  * This works with a lookup table. If the value of 'power' does not exist in
102  * the lookup table, TXPOWER will be set to the immediately higher available
103  * value
104  */
105 rf_ble_beacond_result_t rf_ble_set_tx_power(int8_t dbm);
106 
107 /**
108  * \brief Get TX power for BLE advertisements
109  * \return The TX power for BLE advertisements
110  */
111 int8_t rf_ble_get_tx_power(void);
112 /*---------------------------------------------------------------------------*/
113 #endif /* RF_BLE_BEACOND_H_ */
114 /*---------------------------------------------------------------------------*/
115 /**
116  * @}
117  * @}
118  */
void rf_ble_beacond_stop()
Stop the BLE advertisement/beacon daemon.
Definition: rf-ble.c:268
radio_value_t rf_ble_get_tx_power(void)
Get TX power for BLE advertisements.
Definition: rf-ble.c:193
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
rf_ble_beacond_result_t rf_ble_beacond_init(void)
Initialize the BLE advertisement/beacon daemon.
Definition: ble-beacond.c:312
uint8_t rf_ble_beacond_start()
Start the BLE advertisement/beacon daemon.
Definition: rf-ble.c:240