Delayed disconnecting after pairing complete by 500ms
This commit is contained in:
parent
12bf127ae2
commit
ddbcec094e
2 changed files with 11 additions and 2 deletions
|
@ -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,8 @@ DEALINGS IN THE SOFTWARE.
|
|||
#include "MicroBitEddystone.h"
|
||||
#include "MicroBitStorage.h"
|
||||
#include "MicroBitFiber.h"
|
||||
#include "MicroBitSystemTimer.h"
|
||||
#include <inttypes.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 +479,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,8 +494,10 @@ 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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue