diff -ubswr usr/src/sys/netgraph/bluetooth/include/ng_hci.h ng/usr/src/sys/netgraph/bluetooth/include/ng_hci.h
--- usr/src/sys/netgraph/bluetooth/include/ng_hci.h 2024-11-29 02:03:47.000000000 +0200
+++ ng/usr/src/sys/netgraph/bluetooth/include/ng_hci.h 2025-06-03 10:39:57.000000000 +0300
@@ -1374,6 +1374,19 @@
typedef ng_hci_status_rp ng_hci_write_page_scan_rp;
+#define NG_HCI_OCF_READ_INQUIRY_MODE 0x0044
+typedef struct {
+ u_int8_t status; /* 0x00 - success */
+ u_int8_t inquiry_mode; /* Inquiry mode */
+} __attribute__ ((packed)) ng_hci_read_inquiry_mode_rp;
+
+#define NG_HCI_OCF_WRITE_INQUIRY_MODE 0x0045
+typedef struct {
+ u_int8_t inquiry_mode; /* Inquiry mode */
+} __attribute__ ((packed)) ng_hci_write_inquiry_mode_cp;
+
+typedef ng_hci_status_rp ng_hci_write_inquiry_mode_rp;
+
#define NG_HCI_OCF_READ_LE_HOST_SUPPORTED 0x6c
typedef struct {
u_int8_t status; /* 0x00 - success */
@@ -1809,6 +1822,7 @@
} __attribute__ ((packed)) ng_hci_inquiry_compl_ep;
#define NG_HCI_EVENT_INQUIRY_RESULT 0x02
+#define NG_HCI_EVENT_INQUIRY_RESULT_RSSI 0x22
typedef struct {
u_int8_t num_responses; /* number of responses */
/* ng_hci_inquiry_response[num_responses] -- see below */
@@ -1822,6 +1836,15 @@
u_int8_t uclass[NG_HCI_CLASS_SIZE];/* unit class */
u_int16_t clock_offset; /* clock offset */
} __attribute__ ((packed)) ng_hci_inquiry_response;
+
+typedef struct {
+ bdaddr_t bdaddr; /* unit address */
+ u_int8_t page_scan_rep_mode; /* page scan rep. mode */
+ u_int8_t reserved; /* reserved */
+ u_int8_t uclass[NG_HCI_CLASS_SIZE];/* unit class */
+ u_int16_t clock_offset; /* clock offset */
+ int8_t rssi; /* Range: -127 to +20 dbm */
+} __attribute__ ((packed)) ng_hci_inquiry_response_rssi;
#define NG_HCI_EVENT_CON_COMPL 0x03
typedef struct {
diff -ubswr usr/src/usr.sbin/bluetooth/hccontrol/hccontrol.c ng/usr/src/usr.sbin/bluetooth/hccontrol/hccontrol.c
--- usr/src/usr.sbin/bluetooth/hccontrol/hccontrol.c 2024-11-29 02:03:48.000000000 +0200
+++ ng/usr/src/usr.sbin/bluetooth/hccontrol/hccontrol.c 2025-06-03 08:59:38.000000000 +0300
@@ -138,6 +138,7 @@
bit_set(filter.event_mask, NG_HCI_EVENT_COMMAND_STATUS - 1);
bit_set(filter.event_mask, NG_HCI_EVENT_INQUIRY_COMPL - 1);
bit_set(filter.event_mask, NG_HCI_EVENT_INQUIRY_RESULT - 1);
+ bit_set(filter.event_mask, NG_HCI_EVENT_INQUIRY_RESULT_RSSI - 1);
bit_set(filter.event_mask, NG_HCI_EVENT_CON_COMPL - 1);
bit_set(filter.event_mask, NG_HCI_EVENT_DISCON_COMPL - 1);
bit_set(filter.event_mask, NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL - 1);
diff -ubswr usr/src/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c ng/usr/src/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c
--- usr/src/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c 2024-11-29 02:03:48.000000000 +0200
+++ ng/usr/src/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c 2025-06-02 22:01:56.000000000 +0300
@@ -1489,7 +1489,71 @@
return (OK);
} /* hci_write_page_scan_mode */
+
+/* Send Read_Inquiry_Mode command to the unit */
static int
+hci_read_inquiry_mode(int s, int argc, char **argv)
+{
+ ng_hci_read_inquiry_mode_rp rp;
+ int n;
+
+ n = sizeof(rp);
+ if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND,
+ NG_HCI_OCF_READ_INQUIRY_MODE),
+ (char *) &rp, &n) == ERROR)
+ return (ERROR);
+
+ if (rp.status != 0x00) {
+ fprintf(stdout, "Status: %s [%#02x]\n",
+ hci_status2str(rp.status), rp.status);
+ return (FAILED);
+ }
+
+ fprintf(stdout, "Inquiry mode: %#02x\n", rp.inquiry_mode);
+
+ return (OK);
+} /* hci_read_inquiry_mode */
+
+/* Send Write_Inquiry_Mode command to the unit */
+static int
+hci_write_inquiry_mode(int s, int argc, char **argv)
+{
+ ng_hci_write_inquiry_mode_cp cp;
+ ng_hci_write_inquiry_mode_rp rp;
+ int n;
+
+ /* parse command arguments */
+ switch (argc) {
+ case 1:
+ if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 3)
+ return (USAGE);
+
+ cp.inquiry_mode = (n & 0xff);
+ break;
+
+ default:
+ return (USAGE);
+ }
+
+ /* send command */
+ n = sizeof(rp);
+ if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND,
+ NG_HCI_OCF_WRITE_INQUIRY_MODE),
+ (char const *) &cp, sizeof(cp),
+ (char *) &rp, &n) == ERROR)
+ return (ERROR);
+
+ if (rp.status != 0x00) {
+ fprintf(stdout, "Status: %s [%#02x]\n",
+ hci_status2str(rp.status), rp.status);
+ return (FAILED);
+ }
+
+ return (OK);
+} /* hci_write_inquiry_mode */
+
+
+static int
hci_read_le_host_support(int s, int argc, char **argv)
{
ng_hci_read_le_host_supported_rp rp;
@@ -1945,6 +2009,22 @@
"\t0x02 - Optional Page Scan Mode II\n" \
"\t0x03 - Optional Page Scan Mode III",
&hci_write_page_scan_mode
+},
+{
+"read_inquiry_mode",
+"\nThis command is used to read the default inquiry mode of the local\n" \
+"0 = Std, 1 = With RSSI, 2 = Extended.",
+&hci_read_inquiry_mode
+},
+{
+"write_inquiry_mode <inquiry_mode>",
+"\nThis command is used to write the default inquiry mode of the local\n" \
+"Bluetooth device. \n"\
+"\t<page_scan_mode> - dd; inquiry mode:\n" \
+"\t0x00 - Standard\n" \
+"\t0x01 - With RSSI included\n" \
+"\t0x02 - Extended (EID)",
+&hci_write_inquiry_mode
},
{
"read_le_host_support", \
diff -ubswr usr/src/usr.sbin/bluetooth/hccontrol/link_control.c ng/usr/src/usr.sbin/bluetooth/hccontrol/link_control.c
--- usr/src/usr.sbin/bluetooth/hccontrol/link_control.c 2024-11-29 02:03:48.000000000 +0200
+++ ng/usr/src/usr.sbin/bluetooth/hccontrol/link_control.c 2025-06-03 10:35:38.000000000 +0300
@@ -38,6 +38,7 @@
#include "hccontrol.h"
static void hci_inquiry_response (int n, uint8_t **b);
+static void hci_inquiry_response_rssi (int n, uint8_t **b);
/* Send Inquiry command to the unit */
static int
@@ -114,7 +115,6 @@
errno = EIO;
return (ERROR);
}
-
switch (e->event) {
case NG_HCI_EVENT_INQUIRY_RESULT: {
ng_hci_inquiry_result_ep *ir =
@@ -129,7 +129,20 @@
goto wait_for_more;
}
+ case NG_HCI_EVENT_INQUIRY_RESULT_RSSI: {
+ ng_hci_inquiry_result_ep *ir =
+ (ng_hci_inquiry_result_ep *)(e + 1);
+ uint8_t *r = (uint8_t *)(ir + 1);
+ fprintf(stdout, "Inquiry result, num_responses=%d\n",
+ ir->num_responses);
+
+ for (n0 = 0; n0 < ir->num_responses; n0++)
+ hci_inquiry_response_rssi(n0, &r);
+
+ goto wait_for_more;
+ }
+
case NG_HCI_EVENT_INQUIRY_COMPL:
fprintf(stdout, "Inquiry complete. Status: %s [%#02x]\n",
hci_status2str(*(b + sizeof(*e))), *(b + sizeof(*e)));
@@ -165,6 +178,25 @@
*b += sizeof(*ir);
} /* hci_inquiry_response */
+
+/* Print Inquiry_Result_Rssi event */
+static void
+hci_inquiry_response_rssi(int n, uint8_t **b)
+{
+ ng_hci_inquiry_response_rssi *ir = (ng_hci_inquiry_response_rssi *)(*b);
+
+ fprintf(stdout, "Inquiry result #%d\n", n);
+ fprintf(stdout, "\tBD_ADDR: %s\n", hci_bdaddr2str(&ir->bdaddr));
+ fprintf(stdout, "\tPage Scan Rep. Mode: %#02x\n",
+ ir->page_scan_rep_mode);
+ fprintf(stdout, "\tClass: %02x:%02x:%02x\n",
+ ir->uclass[2], ir->uclass[1], ir->uclass[0]);
+ fprintf(stdout, "\tClock offset: %#04x\n",
+ le16toh(ir->clock_offset));
+ fprintf(stdout, "\tRssi: %d dBm\n",
+ le16toh(ir->rssi ));
+ *b += sizeof(*ir);
+} /* hci_inquiry_response_rssi */
/* Send Create_Connection command to the unit */
static int