Skip to content

Commit 687ecc1

Browse files
authored
Merge pull request #45 from pan-/notdic-sdk-update
Nordic sdk update
2 parents f1c3fdb + 2cb6e65 commit 687ecc1

File tree

79 files changed

+2687
-20713
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2687
-20713
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xGattServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ ble_error_t nRF5xGattServer::reset(void)
469469
@brief Callback handler for events getting pushed up from the SD
470470
*/
471471
/**************************************************************************/
472-
void nRF5xGattServer::hwCallback(ble_evt_t *p_ble_evt)
472+
void nRF5xGattServer::hwCallback(const ble_evt_t *p_ble_evt)
473473
{
474474
GattAttribute::Handle_t handle_value;
475475
GattServerEvents::gattEvent_t eventType;

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xn.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,12 @@ nRF5xn::waitForEvent(void)
233233
}
234234

235235
void nRF5xn::processEvents() {
236+
core_util_critical_section_enter();
236237
if (isEventsSignaled) {
237238
isEventsSignaled = false;
239+
core_util_critical_section_exit();
238240
intern_softdevice_events_execute();
241+
} else {
242+
core_util_critical_section_exit();
239243
}
240244
}

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5x/source/btle/btle.cpp

Lines changed: 27 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,12 @@
2121
#include "btle_clock.h"
2222

2323
#include "ble_flash.h"
24-
#include "ble_conn_params.h"
2524

26-
#include "btle_gap.h"
2725
#include "custom/custom_helper.h"
2826

2927
#include "ble/GapEvents.h"
3028
#include "nRF5xn.h"
3129

32-
// This is a C++ file, so C11 _Static_assert (works with -std=gnu99 on GCC) won't work
33-
#undef STATIC_ASSERT_SIMPLE
34-
#undef STATIC_ASSERT_MSG
35-
36-
// FIXME : We can't use mbed_assert.h because we're using these macros within functions
37-
#define STATIC_ASSERT_MSG(EXPR, MSG)
38-
#define STATIC_ASSERT_SIMPLE(EXPR)
39-
40-
#warning FIXME : We can't use mbed_assert.h because we're using these within functions
41-
4230
#ifdef S110
4331
#define IS_LEGACY_DEVICE_MANAGER_ENABLED 1
4432
#elif defined(S130) || defined(S132)
@@ -52,8 +40,6 @@ extern "C" {
5240
#else
5341
#include "nrf_fstorage.h"
5442
#include "fds.h"
55-
#include "peer_manager.h"
56-
#include "ble_conn_state.h"
5743
#endif
5844

5945
#include "nrf_sdh.h"
@@ -64,6 +50,16 @@ extern "C" {
6450

6551
#include "nRF5xPalGattClient.h"
6652

53+
// This is a C++ file, so C11 _Static_assert (works with -std=gnu99 on GCC) won't work
54+
#undef STATIC_ASSERT_SIMPLE
55+
#undef STATIC_ASSERT_MSG
56+
57+
// FIXME : We can't use mbed_assert.h because we're using these macros within functions
58+
#define STATIC_ASSERT_MSG(EXPR, MSG)
59+
#define STATIC_ASSERT_SIMPLE(EXPR)
60+
61+
#warning FIXME : We can't use mbed_assert.h because we're using these within functions
62+
6763

6864
// Make this volatile at it will be set in interrupt context
6965
volatile bool isEventsSignaled = false;
@@ -76,9 +72,9 @@ void app_error_handler(uint32_t error_code, uint32_t line_num, const
7672
extern "C" void SD_EVT_IRQHandler(void); // export the softdevice event handler for registration by nvic-set-vector.
7773

7874
#if NRF_SDK14PLUS_EVENT_HANDLERS
79-
static void btle_handler(const ble_evt_t *p_ble_evt, void *p_context);
75+
void btle_handler(const ble_evt_t *p_ble_evt, void *p_context);
8076
#else
81-
static void btle_handler(ble_evt_t *p_ble_evt);
77+
void btle_handler(ble_evt_t *p_ble_evt);
8278
#endif
8379

8480
#if !NRF_SDK14PLUS_EVENT_HANDLERS
@@ -232,9 +228,6 @@ error_t btle_init(void)
232228
}
233229
#endif
234230

235-
// Peer Manger must been initialised prior any other call to its API (this file and btle_security_pm.cpp)
236-
pm_init();
237-
238231
#if (NRF_SD_BLE_API_VERSION <= 2)
239232
ble_gap_addr_t addr;
240233
if (sd_ble_gap_address_get(&addr) != NRF_SUCCESS) {
@@ -243,10 +236,6 @@ error_t btle_init(void)
243236
if (sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr) != NRF_SUCCESS) {
244237
return ERROR_INVALID_PARAM;
245238
}
246-
#else
247-
ble_gap_privacy_params_t privacy_params = {0};
248-
privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_OFF;
249-
pm_privacy_set(&privacy_params);
250239
#endif
251240

252241
// From SDK 14 onwards event handlers are registered differently
@@ -259,19 +248,20 @@ error_t btle_init(void)
259248
ASSERT_STATUS( softdevice_sys_evt_handler_set(sys_evt_dispatch));
260249
#endif
261250

262-
return btle_gap_init();
251+
return ERROR_NONE;
263252
}
264253

265254
#if NRF_SDK14PLUS_EVENT_HANDLERS
266-
static void btle_handler(const ble_evt_t *p_ble_evt, void *p_context)
255+
void btle_handler(const ble_evt_t *p_ble_evt, void *p_context)
267256
#else
268-
static void btle_handler(ble_evt_t *p_ble_evt)
257+
void btle_handler(const ble_evt_t *p_ble_evt)
269258
#endif
270259
{
271260
#if NRF_SDK14PLUS_EVENT_HANDLERS
272261
(void)p_context; // Keep compiler happy
273262
#endif
274263
using ble::pal::vendor::nordic::nRF5xGattClient;
264+
using ble::pal::vendor::nordic::nRF5xSecurityManager;
275265

276266
// In SDK14+, all other modules from the SDK will be registered independently as softdevice events observers
277267
#if !NRF_SDK14PLUS_EVENT_HANDLERS
@@ -286,9 +276,6 @@ static void btle_handler(ble_evt_t *p_ble_evt)
286276
// Forward BLE events to the Connection State module.
287277
// This must be called before any event handler that uses this module.
288278
ble_conn_state_on_ble_evt(p_ble_evt);
289-
290-
// Forward BLE events to the Peer Manager
291-
pm_on_ble_evt(p_ble_evt);
292279
#endif
293280
#endif
294281

@@ -299,42 +286,16 @@ static void btle_handler(ble_evt_t *p_ble_evt)
299286
nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
300287
nRF5xGap &gap = (nRF5xGap &) ble.getGap();
301288
nRF5xGattServer &gattServer = (nRF5xGattServer &) ble.getGattServer();
302-
nRF5xSecurityManager &securityManager = (nRF5xSecurityManager &) ble.getSecurityManager();
289+
nRF5xSecurityManager &securityManager = nRF5xSecurityManager::get_security_manager();
303290

304291
/* Custom event handler */
305292
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
293+
case BLE_GAP_EVT_CONNECTED:
294+
gap.on_connection(
295+
p_ble_evt->evt.gap_evt.conn_handle,
296+
p_ble_evt->evt.gap_evt.params.connected
297+
);
336298
break;
337-
}
338299

339300
case BLE_GAP_EVT_DISCONNECTED: {
340301
Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle;
@@ -416,10 +377,6 @@ static void btle_handler(ble_evt_t *p_ble_evt)
416377
}
417378
#endif
418379

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-
423380
case BLE_GAP_EVT_TIMEOUT:
424381
gap.processTimeoutEvent(static_cast<Gap::TimeoutSource_t>(p_ble_evt->evt.gap_evt.params.timeout.src));
425382
break;
@@ -431,21 +388,17 @@ static void btle_handler(ble_evt_t *p_ble_evt)
431388
// BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION));
432389
break;
433390

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);
391+
case BLE_GAP_EVT_ADV_REPORT:
392+
gap.on_advertising_packet(p_ble_evt->evt.gap_evt.params.adv_report);
442393
break;
443-
}
444394

445395
default:
446396
break;
447397
}
448398

399+
// Process security manager events
400+
securityManager.sm_handler(p_ble_evt);
401+
449402
gattServer.hwCallback(p_ble_evt);
450403
}
451404

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5x/source/btle/btle.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ extern "C" {
2323

2424
#include "common/common.h"
2525

26-
#include "ble_srv_common.h"
2726
#include "headers/nrf_ble.h"
2827

2928
#if NRF_SD_BLE_API_VERSION >= 5

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5x/source/btle/btle_gap.cpp

Lines changed: 0 additions & 99 deletions
This file was deleted.

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5x/source/btle/btle_gap.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)