Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NRF5 + NRF52840]: Merge nrf52840 to [NRF5] sources #4245

Merged
merged 8 commits into from May 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Expand Up @@ -24,7 +24,6 @@
#include "ble_conn_params.h"

#include "btle_gap.h"
#include "btle_advertising.h"
#include "custom/custom_helper.h"

#include "ble/GapEvents.h"
Expand Down Expand Up @@ -165,13 +164,22 @@ error_t btle_init(void)
return ERROR_INVALID_PARAM;
}

// Peer Manger must been initialised prior any other call to its API (this file and btle_security_pm.cpp)
pm_init();

#if (NRF_SD_BLE_API_VERSION <= 2)
ble_gap_addr_t addr;
if (sd_ble_gap_address_get(&addr) != NRF_SUCCESS) {
return ERROR_INVALID_PARAM;
}
if (sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr) != NRF_SUCCESS) {
return ERROR_INVALID_PARAM;
}
#else
ble_gap_privacy_params_t privacy_params = {0};
privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_OFF;
pm_privacy_set(&privacy_params);
#endif

ASSERT_STATUS( softdevice_ble_evt_handler_set(btle_handler));
ASSERT_STATUS( softdevice_sys_evt_handler_set(sys_evt_dispatch));
Expand Down Expand Up @@ -219,12 +227,25 @@ static void btle_handler(ble_evt_t *p_ble_evt)
gap.setConnectionHandle(handle);
const Gap::ConnectionParams_t *params = reinterpret_cast<Gap::ConnectionParams_t *>(&(p_ble_evt->evt.gap_evt.params.connected.conn_params));
const ble_gap_addr_t *peer = &p_ble_evt->evt.gap_evt.params.connected.peer_addr;
#if (NRF_SD_BLE_API_VERSION <= 2)
const ble_gap_addr_t *own = &p_ble_evt->evt.gap_evt.params.connected.own_addr;

gap.processConnectionEvent(handle,
role,
static_cast<BLEProtocol::AddressType_t>(peer->addr_type), peer->addr,
static_cast<BLEProtocol::AddressType_t>(own->addr_type), own->addr,
params);
role,
static_cast<BLEProtocol::AddressType_t>(peer->addr_type), peer->addr,
static_cast<BLEProtocol::AddressType_t>(own->addr_type), own->addr,
params);
#else
Gap::AddressType_t addr_type;
Gap::Address_t own_address;
gap.getAddress(&addr_type, own_address);

gap.processConnectionEvent(handle,
role,
static_cast<BLEProtocol::AddressType_t>(peer->addr_type), peer->addr,
addr_type, own_address,
params);
#endif
break;
}

Expand Down
Expand Up @@ -24,7 +24,7 @@ extern "C" {
#include "common/common.h"

#include "ble_srv_common.h"
#include "nrf_ble.h"
#include "headers/nrf_ble.h"

error_t btle_init(void);

Expand Down

This file was deleted.

This file was deleted.

Expand Up @@ -57,7 +57,7 @@ void bleGattcEventHandler(const ble_evt_t *p_ble_evt)

case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP:
if (sdSingleton.isActive()) {
sdSingleton.processDiscoverUUIDResponse(&p_ble_evt->evt.gattc_evt.params.char_val_by_uuid_read_rsp);
sdSingleton.processDiscoverUUIDResponse(&p_ble_evt->evt.gattc_evt);
}
break;

Expand Down
Expand Up @@ -15,7 +15,7 @@
*/
#include "common/common.h"

#include "nrf_ble_gap.h"
#include "headers/nrf_ble_gap.h"
#include "ble_conn_params.h"

static inline uint32_t msec_to_1_25msec(uint32_t interval_ms) ATTR_ALWAYS_INLINE ATTR_CONST;
Expand Down
Expand Up @@ -84,6 +84,7 @@ ble_error_t btle_setLinkSecurity(Gap::Handle_t connectionHandle, SecurityManager
*/
ble_error_t btle_purgeAllBondingState(void);

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

/**
* Function to test whether a BLE address is generated using an IRK.
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if defined(S130) || defined(S132)
#if defined(S130) || defined(S132) || defined(S140)
#include "btle.h"

#include "nRF5xn.h"
Expand Down Expand Up @@ -94,10 +94,6 @@ btle_initializeSecurity(bool enableBonding,
}
}

if (pm_init() != NRF_SUCCESS) {
return BLE_ERROR_UNSPECIFIED;
}

// update default security parameters with function call parameters
securityParameters.bond = enableBonding;
securityParameters.mitm = requireMITM;
Expand Down Expand Up @@ -393,6 +389,7 @@ void pm_handler(pm_evt_t const *p_event)
}
}

#if (NRF_SD_BLE_API_VERSION <= 2)
ble_error_t
btle_createWhitelistFromBondTable(ble_gap_whitelist_t *p_whitelist)
{
Expand All @@ -408,7 +405,7 @@ btle_createWhitelistFromBondTable(ble_gap_whitelist_t *p_whitelist)
return BLE_ERROR_INVALID_STATE;
}
}

#endif

bool
btle_matchAddressAndIrk(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * p_irk)
Expand Down
Expand Up @@ -18,7 +18,7 @@
#define _CUSTOM_HELPER_H_

#include "common/common.h"
#include "nrf_ble.h"
#include "headers/nrf_ble.h"
#include "ble/UUID.h"
#include "ble/GattCharacteristic.h"

Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
#include "nRF5xCharacteristicDescriptorDiscoverer.h"
#include "nrf_ble_err.h"
#include "headers/nrf_ble_err.h"
#include "ble/DiscoveredCharacteristicDescriptor.h"

nRF5xCharacteristicDescriptorDiscoverer::nRF5xCharacteristicDescriptorDiscoverer() :
Expand Down Expand Up @@ -136,6 +136,7 @@ void nRF5xCharacteristicDescriptorDiscoverer::processAttributeInformation(
return;
}

#if (NRF_SD_BLE_API_VERSION <= 2)
// for all UUIDS found, process the discovery
for (uint16_t i = 0; i < infos.count; ++i) {
bool use_16bits_uuids = infos.format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT;
Expand All @@ -146,6 +147,27 @@ void nRF5xCharacteristicDescriptorDiscoverer::processAttributeInformation(

// prepare the next round of descriptors discovery
uint16_t startHandle = infos.attr_info[infos.count - 1].handle + 1;
#else
uint16_t startHandle;
// for all UUIDS found, process the discovery
if (infos.format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT) {
for (uint16_t i = 0; i < infos.count; ++i) {
UUID uuid = UUID(infos.info.attr_info16[i].uuid.uuid);
discovery->process(infos.info.attr_info16[i].handle, uuid);
}

// prepare the next round of descriptors discovery
startHandle = infos.info.attr_info16[infos.count - 1].handle + 1;
} else {
for (uint16_t i = 0; i < infos.count; ++i) {
UUID uuid = UUID(infos.info.attr_info128[i].uuid.uuid128, UUID::LSB);
discovery->process(infos.info.attr_info128[i].handle, uuid);
}

// prepare the next round of descriptors discovery
startHandle = infos.info.attr_info128[infos.count - 1].handle + 1;
}
#endif
uint16_t endHandle = discovery->getCharacteristic().getLastHandle();

if(startHandle > endHandle) {
Expand Down
Expand Up @@ -21,7 +21,7 @@
#include "ble/DiscoveredCharacteristic.h"
#include "ble/CharacteristicDescriptorDiscovery.h"
#include "ble/GattClient.h"
#include "nrf_ble_gattc.h"
#include "headers/nrf_ble_gattc.h"

/**
* @brief Manage the discovery of Characteristic descriptors
Expand Down
Expand Up @@ -16,7 +16,7 @@

#include "nRF5xDiscoveredCharacteristic.h"
#include "nRF5xGattClient.h"
#include "nrf_ble_gatt.h"
#include "headers/nrf_ble_gatt.h"

void
nRF5xDiscoveredCharacteristic::setup(nRF5xGattClient *gattcIn,
Expand Down
Expand Up @@ -18,7 +18,7 @@
#define __NRF_DISCOVERED_CHARACTERISTIC_H__

#include "ble/DiscoveredCharacteristic.h"
#include "nrf_ble_gatt.h"
#include "headers/nrf_ble_gatt.h"

class nRF5xGattClient; /* forward declaration */

Expand Down