Developer World
Spresense SDK Library v1.4.2-3df2e9d
bt_common.h
Go to the documentation of this file.
1 /****************************************************************************
2  * modules/include/bluetooth/bt_common.h
3  *
4  * Copyright 2018 Sony Semiconductor Solutions Corporation
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  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17  * the names of its contributors may be used to endorse or promote
18  * products derived from this software without specific prior written
19  * permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  ****************************************************************************/
35 
43 #ifndef __MODULES_INCLUDE_BLUETOOTH_BT_COMMON_H
44 #define __MODULES_INCLUDE_BLUETOOTH_BT_COMMON_H
45 
46 /****************************************************************************
47  * Included Files
48  ****************************************************************************/
49 
50 #include <stdint.h>
51 #include <bluetooth/bluetooth.h>
52 
53 /****************************************************************************
54  * Public Types
55  ****************************************************************************/
56 
61 typedef enum
62 {
68 
74 {
81  char bt_name[BT_NAME_LEN];
82  char ble_name[BT_NAME_LEN];
83 };
84 
90 {
94  char bt_target_name[BT_NAME_LEN];
95 };
96 
102 {
107  char bt_target_name[BT_NAME_LEN];
108 };
109 
115 {
116  void (*command_status)(BT_CMD_STATUS status);
117  void (*pairing_complete)(BT_ADDR addr, BT_PAIR_STATUS status);
118  void (*inquiry_result)(BT_ADDR addr, char *name);
119  void (*inquiry_complete)(void);
120  void (*connect_status_changed)(struct bt_acl_state_s *bt_acl_state, bool connected, int status);
121  void (*connected_device_name)(const char *name);
122  void (*bond_info)(BT_ADDR addr);
123 };
124 
130 {
131  void (*connect_status_changed)(struct ble_state_s *ble_state, bool connected);
132  void (*connected_device_name_resp)(const char *name);
133  void (*scan_result)(BT_ADDR addr, char *dev_name);
134 };
135 
136 /****************************************************************************
137  * Public Function Prototypes
138  ****************************************************************************/
139 
147 int bt_init(void);
148 
155 int bt_finalize(void);
156 
166 int bt_set_address(BT_ADDR *addr);
167 
176 int bt_get_address(BT_ADDR *addr);
177 
187 int bt_set_name(char *name);
188 
197 int bt_get_name(char *name);
198 
206 int bt_enable(void);
207 
215 int bt_disable(void);
216 
224 int bt_pairing_enable(void);
225 
233 int bt_paring_disable(void);
234 
245 int bt_get_bond_list(BT_ADDR *addr, int *num);
246 
256 int bt_unbond(BT_ADDR *addr);
257 
267 int bt_set_visibility(BT_VISIBILITY visibility);
268 
276 int bt_start_inquiry(void);
277 
285 int bt_cancel_inquiry(void);
286 
297 
307 int ble_set_address(BT_ADDR *addr);
308 
317 int ble_get_address(BT_ADDR *addr);
318 
328 int ble_set_name(char *name);
329 
338 int ble_get_name(char *name);
339 
346 int ble_enable(void);
347 
354 int ble_disable(void);
355 
364 int ble_connect(struct ble_state_s *ble_state);
365 
374 int ble_disconnect(struct ble_state_s *ble_state);
375 
383 int ble_start_advertise(void);
384 
392 int ble_cancel_advertise(void);
393 
401 int ble_start_scan(void);
402 
410 int ble_cancel_scan(void);
411 
422 
423 #endif /* __MODULES_INCLUDE_BLUETOOTH_BT_COMMON_H */
BT_CONNECT_STATUS ble_connection
Definition: bt_common.h:103
struct bt_hal_common_ops_s * bt_hal_common_ops
Definition: bt_common.h:75
int ble_start_advertise(void)
Bluetooth LE start advertise Start BLE advertise mode.
int ble_connect(struct ble_state_s *ble_state)
Bluetooth LE connect for Central.
int bt_start_inquiry(void)
Bluetooth inquiry start Start to inquiry for connect peer device.
BT_PAIR_STATUS
BT pairing result.
Definition: bluetooth.h:159
BT address types.
Definition: bluetooth.h:120
int ble_get_address(BT_ADDR *addr)
Get Bluetooth LE module address.
int ble_get_name(char *name)
Get Bluetooth LE module name.
int bt_disable(void)
Bluetooth module disable Bluetooth set power off.
Bluetooth LE common HAL callbacks.
Definition: bt_if.h:138
int ble_enable(void)
Bluetooth LE enable.
Bluetooth LE Common application callbacks.
Definition: bt_common.h:129
int ble_cancel_advertise(void)
Bluetooth LE cancel advertise Cancel BLE advertise mode.
Bluetooth Common HAL callbacks.
Definition: bt_if.h:69
Definition: bt_common.h:65
Bluetooth LE context.
Definition: bt_common.h:101
BT_ADDR bt_target_addr
Definition: bt_common.h:106
int ble_set_name(char *name)
Set Bluetooth LE module name This name visible for other devices and should be call before bt_enable...
struct bt_common_state_s * bt_common_state
Definition: bt_common.h:105
int bt_set_name(char *name)
Set Bluetooth module name This name visible for other devices and should be call before bt_enable...
int ble_start_scan(void)
Bluetooth LE start scan Start BLE scan mode.
int ble_disconnect(struct ble_state_s *ble_state)
Bluetooth LE dicsonnect for Central.
uint16_t ble_connect_handle
Definition: bt_common.h:104
Definition: bt_common.h:63
BT_ADDR bt_target_addr
Definition: bt_common.h:93
struct ble_hal_common_ops_s * ble_hal_common_ops
Definition: bt_common.h:76
int bt_get_bond_list(BT_ADDR *addr, int *num)
Bluetooth get bond device list Get bond devices list with BD_ADDR.
int bt_unbond(BT_ADDR *addr)
Bluetooth unbond by BD_ADDR Unbond device by BD_ADDR.
Bluetooth base context.
Definition: bt_common.h:73
BT_VISIBILITY
BT visibility ID.
Definition: bluetooth.h:199
struct bt_common_state_s * bt_common_state
Definition: bt_common.h:92
char ble_name[BT_NAME_LEN]
Definition: bt_common.h:82
Definition: bt_common.h:64
int bt_set_address(BT_ADDR *addr)
Set Bluetooth module address This is Spresense side address and should be call before bt_enable...
int bt_init(void)
Bluetooth module initialize For initialize a pin config, NV storage, UART, etc.
int bt_enable(void)
Bluetooth module enable Bluetooth set power on(and download firmware, etc).
char bt_name[BT_NAME_LEN]
Definition: bt_common.h:81
BT_ADDR ble_addr
Definition: bt_common.h:80
int bt_get_address(BT_ADDR *addr)
Get Bluetooth module address.
BT_CONNECT_STATUS
BT profile connection status.
Definition: bt_common.h:61
int bt_set_visibility(BT_VISIBILITY visibility)
Bluetooth set visible Visible this device from others.
int bt_pairing_enable(void)
Bluetooth pairing enable Entering bluetooth pairing mode.
char name[32]
Definition: video.h:80
BT_CONNECT_STATUS bt_acl_connection
Definition: bt_common.h:91
Bluetooth Common application callbacks.
Definition: bt_common.h:114
int bt_finalize(void)
Bluetooth module finalize.
struct ble_common_ops_s * ble_common_ops
Definition: bt_common.h:78
int bt_paring_disable(void)
Bluetooth pairing disable Escaping bluetooth pairing mode.
Bluetooth ACL context.
Definition: bt_common.h:89
BT_ADDR bt_addr
Definition: bt_common.h:79
BT_CMD_STATUS
BT hci command status.
Definition: bluetooth.h:138
int ble_disable(void)
Bluetooth LE disable.
Definition: bt_common.h:66
int bt_register_common_cb(struct bt_common_ops_s *bt_common_ops)
Bluetooth register common callbacks Register Connect/Pairing/Inquiry callback.
int bt_cancel_inquiry(void)
Bluetooth inquiry cancel Cancel to inquiry.
int ble_register_common_cb(struct ble_common_ops_s *ble_common_ops)
Bluetooth LE register common callbacks Register Connect/Advertise/Scan callback.
Bluetooth common header for SDK on Spresense.
int bt_get_name(char *name)
Get Bluetooth module name.
int ble_cancel_scan(void)
Bluetooth LE cancel scan Cancel BLE scan mode.
int ble_set_address(BT_ADDR *addr)
Set Bluetooth LE module address This is Spresense side address and should be call before bt_enable...
struct bt_common_ops_s * bt_common_ops
Definition: bt_common.h:77