4 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
6 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * $Id: info.c,v 1.3 2003/08/18 19:19:54 max Exp $
34 #define L2CAP_SOCKET_CHECKED
35 #include <bluetooth.h>
39 #include "hccontrol.h"
41 /* Send Read_Local_Version_Information command to the unit */
43 hci_read_local_version_information(int s, int argc, char **argv)
45 ng_hci_read_local_ver_rp rp;
49 if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
50 NG_HCI_OCF_READ_LOCAL_VER), (char *) &rp, &n) == ERROR)
53 if (rp.status != 0x00) {
54 fprintf(stdout, "Status: %s [%#02x]\n",
55 hci_status2str(rp.status), rp.status);
59 rp.manufacturer = le16toh(rp.manufacturer);
61 fprintf(stdout, "HCI version: %s [%#02x]\n",
62 hci_ver2str(rp.hci_version), rp.hci_version);
63 fprintf(stdout, "HCI revision: %#04x\n",
64 le16toh(rp.hci_revision));
65 fprintf(stdout, "LMP version: %s [%#02x]\n",
66 hci_lmpver2str(rp.lmp_version), rp.lmp_version);
67 fprintf(stdout, "LMP sub-version: %#04x\n",
68 le16toh(rp.lmp_subversion));
69 fprintf(stdout, "Manufacturer: %s [%#04x]\n",
70 hci_manufacturer2str(rp.manufacturer), rp.manufacturer);
73 } /* hci_read_local_version_information */
75 /* Send Read_Local_Supported_Features command to the unit */
77 hci_read_local_supported_features(int s, int argc, char **argv)
79 ng_hci_read_local_features_rp rp;
84 if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
85 NG_HCI_OCF_READ_LOCAL_FEATURES),
86 (char *) &rp, &n) == ERROR)
89 if (rp.status != 0x00) {
90 fprintf(stdout, "Status: %s [%#02x]\n",
91 hci_status2str(rp.status), rp.status);
95 fprintf(stdout, "Features: ");
96 for (n = 0; n < sizeof(rp.features); n++)
97 fprintf(stdout, "%#02x ", rp.features[n]);
98 fprintf(stdout, "\n%s\n", hci_features2str(rp.features,
99 buffer, sizeof(buffer)));
102 } /* hci_read_local_supported_features */
104 /* Sent Read_Buffer_Size command to the unit */
106 hci_read_buffer_size(int s, int argc, char **argv)
108 ng_hci_read_buffer_size_rp rp;
112 if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
113 NG_HCI_OCF_READ_BUFFER_SIZE),
114 (char *) &rp, &n) == ERROR)
117 if (rp.status != 0x00) {
118 fprintf(stdout, "Status: %s [%#02x]\n",
119 hci_status2str(rp.status), rp.status);
123 fprintf(stdout, "Max. ACL packet size: %d bytes\n",
124 le16toh(rp.max_acl_size));
125 fprintf(stdout, "Number of ACL packets: %d\n",
126 le16toh(rp.num_acl_pkt));
127 fprintf(stdout, "Max. SCO packet size: %d bytes\n",
129 fprintf(stdout, "Number of SCO packets: %d\n",
130 le16toh(rp.num_sco_pkt));
133 } /* hci_read_buffer_size */
135 /* Send Read_Country_Code command to the unit */
137 hci_read_country_code(int s, int argc, char **argv)
139 ng_hci_read_country_code_rp rp;
143 if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
144 NG_HCI_OCF_READ_COUNTRY_CODE),
145 (char *) &rp, &n) == ERROR)
148 if (rp.status != 0x00) {
149 fprintf(stdout, "Status: %s [%#02x]\n",
150 hci_status2str(rp.status), rp.status);
154 fprintf(stdout, "Country code: %s [%#02x]\n",
155 hci_cc2str(rp.country_code), rp.country_code);
158 } /* hci_read_country_code */
160 /* Send Read_BD_ADDR command to the unit */
162 hci_read_bd_addr(int s, int argc, char **argv)
164 ng_hci_read_bdaddr_rp rp;
168 if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
169 NG_HCI_OCF_READ_BDADDR), (char *) &rp, &n) == ERROR)
172 if (rp.status != 0x00) {
173 fprintf(stdout, "Status: %s [%#02x]\n",
174 hci_status2str(rp.status), rp.status);
178 fprintf(stdout, "BD_ADDR: %s\n", bt_ntoa(&rp.bdaddr, NULL));
181 } /* hci_read_bd_addr */
183 struct hci_command info_commands[] = {
185 "read_local_version_information",
186 "\nThis command will read the values for the version information for the\n" \
187 "local Bluetooth unit.",
188 &hci_read_local_version_information
191 "read_local_supported_features",
192 "\nThis command requests a list of the supported features for the local\n" \
193 "unit. This command will return a list of the LMP features.",
194 &hci_read_local_supported_features
198 "\nThe Read_Buffer_Size command is used to read the maximum size of the\n" \
199 "data portion of HCI ACL and SCO Data Packets sent from the Host to the\n" \
201 &hci_read_buffer_size
205 "\nThis command will read the value for the Country_Code return parameter.\n" \
206 "The Country_Code defines which range of frequency band of the ISM 2.4 GHz\n" \
207 "band will be used by the unit.",
208 &hci_read_country_code
212 "\nThis command will read the value for the BD_ADDR parameter. The BD_ADDR\n" \
213 "is a 48-bit unique identifier for a Bluetooth unit.",