Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
classic.h
Go to the documentation of this file.
1
4
5/*
6 * Copyright (c) 2015-2016 Intel Corporation
7 * Copyright 2024 NXP
8 *
9 * SPDX-License-Identifier: Apache-2.0
10 */
11#ifndef ZEPHYR_INCLUDE_BLUETOOTH_CLASSIC_H_
12#define ZEPHYR_INCLUDE_BLUETOOTH_CLASSIC_H_
13
20
21#include <stdbool.h>
22#include <string.h>
23
24#include <zephyr/sys/util.h>
25#include <zephyr/net_buf.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
42
47struct bt_br_discovery_priv {
49 uint16_t clock_offset;
51 uint8_t pscan_rep_mode;
53 uint8_t resolve_state;
54};
55
57#define BT_BR_EIR_SIZE_MAX 240
58
62 struct bt_br_discovery_priv _priv;
63
66
69
72
75};
76
87
106 struct bt_br_discovery_result *results, size_t count);
107
118
120
126 void (*recv)(const struct bt_br_discovery_result *result);
127
133 void (*timeout)(const struct bt_br_discovery_result *results,
134 size_t count);
135
137};
138
151
160
165
175
193int bt_br_set_discoverable(bool enable, bool limited);
194
213
228typedef enum bt_br_conn_req_rsp (*bt_br_conn_req_func_t)(const bt_addr_t *addr, uint32_t cod);
229
251
253#define BT_BR_SCAN_INTERVAL_MIN 0x0012
255#define BT_BR_SCAN_INTERVAL_MAX 0x1000
256
258#define BT_BR_SCAN_WINDOW_MIN 0x0011
260#define BT_BR_SCAN_WINDOW_MAX 0x1000
261
266
268#define BT_BR_PAGE_SCAN_INTERVAL_R0 0x0800
270#define BT_BR_PAGE_SCAN_WINDOW_R0 0x0800
271
273#define BT_BR_PAGE_SCAN_FAST_INTERVAL_R1 0x00a0
275#define BT_BR_PAGE_SCAN_FAST_WINDOW_R1 0x0011
276
278#define BT_BR_PAGE_SCAN_MEDIUM_INTERVAL_R1 0x0800
280#define BT_BR_PAGE_SCAN_MEDIUM_WINDOW_R1 0x0011
281
283#define BT_BR_PAGE_SCAN_SLOW_INTERVAL_R1 0x0800
285#define BT_BR_PAGE_SCAN_SLOW_WINDOW_R1 0x0011
286
288#define BT_BR_PAGE_SCAN_FAST_INTERVAL_R2 0x1000
290#define BT_BR_PAGE_SCAN_FAST_WINDOW_R2 0x0011
291
293#define BT_BR_PAGE_SCAN_SLOW_INTERVAL_R2 0x1000
295#define BT_BR_PAGE_SCAN_SLOW_WINDOW_R2 0x0011
296
300
309
330
338
339#define BT_BR_SCAN_INIT(_interval, _window, _type) \
340{ \
341 .interval = (_interval), \
342 .window = (_window), \
343 .type = (_type) \
344}
345
353
354#define BT_BR_PAGE_SCAN_PARAM(_interval, _window, _type) \
355 ((const struct bt_br_page_scan_param[]) { \
356 BT_BR_SCAN_INIT(_interval, _window, _type) \
357 })
358
365#define BT_BR_PAGE_SCAN_PARAM_R0 BT_BR_PAGE_SCAN_PARAM(BT_BR_PAGE_SCAN_INTERVAL_R0, \
366 BT_BR_PAGE_SCAN_WINDOW_R0, \
367 BT_BR_SCAN_TYPE_STANDARD)
368
376#define BT_BR_PAGE_SCAN_PARAM_FAST_R1 \
377 BT_BR_PAGE_SCAN_PARAM(BT_BR_PAGE_SCAN_FAST_INTERVAL_R1, \
378 BT_BR_PAGE_SCAN_FAST_WINDOW_R1, \
379 BT_BR_SCAN_TYPE_INTERLACED)
380
388#define BT_BR_PAGE_SCAN_PARAM_MEDIUM_R1 \
389 BT_BR_PAGE_SCAN_PARAM( \
390 BT_BR_PAGE_SCAN_MEDIUM_INTERVAL_R1, \
391 BT_BR_PAGE_SCAN_MEDIUM_WINDOW_R1, \
392 BT_BR_SCAN_TYPE_INTERLACED)
393
401#define BT_BR_PAGE_SCAN_PARAM_SLOW_R1 \
402 BT_BR_PAGE_SCAN_PARAM( \
403 BT_BR_PAGE_SCAN_SLOW_INTERVAL_R1, \
404 BT_BR_PAGE_SCAN_SLOW_WINDOW_R1, \
405 BT_BR_SCAN_TYPE_STANDARD)
406
414#define BT_BR_PAGE_SCAN_PARAM_FAST_R2 \
415 BT_BR_PAGE_SCAN_PARAM( \
416 BT_BR_PAGE_SCAN_FAST_INTERVAL_R2, \
417 BT_BR_PAGE_SCAN_FAST_WINDOW_R2, \
418 BT_BR_SCAN_TYPE_INTERLACED)
419
427#define BT_BR_PAGE_SCAN_PARAM_SLOW_R2 \
428 BT_BR_PAGE_SCAN_PARAM( \
429 BT_BR_PAGE_SCAN_SLOW_INTERVAL_R2, \
430 BT_BR_PAGE_SCAN_SLOW_WINDOW_R2, \
431 BT_BR_SCAN_TYPE_STANDARD)
432
472
497
502
504#define BT_BR_INQUIRY_SCAN_INTERVAL_DEFAULT 0x1000
506#define BT_BR_INQUIRY_SCAN_WINDOW_DEFAULT 0x0012
507
511
519#define BT_BR_INQUIRY_SCAN_PARAM(_interval, _window, _type) \
520 ((const struct bt_br_inquiry_scan_param[]){BT_BR_SCAN_INIT(_interval, _window, _type)})
521
529#define BT_BR_INQUIRY_SCAN_PARAM_DEFAULT \
530 BT_BR_INQUIRY_SCAN_PARAM(BT_BR_INQUIRY_SCAN_INTERVAL_DEFAULT, \
531 BT_BR_INQUIRY_SCAN_WINDOW_DEFAULT, BT_BR_SCAN_TYPE_STANDARD)
532
565
593
605
612bool bt_br_bond_exists(const bt_addr_t *addr);
613
621int bt_br_unpair(const bt_addr_t *addr);
622
628
635void bt_br_foreach_bond(void (*func)(const struct bt_br_bond_info *info, void *user_data),
636 void *user_data);
637
649int bt_br_write_eir(const struct bt_data *eir, size_t eir_count, bool fec_required);
650
654
655#ifdef __cplusplus
656}
657#endif
661
662#endif /* ZEPHYR_INCLUDE_BLUETOOTH_CLASSIC_H_ */
Bluetooth device address definitions and utilities.
Bluetooth data types and helpers.
bt_br_scan_type
Page scan type.
Definition classic.h:302
int bt_br_set_class_of_device(uint32_t cod)
Set the Class of Device of the local BR/EDR Controller.
void bt_br_discovery_cb_unregister(struct bt_br_discovery_cb *cb)
Unregister discovery packet callbacks.
int bt_br_oob_get_local(struct bt_br_oob *oob)
Get BR/EDR local Out Of Band information.
void bt_br_discovery_cb_register(struct bt_br_discovery_cb *cb)
Register discovery packet callbacks.
void bt_br_foreach_bond(void(*func)(const struct bt_br_bond_info *info, void *user_data), void *user_data)
Iterate through all existing bonds of Classic.
int bt_br_discovery_stop(void)
Stop BR/EDR discovery.
int bt_br_set_connectable(bool enable, bt_br_conn_req_func_t func)
Enable/disable set controller in connectable state.
int bt_br_inquiry_scan_update_param(const struct bt_br_inquiry_scan_param *param)
Update BR/EDR inquiry scan parameters.
int bt_br_page_scan_update_param(const struct bt_br_page_scan_param *param)
Update BR/EDR page scan parameters.
#define BT_BR_EIR_SIZE_MAX
Maximum size of Extended Inquiry Response.
Definition classic.h:57
int bt_br_discovery_start(const struct bt_br_discovery_param *param, struct bt_br_discovery_result *results, size_t count)
Start BR/EDR discovery.
int bt_br_write_eir(const struct bt_data *eir, size_t eir_count, bool fec_required)
Write Extended Inquiry Response data.
int bt_br_get_class_of_device(uint32_t *cod)
Get the Class of Device of the local BR/EDR Controller.
enum bt_br_conn_req_rsp(* bt_br_conn_req_func_t)(const bt_addr_t *addr, uint32_t cod)
Callback type for incoming BR/EDR connection requests.
Definition classic.h:228
bt_br_conn_req_rsp
BR/EDR connection request response codes.
Definition classic.h:201
int bt_br_unpair(const bt_addr_t *addr)
Clear classic pairing information .
bool bt_br_bond_exists(const bt_addr_t *addr)
Check if a Bluetooth classic device address is bonded.
int bt_br_set_discoverable(bool enable, bool limited)
Enable/disable set controller in discoverable state.
@ BT_BR_SCAN_TYPE_STANDARD
Standard scan (default).
Definition classic.h:304
@ BT_BR_SCAN_TYPE_INTERLACED
Interlaced scan (1.2 devices only).
Definition classic.h:307
@ BT_BR_CONN_REQ_REJECT_SECURITY
Reject connection due to insufficient security.
Definition classic.h:209
@ BT_BR_CONN_REQ_ACCEPT_PERIPHERAL
Accept connection as peripheral role.
Definition classic.h:205
@ BT_BR_CONN_REQ_ACCEPT_CENTRAL
Accept connection as central role.
Definition classic.h:203
@ BT_BR_CONN_REQ_REJECT_ADDR
Reject connection due to unacceptable device address.
Definition classic.h:211
@ BT_BR_CONN_REQ_REJECT_NO_RESOURCES
Reject connection due to insufficient resources.
Definition classic.h:207
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
#define BT_HCI_ERR_INSUFFICIENT_SECURITY
Definition hci_types.h:4536
#define BT_HCI_ERR_INSUFFICIENT_RESOURCES
Definition hci_types.h:4535
#define BT_HCI_ROLE_CENTRAL
Definition hci_types.h:3467
#define BT_HCI_ERR_BD_ADDR_UNACCEPTABLE
Definition hci_types.h:4537
#define BT_HCI_ROLE_PERIPHERAL
Definition hci_types.h:3468
Buffer management.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT8_TYPE__ int8_t
Definition stdint.h:72
Bluetooth Device Address.
Definition addr.h:40
Information about a bond with a remote device.
Definition classic.h:624
bt_addr_t addr
Address of the remote device.
Definition classic.h:626
Definition classic.h:119
void(* timeout)(const struct bt_br_discovery_result *results, size_t count)
The inquiry has stopped after discovery timeout.
Definition classic.h:133
void(* recv)(const struct bt_br_discovery_result *result)
An inquiry response received callback.
Definition classic.h:126
sys_snode_t node
Definition classic.h:136
BR/EDR discovery parameters.
Definition classic.h:78
uint8_t length
Maximum length of the discovery in units of 1.28 seconds.
Definition classic.h:82
bool limited
True if limited discovery procedure is to be used.
Definition classic.h:85
BR/EDR discovery result structure.
Definition classic.h:60
uint8_t eir[240]
Extended Inquiry Response.
Definition classic.h:74
bt_addr_t addr
Remote device address.
Definition classic.h:65
int8_t rssi
RSSI from inquiry.
Definition classic.h:68
uint8_t cod[3]
Class of Device.
Definition classic.h:71
BR/EDR inquiry scan parameters.
Definition classic.h:478
enum bt_br_scan_type type
Inquiry scan type.
Definition classic.h:495
uint16_t interval
Inquiry scan interval in 0.625 ms units Range: 0x0012 to 0x1000.
Definition classic.h:487
uint16_t window
Inquiry scan window in 0.625 ms units Range: 0x0011 to 0x1000.
Definition classic.h:492
Definition classic.h:161
bt_addr_t addr
BR/EDR address.
Definition classic.h:163
Page scan parameters.
Definition classic.h:311
uint16_t window
Page scan window in 0.625 ms units Range: 0x0011 to 0x1000.
Definition classic.h:325
uint16_t interval
Page scan interval in 0.625 ms units Range: 0x0012 to 0x1000.
Definition classic.h:320
enum bt_br_scan_type type
Page scan type.
Definition classic.h:328
Bluetooth data.
Definition data.h:40
Misc utilities.