'\" t .\" Man page generated from reStructuredText .\" by the Docutils 0.23 manpage writer. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "hci" "7" "October 2024" "BlueZ" "Linux System Administration" .SH Name hci \- Bluetooth HCI protocol .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .EX #include #include #include hci_socket = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); .EE .UNINDENT .UNINDENT .SH DESCRIPTION .sp Bluetooth Host Controller Interface (HCI) is the standard protocol to communicate with Bluetooth adapters. HCI protocol provides a uniform command method for the Host to access Controller capabilities and to control connections to other Controllers. .SH SOCKET ADDRESS .INDENT 0.0 .INDENT 3.5 .sp .EX struct sockaddr_hci { sa_family_t hci_family; unsigned short hci_dev; unsigned short hci_channel; }; .EE .UNINDENT .UNINDENT .sp Possible values for hci_channel: .TS box center; l|l|l. T{ Define T} T{ Value T} T{ Description T} _ T{ \fBHCI_CHANNEL_RAW\fP T} T{ 0x00 T} T{ Raw channel \- Used for raw HCI communication T} _ T{ \fBHCI_CHANNEL_USER\fP T} T{ 0x01 T} T{ User channel \- Used for userspace HCI communication (disables kernel processing) T} _ T{ \fBHCI_CHANNEL_MONITOR\fP T} T{ 0x02 T} T{ Monitor channel \- Used for monitoring HCI traffic (btmon(1)) T} _ T{ \fBHCI_CHANNEL_CONTROL\fP T} T{ 0x03 T} T{ Control channel \- Used to manage local adapters (bluetoothd(7)) T} _ T{ \fBHCI_CHANNEL_LOGGING\fP T} T{ 0x04 T} T{ Logging channel \- Used to inject logging messages (bluetoothd(7)) T} .TE .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX struct sockaddr_hci addr; memset(&addr, 0, sizeof(addr)); addr.hci_family = AF_BLUETOOTH; addr.hci_dev = HCI_DEV_NONE; addr.hci_channel = HCI_CHANNEL_CONTROL; .EE .UNINDENT .UNINDENT .SH SOCKET OPTIONS .sp The socket options listed below can be set by using \fBsetsockopt(2)\fP and read with \fBgetsockopt(2)\fP with the socket level set to SOL_BLUETOOTH or SOL_HCI (HCI_FILTER). .SS HCI_FILTER (since Linux 2.6) .sp Filter by HCI events, requires hci_channel to be set to HCI_CHANNEL_RAW, possible values: .INDENT 0.0 .INDENT 3.5 .sp .EX struct hci_filter { uint32_t type_mask; uint32_t event_mask[2]; uint16_t opcode; }; .EE .UNINDENT .UNINDENT .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX struct hci_filter flt; memset(&flt, 0, sizeof(flt)); flt.type_mask = 1 << BT_H4_EVT_PKT; flt.event_mask[0] = 0xffffffff; flt.event_mask[1] = 0xffffffff; setsockopt(fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)); .EE .UNINDENT .UNINDENT .SS BT_SNDBUF (since Linux 5.16) .sp Set send buffer size, requires hci_channel to be set to HCI_CHANNEL_MONITOR, HCI_CHANNEL_CONTROL or HCI_CHANNEL_LOGGING. .sp Default value is 1028. .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX uint16_t mtu = UINT16_MAX; int err; err = setsockopt(fd, SOL_BLUETOOTH, BT_SNDMTU, &mtu, sizeof(mtu)); .EE .UNINDENT .UNINDENT .SS BT_RCVBUF (since Linux 5.16) .sp Set receive buffer size, requires hci_channel to be set to HCI_CHANNEL_MONITOR, HCI_CHANNEL_CONTROL or HCI_CHANNEL_LOGGING. .sp Default value is 1028. .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX uint16_t mtu; socklen_t len; int err; len = sizeof(mtu); err = getsockopt(sock, SOL_BLUETOOTH, BT_RCVMTU, mtu, &len); .EE .UNINDENT .UNINDENT .SH RESOURCES .sp \% .SH REPORTING BUGS .sp \% .SH SEE ALSO .sp socket(7) .SH Copyright Free use of this software is granted under the terms of the GNU Lesser General Public Licenses (LGPL). .\" End of generated man page.