New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delayed disconnecting after pairing complete by 500ms #255

Merged
merged 3 commits into from Dec 21, 2016
Jump to file or symbol
Failed to load files and symbols.
+12 −3
Diff settings

Always

Just for now

@@ -277,6 +277,9 @@ class MicroBitBLEManager : MicroBitComponent
*/
void showNameHistogram(MicroBitDisplay &display);
#define MICROBIT_BLE_DISCONNECT_AFTER_PAIRING_DELAY 500
unsigned long pairing_completed_at_time;
int pairingStatus;
ManagedString passKey;
ManagedString deviceName;
@@ -28,6 +28,7 @@ DEALINGS IN THE SOFTWARE.
#include "MicroBitEddystone.h"
#include "MicroBitStorage.h"
#include "MicroBitFiber.h"
#include "MicroBitSystemTimer.h"
/* The underlying Nordic libraries that support BLE do not compile cleanly with the stringent GCC settings we employ.
* If we're compiling under GCC, then we suppress any warnings generated from this code (but not the rest of the DAL)
@@ -477,6 +478,8 @@ void MicroBitBLEManager::pairingComplete(bool success)
{
this->pairingStatus = MICROBIT_BLE_PAIR_COMPLETE;
pairing_completed_at_time = system_timer_current_time();
if (success)
{
this->pairingStatus |= MICROBIT_BLE_PAIR_SUCCESSFUL;
@@ -490,12 +493,15 @@ void MicroBitBLEManager::pairingComplete(bool success)
*/
void MicroBitBLEManager::idleTick()
{
if (ble)
ble->disconnect(pairingHandle, Gap::REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF);
if((system_timer_current_time() - pairing_completed_at_time) >= MICROBIT_BLE_DISCONNECT_AFTER_PAIRING_DELAY) {
if (ble)
ble->disconnect(pairingHandle, Gap::REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF);
fiber_remove_idle_component(this);
}
fiber_remove_idle_component(this);
}
/**
* Stops any currently running BLE advertisements
*/
ProTip! Use n and p to navigate between commits in a pull request.