nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
bt_mgmt.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef _BT_MGMT_H_
8#define _BT_MGMT_H_
9
10#include <zephyr/bluetooth/bluetooth.h>
11#include <zephyr/bluetooth/conn.h>
12#include <zephyr/bluetooth/audio/audio.h>
13
14#define LE_AUDIO_EXTENDED_ADV_NAME \
15 BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_USE_NAME, \
16 CONFIG_BLE_ACL_EXT_ADV_INT_MIN, CONFIG_BLE_ACL_EXT_ADV_INT_MAX, NULL)
17
18#define LE_AUDIO_EXTENDED_ADV_CONN_NAME \
19 BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CONNECTABLE | \
20 BT_LE_ADV_OPT_USE_NAME, \
21 CONFIG_BLE_ACL_EXT_ADV_INT_MIN, CONFIG_BLE_ACL_EXT_ADV_INT_MAX, NULL)
22
23#define LE_AUDIO_EXTENDED_ADV_CONN_NAME_FILTER \
24 BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CONNECTABLE | \
25 BT_LE_ADV_OPT_USE_NAME | BT_LE_ADV_OPT_FILTER_CONN, \
26 CONFIG_BLE_ACL_EXT_ADV_INT_MIN, CONFIG_BLE_ACL_EXT_ADV_INT_MAX, NULL)
27
28#define LE_AUDIO_PERIODIC_ADV \
29 BT_LE_PER_ADV_PARAM(CONFIG_BLE_ACL_PER_ADV_INT_MIN, CONFIG_BLE_ACL_PER_ADV_INT_MAX, \
30 BT_LE_PER_ADV_OPT_NONE)
31
32#define BT_LE_ADV_FAST_CONN \
33 BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE, BT_GAP_ADV_FAST_INT_MIN_1, \
34 BT_GAP_ADV_FAST_INT_MAX_1, NULL)
35
36/* Broadcast name can be max 32 bytes long, so this will be the limit for both.
37 * Add one for '\0' at the end.
38 */
39#define BLE_SEARCH_NAME_MAX_LEN 33
40
41#if (CONFIG_SCAN_MODE_ACTIVE)
42#define NRF5340_AUDIO_GATEWAY_SCAN_TYPE BT_LE_SCAN_TYPE_ACTIVE
43#define NRF5340_AUDIO_GATEWAY_SCAN_PARAMS BT_LE_SCAN_ACTIVE
44#elif (CONFIG_SCAN_MODE_PASSIVE)
45#define NRF5340_AUDIO_GATEWAY_SCAN_TYPE BT_LE_SCAN_TYPE_PASSIVE
46#define NRF5340_AUDIO_GATEWAY_SCAN_PARAMS BT_LE_SCAN_PASSIVE
47#else
48#error "Select either CONFIG_SCAN_MODE_ACTIVE or CONFIG_SCAN_MODE_PASSIVE"
49#endif
50
54};
55
56#define BRDCAST_ID_NOT_USED (BT_AUDIO_BROADCAST_ID_MAX + 1)
57
64void bt_mgmt_set_size_filled_get(uint8_t *num_filled);
65
72void bt_mgmt_scan_sirk_set(uint8_t const *const sirk);
73
86int bt_mgmt_adv_buffer_put(struct bt_data *const adv_buf, uint32_t *index, size_t adv_buf_vacant,
87 size_t data_len, uint8_t type, void *data);
88
112int bt_mgmt_scan_start(uint16_t scan_intvl, uint16_t scan_win, enum bt_mgmt_scan_type type,
113 char const *const name, uint32_t brdcast_id);
114
123int bt_mgmt_manufacturer_uuid_populate(struct net_buf_simple *uuid_buf, uint16_t company_id);
124
134int bt_mgmt_per_adv_stop(uint8_t ext_adv_index);
135
141int bt_mgmt_ext_adv_stop(uint8_t ext_adv_index);
142
159int bt_mgmt_adv_start(uint8_t ext_adv_index, const struct bt_data *ext_adv, size_t ext_adv_size,
160 const struct bt_data *per_adv, size_t per_adv_size, bool connectable);
161
167void bt_mgmt_num_conn_get(uint8_t *num_conn);
168
175
180
186void bt_mgmt_broadcast_code_ptr_get(uint8_t **broadcast_code_ptr);
187
195int bt_mgmt_pa_sync_delete(struct bt_le_per_adv_sync *pa_sync);
196
206int bt_mgmt_conn_disconnect(struct bt_conn *conn, uint8_t reason);
207
213int bt_mgmt_init(void);
214
215#endif /* _BT_MGMT_H_ */
int bt_mgmt_pa_sync_delete(struct bt_le_per_adv_sync *pa_sync)
Delete a periodic advertisement sync.
int bt_mgmt_conn_disconnect(struct bt_conn *conn, uint8_t reason)
Disconnect from a remote device or cancel the pending connection.
int bt_mgmt_scan_start(uint16_t scan_intvl, uint16_t scan_win, enum bt_mgmt_scan_type type, char const *const name, uint32_t brdcast_id)
Start scanning for advertisements.
void bt_mgmt_broadcast_code_ptr_get(uint8_t **broadcast_code_ptr)
Get the pointer to broadcast code.
void bt_mgmt_set_size_filled_get(uint8_t *num_filled)
Get the numbers of connected members of a given 'Set Identity Resolving Key' (SIRK)....
int bt_mgmt_manufacturer_uuid_populate(struct net_buf_simple *uuid_buf, uint16_t company_id)
Add manufacturer ID UUID to the advertisement packet.
int bt_mgmt_per_adv_stop(uint8_t ext_adv_index)
Stop periodic advertising.
void bt_mgmt_scan_sirk_set(uint8_t const *const sirk)
Set 'Set Identity Resolving Key' (SIRK). Used for searching for other member of the same set.
void bt_mgmt_num_conn_get(uint8_t *num_conn)
Get the number of active connections.
bt_mgmt_scan_type
Definition: bt_mgmt.h:51
@ BT_MGMT_SCAN_TYPE_BROADCAST
Definition: bt_mgmt.h:53
@ BT_MGMT_SCAN_TYPE_CONN
Definition: bt_mgmt.h:52
int bt_mgmt_init(void)
Initialize the Bluetooth management module.
int bt_mgmt_ext_adv_stop(uint8_t ext_adv_index)
Stop extended advertising.
int bt_mgmt_adv_start(uint8_t ext_adv_index, const struct bt_data *ext_adv, size_t ext_adv_size, const struct bt_data *per_adv, size_t per_adv_size, bool connectable)
Create and start advertising for an ACL connection.
void bt_mgmt_scan_delegator_init(void)
Scan delegator feature initialization.
int bt_mgmt_bonding_clear(void)
Clear all bonded devices.
int bt_mgmt_adv_buffer_put(struct bt_data *const adv_buf, uint32_t *index, size_t adv_buf_vacant, size_t data_len, uint8_t type, void *data)
Load advertising data into an advertising buffer.