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_Commands command to the unit */
77 hci_read_local_supported_commands(int s, int argc, char **argv)
79 ng_hci_read_local_commands_rp rp;
84 if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
85 NG_HCI_OCF_READ_LOCAL_COMMANDS),
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, "Supported commands:");
96 for (n = 0; n < sizeof(rp.features); n++) {
98 fprintf(stdout, "\n");
99 fprintf(stdout, "%#02x ", rp.features[n]);
101 fprintf(stdout, "\n%s\n", hci_commands2str(rp.features,
102 buffer, sizeof(buffer)));
105 } /* hci_read_local_supported_commands */
107 /* Send Read_Local_Supported_Features command to the unit */
109 hci_read_local_supported_features(int s, int argc, char **argv)
111 ng_hci_read_local_features_rp rp;
116 if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
117 NG_HCI_OCF_READ_LOCAL_FEATURES),
118 (char *) &rp, &n) == ERROR)
121 if (rp.status != 0x00) {
122 fprintf(stdout, "Status: %s [%#02x]\n",
123 hci_status2str(rp.status), rp.status);
127 fprintf(stdout, "Features: ");
128 for (n = 0; n < sizeof(rp.features); n++)
129 fprintf(stdout, "%#02x ", rp.features[n]);
130 fprintf(stdout, "\n%s\n", hci_features2str(rp.features,
131 buffer, sizeof(buffer)));
134 } /* hci_read_local_supported_features */
136 /* Sent Read_Buffer_Size command to the unit */
138 hci_read_buffer_size(int s, int argc, char **argv)
140 ng_hci_read_buffer_size_rp rp;
144 if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
145 NG_HCI_OCF_READ_BUFFER_SIZE),
146 (char *) &rp, &n) == ERROR)
149 if (rp.status != 0x00) {
150 fprintf(stdout, "Status: %s [%#02x]\n",
151 hci_status2str(rp.status), rp.status);
155 fprintf(stdout, "Max. ACL packet size: %d bytes\n",
156 le16toh(rp.max_acl_size));
157 fprintf(stdout, "Number of ACL packets: %d\n",
158 le16toh(rp.num_acl_pkt));
159 fprintf(stdout, "Max. SCO packet size: %d bytes\n",
161 fprintf(stdout, "Number of SCO packets: %d\n",
162 le16toh(rp.num_sco_pkt));
165 } /* hci_read_buffer_size */
167 /* Send Read_Country_Code command to the unit */
169 hci_read_country_code(int s, int argc, char **argv)
171 ng_hci_read_country_code_rp rp;
175 if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
176 NG_HCI_OCF_READ_COUNTRY_CODE),
177 (char *) &rp, &n) == ERROR)
180 if (rp.status != 0x00) {
181 fprintf(stdout, "Status: %s [%#02x]\n",
182 hci_status2str(rp.status), rp.status);
186 fprintf(stdout, "Country code: %s [%#02x]\n",
187 hci_cc2str(rp.country_code), rp.country_code);
190 } /* hci_read_country_code */
192 /* Send Read_BD_ADDR command to the unit */
194 hci_read_bd_addr(int s, int argc, char **argv)
196 ng_hci_read_bdaddr_rp rp;
200 if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO,
201 NG_HCI_OCF_READ_BDADDR), (char *) &rp, &n) == ERROR)
204 if (rp.status != 0x00) {
205 fprintf(stdout, "Status: %s [%#02x]\n",
206 hci_status2str(rp.status), rp.status);
210 fprintf(stdout, "BD_ADDR: %s\n", bt_ntoa(&rp.bdaddr, NULL));
213 } /* hci_read_bd_addr */
215 struct hci_command info_commands[] = {
217 "read_local_version_information",
218 "\nThis command will read the values for the version information for the\n" \
219 "local Bluetooth unit.",
220 &hci_read_local_version_information
223 "read_local_supported_commands",
224 "\nThis command will read the commands the local Bluetooth unit supports.\n",
225 &hci_read_local_supported_commands
228 "read_local_supported_features",
229 "\nThis command requests a list of the supported features for the local\n" \
230 "unit. This command will return a list of the LMP features.",
231 &hci_read_local_supported_features
235 "\nThe Read_Buffer_Size command is used to read the maximum size of the\n" \
236 "data portion of HCI ACL and SCO Data Packets sent from the Host to the\n" \
238 &hci_read_buffer_size
242 "\nThis command will read the value for the Country_Code return parameter.\n" \
243 "The Country_Code defines which range of frequency band of the ISM 2.4 GHz\n" \
244 "band will be used by the unit.",
245 &hci_read_country_code
249 "\nThis command will read the value for the BD_ADDR parameter. The BD_ADDR\n" \
250 "is a 48-bit unique identifier for a Bluetooth unit.",