hci.c (521bd5ff305c1eb2a56a015634d4a6e9fd7977de) hci.c (32a127304c5c9da6fe53a9a8a37ffbb67c6047e9)
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

--- 1333 unchanged lines hidden (view full) ---

1342 return;
1343 }
1344 // write page scan type
1345 if ((hci_stack->gap_tasks & GAP_TASK_WRITE_PAGE_SCAN_TYPE) != 0) {
1346 hci_stack->gap_tasks &= ~GAP_TASK_WRITE_PAGE_SCAN_TYPE;
1347 hci_send_cmd(&hci_write_page_scan_type, hci_stack->new_page_scan_type);
1348 return;
1349 }
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

--- 1333 unchanged lines hidden (view full) ---

1342 return;
1343 }
1344 // write page scan type
1345 if ((hci_stack->gap_tasks & GAP_TASK_WRITE_PAGE_SCAN_TYPE) != 0) {
1346 hci_stack->gap_tasks &= ~GAP_TASK_WRITE_PAGE_SCAN_TYPE;
1347 hci_send_cmd(&hci_write_page_scan_type, hci_stack->new_page_scan_type);
1348 return;
1349 }
1350 // write page timeout
1351 if ((hci_stack->gap_tasks & GAP_TASK_WRITE_PAGE_TIMEOUT) != 0) {
1352 hci_stack->gap_tasks &= ~GAP_TASK_WRITE_PAGE_TIMEOUT;
1353 hci_send_cmd(&hci_write_page_timeout, hci_stack->page_timeout);
1354 return;
1355 }
1350 // send scan enable
1351 if ((hci_stack->gap_tasks & GAP_TASK_WRITE_SCAN_ENABLE) != 0) {
1352 hci_stack->gap_tasks &= ~GAP_TASK_WRITE_SCAN_ENABLE;
1353 hci_send_cmd(&hci_write_scan_enable, hci_stack->new_scan_enable_value);
1354 return;
1355 }
1356}
1357#endif

--- 291 unchanged lines hidden (view full) ---

1649 // skip write secure connections host support if not supported or disabled
1650 if (hci_classic_supported() && hci_stack->secure_connections_enable && (hci_stack->local_supported_commands[1u] & 0x02u) != 0u) {
1651 hci_send_cmd(&hci_write_secure_connections_host_support, 1);
1652 hci_stack->secure_connections_active = true;
1653 hci_stack->substate = HCI_INIT_W4_WRITE_SECURE_CONNECTIONS_HOST_ENABLE;
1654 break;
1655 }
1656
1356 // send scan enable
1357 if ((hci_stack->gap_tasks & GAP_TASK_WRITE_SCAN_ENABLE) != 0) {
1358 hci_stack->gap_tasks &= ~GAP_TASK_WRITE_SCAN_ENABLE;
1359 hci_send_cmd(&hci_write_scan_enable, hci_stack->new_scan_enable_value);
1360 return;
1361 }
1362}
1363#endif

--- 291 unchanged lines hidden (view full) ---

1655 // skip write secure connections host support if not supported or disabled
1656 if (hci_classic_supported() && hci_stack->secure_connections_enable && (hci_stack->local_supported_commands[1u] & 0x02u) != 0u) {
1657 hci_send_cmd(&hci_write_secure_connections_host_support, 1);
1658 hci_stack->secure_connections_active = true;
1659 hci_stack->substate = HCI_INIT_W4_WRITE_SECURE_CONNECTIONS_HOST_ENABLE;
1660 break;
1661 }
1662
1657 /* fall through */
1658
1659 case HCI_INIT_WRITE_PAGE_TIMEOUT:
1660 if (hci_classic_supported()){
1661 hci_stack->substate = HCI_INIT_W4_WRITE_PAGE_TIMEOUT;
1662 hci_send_cmd(&hci_write_page_timeout, 0x6000); // ca. 15 sec
1663 break;
1664 }
1665
1666#ifdef ENABLE_SCO_OVER_HCI
1667 /* fall through */
1668
1669 // only sent if ENABLE_SCO_OVER_HCI is defined
1670 case HCI_INIT_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE:
1671 // skip write synchronous flow control if not supported
1672 if (hci_classic_supported() && ((hci_stack->local_supported_commands[0] & 0x04) != 0)){
1673 hci_stack->substate = HCI_INIT_W4_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE;

--- 1773 unchanged lines hidden (view full) ---

3447
3448 // no pending cmds
3449 hci_stack->decline_reason = 0;
3450
3451 hci_stack->secure_connections_active = false;
3452
3453#ifdef ENABLE_CLASSIC
3454 hci_stack->inquiry_lap = GAP_IAC_GENERAL_INQUIRY;
1663#ifdef ENABLE_SCO_OVER_HCI
1664 /* fall through */
1665
1666 // only sent if ENABLE_SCO_OVER_HCI is defined
1667 case HCI_INIT_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE:
1668 // skip write synchronous flow control if not supported
1669 if (hci_classic_supported() && ((hci_stack->local_supported_commands[0] & 0x04) != 0)){
1670 hci_stack->substate = HCI_INIT_W4_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE;

--- 1773 unchanged lines hidden (view full) ---

3444
3445 // no pending cmds
3446 hci_stack->decline_reason = 0;
3447
3448 hci_stack->secure_connections_active = false;
3449
3450#ifdef ENABLE_CLASSIC
3451 hci_stack->inquiry_lap = GAP_IAC_GENERAL_INQUIRY;
3452 hci_stack->page_timeout = 0x6000; // ca. 15 sec
3453
3455 hci_stack->gap_tasks =
3456 GAP_TASK_SET_DEFAULT_LINK_POLICY |
3457 GAP_TASK_SET_CLASS_OF_DEVICE |
3458 GAP_TASK_SET_LOCAL_NAME |
3459 GAP_TASK_SET_EIR_DATA |
3454 hci_stack->gap_tasks =
3455 GAP_TASK_SET_DEFAULT_LINK_POLICY |
3456 GAP_TASK_SET_CLASS_OF_DEVICE |
3457 GAP_TASK_SET_LOCAL_NAME |
3458 GAP_TASK_SET_EIR_DATA |
3460 GAP_TASK_WRITE_SCAN_ENABLE;
3459 GAP_TASK_WRITE_SCAN_ENABLE |
3460 GAP_TASK_WRITE_PAGE_TIMEOUT;
3461#endif
3462
3463#ifdef ENABLE_CLASSIC_PAIRING_OOB
3464 hci_stack->classic_read_local_oob_data = false;
3465 hci_stack->classic_oob_con_handle = HCI_CON_HANDLE_INVALID;
3466#endif
3467
3468 // LE

--- 3372 unchanged lines hidden (view full) ---

6841}
6842
6843void gap_set_page_scan_type(page_scan_type_t page_scan_type){
6844 hci_stack->new_page_scan_type = (uint8_t) page_scan_type;
6845 hci_stack->gap_tasks |= GAP_TASK_WRITE_PAGE_SCAN_TYPE;
6846 hci_run();
6847}
6848
3461#endif
3462
3463#ifdef ENABLE_CLASSIC_PAIRING_OOB
3464 hci_stack->classic_read_local_oob_data = false;
3465 hci_stack->classic_oob_con_handle = HCI_CON_HANDLE_INVALID;
3466#endif
3467
3468 // LE

--- 3372 unchanged lines hidden (view full) ---

6841}
6842
6843void gap_set_page_scan_type(page_scan_type_t page_scan_type){
6844 hci_stack->new_page_scan_type = (uint8_t) page_scan_type;
6845 hci_stack->gap_tasks |= GAP_TASK_WRITE_PAGE_SCAN_TYPE;
6846 hci_run();
6847}
6848
6849void gap_set_page_timeout(uint16_t page_timeout){
6850 hci_stack->page_timeout = page_timeout;
6851 hci_stack->gap_tasks |= GAP_TASK_WRITE_PAGE_TIMEOUT;
6852 hci_run();
6853}
6854
6849#endif
6850
6851void hci_halting_defer(void){
6852 if (hci_stack->state != HCI_STATE_HALTING) return;
6853 switch (hci_stack->substate){
6854 case HCI_HALTING_DISCONNECT_ALL_NO_TIMER:
6855 case HCI_HALTING_CLOSE:
6856 hci_stack->substate = HCI_HALTING_DISCONNECT_ALL_TIMER;

--- 109 unchanged lines hidden ---
6855#endif
6856
6857void hci_halting_defer(void){
6858 if (hci_stack->state != HCI_STATE_HALTING) return;
6859 switch (hci_stack->substate){
6860 case HCI_HALTING_DISCONNECT_ALL_NO_TIMER:
6861 case HCI_HALTING_CLOSE:
6862 hci_stack->substate = HCI_HALTING_DISCONNECT_ALL_TIMER;

--- 109 unchanged lines hidden ---