File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -62,23 +62,17 @@ class PrivacyDevice : private mbed::NonCopyable<PrivacyDevice>,
62
62
_bonded (false ),
63
63
_led1 (LED1, 0 ) { };
64
64
65
- virtual ~PrivacyDevice ()
66
- {
67
- if (_ble.hasInitialized ()) {
68
- _ble.shutdown ();
69
- }
70
- };
65
+ virtual ~PrivacyDevice () { };
71
66
72
67
/* * Start BLE interface initialisation */
73
68
void run ()
74
69
{
75
- ble_error_t error;
76
-
77
70
/* to show we're running we'll blink every 500ms */
78
71
_event_queue.call_every (500 , this , &PrivacyDevice::blink);
79
72
80
73
if (_ble.hasInitialized ()) {
81
- printf (" Ble instance already initialised.\r\n " );
74
+ /* ble instance already initialised, skip init and start activity */
75
+ start ();
82
76
return ;
83
77
}
84
78
@@ -192,6 +186,14 @@ class PrivacyDevice : private mbed::NonCopyable<PrivacyDevice>,
192
186
print_address (connection_event->peerResolvableAddr );
193
187
194
188
_handle = connection_event->handle ;
189
+
190
+ if (_bonded) {
191
+ /* disconnect in 2s */
192
+ _event_queue.call_in (
193
+ 2000 , &_ble.gap (),
194
+ &Gap::disconnect, _handle, Gap::REMOTE_USER_TERMINATED_CONNECTION
195
+ );
196
+ }
195
197
};
196
198
197
199
/* * This is called by Gap to notify the application we disconnected */
You can’t perform that action at this time.
0 commit comments