Skip to content

Commit ddbb177

Browse files
committed
BLE - Devirtualization of the NRF51 port.
1 parent b86049d commit ddbb177

File tree

14 files changed

+775
-328
lines changed

14 files changed

+775
-328
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
27+
#include "ble/gap/Gap.h"
28+
#include "ble/Gap.h"
29+
#include "source/gap/Gap.tpp"
30+
#include "source/LegacyGap.tpp"
31+
#include "nRF5xGap.h"
32+
33+
#include "ble/SecurityManager.h"
34+
#include "source/SecurityManager.tpp"
35+
#include "generic/GenericSecurityManager.h"
36+
#include "source/generic/GenericSecurityManager.tpp"
37+
#include "nRF5xPalSecurityManager.h"
38+
#include "nRF5xPalSecurityManager.tpp"
39+
#include "nRF5xPalGattClient.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+
// see nRF5xGap.cpp (work around for armcc5)
88+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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<template<class> class TPalGattClient, class SigningMonitorEventHandler>
54+
class GenericGattClient;
55+
56+
} // namespace generic
57+
58+
59+
namespace pal {
60+
61+
template<class Impl, class EventHandler>
62+
class SecurityManager;
63+
64+
template<class Impl>
65+
class SigningMonitorEventHandler;
66+
67+
template<class Impl>
68+
class ConnectionEventMonitorEventHandler;
69+
70+
namespace vendor {
71+
namespace nordic {
72+
73+
template <class EventHandler>
74+
class nRF5xSecurityManager;
75+
76+
template<class EventHandler>
77+
class nRF5xGattClient;
78+
79+
} // nordic
80+
} // vendor
81+
} // pal
82+
83+
namespace vendor {
84+
namespace nordic {
85+
86+
template<class>
87+
class DummySigningEventMonitor;
88+
89+
} // nordic
90+
} // vendor
91+
92+
93+
} // ble
94+
95+
class nRF5xGap;
96+
class nRF5xGattServer;
97+
98+
// implementation assembly
99+
namespace ble {
100+
namespace impl {
101+
// SECURITY MANAGER
102+
typedef generic::GenericSecurityManager<
103+
pal::vendor::nordic::nRF5xSecurityManager,
104+
vendor::nordic::DummySigningEventMonitor
105+
> GenericSecurityManagerImpl;
106+
107+
typedef interface::SecurityManager<GenericSecurityManagerImpl> SecurityManager;
108+
109+
typedef GenericSecurityManagerImpl SigningEventHandler;
110+
111+
typedef GenericSecurityManagerImpl ConnectionEventHandler;
112+
113+
typedef pal::vendor::nordic::nRF5xSecurityManager<
114+
GenericSecurityManagerImpl
115+
> PalSecurityManagerImpl;
116+
117+
typedef ::ble::pal::SecurityManager<
118+
PalSecurityManagerImpl,
119+
GenericSecurityManagerImpl
120+
> PalSecurityManager;
121+
122+
// GAP
123+
typedef interface::LegacyGap<nRF5xGap> LegacyGap;
124+
125+
typedef interface::Gap<nRF5xGap> Gap;
126+
127+
// GATT CLIENT
128+
129+
typedef generic::GenericGattClient<
130+
ble::pal::vendor::nordic::nRF5xGattClient,
131+
SigningEventHandler
132+
> GenericGattClientImpl;
133+
134+
typedef ble::pal::vendor::nordic::nRF5xGattClient<
135+
GenericGattClientImpl
136+
> PalGattClient;
137+
138+
// construct the final GattClient type
139+
typedef interface::GattClient<GenericGattClientImpl> GattClient;
140+
141+
142+
// GATT SERVER
143+
typedef ble::interface::GattServer<nRF5xGattServer> GattServer;
144+
} // impl
145+
} // ble
146+
147+
148+
#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_NRF51/source/btle/btle.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,14 @@ void btle_handler(ble_evt_t *p_ble_evt)
165165
#endif
166166

167167
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
168-
nRF5xGattClient::handle_events(p_ble_evt);
168+
ble::impl::PalGattClient::handle_events(p_ble_evt);
169169
#endif
170170

171171
nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
172172
nRF5xGap &gap = (nRF5xGap &) ble.getGap();
173173
nRF5xGattServer &gattServer = (nRF5xGattServer &) ble.getGattServer();
174-
nRF5xSecurityManager &securityManager = nRF5xSecurityManager::get_security_manager();
174+
ble::impl::PalSecurityManagerImpl &securityManager =
175+
ble::impl::PalSecurityManagerImpl::get_security_manager();
175176

176177
/* Custom event handler */
177178
switch (p_ble_evt->header.evt_id) {
@@ -208,7 +209,7 @@ void btle_handler(ble_evt_t *p_ble_evt)
208209

209210
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
210211
// Close all pending discoveries for this connection
211-
nRF5xGattClient::handle_connection_termination(handle);
212+
ble::impl::PalGattClient::handle_connection_termination(handle);
212213
#endif
213214

214215
gap.processDisconnectionEvent(handle, reason);

0 commit comments

Comments
 (0)