@@ -272,6 +272,7 @@ void btle_handler(const ble_evt_t *p_ble_evt)
272
272
(void )p_context; // Keep compiler happy
273
273
#endif
274
274
using ble::pal::vendor::nordic::nRF5xGattClient;
275
+ using ble::pal::vendor::nordic::nRF5xSecurityManager;
275
276
276
277
// In SDK14+, all other modules from the SDK will be registered independently as softdevice events observers
277
278
#if !NRF_SDK14PLUS_EVENT_HANDLERS
@@ -299,42 +300,16 @@ void btle_handler(const ble_evt_t *p_ble_evt)
299
300
nRF5xn &ble = nRF5xn::Instance (BLE::DEFAULT_INSTANCE);
300
301
nRF5xGap &gap = (nRF5xGap &) ble.getGap ();
301
302
nRF5xGattServer &gattServer = (nRF5xGattServer &) ble.getGattServer ();
302
- nRF5xSecurityManager &securityManager = ( nRF5xSecurityManager &) ble. getSecurityManager ();
303
+ nRF5xSecurityManager &securityManager = nRF5xSecurityManager::get_security_manager ();
303
304
304
305
/* Custom event handler */
305
306
switch (p_ble_evt->header .evt_id ) {
306
- case BLE_GAP_EVT_CONNECTED: {
307
- Gap::Handle_t handle = p_ble_evt->evt .gap_evt .conn_handle ;
308
- #if defined(TARGET_MCU_NRF51_16K_S110) || defined(TARGET_MCU_NRF51_32K_S110)
309
- /* Only peripheral role is supported by S110 */
310
- Gap::Role_t role = Gap::PERIPHERAL;
311
- #else
312
- Gap::Role_t role = static_cast <Gap::Role_t>(p_ble_evt->evt .gap_evt .params .connected .role );
313
- #endif
314
- gap.setConnectionHandle (handle);
315
- const Gap::ConnectionParams_t *params = reinterpret_cast <const Gap::ConnectionParams_t *>(&(p_ble_evt->evt .gap_evt .params .connected .conn_params ));
316
- const ble_gap_addr_t *peer = &p_ble_evt->evt .gap_evt .params .connected .peer_addr ;
317
- #if (NRF_SD_BLE_API_VERSION <= 2)
318
- const ble_gap_addr_t *own = &p_ble_evt->evt .gap_evt .params .connected .own_addr ;
319
-
320
- gap.processConnectionEvent (handle,
321
- role,
322
- static_cast <BLEProtocol::AddressType_t>(peer->addr_type ), peer->addr ,
323
- static_cast <BLEProtocol::AddressType_t>(own->addr_type ), own->addr ,
324
- params);
325
- #else
326
- Gap::AddressType_t addr_type;
327
- Gap::Address_t own_address;
328
- gap.getAddress (&addr_type, own_address);
329
-
330
- gap.processConnectionEvent (handle,
331
- role,
332
- static_cast <BLEProtocol::AddressType_t>(peer->addr_type ), peer->addr ,
333
- addr_type, own_address,
334
- params);
335
- #endif
307
+ case BLE_GAP_EVT_CONNECTED:
308
+ gap.on_connection (
309
+ p_ble_evt->evt .gap_evt .conn_handle ,
310
+ p_ble_evt->evt .gap_evt .params .connected
311
+ );
336
312
break ;
337
- }
338
313
339
314
case BLE_GAP_EVT_DISCONNECTED: {
340
315
Gap::Handle_t handle = p_ble_evt->evt .gap_evt .conn_handle ;
@@ -416,10 +391,6 @@ void btle_handler(const ble_evt_t *p_ble_evt)
416
391
}
417
392
#endif
418
393
419
- case BLE_GAP_EVT_PASSKEY_DISPLAY:
420
- securityManager.processPasskeyDisplayEvent (p_ble_evt->evt .gap_evt .conn_handle , p_ble_evt->evt .gap_evt .params .passkey_display .passkey );
421
- break ;
422
-
423
394
case BLE_GAP_EVT_TIMEOUT:
424
395
gap.processTimeoutEvent (static_cast <Gap::TimeoutSource_t>(p_ble_evt->evt .gap_evt .params .timeout .src ));
425
396
break ;
@@ -431,21 +402,17 @@ void btle_handler(const ble_evt_t *p_ble_evt)
431
402
// BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION));
432
403
break ;
433
404
434
- case BLE_GAP_EVT_ADV_REPORT: {
435
- const ble_gap_evt_adv_report_t *advReport = &p_ble_evt->evt .gap_evt .params .adv_report ;
436
- gap.processAdvertisementReport (advReport->peer_addr .addr ,
437
- advReport->rssi ,
438
- advReport->scan_rsp ,
439
- static_cast <GapAdvertisingParams::AdvertisingType_t>(advReport->type ),
440
- advReport->dlen ,
441
- advReport->data );
405
+ case BLE_GAP_EVT_ADV_REPORT:
406
+ gap.on_advertising_packet (p_ble_evt->evt .gap_evt .params .adv_report );
442
407
break ;
443
- }
444
408
445
409
default :
446
410
break ;
447
411
}
448
412
413
+ // Process security manager events
414
+ securityManager.sm_handler (p_ble_evt);
415
+
449
416
gattServer.hwCallback (p_ble_evt);
450
417
}
451
418
0 commit comments