Skip to content

Commit 60f661d

Browse files
authored
Merge pull request #2684 from nvlsianpu/introduce_peer_manager
[BLE NRF5] introduce the SDK nRF5 Peer manager into BLE security features
2 parents 584384c + 13a1fd5 commit 60f661d

File tree

6 files changed

+480
-7
lines changed

6 files changed

+480
-7
lines changed

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

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,23 @@
3030
#include "ble/GapEvents.h"
3131
#include "nRF5xn.h"
3232

33+
#ifdef S110
34+
#define IS_LEGACY_DEVICE_MANAGER_ENABLED 1
35+
#elif defined(S130) || defined(S132)
36+
#define IS_LEGACY_DEVICE_MANAGER_ENABLED 0
37+
#endif
38+
3339
extern "C" {
34-
#include "pstorage.h"
35-
#include "device_manager.h"
40+
#if (IS_LEGACY_DEVICE_MANAGER_ENABLED)
41+
#include "pstorage.h"
42+
#include "device_manager.h"
43+
#else
44+
#include "fstorage.h"
45+
#include "fds.h"
46+
#include "peer_manager.h"
47+
#include "ble_conn_state.h"
48+
#endif
49+
3650
#include "softdevice_handler.h"
3751
#include "ble_stack_handler_types.h"
3852
}
@@ -70,7 +84,12 @@ static void btle_handler(ble_evt_t *p_ble_evt);
7084

7185
static void sys_evt_dispatch(uint32_t sys_evt)
7286
{
87+
#if (IS_LEGACY_DEVICE_MANAGER_ENABLED)
7388
pstorage_sys_event_handler(sys_evt);
89+
#else
90+
// Forward Softdevice events to the fstorage module
91+
fs_sys_event_handler(sys_evt);
92+
#endif
7493
}
7594

7695
/**
@@ -160,7 +179,16 @@ static void btle_handler(ble_evt_t *p_ble_evt)
160179
ble_conn_params_on_ble_evt(p_ble_evt);
161180
#endif
162181

182+
#if (IS_LEGACY_DEVICE_MANAGER_ENABLED)
163183
dm_ble_evt_handler(p_ble_evt);
184+
#else
185+
// Forward BLE events to the Connection State module.
186+
// This must be called before any event handler that uses this module.
187+
ble_conn_state_on_ble_evt(p_ble_evt);
188+
189+
// Forward BLE events to the Peer Manager
190+
pm_on_ble_evt(p_ble_evt);
191+
#endif
164192

165193
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
166194
bleGattcEventHandler(p_ble_evt);

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/btle_discovery.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
2424
{
2525
nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
26-
nRF5xGap &gap = (nRF5xGap &) ble.getGap();
2726
nRF5xGattClient &gattClient = (nRF5xGattClient &) ble.getGattClient();
2827
nRF5xServiceDiscovery &sdSingleton = gattClient.discovery();
2928
nRF5xCharacteristicDescriptorDiscoverer &characteristicDescriptorDiscoverer =

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/btle_security.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
16+
#if defined(S110)
1717
#include "btle.h"
1818

1919
#include "nRF5xn.h"
@@ -323,3 +323,4 @@ btle_generateResolvableAddress(const ble_gap_irk_t &irk, ble_gap_addr_t &address
323323
/* Calculate the hash and store it in the top half of the address */
324324
ah(irk.irk, &address.addr[BLE_GAP_ADDR_LEN - 3], address.addr);
325325
}
326+
#endif

0 commit comments

Comments
 (0)