hci.c (3b65523c3989646481988e81495e76f9d69d7501) | hci.c (5d23aae8c99ae76ea4cbc60923752604dceb7324) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 1459 unchanged lines hidden (view full) --- 1468 } 1469 hci_send_cmd_packet(packet, HCI_CMD_HEADER_SIZE + 1 + EXTENDED_INQUIRY_RESPONSE_DATA_LEN); 1470 break; 1471 } 1472 case HCI_INIT_WRITE_INQUIRY_MODE: 1473 hci_stack->substate = HCI_INIT_W4_WRITE_INQUIRY_MODE; 1474 hci_send_cmd(&hci_write_inquiry_mode, (int) hci_stack->inquiry_mode); 1475 break; | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 1459 unchanged lines hidden (view full) --- 1468 } 1469 hci_send_cmd_packet(packet, HCI_CMD_HEADER_SIZE + 1 + EXTENDED_INQUIRY_RESPONSE_DATA_LEN); 1470 break; 1471 } 1472 case HCI_INIT_WRITE_INQUIRY_MODE: 1473 hci_stack->substate = HCI_INIT_W4_WRITE_INQUIRY_MODE; 1474 hci_send_cmd(&hci_write_inquiry_mode, (int) hci_stack->inquiry_mode); 1475 break; |
1476 case HCI_INIT_WRITE_SECURE_CONNECTIONS_HOST_ENABLE: 1477 hci_send_cmd(&hci_write_secure_connections_host_support, 1); 1478 hci_stack->substate = HCI_INIT_W4_WRITE_SECURE_CONNECTIONS_HOST_ENABLE; 1479 break; |
|
1476 case HCI_INIT_WRITE_SCAN_ENABLE: 1477 hci_send_cmd(&hci_write_scan_enable, (hci_stack->connectable << 1) | hci_stack->discoverable); // page scan 1478 hci_stack->substate = HCI_INIT_W4_WRITE_SCAN_ENABLE; 1479 break; 1480 // only sent if ENABLE_SCO_OVER_HCI is defined 1481 case HCI_INIT_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE: 1482 hci_stack->substate = HCI_INIT_W4_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE; 1483 hci_send_cmd(&hci_write_synchronous_flow_control_enable, 1); // SCO tracking enabled --- 317 unchanged lines hidden (view full) --- 1801 hci_stack->substate = HCI_INIT_READ_WHITE_LIST_SIZE; 1802#else 1803 hci_init_done(); 1804#endif 1805 return; 1806#endif /* ENABLE_LE_DATA_LENGTH_EXTENSION */ 1807 1808#endif /* ENABLE_BLE */ | 1480 case HCI_INIT_WRITE_SCAN_ENABLE: 1481 hci_send_cmd(&hci_write_scan_enable, (hci_stack->connectable << 1) | hci_stack->discoverable); // page scan 1482 hci_stack->substate = HCI_INIT_W4_WRITE_SCAN_ENABLE; 1483 break; 1484 // only sent if ENABLE_SCO_OVER_HCI is defined 1485 case HCI_INIT_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE: 1486 hci_stack->substate = HCI_INIT_W4_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE; 1487 hci_send_cmd(&hci_write_synchronous_flow_control_enable, 1); // SCO tracking enabled --- 317 unchanged lines hidden (view full) --- 1805 hci_stack->substate = HCI_INIT_READ_WHITE_LIST_SIZE; 1806#else 1807 hci_init_done(); 1808#endif 1809 return; 1810#endif /* ENABLE_LE_DATA_LENGTH_EXTENSION */ 1811 1812#endif /* ENABLE_BLE */ |
1809 | 1813 1814 case HCI_INIT_W4_WRITE_INQUIRY_MODE: 1815 // skip write secure connections host support if not supported or disabled 1816 if (hci_stack->secure_connections_enable && hci_stack->local_supported_commands[1] & 0x02) { 1817 hci_stack->substate = HCI_INIT_WRITE_SCAN_ENABLE; 1818 return; 1819 } 1820 break; 1821 |
1810#ifdef ENABLE_SCO_OVER_HCI 1811 case HCI_INIT_W4_WRITE_SCAN_ENABLE: 1812 // skip write synchronous flow control if not supported 1813 if (hci_stack->local_supported_commands[0] & 0x04) break; 1814 hci_stack->substate = HCI_INIT_W4_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE; 1815 1816 /* fall through */ 1817 --- 234 unchanged lines hidden (view full) --- 2052 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+24] & 0x40) >> 5) | // bit 1 = Octet 24, bit 6 / Write Le Host Supported 2053 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+10] & 0x10) >> 2) | // bit 2 = Octet 10, bit 4 / Write Synchronous Flow Control Enable 2054 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+18] & 0x08) ) | // bit 3 = Octet 18, bit 3 / Write Default Erroneous Data Reporting 2055 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+34] & 0x01) << 4) | // bit 4 = Octet 34, bit 0 / LE Write Suggested Default Data Length 2056 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+35] & 0x08) << 2) | // bit 5 = Octet 35, bit 3 / LE Read Maximum Data Length 2057 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+35] & 0x20) << 1) | // bit 6 = Octet 35, bit 5 / LE Set Default PHY 2058 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+20] & 0x10) << 3); // bit 7 = Octet 20, bit 4 / Read Encryption Key Size 2059 hci_stack->local_supported_commands[1] = | 1822#ifdef ENABLE_SCO_OVER_HCI 1823 case HCI_INIT_W4_WRITE_SCAN_ENABLE: 1824 // skip write synchronous flow control if not supported 1825 if (hci_stack->local_supported_commands[0] & 0x04) break; 1826 hci_stack->substate = HCI_INIT_W4_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE; 1827 1828 /* fall through */ 1829 --- 234 unchanged lines hidden (view full) --- 2064 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+24] & 0x40) >> 5) | // bit 1 = Octet 24, bit 6 / Write Le Host Supported 2065 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+10] & 0x10) >> 2) | // bit 2 = Octet 10, bit 4 / Write Synchronous Flow Control Enable 2066 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+18] & 0x08) ) | // bit 3 = Octet 18, bit 3 / Write Default Erroneous Data Reporting 2067 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+34] & 0x01) << 4) | // bit 4 = Octet 34, bit 0 / LE Write Suggested Default Data Length 2068 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+35] & 0x08) << 2) | // bit 5 = Octet 35, bit 3 / LE Read Maximum Data Length 2069 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+35] & 0x20) << 1) | // bit 6 = Octet 35, bit 5 / LE Set Default PHY 2070 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+20] & 0x10) << 3); // bit 7 = Octet 20, bit 4 / Read Encryption Key Size 2071 hci_stack->local_supported_commands[1] = |
2060 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+ 2] & 0x40) >> 6); // bit 8 = Octet 2, bit 6 / Read Remote Extended Features | 2072 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+ 2] & 0x40) >> 6) | // bit 8 = Octet 2, bit 6 / Read Remote Extended Features 2073 ((packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1+32] & 0x08) >> 2); // bit 9 = Octet 32, bit 3 / Write Secure Connections Host |
2061 log_info("Local supported commands summary %02x - %02x", hci_stack->local_supported_commands[0], hci_stack->local_supported_commands[1]); 2062 } 2063#ifdef ENABLE_CLASSIC 2064 else if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_write_synchronous_flow_control_enable)){ 2065 if (packet[5] == 0){ 2066 hci_stack->synchronous_flow_control_enabled = 1; 2067 } 2068 } --- 827 unchanged lines hidden (view full) --- 2896#endif 2897 2898 // Secure Simple Pairing default: enable, no I/O capabilities, general bonding, mitm not required, auto accept 2899 hci_stack->ssp_enable = 1; 2900 hci_stack->ssp_io_capability = SSP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT; 2901 hci_stack->ssp_authentication_requirement = SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_GENERAL_BONDING; 2902 hci_stack->ssp_auto_accept = 1; 2903 | 2074 log_info("Local supported commands summary %02x - %02x", hci_stack->local_supported_commands[0], hci_stack->local_supported_commands[1]); 2075 } 2076#ifdef ENABLE_CLASSIC 2077 else if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_write_synchronous_flow_control_enable)){ 2078 if (packet[5] == 0){ 2079 hci_stack->synchronous_flow_control_enabled = 1; 2080 } 2081 } --- 827 unchanged lines hidden (view full) --- 2909#endif 2910 2911 // Secure Simple Pairing default: enable, no I/O capabilities, general bonding, mitm not required, auto accept 2912 hci_stack->ssp_enable = 1; 2913 hci_stack->ssp_io_capability = SSP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT; 2914 hci_stack->ssp_authentication_requirement = SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_GENERAL_BONDING; 2915 hci_stack->ssp_auto_accept = 1; 2916 |
2917 // Secure Connections: enable (requires support from Controller) 2918 hci_stack->secure_connections_enable = true; 2919 |
|
2904 // voice setting - signed 16 bit pcm data with CVSD over the air 2905 hci_stack->sco_voice_setting = 0x60; 2906 2907#ifdef ENABLE_LE_CENTRAL 2908 // connection parameter to use for outgoing connections 2909 hci_stack->le_connection_scan_interval = 0x0060; // 60ms 2910 hci_stack->le_connection_scan_window = 0x0030; // 30ms 2911 hci_stack->le_connection_interval_min = 0x0008; // 10 ms --- 1279 unchanged lines hidden (view full) --- 4191void gap_ssp_set_authentication_requirement(int authentication_requirement){ 4192 hci_stack->ssp_authentication_requirement = authentication_requirement; 4193} 4194 4195// if set, BTstack will confirm a numberic comparion and enter '000000' if requested 4196void gap_ssp_set_auto_accept(int auto_accept){ 4197 hci_stack->ssp_auto_accept = auto_accept; 4198} | 2920 // voice setting - signed 16 bit pcm data with CVSD over the air 2921 hci_stack->sco_voice_setting = 0x60; 2922 2923#ifdef ENABLE_LE_CENTRAL 2924 // connection parameter to use for outgoing connections 2925 hci_stack->le_connection_scan_interval = 0x0060; // 60ms 2926 hci_stack->le_connection_scan_window = 0x0030; // 30ms 2927 hci_stack->le_connection_interval_min = 0x0008; // 10 ms --- 1279 unchanged lines hidden (view full) --- 4207void gap_ssp_set_authentication_requirement(int authentication_requirement){ 4208 hci_stack->ssp_authentication_requirement = authentication_requirement; 4209} 4210 4211// if set, BTstack will confirm a numberic comparion and enter '000000' if requested 4212void gap_ssp_set_auto_accept(int auto_accept){ 4213 hci_stack->ssp_auto_accept = auto_accept; 4214} |
4215 4216void gap_secure_connections_enable(bool enable){ 4217 hci_stack->secure_connections_enable = enable; 4218} 4219 |
|
4199#endif 4200 4201// va_list part of hci_send_cmd 4202int hci_send_cmd_va_arg(const hci_cmd_t *cmd, va_list argptr){ 4203 if (!hci_can_send_command_packet_now()){ 4204 log_error("hci_send_cmd called but cannot send packet now"); 4205 return 0; 4206 } --- 1307 unchanged lines hidden --- | 4220#endif 4221 4222// va_list part of hci_send_cmd 4223int hci_send_cmd_va_arg(const hci_cmd_t *cmd, va_list argptr){ 4224 if (!hci_can_send_command_packet_now()){ 4225 log_error("hci_send_cmd called but cannot send packet now"); 4226 return 0; 4227 } --- 1307 unchanged lines hidden --- |