Lines Matching +full:0 +full:- +full:n

1 /*-
4 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
40 static void hci_inquiry_response (int n, uint8_t **b);
52 cp.lap[2] = 0x9e; in hci_inquiry()
53 cp.lap[1] = 0x8b; in hci_inquiry()
54 cp.lap[0] = 0x33; in hci_inquiry()
61 /* number of responses, range 0x00 - 0xff */ in hci_inquiry()
62 if (sscanf(argv[2], "%d", &n0) != 1 || n0 < 0 || n0 > 0xff) in hci_inquiry()
65 cp.num_responses = (n0 & 0xff); in hci_inquiry()
68 /* inquiry length (N * 1.28) sec, range 0x01 - 0x30 */ in hci_inquiry()
69 if (sscanf(argv[1], "%d", &n0) != 1 || n0 < 0x1 || n0 > 0x30) in hci_inquiry()
72 cp.inquiry_length = (n0 & 0xff); in hci_inquiry()
76 if (sscanf(argv[0], "%x:%x:%x", &n2, &n1, &n0) != 3) in hci_inquiry()
79 cp.lap[0] = (n0 & 0xff); in hci_inquiry()
80 cp.lap[1] = (n1 & 0xff); in hci_inquiry()
81 cp.lap[2] = (n2 & 0xff); in hci_inquiry()
83 case 0: in hci_inquiry()
98 if (*b != 0x00) in hci_inquiry()
118 switch (e->event) { in hci_inquiry()
124 fprintf(stdout, "Inquiry result, num_responses=%d\n", in hci_inquiry()
125 ir->num_responses); in hci_inquiry()
127 for (n0 = 0; n0 < ir->num_responses; n0++) in hci_inquiry()
134 fprintf(stdout, "Inquiry complete. Status: %s [%#02x]\n", in hci_inquiry()
149 hci_inquiry_response(int n, uint8_t **b) in hci_inquiry_response() argument
153 fprintf(stdout, "Inquiry result #%d\n", n); in hci_inquiry_response()
154 fprintf(stdout, "\tBD_ADDR: %s\n", hci_bdaddr2str(&ir->bdaddr)); in hci_inquiry_response()
155 fprintf(stdout, "\tPage Scan Rep. Mode: %#02x\n", in hci_inquiry_response()
156 ir->page_scan_rep_mode); in hci_inquiry_response()
157 fprintf(stdout, "\tPage Scan Period Mode: %#02x\n", in hci_inquiry_response()
158 ir->page_scan_period_mode); in hci_inquiry_response()
159 fprintf(stdout, "\tPage Scan Mode: %#02x\n", in hci_inquiry_response()
160 ir->page_scan_mode); in hci_inquiry_response()
161 fprintf(stdout, "\tClass: %02x:%02x:%02x\n", in hci_inquiry_response()
162 ir->uclass[2], ir->uclass[1], ir->uclass[0]); in hci_inquiry_response()
163 fprintf(stdout, "\tClock offset: %#04x\n", in hci_inquiry_response()
164 le16toh(ir->clock_offset)); in hci_inquiry_response()
179 memset(&cp, 0, sizeof(cp)); in hci_create_connection()
185 cp.clock_offset = 0; in hci_create_connection()
195 cp.accept_role_switch = n0 ? 1 : 0; in hci_create_connection()
202 cp.clock_offset = (n0 & 0xffff); in hci_create_connection()
207 if (sscanf(argv[3], "%d", &n0) != 1 || n0 < 0 || n0 > 3) in hci_create_connection()
210 cp.page_scan_mode = (n0 & 0xff); in hci_create_connection()
214 if (sscanf(argv[2], "%d", &n0) != 1 || n0 < 0 || n0 > 2) in hci_create_connection()
217 cp.page_scan_rep_mode = (n0 & 0xff); in hci_create_connection()
227 if (n0 == 0) in hci_create_connection()
230 cp.pkt_type = (n0 & 0xffff); in hci_create_connection()
235 if (!bt_aton(argv[0], &cp.bdaddr)) { in hci_create_connection()
238 if ((he = bt_gethostbyname(argv[0])) == NULL) in hci_create_connection()
241 memcpy(&cp.bdaddr, he->h_addr, sizeof(cp.bdaddr)); in hci_create_connection()
256 if (*b != 0x00) in hci_create_connection()
269 if (e->event == NG_HCI_EVENT_CON_COMPL) { in hci_create_connection()
272 if (ep->status != 0x00) { in hci_create_connection()
273 fprintf(stdout, "Status: %s [%#02x]\n", in hci_create_connection()
274 hci_status2str(ep->status), ep->status); in hci_create_connection()
278 fprintf(stdout, "BD_ADDR: %s\n", hci_bdaddr2str(&ep->bdaddr)); in hci_create_connection()
279 fprintf(stdout, "Connection handle: %d\n", in hci_create_connection()
280 le16toh(ep->con_handle)); in hci_create_connection()
281 fprintf(stdout, "Encryption mode: %s [%d]\n", in hci_create_connection()
282 hci_encrypt2str(ep->encryption_mode, 0), in hci_create_connection()
283 ep->encryption_mode); in hci_create_connection()
294 int n; in hci_disconnect() local
300 memset(&cp, 0, sizeof(cp)); in hci_disconnect()
301 cp.reason = 0x13; in hci_disconnect()
307 if (sscanf(argv[1], "%d", &n) != 1 || n <= 0x00 || n > 0xff) in hci_disconnect()
310 cp.reason = (uint8_t) (n & 0xff); in hci_disconnect()
314 if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) in hci_disconnect()
317 cp.con_handle = (uint16_t) (n & 0x0fff); in hci_disconnect()
326 n = sizeof(b); in hci_disconnect()
329 (char const *) &cp, sizeof(cp), b, &n) == ERROR) in hci_disconnect()
332 if (*b != 0x00) in hci_disconnect()
337 n = sizeof(b); in hci_disconnect()
338 if (hci_recv(s, b, &n) == ERROR) in hci_disconnect()
340 if (n < sizeof(*e)) { in hci_disconnect()
345 if (e->event == NG_HCI_EVENT_DISCON_COMPL) { in hci_disconnect()
348 if (ep->status != 0x00) { in hci_disconnect()
349 fprintf(stdout, "Status: %s [%#02x]\n", in hci_disconnect()
350 hci_status2str(ep->status), ep->status); in hci_disconnect()
354 fprintf(stdout, "Connection handle: %d\n", in hci_disconnect()
355 le16toh(ep->con_handle)); in hci_disconnect()
356 fprintf(stdout, "Reason: %s [%#02x]\n", in hci_disconnect()
357 hci_status2str(ep->reason), ep->reason); in hci_disconnect()
368 int n; in hci_add_sco_connection() local
374 memset(&cp, 0, sizeof(cp)); in hci_add_sco_connection()
381 if (sscanf(argv[1], "%x", &n) != 1) in hci_add_sco_connection()
384 n &= (NG_HCI_PKT_HV1 | NG_HCI_PKT_HV2 | NG_HCI_PKT_HV3); in hci_add_sco_connection()
385 if (n == 0) in hci_add_sco_connection()
388 cp.pkt_type = (uint16_t) (n & 0x0fff); in hci_add_sco_connection()
393 if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) in hci_add_sco_connection()
396 cp.con_handle = (uint16_t) (n & 0x0fff); in hci_add_sco_connection()
405 n = sizeof(b); in hci_add_sco_connection()
408 (char const *) &cp, sizeof(cp), b, &n) == ERROR) in hci_add_sco_connection()
411 if (*b != 0x00) in hci_add_sco_connection()
416 n = sizeof(b); in hci_add_sco_connection()
417 if (hci_recv(s, b, &n) == ERROR) in hci_add_sco_connection()
419 if (n < sizeof(*e)) { in hci_add_sco_connection()
424 if (e->event == NG_HCI_EVENT_CON_COMPL) { in hci_add_sco_connection()
427 if (ep->status != 0x00) { in hci_add_sco_connection()
428 fprintf(stdout, "Status: %s [%#02x]\n", in hci_add_sco_connection()
429 hci_status2str(ep->status), ep->status); in hci_add_sco_connection()
433 fprintf(stdout, "BD_ADDR: %s\n", hci_bdaddr2str(&ep->bdaddr)); in hci_add_sco_connection()
434 fprintf(stdout, "Connection handle: %d\n", in hci_add_sco_connection()
435 le16toh(ep->con_handle)); in hci_add_sco_connection()
436 fprintf(stdout, "Encryption mode: %s [%d]\n", in hci_add_sco_connection()
437 hci_encrypt2str(ep->encryption_mode, 0), in hci_add_sco_connection()
438 ep->encryption_mode); in hci_add_sco_connection()
449 int n; in hci_change_connection_packet_type() local
457 if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) in hci_change_connection_packet_type()
460 cp.con_handle = (uint16_t) (n & 0x0fff); in hci_change_connection_packet_type()
464 if (sscanf(argv[1], "%x", &n) != 1) in hci_change_connection_packet_type()
467 cp.pkt_type = (uint16_t) (n & 0xffff); in hci_change_connection_packet_type()
476 n = sizeof(b); in hci_change_connection_packet_type()
479 (char const *) &cp, sizeof(cp), b, &n) == ERROR) in hci_change_connection_packet_type()
482 if (*b != 0x00) in hci_change_connection_packet_type()
487 n = sizeof(b); in hci_change_connection_packet_type()
488 if (hci_recv(s, b, &n) == ERROR) in hci_change_connection_packet_type()
490 if (n < sizeof(*e)) { in hci_change_connection_packet_type()
495 if (e->event == NG_HCI_EVENT_CON_PKT_TYPE_CHANGED) { in hci_change_connection_packet_type()
499 if (ep->status != 0x00) { in hci_change_connection_packet_type()
500 fprintf(stdout, "Status: %s [%#02x]\n", in hci_change_connection_packet_type()
501 hci_status2str(ep->status), ep->status); in hci_change_connection_packet_type()
505 fprintf(stdout, "Connection handle: %d\n", in hci_change_connection_packet_type()
506 le16toh(ep->con_handle)); in hci_change_connection_packet_type()
507 fprintf(stdout, "Packet type: %#04x\n", in hci_change_connection_packet_type()
508 le16toh(ep->pkt_type)); in hci_change_connection_packet_type()
524 memset(&cp, 0, sizeof(cp)); in hci_remote_name_request()
535 cp.clock_offset = (n0 & 0xffff); in hci_remote_name_request()
540 if (sscanf(argv[2], "%d", &n0) != 1 || n0 < 0x00 || n0 > 0x03) in hci_remote_name_request()
543 cp.page_scan_mode = (n0 & 0xff); in hci_remote_name_request()
547 if (sscanf(argv[1], "%d", &n0) != 1 || n0 < 0x00 || n0 > 0x02) in hci_remote_name_request()
550 cp.page_scan_rep_mode = (n0 & 0xff); in hci_remote_name_request()
554 if (!bt_aton(argv[0], &cp.bdaddr)) { in hci_remote_name_request()
557 if ((he = bt_gethostbyname(argv[0])) == NULL) in hci_remote_name_request()
560 memcpy(&cp.bdaddr, he->h_addr, sizeof(cp.bdaddr)); in hci_remote_name_request()
575 if (*b != 0x00) in hci_remote_name_request()
588 if (e->event == NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL) { in hci_remote_name_request()
592 if (ep->status != 0x00) { in hci_remote_name_request()
593 fprintf(stdout, "Status: %s [%#02x]\n", in hci_remote_name_request()
594 hci_status2str(ep->status), ep->status); in hci_remote_name_request()
598 fprintf(stdout, "BD_ADDR: %s\n", hci_bdaddr2str(&ep->bdaddr)); in hci_remote_name_request()
599 fprintf(stdout, "Name: %s\n", ep->name); in hci_remote_name_request()
610 int n; in hci_read_remote_supported_features() local
620 if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 0x0eff) in hci_read_remote_supported_features()
623 cp.con_handle = (n & 0x0fff); in hci_read_remote_supported_features()
632 n = sizeof(b); in hci_read_remote_supported_features()
635 (char const *) &cp, sizeof(cp), b, &n) == ERROR) in hci_read_remote_supported_features()
638 if (*b != 0x00) in hci_read_remote_supported_features()
643 n = sizeof(b); in hci_read_remote_supported_features()
644 if (hci_recv(s, b, &n) == ERROR) in hci_read_remote_supported_features()
647 if (n < sizeof(*e)) { in hci_read_remote_supported_features()
652 if (e->event == NG_HCI_EVENT_READ_REMOTE_FEATURES_COMPL) { in hci_read_remote_supported_features()
656 if (ep->status != 0x00) { in hci_read_remote_supported_features()
657 fprintf(stdout, "Status: %s [%#02x]\n", in hci_read_remote_supported_features()
658 hci_status2str(ep->status), ep->status); in hci_read_remote_supported_features()
662 fprintf(stdout, "Connection handle: %d\n", in hci_read_remote_supported_features()
663 le16toh(ep->con_handle)); in hci_read_remote_supported_features()
665 for (n = 0; n < sizeof(ep->features); n++) in hci_read_remote_supported_features()
666 fprintf(stdout, "%#02x ", ep->features[n]); in hci_read_remote_supported_features()
667 fprintf(stdout, "\n%s\n", hci_features2str(ep->features, in hci_read_remote_supported_features()
679 int n; in hci_read_remote_version_information() local
688 if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 0x0eff) in hci_read_remote_version_information()
691 cp.con_handle = (n & 0x0fff); in hci_read_remote_version_information()
700 n = sizeof(b); in hci_read_remote_version_information()
703 (char const *) &cp, sizeof(cp), b, &n) == ERROR) in hci_read_remote_version_information()
706 if (*b != 0x00) in hci_read_remote_version_information()
711 n = sizeof(b); in hci_read_remote_version_information()
712 if (hci_recv(s, b, &n) == ERROR) in hci_read_remote_version_information()
715 if (n < sizeof(*e)) { in hci_read_remote_version_information()
720 if (e->event == NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL) { in hci_read_remote_version_information()
724 if (ep->status != 0x00) { in hci_read_remote_version_information()
725 fprintf(stdout, "Status: %s [%#02x]\n", in hci_read_remote_version_information()
726 hci_status2str(ep->status), ep->status); in hci_read_remote_version_information()
730 ep->manufacturer = le16toh(ep->manufacturer); in hci_read_remote_version_information()
732 fprintf(stdout, "Connection handle: %d\n", in hci_read_remote_version_information()
733 le16toh(ep->con_handle)); in hci_read_remote_version_information()
734 fprintf(stdout, "LMP version: %s [%#02x]\n", in hci_read_remote_version_information()
735 hci_lmpver2str(ep->lmp_version), ep->lmp_version); in hci_read_remote_version_information()
736 fprintf(stdout, "LMP sub-version: %#04x\n", in hci_read_remote_version_information()
737 le16toh(ep->lmp_subversion)); in hci_read_remote_version_information()
738 fprintf(stdout, "Manufacturer: %s [%#04x]\n", in hci_read_remote_version_information()
739 hci_manufacturer2str(ep->manufacturer), in hci_read_remote_version_information()
740 ep->manufacturer); in hci_read_remote_version_information()
751 int n; in hci_read_clock_offset() local
760 if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 0x0eff) in hci_read_clock_offset()
763 cp.con_handle = (n & 0x0fff); in hci_read_clock_offset()
772 n = sizeof(b); in hci_read_clock_offset()
775 (char const *) &cp, sizeof(cp), b, &n) == ERROR) in hci_read_clock_offset()
778 if (*b != 0x00) in hci_read_clock_offset()
783 n = sizeof(b); in hci_read_clock_offset()
784 if (hci_recv(s, b, &n) == ERROR) in hci_read_clock_offset()
787 if (n < sizeof(*e)) { in hci_read_clock_offset()
792 if (e->event == NG_HCI_EVENT_READ_CLOCK_OFFSET_COMPL) { in hci_read_clock_offset()
796 if (ep->status != 0x00) { in hci_read_clock_offset()
797 fprintf(stdout, "Status: %s [%#02x]\n", in hci_read_clock_offset()
798 hci_status2str(ep->status), ep->status); in hci_read_clock_offset()
802 fprintf(stdout, "Connection handle: %d\n", in hci_read_clock_offset()
803 le16toh(ep->con_handle)); in hci_read_clock_offset()
804 fprintf(stdout, "Clock offset: %#04x\n", in hci_read_clock_offset()
805 le16toh(ep->clock_offset)); in hci_read_clock_offset()
815 "\nThis command will cause the Bluetooth unit to enter Inquiry Mode.\n" \
816 "Inquiry Mode is used to discover other nearby Bluetooth units. The LAP\n" \
817 "input parameter contains the LAP from which the inquiry access code shall\n" \
818 "be derived when the inquiry procedure is made. The Inquiry_Length parameter\n"\
819 "specifies the total duration of the Inquiry Mode and, when this time\n" \
820 "expires, Inquiry will be halted. The Num_Responses parameter specifies the\n" \
821 "number of responses that can be received before the Inquiry is halted.\n\n" \
822 "\t<LAP> - xx:xx:xx; 9e:8b:33 (GIAC), 93:8b:00 (LDIAC)\n" \
823 "\t<inquiry_length> - dd; total length == dd * 1.28 sec\n" \
824 "\t<num_responses> - dd",
830 "\t<BD_ADDR> - xx:xx:xx:xx:xx:xx BD_ADDR or name\n\n" \
831 "\t<pkt> - xxxx; packet type\n" \
833 "\t\tACL packets\n" \
834 "\t\t-----------\n" \
835 "\t\t0x0008 DM1\n" \
836 "\t\t0x0010 DH1\n" \
837 "\t\t0x0400 DM3\n" \
838 "\t\t0x0800 DH3\n" \
839 "\t\t0x4000 DM5\n" \
840 "\t\t0x8000 DH5\n\n" \
842 "\trep_mode - d; page scan repetition mode\n" \
844 "\t\tPage scan repetition modes\n" \
845 "\t\t--------------------------\n" \
846 "\t\t0 Page scan repetition mode 0\n" \
847 "\t\t1 Page scan repetition mode 1\n" \
848 "\t\t2 Page scan repetition mode 2\n" \
849 "\n" \
850 "\tps_mode - d; Page scan mode\n" \
852 "\t\tPage scan modes\n" \
853 "\t\t---------------\n" \
854 "\t\t0 Mandatory page scan mode\n" \
855 "\t\t1 Optional page scan mode1\n" \
856 "\t\t2 Optional page scan mode2\n" \
857 "\t\t3 Optional page scan mode3\n" \
858 "\n" \
859 "\tclck_off - dddd; clock offset. Use 0 if unknown\n\n" \
860 "\trole_sw - d; allow (1) or deny role switch\n",
865 "\nThe Disconnection command is used to terminate an existing connection.\n" \
866 "The connection handle command parameter indicates which connection is to\n" \
867 "be disconnected. The Reason command parameter indicates the reason for\n" \
868 "ending the connection.\n\n" \
869 "\t<connection_handle> - dddd; connection handle\n" \
870 "\t<reason> - dd; reason; usually 19 (0x13) - user ended;\n" \
871 "\t also 0x05, 0x13-0x15, 0x1A, 0x29",
876 "This command will cause the link manager to create a SCO connection using\n" \
877 "the ACL connection specified by the connection handle command parameter.\n" \
878 "The Link Manager will determine how the new connection is established. This\n"\
879 "connection is determined by the current state of the device, its piconet,\n" \
880 "and the state of the device to be connected. The packet type command parameter\n" \
881 "specifies which packet types the Link Manager should use for the connection.\n"\
882 "The Link Manager must only use the packet type(s) specified by the packet\n" \
883 "type command parameter for sending HCI SCO data packets. Multiple packet\n" \
884 "types may be specified for the packet type command parameter by performing\n" \
885 "a bitwise OR operation of the different packet types. Note: An SCO connection\n" \
886 "can only be created when an ACL connection already exists and when it is\n" \
887 "not put in park mode.\n\n" \
888 "\t<connection_handle> - dddd; ACL connection handle\n" \
889 "\t<packet_type> - xxxx; packet type\n" \
891 "\t\tSCO packets\n" \
892 "\t\t-----------\n" \
893 "\t\t0x0020 HV1\n" \
894 "\t\t0x0040 HV2\n" \
895 "\t\t0x0080 HV3\n",
900 "The Change_Connection_Packet_Type command is used to change which packet\n" \
901 "types can be used for a connection that is currently established. This\n" \
902 "allows current connections to be dynamically modified to support different\n" \
903 "types of user data. The Packet_Type command parameter specifies which\n" \
904 "packet types the Link Manager can use for the connection. Multiple packet\n" \
905 "types may be specified for the Packet_Type command parameter by bitwise OR\n" \
906 "operation of the different packet types.\n\n" \
907 "\t<connection_handle> - dddd; connection handle\n" \
908 "\t<packet_type> - xxxx; packet type mask\n" \
910 "\t\tACL packets\n" \
911 "\t\t-----------\n" \
912 "\t\t0x0008 DM1\n" \
913 "\t\t0x0010 DH1\n" \
914 "\t\t0x0400 DM3\n" \
915 "\t\t0x0800 DH3\n" \
916 "\t\t0x4000 DM5\n" \
917 "\t\t0x8000 DH5\n\n" \
919 "\t\tSCO packets\n" \
920 "\t\t-----------\n" \
921 "\t\t0x0020 HV1\n" \
922 "\t\t0x0040 HV2\n" \
923 "\t\t0x0080 HV3\n" \
929 "\nThe Remote_Name_Request command is used to obtain the user-friendly\n" \
930 "name of another Bluetooth unit.\n\n" \
931 "\t<BD_ADDR> - xx:xx:xx:xx:xx:xx BD_ADDR or name\n" \
932 "\t<ps_rep_mode> - dd; page scan repetition mode [0-2]\n" \
933 "\t<ps_mode> - dd; page scan mode [0-3]\n" \
934 "\t<clock_offset> - xxxx; clock offset [0 - 0xffff]",
939 "\nThis command requests a list of the supported features for the remote\n" \
940 "unit identified by the connection handle parameter. The connection handle\n" \
941 "must be a connection handle for an ACL connection.\n\n" \
942 "\t<connection_handle> - dddd; connection handle",
947 "\nThis command will obtain the values for the version information for the\n" \
948 "remote Bluetooth unit identified by the connection handle parameter. The\n" \
949 "connection handle must be a connection handle for an ACL connection.\n\n" \
950 "\t<connection_handle> - dddd; connection handle",
955 "\nThis command allows the Host to read the clock offset from the remote unit.\n" \
956 "\t<connection_handle> - dddd; connection handle",