Skip to content

Commit 689d12d

Browse files
committed
NRF5_SDK13: Make BLE sources compilable - this is not redy to use!
- Remove ble_advertising.h/c - it was unused, redundant code - includes for SD header ble.h were changed to headers\ble.h in order to distingusch form feature-ble BLE.h - btle_init() introduced PM for disable <B>privacy</B> for API 3 and further. - temporary removed or mocked real implemantation of whitelist-ing support functionalities: btle_security.createWhitelistFromBondTable , gap::startAdvertising, gat::startRadioScan, gap::stopAdvertising Gap::generateStackWhitelist, Gap::getStackWhiteIdentityList-(mock) - Characteristic Descriptor Discoverer - aligned to the apply SD API - long uuid service's read spupport - add BLE features support to sdk configurations file - publicate sdk's id_manager.ah() function. - cutted out f. app_error_handler for mbed-os - removed PACKED definition form app_util_platform (redefined by mbed-os) - Gap::setAddress - allign to new SD API using peer manager - extend Gap::getPermittedTxPowerValues for nRF52840
1 parent 5b36de9 commit 689d12d

Some content is hidden

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

41 files changed

+356
-120
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "ble_conn_params.h"
2525

2626
#include "btle_gap.h"
27-
#include "btle_advertising.h"
27+
//#include "btle_advertising.h"
2828
#include "custom/custom_helper.h"
2929

3030
#include "ble/GapEvents.h"
@@ -165,13 +165,19 @@ error_t btle_init(void)
165165
return ERROR_INVALID_PARAM;
166166
}
167167

168+
#if (NRF_SD_BLE_API_VERSION <= 2)
168169
ble_gap_addr_t addr;
169170
if (sd_ble_gap_address_get(&addr) != NRF_SUCCESS) {
170171
return ERROR_INVALID_PARAM;
171172
}
172173
if (sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr) != NRF_SUCCESS) {
173174
return ERROR_INVALID_PARAM;
174175
}
176+
#else
177+
ble_gap_privacy_params_t privacy_params = {0};
178+
privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_OFF;
179+
pm_privacy_set(&privacy_params);
180+
#endif
175181

176182
ASSERT_STATUS( softdevice_ble_evt_handler_set(btle_handler));
177183
ASSERT_STATUS( softdevice_sys_evt_handler_set(sys_evt_dispatch));
@@ -218,8 +224,13 @@ static void btle_handler(ble_evt_t *p_ble_evt)
218224
#endif
219225
gap.setConnectionHandle(handle);
220226
const Gap::ConnectionParams_t *params = reinterpret_cast<Gap::ConnectionParams_t *>(&(p_ble_evt->evt.gap_evt.params.connected.conn_params));
227+
#if (NRF_SD_BLE_API_VERSION <= 2)
221228
const ble_gap_addr_t *peer = &p_ble_evt->evt.gap_evt.params.connected.peer_addr;
222229
const ble_gap_addr_t *own = &p_ble_evt->evt.gap_evt.params.connected.own_addr;
230+
#else
231+
const ble_gap_addr_t *peer = NULL; // @todo real implemantation pm_device_identities_list_set/get
232+
const ble_gap_addr_t *own = NULL;
233+
#endif
223234
gap.processConnectionEvent(handle,
224235
role,
225236
static_cast<BLEProtocol::AddressType_t>(peer->addr_type), peer->addr,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extern "C" {
2424
#include "common/common.h"
2525

2626
#include "ble_srv_common.h"
27-
#include "ble.h"
27+
#include "headers\ble.h"
2828

2929
error_t btle_init(void);
3030

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5_SDK13/source/btle/btle_advertising.cpp

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

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5_SDK13/source/btle/btle_advertising.h

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

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5_SDK13/source/btle/btle_security.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ ble_error_t btle_setLinkSecurity(Gap::Handle_t connectionHandle, SecurityManager
8484
*/
8585
ble_error_t btle_purgeAllBondingState(void);
8686

87+
#if (NRF_SD_BLE_API_VERSION <= 2)
8788
/**
8889
* Query the SoftDevice bond table to extract a whitelist containing the BLE
8990
* addresses and IRKs of bonded devices.
@@ -98,6 +99,7 @@ ble_error_t btle_purgeAllBondingState(void);
9899
* @return BLE_ERROR_NONE Or appropriate error code indicating reason for failure.
99100
*/
100101
ble_error_t btle_createWhitelistFromBondTable(ble_gap_whitelist_t *p_whitelist);
102+
#endif
101103

102104
/**
103105
* Function to test whether a BLE address is generated using an IRK.

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5_SDK13/source/btle/btle_security_pm.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
#if defined(S130) || defined(S132)
17+
#if defined(S130) || defined(S132) || defined(S140)
1818
#include "btle.h"
1919

2020
#include "nRF5xn.h"
@@ -393,6 +393,7 @@ void pm_handler(pm_evt_t const *p_event)
393393
}
394394
}
395395

396+
#if (NRF_SD_BLE_API_VERSION <= 2)
396397
ble_error_t
397398
btle_createWhitelistFromBondTable(ble_gap_whitelist_t *p_whitelist)
398399
{
@@ -408,7 +409,7 @@ btle_createWhitelistFromBondTable(ble_gap_whitelist_t *p_whitelist)
408409
return BLE_ERROR_INVALID_STATE;
409410
}
410411
}
411-
412+
#endif
412413

413414
bool
414415
btle_matchAddressAndIrk(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * p_irk)

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5_SDK13/source/btle/custom/custom_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define _CUSTOM_HELPER_H_
1919

2020
#include "common/common.h"
21-
#include "ble.h"
21+
#include "headers\ble.h"
2222
#include "ble/UUID.h"
2323
#include "ble/GattCharacteristic.h"
2424

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5_SDK13/source/nRF5xCharacteristicDescriptorDiscoverer.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,38 @@ void nRF5xCharacteristicDescriptorDiscoverer::processAttributeInformation(
136136
return;
137137
}
138138

139+
#if (NRF_SD_BLE_API_VERSION <= 2)
139140
// for all UUIDS found, process the discovery
140141
for (uint16_t i = 0; i < infos.count; ++i) {
141142
bool use_16bits_uuids = infos.format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT;
142143
const ble_gattc_attr_info_t& attr_info = infos.attr_info[i];
143144
UUID uuid = use_16bits_uuids ? UUID(attr_info.info.uuid16.uuid) : UUID(attr_info.info.uuid128.uuid128, UUID::LSB);
144145
discovery->process(attr_info.handle, uuid);
145146
}
146-
147147
// prepare the next round of descriptors discovery
148148
uint16_t startHandle = infos.attr_info[infos.count - 1].handle + 1;
149+
#else
150+
uint16_t startHandle;
151+
// for all UUIDS found, process the discovery
152+
if (infos.format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT) {
153+
154+
for (uint16_t i = 0; i < infos.count; ++i) {
155+
UUID uuid = UUID(infos.info.attr_info16[i].uuid.uuid);
156+
discovery->process(infos.info.attr_info16[i].handle, uuid);
157+
}
158+
159+
// prepare the next round of descriptors discovery
160+
startHandle = infos.info.attr_info16[infos.count - 1].handle + 1;
161+
} else {
162+
for (uint16_t i = 0; i < infos.count; ++i) {
163+
UUID uuid = UUID(infos.info.attr_info128[i].uuid.uuid128, UUID::LSB);
164+
discovery->process(infos.info.attr_info128[i].handle, uuid);
165+
}
166+
167+
// prepare the next round of descriptors discovery
168+
startHandle = infos.info.attr_info128[infos.count - 1].handle + 1;
169+
}
170+
#endif
149171
uint16_t endHandle = discovery->getCharacteristic().getLastHandle();
150172

151173
if(startHandle > endHandle) {

0 commit comments

Comments
 (0)