hci.c (1e83575a3b15c4aacee6292e7aab8e50eda9f291) hci.c (51e51a58dec605e986a053950dbc1e3dd173d630)
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

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

4514#ifdef ENABLE_LE_CENTRAL
4515 // scanning control
4516 if (hci_stack->le_scanning_active) {
4517 // stop if:
4518 // - parameter change required
4519 // - it's disabled
4520 // - whitelist change required but used for scanning
4521 // - resolving list modified
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

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

4514#ifdef ENABLE_LE_CENTRAL
4515 // scanning control
4516 if (hci_stack->le_scanning_active) {
4517 // stop if:
4518 // - parameter change required
4519 // - it's disabled
4520 // - whitelist change required but used for scanning
4521 // - resolving list modified
4522 // - own address changes
4522 bool scanning_uses_whitelist = (hci_stack->le_scan_filter_policy & 1) == 1;
4523 if ((hci_stack->le_scanning_param_update) ||
4524 !hci_stack->le_scanning_enabled ||
4525 scanning_uses_whitelist ||
4523 bool scanning_uses_whitelist = (hci_stack->le_scan_filter_policy & 1) == 1;
4524 if ((hci_stack->le_scanning_param_update) ||
4525 !hci_stack->le_scanning_enabled ||
4526 scanning_uses_whitelist ||
4526 resolving_list_modification_pending){
4527 resolving_list_modification_pending ||
4528 random_address_change){
4527
4528 scanning_stop = true;
4529 }
4530 }
4531#endif
4532
4533#ifdef ENABLE_LE_CENTRAL
4534 // connecting control
4535 bool connecting_with_whitelist;
4536 switch (hci_stack->le_connecting_state){
4537 case LE_CONNECTING_DIRECT:
4538 case LE_CONNECTING_WHITELIST:
4539 // stop connecting if:
4540 // - connecting uses white and whitelist modification pending
4541 // - if it got disabled
4542 // - resolving list modified
4529
4530 scanning_stop = true;
4531 }
4532 }
4533#endif
4534
4535#ifdef ENABLE_LE_CENTRAL
4536 // connecting control
4537 bool connecting_with_whitelist;
4538 switch (hci_stack->le_connecting_state){
4539 case LE_CONNECTING_DIRECT:
4540 case LE_CONNECTING_WHITELIST:
4541 // stop connecting if:
4542 // - connecting uses white and whitelist modification pending
4543 // - if it got disabled
4544 // - resolving list modified
4545 // - own address changes
4543 connecting_with_whitelist = hci_stack->le_connecting_state == LE_CONNECTING_WHITELIST;
4544 if ((connecting_with_whitelist && whitelist_modification_pending) ||
4545 (hci_stack->le_connecting_request == LE_CONNECTING_IDLE) ||
4546 connecting_with_whitelist = hci_stack->le_connecting_state == LE_CONNECTING_WHITELIST;
4547 if ((connecting_with_whitelist && whitelist_modification_pending) ||
4548 (hci_stack->le_connecting_request == LE_CONNECTING_IDLE) ||
4546 resolving_list_modification_pending) {
4549 resolving_list_modification_pending ||
4550 random_address_change) {
4547
4548 connecting_stop = true;
4549 }
4550 break;
4551 default:
4552 break;
4553 }
4554#endif
4555
4556#ifdef ENABLE_LE_PERIPHERAL
4557 // le advertisement control
4558 if (hci_stack->le_advertisements_active){
4559 // stop if:
4560 // - parameter change required
4561 // - random address used in advertising and changes
4562 // - it's disabled
4563 // - whitelist change required but used for advertisement filter policy
4564 // - resolving list modified
4551
4552 connecting_stop = true;
4553 }
4554 break;
4555 default:
4556 break;
4557 }
4558#endif
4559
4560#ifdef ENABLE_LE_PERIPHERAL
4561 // le advertisement control
4562 if (hci_stack->le_advertisements_active){
4563 // stop if:
4564 // - parameter change required
4565 // - random address used in advertising and changes
4566 // - it's disabled
4567 // - whitelist change required but used for advertisement filter policy
4568 // - resolving list modified
4569 // - own address changes
4565 bool advertising_uses_whitelist = hci_stack->le_advertisements_filter_policy != 0;
4566 bool advertising_uses_random_address = hci_stack->le_own_addr_type != BD_ADDR_TYPE_LE_PUBLIC;
4567 bool advertising_change = (hci_stack->le_advertisements_todo & LE_ADVERTISEMENT_TASKS_SET_PARAMS) != 0;
4568 if (advertising_change ||
4569 (advertising_uses_random_address && random_address_change) ||
4570 (hci_stack->le_advertisements_enabled_for_current_roles == 0) ||
4571 (advertising_uses_whitelist && whitelist_modification_pending) ||
4570 bool advertising_uses_whitelist = hci_stack->le_advertisements_filter_policy != 0;
4571 bool advertising_uses_random_address = hci_stack->le_own_addr_type != BD_ADDR_TYPE_LE_PUBLIC;
4572 bool advertising_change = (hci_stack->le_advertisements_todo & LE_ADVERTISEMENT_TASKS_SET_PARAMS) != 0;
4573 if (advertising_change ||
4574 (advertising_uses_random_address && random_address_change) ||
4575 (hci_stack->le_advertisements_enabled_for_current_roles == 0) ||
4576 (advertising_uses_whitelist && whitelist_modification_pending) ||
4572 resolving_list_modification_pending) {
4577 resolving_list_modification_pending ||
4578 random_address_change) {
4573
4574 advertising_stop = true;
4575 }
4576 }
4577#endif
4578
4579
4580 // Phase 2: stop everything that should be off during modifications

--- 2537 unchanged lines hidden ---
4579
4580 advertising_stop = true;
4581 }
4582 }
4583#endif
4584
4585
4586 // Phase 2: stop everything that should be off during modifications

--- 2537 unchanged lines hidden ---