Skip to content

Commit 9ab2849

Browse files
committed
BLE - Devirtualization of the NRF52 softdevice port.
1 parent ddbb177 commit 9ab2849

File tree

14 files changed

+775
-326
lines changed

14 files changed

+775
-326
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "ble/GattServer.h"
18+
#include "source/GattServer.tpp"
19+
#include "nRF5xGattServer.h"
20+
21+
#include "ble/GattClient.h"
22+
#include "source/GattClient.tpp"
23+
#include "ble/generic/GenericGattClient.h"
24+
#include "source/generic/GenericGattClient.tpp"
25+
#include "nRF5xPalGattClient.h"
26+
#include "nRF5xPalGattClient.tpp"
27+
28+
#include "ble/gap/Gap.h"
29+
#include "ble/Gap.h"
30+
#include "source/gap/Gap.tpp"
31+
#include "source/LegacyGap.tpp"
32+
#include "nRF5xGap.h"
33+
34+
#include "ble/SecurityManager.h"
35+
#include "source/SecurityManager.tpp"
36+
#include "generic/GenericSecurityManager.h"
37+
#include "source/generic/GenericSecurityManager.tpp"
38+
#include "nRF5xPalSecurityManager.h"
39+
#include "nRF5xPalSecurityManager.tpp"
40+
41+
#include "DummySigningEventMonitor.h"
42+
43+
// SECURITY MANAGER
44+
45+
template class ble::generic::GenericSecurityManager<
46+
ble::pal::vendor::nordic::nRF5xSecurityManager,
47+
ble::vendor::nordic::DummySigningEventMonitor
48+
>;
49+
50+
template class ::ble::pal::SecurityManager<
51+
ble::impl::PalSecurityManagerImpl,
52+
ble::impl::GenericSecurityManagerImpl
53+
>;
54+
55+
template class ble::pal::vendor::nordic::nRF5xSecurityManager<
56+
ble::generic::GenericSecurityManager<
57+
ble::pal::vendor::nordic::nRF5xSecurityManager,
58+
ble::vendor::nordic::DummySigningEventMonitor
59+
>
60+
>;
61+
62+
template class ble::interface::SecurityManager<
63+
ble::impl::GenericSecurityManagerImpl
64+
>;
65+
66+
// GATT CLIENT
67+
68+
template class ble::generic::GenericGattClient<
69+
ble::pal::vendor::nordic::nRF5xGattClient,
70+
ble::impl::SigningEventHandler
71+
>;
72+
73+
template class ble::pal::vendor::nordic::nRF5xGattClient<
74+
ble::impl::GenericGattClientImpl
75+
>;
76+
77+
template class ble::interface::GattClient<
78+
ble::impl::GenericGattClientImpl
79+
>;
80+
81+
// GATT SERVER
82+
83+
template class ble::interface::GattServer<nRF5xGattServer>;
84+
85+
// GAP
86+
87+
// Instantiated in nRF5xGap.cpp as a workaround for ARMCC5
88+
//template class ble::interface::LegacyGap<nRF5xGap>;
89+
//template class ble::interface::Gap<nRF5xGap>;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef BLE_IMPLEMENTATION_FORWARD_H_
18+
#define BLE_IMPLEMENTATION_FORWARD_H_
19+
20+
////////////////////////////////////////////////////////////////////////////////
21+
// Forward declarations of the implementation types
22+
//
23+
namespace ble {
24+
25+
namespace interface {
26+
27+
template<class Impl>
28+
class LegacyGap;
29+
30+
template<class Impl>
31+
class Gap;
32+
33+
template<class Impl>
34+
class GattClient;
35+
36+
template<class Impl>
37+
class SecurityManager;
38+
39+
template<class Impl>
40+
class GattServer;
41+
42+
} // namespace interface
43+
44+
45+
namespace generic {
46+
47+
template <
48+
template<class> class TPalSecurityManager,
49+
template<class> class SigningMonitor
50+
>
51+
class GenericSecurityManager;
52+
53+
template<
54+
template<class> class TPalGattClient,
55+
class SigningMonitorEventHandler
56+
>
57+
class GenericGattClient;
58+
59+
} // namespace generic
60+
61+
62+
namespace pal {
63+
64+
template<class Impl, class EventHandler>
65+
class SecurityManager;
66+
67+
template<class Impl>
68+
class SigningMonitorEventHandler;
69+
70+
template<class Impl>
71+
class ConnectionEventMonitorEventHandler;
72+
73+
namespace vendor {
74+
namespace nordic {
75+
76+
template <class EventHandler>
77+
class nRF5xSecurityManager;
78+
79+
template<class EventHandler>
80+
class nRF5xGattClient;
81+
82+
} // nordic
83+
} // vendor
84+
} // pal
85+
86+
namespace vendor {
87+
namespace nordic {
88+
89+
template<class>
90+
class DummySigningEventMonitor;
91+
92+
} // nordic
93+
} // vendor
94+
95+
96+
} // ble
97+
98+
class nRF5xGap;
99+
class nRF5xGattServer;
100+
101+
// implementation assembly
102+
namespace ble {
103+
namespace impl {
104+
// SECURITY MANAGER
105+
typedef generic::GenericSecurityManager<
106+
pal::vendor::nordic::nRF5xSecurityManager,
107+
vendor::nordic::DummySigningEventMonitor
108+
> GenericSecurityManagerImpl;
109+
110+
typedef interface::SecurityManager<GenericSecurityManagerImpl> SecurityManager;
111+
112+
typedef GenericSecurityManagerImpl SigningEventHandler;
113+
114+
typedef GenericSecurityManagerImpl ConnectionEventHandler;
115+
116+
typedef pal::vendor::nordic::nRF5xSecurityManager<
117+
GenericSecurityManagerImpl
118+
> PalSecurityManagerImpl;
119+
120+
typedef ::ble::pal::SecurityManager<
121+
PalSecurityManagerImpl,
122+
GenericSecurityManagerImpl
123+
> PalSecurityManager;
124+
125+
// GAP
126+
typedef interface::LegacyGap<nRF5xGap> LegacyGap;
127+
128+
typedef interface::Gap<nRF5xGap> Gap;
129+
130+
// GATT CLIENT
131+
132+
typedef generic::GenericGattClient<
133+
ble::pal::vendor::nordic::nRF5xGattClient,
134+
SigningEventHandler
135+
> GenericGattClientImpl;
136+
137+
typedef ble::pal::vendor::nordic::nRF5xGattClient<
138+
GenericGattClientImpl
139+
> PalGattClientImpl;
140+
141+
// construct the final GattClient type
142+
typedef interface::GattClient<GenericGattClientImpl> GattClient;
143+
144+
145+
// GATT SERVER
146+
typedef ble::interface::GattServer<nRF5xGattServer> GattServer;
147+
} // impl
148+
} // ble
149+
150+
151+
#endif //BLE_IMPLEMENTATION_FORWARD_H_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef NRF5X_DUMMYSIGNINGEVENTMONITOR_H
18+
#define NRF5X_DUMMYSIGNINGEVENTMONITOR_H
19+
20+
#include "ble/pal/SigningEventMonitor.h"
21+
22+
namespace ble {
23+
namespace vendor {
24+
namespace nordic {
25+
26+
template<class Handler>
27+
struct DummySigningEventMonitor :
28+
public ble::pal::SigningEventMonitor<DummySigningEventMonitor<Handler>, Handler >
29+
{
30+
void set_signing_event_handler_(Handler *signing_event_handler)
31+
{
32+
}
33+
};
34+
35+
} // nordic
36+
} // vendor
37+
} // ble
38+
39+
40+
#endif //NRF5X_DUMMYSIGNINGEVENTMONITOR_H

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/btle/btle.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,14 @@ void btle_handler(const ble_evt_t *p_ble_evt)
281281
#endif
282282

283283
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
284-
nRF5xGattClient::handle_events(p_ble_evt);
284+
ble::impl::PalGattClientImpl::handle_events(p_ble_evt);
285285
#endif
286286

287287
nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
288288
nRF5xGap &gap = (nRF5xGap &) ble.getGap();
289289
nRF5xGattServer &gattServer = (nRF5xGattServer &) ble.getGattServer();
290-
nRF5xSecurityManager &securityManager = nRF5xSecurityManager::get_security_manager();
290+
ble::impl::PalSecurityManagerImpl &securityManager =
291+
ble::impl::PalSecurityManagerImpl::get_security_manager();
291292

292293
/* Custom event handler */
293294
switch (p_ble_evt->header.evt_id) {
@@ -324,7 +325,7 @@ void btle_handler(const ble_evt_t *p_ble_evt)
324325

325326
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
326327
// Close all pending discoveries for this connection
327-
nRF5xGattClient::handle_connection_termination(handle);
328+
ble::impl::PalGattClientImpl::handle_connection_termination(handle);
328329
#endif
329330

330331
gap.processDisconnectionEvent(handle, reason);
@@ -417,7 +418,7 @@ void btle_handler(const ble_evt_t *p_ble_evt)
417418
const ble_gattc_evt_exchange_mtu_rsp_t &update =
418419
p_ble_evt->evt.gattc_evt.params.exchange_mtu_rsp;
419420

420-
nRF5xGattClient &gatt_client = (nRF5xGattClient&) ble.getGattClient();
421+
ble::impl::PalGattClientImpl &gatt_client = (ble::impl::PalGattClientImpl&) ble.getGattClient();
421422
if (gatt_client.get_event_handler()) {
422423
gatt_client.get_event_handler()->on_att_mtu_change(
423424
connection,

0 commit comments

Comments
 (0)