hci.c (c950c316786414974bee11c1e31d226762dc219d) | hci.c (59d59ecfa4121af665436066144b11a47ef5a52a) |
---|---|
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 --- 1214 unchanged lines hidden (view full) --- 1223 hci_stack->le_advertisements_enabled_for_current_roles = num_slave_connections < hci_stack->le_max_number_peripheral_connections; 1224 } else { 1225 hci_stack->le_advertisements_enabled_for_current_roles = false; 1226 } 1227} 1228#endif 1229#endif 1230 | 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 --- 1214 unchanged lines hidden (view full) --- 1223 hci_stack->le_advertisements_enabled_for_current_roles = num_slave_connections < hci_stack->le_max_number_peripheral_connections; 1224 } else { 1225 hci_stack->le_advertisements_enabled_for_current_roles = false; 1226 } 1227} 1228#endif 1229#endif 1230 |
1231#ifdef ENABLE_CLASSIC 1232static void gap_run_set_local_name(void){ 1233 hci_reserve_packet_buffer(); 1234 uint8_t * packet = hci_stack->hci_packet_buffer; 1235 // construct HCI Command and send 1236 uint16_t opcode = hci_write_local_name.opcode; 1237 hci_stack->last_cmd_opcode = opcode; 1238 packet[0] = opcode & 0xff; 1239 packet[1] = opcode >> 8; 1240 packet[2] = DEVICE_NAME_LEN; 1241 memset(&packet[3], 0, DEVICE_NAME_LEN); 1242 uint16_t name_len = (uint16_t) strlen(hci_stack->local_name); 1243 uint16_t bytes_to_copy = btstack_min(name_len, DEVICE_NAME_LEN); 1244 // if shorter than DEVICE_NAME_LEN, it's implicitly NULL-terminated by memset call 1245 (void)memcpy(&packet[3], hci_stack->local_name, bytes_to_copy); 1246 // expand '00:00:00:00:00:00' in name with bd_addr 1247 btstack_replace_bd_addr_placeholder(&packet[3], bytes_to_copy, hci_stack->local_bd_addr); 1248 hci_send_cmd_packet(packet, HCI_CMD_HEADER_SIZE + DEVICE_NAME_LEN); 1249} 1250 1251static void gap_run_set_eir_data(void){ 1252 hci_reserve_packet_buffer(); 1253 uint8_t * packet = hci_stack->hci_packet_buffer; 1254 // construct HCI Command in-place and send 1255 uint16_t opcode = hci_write_extended_inquiry_response.opcode; 1256 hci_stack->last_cmd_opcode = opcode; 1257 uint16_t offset = 0; 1258 packet[offset++] = opcode & 0xff; 1259 packet[offset++] = opcode >> 8; 1260 packet[offset++] = 1 + EXTENDED_INQUIRY_RESPONSE_DATA_LEN; 1261 packet[offset++] = 0; // FEC not required 1262 memset(&packet[offset], 0, EXTENDED_INQUIRY_RESPONSE_DATA_LEN); 1263 if (hci_stack->eir_data){ 1264 // copy items and expand '00:00:00:00:00:00' in name with bd_addr 1265 ad_context_t context; 1266 for (ad_iterator_init(&context, EXTENDED_INQUIRY_RESPONSE_DATA_LEN, hci_stack->eir_data) ; ad_iterator_has_more(&context) ; ad_iterator_next(&context)) { 1267 uint8_t data_type = ad_iterator_get_data_type(&context); 1268 uint8_t size = ad_iterator_get_data_len(&context); 1269 const uint8_t *data = ad_iterator_get_data(&context); 1270 // copy item 1271 packet[offset++] = size + 1; 1272 packet[offset++] = data_type; 1273 memcpy(&packet[offset], data, size); 1274 // update name item 1275 if ((data_type == BLUETOOTH_DATA_TYPE_SHORTENED_LOCAL_NAME) || (data_type == BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME)){ 1276 btstack_replace_bd_addr_placeholder(&packet[offset], size, hci_stack->local_bd_addr); 1277 } 1278 offset += size; 1279 } 1280 } else { 1281 uint16_t name_len = (uint16_t) strlen(hci_stack->local_name); 1282 uint16_t bytes_to_copy = btstack_min(name_len, EXTENDED_INQUIRY_RESPONSE_DATA_LEN - 2); 1283 packet[offset++] = bytes_to_copy + 1; 1284 packet[offset++] = BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME; 1285 (void)memcpy(&packet[6], hci_stack->local_name, bytes_to_copy); 1286 // expand '00:00:00:00:00:00' in name with bd_addr 1287 btstack_replace_bd_addr_placeholder(&packet[offset], bytes_to_copy, hci_stack->local_bd_addr); 1288 } 1289 hci_send_cmd_packet(packet, HCI_CMD_HEADER_SIZE + 1 + EXTENDED_INQUIRY_RESPONSE_DATA_LEN); 1290} 1291#endif 1292 |
|
1231#if !defined(HAVE_PLATFORM_IPHONE_OS) && !defined (HAVE_HOST_CONTROLLER_API) 1232 1233static uint32_t hci_transport_uart_get_main_baud_rate(void){ 1234 if (!hci_stack->config) return 0; 1235 uint32_t baud_rate = ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main; 1236 // Limit baud rate for Broadcom chipsets to 3 mbps 1237 if ((hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_BROADCOM_CORPORATION) && (baud_rate > 3000000)){ 1238 baud_rate = 3000000; --- 246 unchanged lines hidden (view full) --- 1485 case HCI_INIT_WRITE_SIMPLE_PAIRING_MODE: 1486 hci_stack->substate = HCI_INIT_W4_WRITE_SIMPLE_PAIRING_MODE; 1487 hci_send_cmd(&hci_write_simple_pairing_mode, hci_stack->ssp_enable); 1488 break; 1489 case HCI_INIT_WRITE_PAGE_TIMEOUT: 1490 hci_stack->substate = HCI_INIT_W4_WRITE_PAGE_TIMEOUT; 1491 hci_send_cmd(&hci_write_page_timeout, 0x6000); // ca. 15 sec 1492 break; | 1293#if !defined(HAVE_PLATFORM_IPHONE_OS) && !defined (HAVE_HOST_CONTROLLER_API) 1294 1295static uint32_t hci_transport_uart_get_main_baud_rate(void){ 1296 if (!hci_stack->config) return 0; 1297 uint32_t baud_rate = ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main; 1298 // Limit baud rate for Broadcom chipsets to 3 mbps 1299 if ((hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_BROADCOM_CORPORATION) && (baud_rate > 3000000)){ 1300 baud_rate = 3000000; --- 246 unchanged lines hidden (view full) --- 1547 case HCI_INIT_WRITE_SIMPLE_PAIRING_MODE: 1548 hci_stack->substate = HCI_INIT_W4_WRITE_SIMPLE_PAIRING_MODE; 1549 hci_send_cmd(&hci_write_simple_pairing_mode, hci_stack->ssp_enable); 1550 break; 1551 case HCI_INIT_WRITE_PAGE_TIMEOUT: 1552 hci_stack->substate = HCI_INIT_W4_WRITE_PAGE_TIMEOUT; 1553 hci_send_cmd(&hci_write_page_timeout, 0x6000); // ca. 15 sec 1554 break; |
1493 case HCI_INIT_WRITE_DEFAULT_LINK_POLICY_SETTING: 1494 hci_stack->substate = HCI_INIT_W4_WRITE_DEFAULT_LINK_POLICY_SETTING; 1495 hci_send_cmd(&hci_write_default_link_policy_setting, hci_stack->default_link_policy_settings); 1496 break; 1497 case HCI_INIT_WRITE_CLASS_OF_DEVICE: 1498 hci_stack->substate = HCI_INIT_W4_WRITE_CLASS_OF_DEVICE; 1499 hci_send_cmd(&hci_write_class_of_device, hci_stack->class_of_device); 1500 break; 1501 case HCI_INIT_WRITE_LOCAL_NAME: { 1502 hci_stack->substate = HCI_INIT_W4_WRITE_LOCAL_NAME; 1503 hci_reserve_packet_buffer(); 1504 uint8_t * packet = hci_stack->hci_packet_buffer; 1505 // construct HCI Command and send 1506 uint16_t opcode = hci_write_local_name.opcode; 1507 hci_stack->last_cmd_opcode = opcode; 1508 packet[0] = opcode & 0xff; 1509 packet[1] = opcode >> 8; 1510 packet[2] = DEVICE_NAME_LEN; 1511 memset(&packet[3], 0, DEVICE_NAME_LEN); 1512 uint16_t name_len = (uint16_t) strlen(hci_stack->local_name); 1513 uint16_t bytes_to_copy = btstack_min(name_len, DEVICE_NAME_LEN); 1514 // if shorter than DEVICE_NAME_LEN, it's implicitly NULL-terminated by memset call 1515 (void)memcpy(&packet[3], hci_stack->local_name, bytes_to_copy); 1516 // expand '00:00:00:00:00:00' in name with bd_addr 1517 btstack_replace_bd_addr_placeholder(&packet[3], bytes_to_copy, hci_stack->local_bd_addr); 1518 hci_send_cmd_packet(packet, HCI_CMD_HEADER_SIZE + DEVICE_NAME_LEN); 1519 break; 1520 } 1521 case HCI_INIT_WRITE_EIR_DATA: { 1522 hci_stack->substate = HCI_INIT_W4_WRITE_EIR_DATA; 1523 hci_reserve_packet_buffer(); 1524 uint8_t * packet = hci_stack->hci_packet_buffer; 1525 // construct HCI Command in-place and send 1526 uint16_t opcode = hci_write_extended_inquiry_response.opcode; 1527 hci_stack->last_cmd_opcode = opcode; 1528 uint16_t offset = 0; 1529 packet[offset++] = opcode & 0xff; 1530 packet[offset++] = opcode >> 8; 1531 packet[offset++] = 1 + EXTENDED_INQUIRY_RESPONSE_DATA_LEN; 1532 packet[offset++] = 0; // FEC not required 1533 memset(&packet[offset], 0, EXTENDED_INQUIRY_RESPONSE_DATA_LEN); 1534 if (hci_stack->eir_data){ 1535 // copy items and expand '00:00:00:00:00:00' in name with bd_addr 1536 ad_context_t context; 1537 for (ad_iterator_init(&context, EXTENDED_INQUIRY_RESPONSE_DATA_LEN, hci_stack->eir_data) ; ad_iterator_has_more(&context) ; ad_iterator_next(&context)) { 1538 uint8_t data_type = ad_iterator_get_data_type(&context); 1539 uint8_t size = ad_iterator_get_data_len(&context); 1540 const uint8_t *data = ad_iterator_get_data(&context); 1541 // copy item 1542 packet[offset++] = size + 1; 1543 packet[offset++] = data_type; 1544 memcpy(&packet[offset], data, size); 1545 // update name item 1546 if ((data_type == BLUETOOTH_DATA_TYPE_SHORTENED_LOCAL_NAME) || (data_type == BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME)){ 1547 btstack_replace_bd_addr_placeholder(&packet[offset], size, hci_stack->local_bd_addr); 1548 } 1549 offset += size; 1550 } 1551 } else { 1552 uint16_t name_len = (uint16_t) strlen(hci_stack->local_name); 1553 uint16_t bytes_to_copy = btstack_min(name_len, EXTENDED_INQUIRY_RESPONSE_DATA_LEN - 2); 1554 packet[offset++] = bytes_to_copy + 1; 1555 packet[offset++] = BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME; 1556 (void)memcpy(&packet[6], hci_stack->local_name, bytes_to_copy); 1557 // expand '00:00:00:00:00:00' in name with bd_addr 1558 btstack_replace_bd_addr_placeholder(&packet[offset], bytes_to_copy, hci_stack->local_bd_addr); 1559 } 1560 hci_send_cmd_packet(packet, HCI_CMD_HEADER_SIZE + 1 + EXTENDED_INQUIRY_RESPONSE_DATA_LEN); 1561 break; 1562 } | |
1563 case HCI_INIT_WRITE_INQUIRY_MODE: 1564 hci_stack->substate = HCI_INIT_W4_WRITE_INQUIRY_MODE; 1565 hci_send_cmd(&hci_write_inquiry_mode, (int) hci_stack->inquiry_mode); 1566 break; 1567 case HCI_INIT_WRITE_SECURE_CONNECTIONS_HOST_ENABLE: 1568 hci_send_cmd(&hci_write_secure_connections_host_support, 1); 1569 hci_stack->secure_connections_active = true; 1570 hci_stack->substate = HCI_INIT_W4_WRITE_SECURE_CONNECTIONS_HOST_ENABLE; --- 1823 unchanged lines hidden (view full) --- 3394 3395 hci_stack->secure_connections_active = false; 3396 3397#ifdef ENABLE_CLASSIC 3398 hci_stack->new_page_scan_interval = 0xffff; 3399 hci_stack->new_page_scan_window = 0xffff; 3400 hci_stack->new_page_scan_type = 0xff; 3401 hci_stack->inquiry_lap = GAP_IAC_GENERAL_INQUIRY; | 1555 case HCI_INIT_WRITE_INQUIRY_MODE: 1556 hci_stack->substate = HCI_INIT_W4_WRITE_INQUIRY_MODE; 1557 hci_send_cmd(&hci_write_inquiry_mode, (int) hci_stack->inquiry_mode); 1558 break; 1559 case HCI_INIT_WRITE_SECURE_CONNECTIONS_HOST_ENABLE: 1560 hci_send_cmd(&hci_write_secure_connections_host_support, 1); 1561 hci_stack->secure_connections_active = true; 1562 hci_stack->substate = HCI_INIT_W4_WRITE_SECURE_CONNECTIONS_HOST_ENABLE; --- 1823 unchanged lines hidden (view full) --- 3386 3387 hci_stack->secure_connections_active = false; 3388 3389#ifdef ENABLE_CLASSIC 3390 hci_stack->new_page_scan_interval = 0xffff; 3391 hci_stack->new_page_scan_window = 0xffff; 3392 hci_stack->new_page_scan_type = 0xff; 3393 hci_stack->inquiry_lap = GAP_IAC_GENERAL_INQUIRY; |
3394 hci_stack->gap_tasks = 3395 GAP_TASK_SET_DEFAULT_LINK_POLICY | 3396 GAP_TASK_SET_CLASS_OF_DEVICE | 3397 GAP_TASK_SET_LOCAL_NAME | 3398 GAP_TASK_SET_EIR_DATA; |
|
3402#endif 3403 3404#ifdef ENABLE_CLASSIC_PAIRING_OOB 3405 hci_stack->classic_read_local_oob_data = true; 3406 hci_stack->classic_oob_con_handle = HCI_CON_HANDLE_INVALID; 3407#endif 3408 3409 // LE --- 244 unchanged lines hidden (view full) --- 3654bool gap_get_secure_connections_only_mode(void){ 3655 return hci_stack->gap_secure_connections_only_mode; 3656} 3657#endif 3658 3659#ifdef ENABLE_CLASSIC 3660void gap_set_class_of_device(uint32_t class_of_device){ 3661 hci_stack->class_of_device = class_of_device; | 3399#endif 3400 3401#ifdef ENABLE_CLASSIC_PAIRING_OOB 3402 hci_stack->classic_read_local_oob_data = true; 3403 hci_stack->classic_oob_con_handle = HCI_CON_HANDLE_INVALID; 3404#endif 3405 3406 // LE --- 244 unchanged lines hidden (view full) --- 3651bool gap_get_secure_connections_only_mode(void){ 3652 return hci_stack->gap_secure_connections_only_mode; 3653} 3654#endif 3655 3656#ifdef ENABLE_CLASSIC 3657void gap_set_class_of_device(uint32_t class_of_device){ 3658 hci_stack->class_of_device = class_of_device; |
3659 hci_stack->gap_tasks |= GAP_TASK_SET_CLASS_OF_DEVICE; 3660 hci_run(); |
|
3662} 3663 3664void gap_set_default_link_policy_settings(uint16_t default_link_policy_settings){ 3665 hci_stack->default_link_policy_settings = default_link_policy_settings; | 3661} 3662 3663void gap_set_default_link_policy_settings(uint16_t default_link_policy_settings){ 3664 hci_stack->default_link_policy_settings = default_link_policy_settings; |
3665 hci_stack->gap_tasks |= GAP_TASK_SET_DEFAULT_LINK_POLICY; 3666 hci_run(); |
|
3666} 3667 3668void gap_set_allow_role_switch(bool allow_role_switch){ 3669 hci_stack->allow_role_switch = allow_role_switch ? 1 : 0; 3670} 3671 3672uint8_t hci_get_allow_role_switch(void){ 3673 return hci_stack->allow_role_switch; --- 424 unchanged lines hidden (view full) --- 4098 } 4099 } 4100 return false; 4101} 4102 4103#ifdef ENABLE_CLASSIC 4104static bool hci_run_general_gap_classic(void){ 4105 | 3667} 3668 3669void gap_set_allow_role_switch(bool allow_role_switch){ 3670 hci_stack->allow_role_switch = allow_role_switch ? 1 : 0; 3671} 3672 3673uint8_t hci_get_allow_role_switch(void){ 3674 return hci_stack->allow_role_switch; --- 424 unchanged lines hidden (view full) --- 4099 } 4100 } 4101 return false; 4102} 4103 4104#ifdef ENABLE_CLASSIC 4105static bool hci_run_general_gap_classic(void){ 4106 |
4107 // assert stack is working and classic is active 4108 if (hci_classic_supported() == false) return false; 4109 if (hci_stack->state != HCI_STATE_WORKING) return false; 4110 |
|
4106 // decline incoming connections 4107 if (hci_stack->decline_reason){ 4108 uint8_t reason = hci_stack->decline_reason; 4109 hci_stack->decline_reason = 0; 4110 hci_send_cmd(&hci_reject_connection_request, hci_stack->decline_addr, reason); 4111 return true; 4112 } | 4111 // decline incoming connections 4112 if (hci_stack->decline_reason){ 4113 uint8_t reason = hci_stack->decline_reason; 4114 hci_stack->decline_reason = 0; 4115 hci_send_cmd(&hci_reject_connection_request, hci_stack->decline_addr, reason); 4116 return true; 4117 } |
4118 4119 if ((hci_stack->gap_tasks & GAP_TASK_SET_CLASS_OF_DEVICE) != 0) { 4120 hci_stack->gap_tasks &= ~GAP_TASK_SET_CLASS_OF_DEVICE; 4121 hci_send_cmd(&hci_write_class_of_device, hci_stack->class_of_device); 4122 return true; 4123 } 4124 if ((hci_stack->gap_tasks & GAP_TASK_SET_LOCAL_NAME) != 0) { 4125 hci_stack->gap_tasks &= ~GAP_TASK_SET_LOCAL_NAME; 4126 gap_run_set_local_name(); 4127 return true; 4128 } 4129 if ((hci_stack->gap_tasks & GAP_TASK_SET_EIR_DATA) != 0) { 4130 hci_stack->gap_tasks &= ~GAP_TASK_SET_EIR_DATA; 4131 gap_run_set_eir_data(); 4132 return true; 4133 } 4134 if ((hci_stack->gap_tasks & GAP_TASK_SET_DEFAULT_LINK_POLICY) != 0) { 4135 hci_stack->gap_tasks &= ~GAP_TASK_SET_DEFAULT_LINK_POLICY; 4136 hci_send_cmd(&hci_write_default_link_policy_setting, hci_stack->default_link_policy_settings); 4137 return true; 4138 } |
|
4113 // write page scan activity | 4139 // write page scan activity |
4114 if ((hci_stack->state == HCI_STATE_WORKING) && (hci_stack->new_page_scan_interval != 0xffff) && hci_classic_supported()){ 4115 hci_send_cmd(&hci_write_page_scan_activity, hci_stack->new_page_scan_interval, hci_stack->new_page_scan_window); | 4140 if (hci_stack->new_page_scan_interval != 0xffff) { 4141 uint16_t new_page_scan_interval = hci_stack->new_page_scan_interval; 4142 uint16_t new_page_scan_window = hci_stack->new_page_scan_window; |
4116 hci_stack->new_page_scan_interval = 0xffff; 4117 hci_stack->new_page_scan_window = 0xffff; | 4143 hci_stack->new_page_scan_interval = 0xffff; 4144 hci_stack->new_page_scan_window = 0xffff; |
4145 hci_send_cmd(&hci_write_page_scan_activity, new_page_scan_interval, new_page_scan_window); |
|
4118 return true; 4119 } 4120 // write page scan type | 4146 return true; 4147 } 4148 // write page scan type |
4121 if ((hci_stack->state == HCI_STATE_WORKING) && (hci_stack->new_page_scan_type != 0xff) && hci_classic_supported()){ 4122 hci_send_cmd(&hci_write_page_scan_type, hci_stack->new_page_scan_type); | 4149 if (hci_stack->new_page_scan_type != 0xff) { 4150 uint8_t new_page_scan_type = hci_stack->new_page_scan_type; |
4123 hci_stack->new_page_scan_type = 0xff; | 4151 hci_stack->new_page_scan_type = 0xff; |
4152 hci_send_cmd(&hci_write_page_scan_type, new_page_scan_type); |
|
4124 return true; 4125 } 4126 // send scan enable | 4153 return true; 4154 } 4155 // send scan enable |
4127 if ((hci_stack->state == HCI_STATE_WORKING) && (hci_stack->new_scan_enable_value != 0xff) && hci_classic_supported()){ 4128 hci_send_cmd(&hci_write_scan_enable, hci_stack->new_scan_enable_value); | 4156 if (hci_stack->new_scan_enable_value != 0xff) { 4157 uint8_t new_scan_enable_value = hci_stack->new_scan_enable_value; |
4129 hci_stack->new_scan_enable_value = 0xff; | 4158 hci_stack->new_scan_enable_value = 0xff; |
4159 hci_send_cmd(&hci_write_scan_enable, new_scan_enable_value); |
|
4130 return true; 4131 } | 4160 return true; 4161 } |
4162 |
|
4132 // start/stop inquiry 4133 if ((hci_stack->inquiry_state >= GAP_INQUIRY_DURATION_MIN) && (hci_stack->inquiry_state <= GAP_INQUIRY_DURATION_MAX)){ 4134 uint8_t duration = hci_stack->inquiry_state; 4135 hci_stack->inquiry_state = GAP_INQUIRY_STATE_W4_ACTIVE; 4136 hci_send_cmd(&hci_inquiry, hci_stack->inquiry_lap, duration, 0); 4137 return true; 4138 } 4139 if (hci_stack->inquiry_state == GAP_INQUIRY_STATE_W2_CANCEL){ --- 5 unchanged lines hidden (view full) --- 4145 if (hci_stack->remote_name_state == GAP_REMOTE_NAME_STATE_W2_SEND){ 4146 hci_stack->remote_name_state = GAP_REMOTE_NAME_STATE_W4_COMPLETE; 4147 hci_send_cmd(&hci_remote_name_request, hci_stack->remote_name_addr, 4148 hci_stack->remote_name_page_scan_repetition_mode, 0, hci_stack->remote_name_clock_offset); 4149 return true; 4150 } 4151#ifdef ENABLE_CLASSIC_PAIRING_OOB 4152 // Local OOB data | 4163 // start/stop inquiry 4164 if ((hci_stack->inquiry_state >= GAP_INQUIRY_DURATION_MIN) && (hci_stack->inquiry_state <= GAP_INQUIRY_DURATION_MAX)){ 4165 uint8_t duration = hci_stack->inquiry_state; 4166 hci_stack->inquiry_state = GAP_INQUIRY_STATE_W4_ACTIVE; 4167 hci_send_cmd(&hci_inquiry, hci_stack->inquiry_lap, duration, 0); 4168 return true; 4169 } 4170 if (hci_stack->inquiry_state == GAP_INQUIRY_STATE_W2_CANCEL){ --- 5 unchanged lines hidden (view full) --- 4176 if (hci_stack->remote_name_state == GAP_REMOTE_NAME_STATE_W2_SEND){ 4177 hci_stack->remote_name_state = GAP_REMOTE_NAME_STATE_W4_COMPLETE; 4178 hci_send_cmd(&hci_remote_name_request, hci_stack->remote_name_addr, 4179 hci_stack->remote_name_page_scan_repetition_mode, 0, hci_stack->remote_name_clock_offset); 4180 return true; 4181 } 4182#ifdef ENABLE_CLASSIC_PAIRING_OOB 4183 // Local OOB data |
4153 if ((hci_stack->state == HCI_STATE_WORKING) && hci_stack->classic_read_local_oob_data){ | 4184 if (hci_stack->classic_read_local_oob_data){ |
4154 hci_stack->classic_read_local_oob_data = false; 4155 if (hci_stack->local_supported_commands[1] & 0x10u){ 4156 hci_send_cmd(&hci_read_local_extended_oob_data); 4157 } else { 4158 hci_send_cmd(&hci_read_local_oob_data); 4159 } 4160 } 4161#endif --- 1583 unchanged lines hidden (view full) --- 5745 hci_run(); 5746 5747 return 0; 5748} 5749#endif 5750 5751void gap_set_local_name(const char * local_name){ 5752 hci_stack->local_name = local_name; | 4185 hci_stack->classic_read_local_oob_data = false; 4186 if (hci_stack->local_supported_commands[1] & 0x10u){ 4187 hci_send_cmd(&hci_read_local_extended_oob_data); 4188 } else { 4189 hci_send_cmd(&hci_read_local_oob_data); 4190 } 4191 } 4192#endif --- 1583 unchanged lines hidden (view full) --- 5776 hci_run(); 5777 5778 return 0; 5779} 5780#endif 5781 5782void gap_set_local_name(const char * local_name){ 5783 hci_stack->local_name = local_name; |
5784 hci_stack->gap_tasks |= GAP_TASK_SET_LOCAL_NAME; 5785 // also update EIR if not set by user 5786 if (hci_stack->eir_data == NULL){ 5787 hci_stack->gap_tasks |= GAP_TASK_SET_EIR_DATA; 5788 } 5789 hci_run(); |
|
5753} 5754 5755 5756#ifdef ENABLE_BLE 5757 5758#ifdef ENABLE_LE_CENTRAL 5759void gap_start_scan(void){ 5760 hci_stack->le_scanning_enabled = true; --- 536 unchanged lines hidden (view full) --- 6297#ifdef ENABLE_CLASSIC 6298/** 6299 * @brief Set Extended Inquiry Response data 6300 * @param eir_data size HCI_EXTENDED_INQUIRY_RESPONSE_DATA_LEN (240) bytes, is not copied make sure memory is accessible during stack startup 6301 * @note has to be done before stack starts up 6302 */ 6303void gap_set_extended_inquiry_response(const uint8_t * data){ 6304 hci_stack->eir_data = data; | 5790} 5791 5792 5793#ifdef ENABLE_BLE 5794 5795#ifdef ENABLE_LE_CENTRAL 5796void gap_start_scan(void){ 5797 hci_stack->le_scanning_enabled = true; --- 536 unchanged lines hidden (view full) --- 6334#ifdef ENABLE_CLASSIC 6335/** 6336 * @brief Set Extended Inquiry Response data 6337 * @param eir_data size HCI_EXTENDED_INQUIRY_RESPONSE_DATA_LEN (240) bytes, is not copied make sure memory is accessible during stack startup 6338 * @note has to be done before stack starts up 6339 */ 6340void gap_set_extended_inquiry_response(const uint8_t * data){ 6341 hci_stack->eir_data = data; |
6342 hci_stack->gap_tasks |= GAP_TASK_SET_EIR_DATA; 6343 hci_run(); |
|
6305} 6306 6307/** 6308 * @brief Start GAP Classic Inquiry 6309 * @param duration in 1.28s units 6310 * @return 0 if ok 6311 * @events: GAP_EVENT_INQUIRY_RESULT, GAP_EVENT_INQUIRY_COMPLETE 6312 */ --- 580 unchanged lines hidden --- | 6344} 6345 6346/** 6347 * @brief Start GAP Classic Inquiry 6348 * @param duration in 1.28s units 6349 * @return 0 if ok 6350 * @events: GAP_EVENT_INQUIRY_RESULT, GAP_EVENT_INQUIRY_COMPLETE 6351 */ --- 580 unchanged lines hidden --- |