ble nano hid over gatt
Dependencies: BLE_API mbed-dev nRF51822
Diff: HIDController_BLE.cpp
- Revision:
- 40:364deaa190fe
- Parent:
- 39:b7889285c9ef
- Child:
- 42:2c3be8694896
--- a/HIDController_BLE.cpp Fri Aug 26 15:39:03 2016 +0000 +++ b/HIDController_BLE.cpp Fri Aug 26 16:03:18 2016 +0000 @@ -52,11 +52,6 @@ static void onTimeout(const Gap::TimeoutSource_t source) { controllerStatus = TIMEOUT; - BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE); - ble.gap().setAdvertisingInterval(1000); - // printf("set advertising timeout\r\n"); - ble.gap().setAdvertisingTimeout(0); - ble.gap().startAdvertising(); } static void passkeyDisplayCallback(Gap::Handle_t handle, const SecurityManager::Passkey_t passkey) { @@ -273,7 +268,7 @@ void HIDController::queueCurrentReportData() { if (!connected()) return; if (keyboardService) { - printf("Q\r\n"); + // printf("Q\r\n"); keyboardService->queueCurrentReportData(); } } @@ -283,12 +278,14 @@ batteryService->updateBatteryLevel(percentage); } -void HIDController::initializeConnection() { +void HIDController::initializeConnection(bool ignoreWhiteList) { ble_error_t error; BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE); ble.gap().setAdvertisingInterval(20); ble.gap().setAdvertisingTimeout(30); - ble.gap().setAdvertisingPolicyMode(Gap::ADV_POLICY_IGNORE_WHITELIST); + if (ignoreWhiteList) { + ble.gap().setAdvertisingPolicyMode(Gap::ADV_POLICY_IGNORE_WHITELIST); + } // printf("advertising\r\n"); error = ble.gap().startAdvertising(); @@ -300,4 +297,3 @@ printf("error with %d\r\n", error); return; } -