| 91 | static bool is_ble_inited = false; |
| 92 | |
| 93 | void stopBLEStack() { |
| 94 | if (pBLEScan) pBLEScan->stop(); |
| 95 | |
| 96 | #if !defined(LITE_VERSION) |
| 97 | if (BLEStateManager::isBLEActive() || BLEStateManager::getActiveClientCount() > 0) { |
| 98 | BLEStateManager::deinitBLE(true); |
| 99 | } else |
| 100 | #endif |
| 101 | if (BLEDevice::getScan() != nullptr || BLEDevice::getAdvertising() != nullptr || |
| 102 | BLEDevice::getServer() != nullptr || BLEConnected || is_ble_inited) { |
| 103 | BLEDevice::deinit(); |
| 104 | } |
| 105 | |
| 106 | pBLEScan = nullptr; |
| 107 | pServer = nullptr; |
| 108 | pService = nullptr; |
| 109 | pTxCharacteristic = nullptr; |
| 110 | pRxCharacteristic = nullptr; |
| 111 | deviceConnected = false; |
| 112 | oldDeviceConnected = false; |
| 113 | bleDataTransferEnabled = false; |
| 114 | is_ble_inited = false; |
| 115 | BLEConnected = false; |
| 116 | #if !defined(LITE_VERSION) |
| 117 | if (hid_ble) { |
| 118 | delete hid_ble; |
| 119 | hid_ble = nullptr; |
| 120 | } |
| 121 | #endif |
| 122 | } |
| 123 | |
| 124 | void ble_scan_setup() { |
| 125 | if (FORCE_RADIO_TEARDOWN_ON_SWITCH) { |
no test coverage detected