mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #4245 from nvlsianpu/merge_nrf52840_to_nrf5
[NRF5 + NRF52840]: Merge nrf52840 to [NRF5] sourcespull/4322/head
commit
ef56d9569b
|
@ -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"
|
||||
|
@ -165,6 +164,10 @@ 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;
|
||||
|
@ -172,6 +175,11 @@ error_t btle_init(void)
|
|||
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));
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "common/common.h"
|
||||
|
||||
#include "ble_advdata.h"
|
||||
#include "btle.h"
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Starts the advertising process
|
||||
|
||||
@returns
|
||||
*/
|
||||
/**************************************************************************/
|
||||
error_t btle_advertising_start(void)
|
||||
{
|
||||
ble_gap_adv_params_t adv_para = {0};
|
||||
|
||||
/* Set the default advertising parameters */
|
||||
adv_para.type = BLE_GAP_ADV_TYPE_ADV_IND;
|
||||
adv_para.p_peer_addr = NULL; /* Undirected advertising */
|
||||
adv_para.fp = BLE_GAP_ADV_FP_ANY;
|
||||
adv_para.p_whitelist = NULL;
|
||||
adv_para.interval = (CFG_GAP_ADV_INTERVAL_MS * 8) / 5; /* Advertising
|
||||
* interval in
|
||||
* units of 0.625
|
||||
* ms */
|
||||
adv_para.timeout = CFG_GAP_ADV_TIMEOUT_S;
|
||||
|
||||
ASSERT_STATUS( sd_ble_gap_adv_start(&adv_para));
|
||||
|
||||
return ERROR_NONE;
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _BTLE_ADVERTISING_H_
|
||||
#define _BTLE_ADVERTISING_H_
|
||||
|
||||
#include "common/common.h"
|
||||
|
||||
error_t btle_advertising_start(void);
|
||||
|
||||
#endif // ifndef _BTLE_ADVERTISING_H_
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
@ -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.
|
||||
|
|
|
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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() :
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -24,7 +24,13 @@
|
|||
|
||||
#include "common/common.h"
|
||||
#include "ble_advdata.h"
|
||||
#include "nrf_ble_hci.h"
|
||||
#include "headers/nrf_ble_hci.h"
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION >= 3)
|
||||
#include "peer_manager.h"
|
||||
#include "peer_data_storage.h"
|
||||
#endif
|
||||
|
||||
|
||||
void radioNotificationStaticCallback(bool param) {
|
||||
nRF5xGap &gap = (nRF5xGap &) nRF5xn::Instance(BLE::DEFAULT_INSTANCE).getGap();
|
||||
|
@ -135,6 +141,9 @@ ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, cons
|
|||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::startAdvertising(const GapAdvertisingParams ¶ms)
|
||||
{
|
||||
uint32_t err;
|
||||
ble_gap_adv_params_t adv_para = {0};
|
||||
|
||||
/* Make sure we support the advertising type */
|
||||
if (params.getAdvertisingType() == GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) {
|
||||
/* ToDo: This requires a propery security implementation, etc. */
|
||||
|
@ -168,6 +177,7 @@ ble_error_t nRF5xGap::startAdvertising(const GapAdvertisingParams ¶ms)
|
|||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
/* Allocate the stack's whitelist statically */
|
||||
ble_gap_whitelist_t whitelist;
|
||||
ble_gap_addr_t *whitelistAddressPtrs[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
||||
|
@ -185,18 +195,22 @@ ble_error_t nRF5xGap::startAdvertising(const GapAdvertisingParams ¶ms)
|
|||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
adv_para.p_whitelist = &whitelist;
|
||||
#endif
|
||||
/* For NRF_SD_BLE_API_VERSION >= 3 nRF5xGap::setWhitelist setups the whitelist. */
|
||||
|
||||
/* Start Advertising */
|
||||
ble_gap_adv_params_t adv_para = {0};
|
||||
|
||||
|
||||
adv_para.type = params.getAdvertisingType();
|
||||
adv_para.p_peer_addr = NULL; // Undirected advertisement
|
||||
adv_para.fp = advertisingPolicyMode;
|
||||
adv_para.p_whitelist = &whitelist;
|
||||
adv_para.interval = params.getIntervalInADVUnits(); // advertising interval (in units of 0.625 ms)
|
||||
adv_para.timeout = params.getTimeout();
|
||||
|
||||
|
||||
uint32_t err = sd_ble_gap_adv_start(&adv_para);
|
||||
err = sd_ble_gap_adv_start(&adv_para);
|
||||
switch(err) {
|
||||
case ERROR_NONE:
|
||||
return BLE_ERROR_NONE;
|
||||
|
@ -211,6 +225,10 @@ ble_error_t nRF5xGap::startAdvertising(const GapAdvertisingParams ¶ms)
|
|||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
ble_error_t nRF5xGap::startRadioScan(const GapScanningParams &scanningParams)
|
||||
{
|
||||
|
||||
ble_gap_scan_params_t scanParams;
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
/* Allocate the stack's whitelist statically */
|
||||
ble_gap_whitelist_t whitelist;
|
||||
ble_gap_addr_t *whitelistAddressPtrs[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
||||
|
@ -229,11 +247,17 @@ ble_error_t nRF5xGap::startRadioScan(const GapScanningParams &scanningParams)
|
|||
}
|
||||
}
|
||||
|
||||
ble_gap_scan_params_t scanParams;
|
||||
|
||||
scanParams.active = scanningParams.getActiveScanning(); /**< If 1, perform active scanning (scan requests). */
|
||||
scanParams.selective = scanningPolicyMode; /**< If 1, ignore unknown devices (non whitelisted). */
|
||||
scanParams.p_whitelist = &whitelist; /**< Pointer to whitelist, NULL if none is given. */
|
||||
#else
|
||||
/* For NRF_SD_BLE_API_VERSION >= 3 nRF5xGap::setWhitelist setups the whitelist. */
|
||||
|
||||
scanParams.use_whitelist = scanningPolicyMode;
|
||||
scanParams.adv_dir_report = 0;
|
||||
#endif
|
||||
|
||||
scanParams.active = scanningParams.getActiveScanning(); /**< If 1, perform active scanning (scan requests). */
|
||||
|
||||
scanParams.interval = scanningParams.getInterval(); /**< Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
|
||||
scanParams.window = scanningParams.getWindow(); /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
|
||||
scanParams.timeout = scanningParams.getTimeout(); /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
|
||||
|
@ -302,6 +326,9 @@ ble_error_t nRF5xGap::connect(const Address_t peerAddr,
|
|||
connParams.conn_sup_timeout = 600;
|
||||
}
|
||||
|
||||
ble_gap_scan_params_t scanParams ={0};
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
/* Allocate the stack's whitelist statically */
|
||||
ble_gap_whitelist_t whitelist;
|
||||
ble_gap_addr_t *whitelistAddressPtrs[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
||||
|
@ -319,10 +346,28 @@ ble_error_t nRF5xGap::connect(const Address_t peerAddr,
|
|||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
ble_gap_scan_params_t scanParams;
|
||||
|
||||
scanParams.selective = scanningPolicyMode; /**< If 1, ignore unknown devices (non whitelisted). */
|
||||
scanParams.p_whitelist = &whitelist; /**< Pointer to whitelist, NULL if none is given. */
|
||||
#else
|
||||
/* For NRF_SD_BLE_API_VERSION >= 3 nRF5xGap::setWhitelist setups the whitelist. */
|
||||
|
||||
scanParams.use_whitelist = (whitelistAddressesSize) ? 1 : 0;
|
||||
|
||||
if ((addr.addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE)
|
||||
|| (addr.addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE)) {
|
||||
/* If a device is using Resolvable Private Addresses Section 1.3.2.2 (Core spec v4.2 volume 6 part B),
|
||||
it shall also have an Identity Address that is either a Public or Random Static address type.”
|
||||
To establish a connection, a static address must be provided by the application to the SoftDevice.
|
||||
The SoftDevice resolves the address and connects to the right device if it is available. */
|
||||
addr.addr_id_peer = 1;
|
||||
addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
|
||||
} else {
|
||||
addr.addr_id_peer = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (scanParamsIn != NULL) {
|
||||
scanParams.active = scanParamsIn->getActiveScanning(); /**< If 1, perform active scanning (scan requests). */
|
||||
scanParams.interval = scanParamsIn->getInterval(); /**< Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
|
||||
|
@ -447,6 +492,7 @@ ble_error_t nRF5xGap::reset(void)
|
|||
|
||||
/* Clear the internal whitelist */
|
||||
whitelistAddressesSize = 0;
|
||||
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
@ -489,7 +535,13 @@ uint16_t nRF5xGap::getConnectionHandle(void)
|
|||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
|
||||
{
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
uint8_t cycle_mode;
|
||||
#else
|
||||
ble_gap_privacy_params_t privacy_params = {0};
|
||||
#endif
|
||||
|
||||
|
||||
ble_gap_addr_t dev_addr;
|
||||
|
||||
/* When using Public or Static addresses, the cycle mode must be None.
|
||||
|
@ -498,12 +550,27 @@ ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
|
|||
*/
|
||||
if ((type == BLEProtocol::AddressType::PUBLIC) || (type == BLEProtocol::AddressType::RANDOM_STATIC))
|
||||
{
|
||||
memcpy(dev_addr.addr, address, ADDR_LEN);
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
cycle_mode = BLE_GAP_ADDR_CYCLE_MODE_NONE;
|
||||
memcpy(dev_addr.addr, address, ADDR_LEN);
|
||||
#else
|
||||
privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_OFF;
|
||||
dev_addr.addr_type = type;
|
||||
|
||||
ASSERT_INT(ERROR_NONE, pm_id_addr_set(&dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
ASSERT_INT(ERROR_NONE, pm_privacy_set(&privacy_params), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
#endif
|
||||
}
|
||||
else if ((type == BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE) || (type == BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE))
|
||||
{
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
cycle_mode = BLE_GAP_ADDR_CYCLE_MODE_AUTO;
|
||||
#else
|
||||
privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY;
|
||||
privacy_params.private_addr_type = type;
|
||||
|
||||
ASSERT_INT(ERROR_NONE, pm_privacy_set(&privacy_params), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
#endif
|
||||
// address is ignored when in auto mode
|
||||
}
|
||||
else
|
||||
|
@ -511,8 +578,10 @@ ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
|
|||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
dev_addr.addr_type = type;
|
||||
ASSERT_INT(ERROR_NONE, sd_ble_gap_address_set(cycle_mode, &dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
#endif
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
@ -520,7 +589,11 @@ ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
|
|||
ble_error_t nRF5xGap::getAddress(AddressType_t *typeP, Address_t address)
|
||||
{
|
||||
ble_gap_addr_t dev_addr;
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
if (sd_ble_gap_address_get(&dev_addr) != NRF_SUCCESS) {
|
||||
#else
|
||||
if (sd_ble_gap_addr_get(&dev_addr) != NRF_SUCCESS) {
|
||||
#endif
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
|
@ -599,6 +672,10 @@ void nRF5xGap::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *co
|
|||
static const int8_t permittedTxValues[] = {
|
||||
-40, -20, -16, -12, -8, -4, 0, 4
|
||||
};
|
||||
#elif defined(NRF52840_XXAA)
|
||||
static const int8_t permittedTxValues[] = {
|
||||
-40, -20, -16, -12, -8, -4, 0, 2, 3, 4, 5, 6, 7, 8, 9
|
||||
};
|
||||
#else
|
||||
#error permitted TX power values unknown for this SOC
|
||||
#endif
|
||||
|
@ -648,9 +725,12 @@ uint8_t nRF5xGap::getMaxWhitelistSize(void) const
|
|||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::getWhitelist(Gap::Whitelist_t &whitelistOut) const
|
||||
{
|
||||
uint8_t i;
|
||||
uint32_t i;
|
||||
for (i = 0; i < whitelistAddressesSize && i < whitelistOut.capacity; ++i) {
|
||||
memcpy(&whitelistOut.addresses[i], &whitelistAddresses[i], sizeof(BLEProtocol::Address_t));
|
||||
memcpy( &whitelistOut.addresses[i].address, &whitelistAddresses[i].addr, sizeof(whitelistOut.addresses[0].address));
|
||||
whitelistOut.addresses[i].type = static_cast<BLEProtocol::AddressType_t> (whitelistAddresses[i].addr_type);
|
||||
|
||||
|
||||
}
|
||||
whitelistOut.size = i;
|
||||
|
||||
|
@ -694,19 +774,24 @@ ble_error_t nRF5xGap::setWhitelist(const Gap::Whitelist_t &whitelistIn)
|
|||
}
|
||||
|
||||
/* Test for invalid parameters before we change the internal state */
|
||||
for (uint8_t i = 0; i < whitelistIn.size; ++i) {
|
||||
for (uint32_t i = 0; i < whitelistIn.size; ++i) {
|
||||
if (whitelistIn.addresses[i].type == BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE) {
|
||||
/* This is not allowed because it is completely meaningless */
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
whitelistAddressesSize = 0;
|
||||
for (uint8_t i = 0; i < whitelistIn.size; ++i) {
|
||||
memcpy(&whitelistAddresses[whitelistAddressesSize], &whitelistIn.addresses[i], sizeof(BLEProtocol::Address_t));
|
||||
whitelistAddressesSize++;
|
||||
whitelistAddressesSize = whitelistIn.size;
|
||||
|
||||
for (uint32_t i = 0; i < whitelistIn.size; ++i) {
|
||||
memcpy(&whitelistAddresses[i].addr , &whitelistIn.addresses[i].address , sizeof(whitelistAddresses[0].addr));
|
||||
whitelistAddresses[i].addr_type = static_cast<uint8_t> (whitelistIn.addresses[i].type);
|
||||
}
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION >= 3)
|
||||
updateWhiteAndIdentityListInStack();
|
||||
#endif
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
@ -846,6 +931,7 @@ Gap::InitiatorPolicyMode_t nRF5xGap::getInitiatorPolicyMode(void) const
|
|||
return Gap::INIT_POLICY_IGNORE_WHITELIST;
|
||||
}
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Helper function used to populate the ble_gap_whitelist_t that
|
||||
|
@ -945,3 +1031,167 @@ ble_error_t nRF5xGap::generateStackWhitelist(ble_gap_whitelist_t &whitelist)
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION >= 3)
|
||||
|
||||
/**
|
||||
* Function for preparing settings of the whitelist feature and the identity-resolving feature (privacy) for the SoftDevice.
|
||||
*
|
||||
* Gap::setWhitelist provides the base for preparation of these settings.
|
||||
* This function matches resolvable addresses (passed by Gap::setWhitelist) to IRK data in bonds table.
|
||||
* Therefore resolvable addresses instead of being passed to the whitelist (intended to be passed to the Softdevice)
|
||||
* are passed to the identities list (intended to be passed to the Softdevice).
|
||||
*
|
||||
* @param[out] gapAdrHelper Reference to the struct for storing settings.
|
||||
*/
|
||||
|
||||
ble_error_t nRF5xGap::getStackWhiteIdentityList(GapWhiteAndIdentityList_t &gapAdrHelper)
|
||||
{
|
||||
pm_peer_id_t peer_id;
|
||||
|
||||
ret_code_t ret;
|
||||
|
||||
pm_peer_data_bonding_t bond_data;
|
||||
|
||||
uint8_t irk_found[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
||||
|
||||
memset(irk_found, 0x00, sizeof(irk_found));
|
||||
|
||||
|
||||
gapAdrHelper.identities_cnt = 0;
|
||||
|
||||
|
||||
peer_id = pm_next_peer_id_get(PM_PEER_ID_INVALID);
|
||||
|
||||
nRF5xSecurityManager& securityManager = (nRF5xSecurityManager&) nRF5xn::Instance(0).getSecurityManager();
|
||||
|
||||
/**
|
||||
* Build identities list:
|
||||
* For every private resolvable address in the bond table check if
|
||||
* there is maching address in th provided whitelist.
|
||||
*/
|
||||
while (peer_id != PM_PEER_ID_INVALID)
|
||||
{
|
||||
memset(&bond_data, 0x00, sizeof(bond_data));
|
||||
|
||||
// Read peer data from flash.
|
||||
ret = pm_peer_data_bonding_load(peer_id, &bond_data);
|
||||
|
||||
|
||||
if ((ret == NRF_ERROR_NOT_FOUND) || (ret == NRF_ERROR_INVALID_PARAM))
|
||||
{
|
||||
// Peer data could not be found in flash or peer ID is not valid.
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
if ( bond_data.peer_ble_id.id_addr_info.addr_type == BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE)
|
||||
{
|
||||
for (uint8_t i = 0; i < whitelistAddressesSize; ++i)
|
||||
{
|
||||
if (!irk_found[i])
|
||||
{
|
||||
if (whitelistAddresses[i].addr_type == BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE)
|
||||
{
|
||||
|
||||
//ble_gap_irk_t *p_dfg = &bond_data.peer_ble_id.id_info;
|
||||
if (securityManager.matchAddressAndIrk(&whitelistAddresses[i], &bond_data.peer_ble_id.id_info))
|
||||
{
|
||||
// Copy data to the buffer.
|
||||
memcpy(&gapAdrHelper.identities[i], &bond_data.peer_ble_id, sizeof(ble_gap_id_key_t));
|
||||
gapAdrHelper.identities_cnt++;
|
||||
|
||||
irk_found[i] = 1; // don't look at this address again
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get next peer id
|
||||
peer_id = pm_next_peer_id_get(peer_id);
|
||||
}
|
||||
|
||||
gapAdrHelper.addrs_cnt = 0;
|
||||
|
||||
/**
|
||||
* Build whitelist from the rest of addresses (explicit addresses)
|
||||
*/
|
||||
for (uint8_t i = 0; i < whitelistAddressesSize; ++i)
|
||||
{
|
||||
if (!irk_found[i])
|
||||
{
|
||||
memcpy(&gapAdrHelper.addrs[i], &whitelistAddresses[i], sizeof(ble_gap_addr_t));
|
||||
gapAdrHelper.addrs[i].addr_id_peer = 0;
|
||||
gapAdrHelper.addrs_cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::applyWhiteIdentityList(GapWhiteAndIdentityList_t &gapAdrHelper)
|
||||
{
|
||||
uint32_t retc;
|
||||
|
||||
if (gapAdrHelper.identities_cnt == 0) {
|
||||
retc = sd_ble_gap_device_identities_set(NULL, NULL, 0);
|
||||
} else {
|
||||
ble_gap_id_key_t * pp_identities[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
|
||||
|
||||
for (uint32_t i = 0; i < gapAdrHelper.identities_cnt; ++i)
|
||||
{
|
||||
pp_identities[i] = &gapAdrHelper.identities[i];
|
||||
}
|
||||
|
||||
retc = sd_ble_gap_device_identities_set(pp_identities, NULL /* Don't use local IRKs*/,gapAdrHelper.identities_cnt);
|
||||
}
|
||||
|
||||
if (retc == NRF_SUCCESS) {
|
||||
if (gapAdrHelper.addrs_cnt == 0) {
|
||||
retc = sd_ble_gap_whitelist_set(NULL, 0);
|
||||
} else {
|
||||
ble_gap_addr_t * pp_addrs[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
|
||||
|
||||
for (uint32_t i = 0; i < gapAdrHelper.addrs_cnt; ++i)
|
||||
{
|
||||
pp_addrs[i] = &gapAdrHelper.addrs[i];
|
||||
}
|
||||
|
||||
retc = sd_ble_gap_whitelist_set(pp_addrs, gapAdrHelper.addrs_cnt);
|
||||
}
|
||||
}
|
||||
|
||||
switch(retc) {
|
||||
case NRF_SUCCESS:
|
||||
return BLE_ERROR_NONE;
|
||||
|
||||
case BLE_ERROR_GAP_WHITELIST_IN_USE: //The whitelist is in use by a BLE role and cannot be set or cleared.
|
||||
case BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE: //The device identity list is in use and cannot be set or cleared.
|
||||
return BLE_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
case NRF_ERROR_INVALID_ADDR:
|
||||
case BLE_ERROR_GAP_INVALID_BLE_ADDR: //Invalid address type is supplied.
|
||||
case NRF_ERROR_DATA_SIZE:
|
||||
case BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE: //The device identity list contains multiple entries with the same identity address.
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
|
||||
default:
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::updateWhiteAndIdentityListInStack()
|
||||
{
|
||||
GapWhiteAndIdentityList_t whiteAndIdentityList;
|
||||
uint32_t err;
|
||||
|
||||
err = getStackWhiteIdentityList(whiteAndIdentityList);
|
||||
|
||||
if (err != BLE_ERROR_NONE) {
|
||||
return (ble_error_t)err;
|
||||
}
|
||||
|
||||
return applyWhiteIdentityList(whiteAndIdentityList);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -29,13 +29,17 @@
|
|||
#define YOTTA_CFG_WHITELIST_MAX_SIZE BLE_GAP_WHITELIST_ADDR_MAX_COUNT
|
||||
#endif
|
||||
#ifndef YOTTA_CFG_IRK_TABLE_MAX_SIZE
|
||||
#define YOTTA_CFG_IRK_TABLE_MAX_SIZE BLE_GAP_WHITELIST_IRK_MAX_COUNT
|
||||
#if (NRF_SD_BLE_API_VERSION >= 3)
|
||||
#define YOTTA_CFG_IRK_TABLE_MAX_SIZE BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT
|
||||
#else
|
||||
#define YOTTA_CFG_IRK_TABLE_MAX_SIZE BLE_GAP_WHITELIST_IRK_MAX_COUNT
|
||||
#endif
|
||||
#elif YOTTA_CFG_IRK_TABLE_MAX_SIZE > BLE_GAP_WHITELIST_IRK_MAX_COUNT
|
||||
#undef YOTTA_CFG_IRK_TABLE_MAX_SIZE
|
||||
#define YOTTA_CFG_IRK_TABLE_MAX_SIZE BLE_GAP_WHITELIST_IRK_MAX_COUNT
|
||||
#endif
|
||||
#include "ble/blecommon.h"
|
||||
#include "nrf_ble.h"
|
||||
#include "headers/nrf_ble.h"
|
||||
#include "ble/GapAdvertisingParams.h"
|
||||
#include "ble/GapAdvertisingData.h"
|
||||
#include "ble/Gap.h"
|
||||
|
@ -135,6 +139,7 @@ private:
|
|||
uint8_t whitelistAddressesSize;
|
||||
ble_gap_addr_t whitelistAddresses[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
/*
|
||||
* An internal function used to populate the ble_gap_whitelist_t that will be used by
|
||||
* the SoftDevice for filtering requests. This function is needed because for the BLE
|
||||
|
@ -142,6 +147,30 @@ private:
|
|||
* the IRK table.
|
||||
*/
|
||||
ble_error_t generateStackWhitelist(ble_gap_whitelist_t &whitelist);
|
||||
#endif
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION >= 3)
|
||||
/* internal type for passing a whitelist and a identities list. */
|
||||
typedef struct
|
||||
{
|
||||
ble_gap_addr_t addrs[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
||||
uint32_t addrs_cnt;
|
||||
|
||||
ble_gap_id_key_t identities[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
|
||||
uint32_t identities_cnt;
|
||||
} GapWhiteAndIdentityList_t;
|
||||
|
||||
/* Function for preparing setting of the whitelist feature and the identity-resolving feature (privacy).*/
|
||||
ble_error_t getStackWhiteIdentityList(GapWhiteAndIdentityList_t &whiteAndIdentityList);
|
||||
|
||||
/* Function for applying setting of the whitelist feature and identity-resolving feature (privacy).*/
|
||||
ble_error_t applyWhiteIdentityList(GapWhiteAndIdentityList_t &whiteAndIdentityList);
|
||||
|
||||
/* Function for introducing whitelist feature and the identity-resolving feature setting into SoftDevice.
|
||||
*
|
||||
* This function incorporates getStackWhiteIdentityList and applyWhiteIdentityList together. */
|
||||
ble_error_t updateWhiteAndIdentityListInStack(void);
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool radioNotificationCallbackParam; /* parameter to be passed into the Timeout-generated radio notification callback. */
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <stddef.h>
|
||||
|
||||
#include "ble/blecommon.h"
|
||||
#include "nrf_ble.h" /* nordic ble */
|
||||
#include "headers/nrf_ble.h" /* nordic ble */
|
||||
#include "ble/Gap.h"
|
||||
#include "ble/GattServer.h"
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
virtual ble_error_t purgeAllBondingState(void) {
|
||||
return btle_purgeAllBondingState();
|
||||
}
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
/**
|
||||
* @brief Returns a list of addresses from peers in the stacks bond table.
|
||||
*
|
||||
|
@ -57,6 +57,8 @@ public:
|
|||
*
|
||||
* @return
|
||||
* BLE_ERROR_NONE if successful.
|
||||
*
|
||||
* @todo check whether remove this function (because it is never called)
|
||||
*/
|
||||
virtual ble_error_t getAddressesFromBondTable(Gap::Whitelist_t &addresses) const {
|
||||
uint8_t i;
|
||||
|
@ -112,7 +114,7 @@ public:
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* @brief Clear nRF5xSecurityManager's state.
|
||||
*
|
||||
|
@ -146,6 +148,7 @@ private:
|
|||
nRF5xSecurityManager(const nRF5xSecurityManager &);
|
||||
const nRF5xSecurityManager& operator=(const nRF5xSecurityManager &);
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION <= 2)
|
||||
/*
|
||||
* Expose an interface that allows us to query the SoftDevice bond table
|
||||
* and extract a whitelist.
|
||||
|
@ -153,7 +156,7 @@ private:
|
|||
ble_error_t createWhitelistFromBondTable(ble_gap_whitelist_t &whitelistFromBondTable) const {
|
||||
return btle_createWhitelistFromBondTable(&whitelistFromBondTable);
|
||||
}
|
||||
|
||||
#endif
|
||||
/*
|
||||
* Given a BLE address and a IRK this function check whether the address
|
||||
* can be generated from the IRK. To do so, this function uses the hash
|
||||
|
|
|
@ -281,12 +281,22 @@ nRF5xServiceDiscovery::CharUUIDDiscoveryQueue::triggerFirst(void)
|
|||
}
|
||||
|
||||
void
|
||||
nRF5xServiceDiscovery::processDiscoverUUIDResponse(const ble_gattc_evt_char_val_by_uuid_read_rsp_t *response)
|
||||
nRF5xServiceDiscovery::processDiscoverUUIDResponse(const ble_gattc_evt_t *p_gattc_evt)
|
||||
{
|
||||
const ble_gattc_evt_char_val_by_uuid_read_rsp_t * response = &p_gattc_evt->params.char_val_by_uuid_read_rsp;
|
||||
|
||||
if (state == DISCOVER_SERVICE_UUIDS) {
|
||||
if ((response->count == 1) && (response->value_len == UUID::LENGTH_OF_LONG_UUID)) {
|
||||
UUID::LongUUIDBytes_t uuid;
|
||||
memcpy(uuid, response->handle_value[0].p_value, UUID::LENGTH_OF_LONG_UUID);
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION >= 3)
|
||||
ble_gattc_handle_value_t iter;
|
||||
memset(&iter, 0, sizeof(ble_gattc_handle_value_t));
|
||||
(void) sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(const_cast<ble_gattc_evt_t*>(p_gattc_evt), &iter);
|
||||
memcpy(uuid, iter.p_value, UUID::LENGTH_OF_LONG_UUID);
|
||||
#else
|
||||
memcpy(uuid, &(response->handle_value[0].p_value[0]), UUID::LENGTH_OF_LONG_UUID);
|
||||
#endif
|
||||
|
||||
unsigned serviceIndex = serviceUUIDDiscoveryQueue.dequeue();
|
||||
services[serviceIndex].setupLongUUID(uuid, UUID::LSB);
|
||||
|
@ -298,9 +308,16 @@ nRF5xServiceDiscovery::processDiscoverUUIDResponse(const ble_gattc_evt_char_val_
|
|||
} else if (state == DISCOVER_CHARACTERISTIC_UUIDS) {
|
||||
if ((response->count == 1) && (response->value_len == UUID::LENGTH_OF_LONG_UUID + 1 /* props */ + 2 /* value handle */)) {
|
||||
UUID::LongUUIDBytes_t uuid;
|
||||
|
||||
|
||||
#if (NRF_SD_BLE_API_VERSION >= 3)
|
||||
ble_gattc_handle_value_t iter;
|
||||
memset(&iter, 0, sizeof(ble_gattc_handle_value_t));
|
||||
(void) sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(const_cast<ble_gattc_evt_t*>(p_gattc_evt), &iter);
|
||||
memcpy(uuid, &(iter.p_value[3]), UUID::LENGTH_OF_LONG_UUID);
|
||||
#else
|
||||
memcpy(uuid, &(response->handle_value[0].p_value[3]), UUID::LENGTH_OF_LONG_UUID);
|
||||
|
||||
#endif
|
||||
|
||||
unsigned charIndex = charUUIDDiscoveryQueue.dequeue();
|
||||
characteristics[charIndex].setupLongUUID(uuid, UUID::LSB);
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "ble/DiscoveredService.h"
|
||||
#include "nRF5xDiscoveredCharacteristic.h"
|
||||
|
||||
#include "nrf_ble.h"
|
||||
#include "nrf_ble_gattc.h"
|
||||
#include "headers/nrf_ble.h"
|
||||
#include "headers/nrf_ble_gattc.h"
|
||||
|
||||
class nRF5xGattClient; /* forward declaration */
|
||||
|
||||
|
@ -139,7 +139,7 @@ private:
|
|||
void setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response);
|
||||
|
||||
void triggerServiceUUIDDiscovery(void);
|
||||
void processDiscoverUUIDResponse(const ble_gattc_evt_char_val_by_uuid_read_rsp_t *response);
|
||||
void processDiscoverUUIDResponse(const ble_gattc_evt_t *p_gattc_evt);
|
||||
void removeFirstServiceNeedingUUIDDiscovery(void);
|
||||
|
||||
void terminateServiceDiscovery(void) {
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef _SDK_CONFIG_H_
|
||||
#define _SDK_CONFIG_H_
|
||||
|
||||
#include "nrf_drv_config.h"
|
||||
|
||||
#define UART_DEFAULT_CONFIG_BAUDRATE UART0_CONFIG_BAUDRATE
|
||||
#define UART_DEFAULT_CONFIG_PARITY UART0_CONFIG_PARITY
|
||||
#define UART_DEFAULT_CONFIG_HWFC UART0_CONFIG_HWFC
|
||||
#define CTS_PIN_NUMBER UART0_CONFIG_PSEL_CTS
|
||||
#define RTS_PIN_NUMBER UART0_CONFIG_PSEL_RTS
|
||||
|
||||
#define SPIS_DEFAULT_ORC NRF_DRV_SPIS_DEFAULT_ORC
|
||||
#define SPIS_DEFAULT_CONFIG_IRQ_PRIORITY SPIS1_CONFIG_IRQ_PRIORITY;
|
||||
#define SPIS_DEFAULT_ORC NRF_DRV_SPIS_DEFAULT_ORC
|
||||
#define SPIS_DEFAULT_DEF NRF_DRV_SPIS_DEFAULT_DEF
|
||||
|
||||
#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY SPI1_CONFIG_IRQ_PRIORITY
|
||||
|
||||
#endif
|
|
@ -1,91 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "mbed_assert.h"
|
||||
#include "analogin_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
#include "app_util_platform.h"
|
||||
#include "nrf_drv_saadc.h"
|
||||
|
||||
#ifdef DEVICE_ANALOGIN
|
||||
|
||||
#define ADC_12BIT_RANGE 0xFFF
|
||||
#define ADC_RANGE ADC_12BIT_RANGE
|
||||
|
||||
static void analog_in_event_handler(nrf_drv_saadc_evt_t const *p_event)// type of nrf_drv_saadc_event_handler_t
|
||||
{
|
||||
(void) p_event;
|
||||
}
|
||||
|
||||
static const nrf_drv_saadc_config_t saadc_config =
|
||||
{
|
||||
.resolution = NRF_SAADC_RESOLUTION_12BIT,
|
||||
.oversample = NRF_SAADC_OVERSAMPLE_DISABLED,
|
||||
.interrupt_priority = SAADC_CONFIG_IRQ_PRIORITY
|
||||
};
|
||||
|
||||
void SAADC_IRQHandler(void);
|
||||
|
||||
void analogin_init(analogin_t *obj, PinName pin)
|
||||
{
|
||||
ret_code_t ret_code;
|
||||
|
||||
NVIC_SetVector(SAADC_IRQn, (uint32_t)SAADC_IRQHandler);
|
||||
|
||||
ret_code = nrf_drv_saadc_init(&saadc_config, analog_in_event_handler);
|
||||
MBED_ASSERT(((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_INVALID_STATE))); //NRF_ERROR_INVALID_STATE expected for multiple channels used.
|
||||
|
||||
uint8_t saadcIn = nrf_drv_saadc_gpio_to_ain(pin);
|
||||
MBED_ASSERT(saadcIn != NRF_SAADC_INPUT_DISABLED);
|
||||
|
||||
obj->adc = ADC0_0; // only one instance of ADC in nRF52 SoC
|
||||
obj->adc_pin = saadcIn - 1;
|
||||
|
||||
nrf_saadc_channel_config_t channel_config =
|
||||
NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(saadcIn); //Single ended, negative input to ADC shorted to GND.
|
||||
|
||||
ret_code = nrf_drv_saadc_channel_init(obj->adc_pin, &channel_config);
|
||||
MBED_ASSERT(ret_code == NRF_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
uint16_t analogin_read_u16(analogin_t *obj)
|
||||
{
|
||||
int16_t adc_value;
|
||||
ret_code_t ret_code;
|
||||
|
||||
ret_code = nrf_drv_saadc_sample_convert(obj->adc_pin, &adc_value);
|
||||
MBED_ASSERT(ret_code == NRF_SUCCESS);
|
||||
|
||||
if (adc_value < 0)
|
||||
{
|
||||
// Even in the single ended mode measured value can be {-0}. Saturation for avoid casting to a big integer.
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (uint16_t) adc_value;
|
||||
}
|
||||
}
|
||||
|
||||
float analogin_read(analogin_t *obj)
|
||||
{
|
||||
uint16_t value = analogin_read_u16(obj);
|
||||
return (float)value * (1.0f / (float)ADC_RANGE);
|
||||
}
|
||||
|
||||
#endif // DEVICE_ANALOGIN
|
|
@ -1,399 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, must reproduce
|
||||
* the above copyright notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mbed_assert.h"
|
||||
#include "mbed_error.h"
|
||||
#include "pwmout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
#if DEVICE_PWMOUT
|
||||
|
||||
#include "app_util_platform.h"
|
||||
#include "nrf_drv_pwm.h"
|
||||
|
||||
#define MAX_PWM_COUNTERTOP (0x7FFF) // 0x7FFF is the max of COUNTERTOP value for the PWM peripherial of the nRF52.
|
||||
#define MAX_PWM_PERIOD_US (MAX_PWM_COUNTERTOP * 8) // PWM hw is driven by 16 MHz clock, hence the tick is 1_us/16,
|
||||
// and 128 is the max prescaler value.
|
||||
#define MAX_PWM_PERIOD_MS ((MAX_PWM_PERIOD_US / 1000) + 1) // approximations advance
|
||||
#define MAX_PWM_PERIOD_S ((MAX_PWM_PERIOD_US / 1000000) + 1) // approximations advance
|
||||
|
||||
|
||||
#define PWM_INSTANCE_COUNT (PWM_COUNT) // import from the nrf_drv_config.h file
|
||||
|
||||
///> instances of nRF52 PWM driver
|
||||
static const nrf_drv_pwm_t m_pwm_driver[PWM_INSTANCE_COUNT] =
|
||||
{
|
||||
#if PWM0_ENABLED
|
||||
NRF_DRV_PWM_INSTANCE(0),
|
||||
#endif
|
||||
#if PWM1_ENABLED
|
||||
NRF_DRV_PWM_INSTANCE(1),
|
||||
#endif
|
||||
#if PWM2_ENABLED
|
||||
NRF_DRV_PWM_INSTANCE(2)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t period_us;
|
||||
uint32_t duty_us;
|
||||
float duty;
|
||||
} pwm_signal_t; /// PWM signal description type
|
||||
|
||||
typedef struct
|
||||
{
|
||||
nrf_drv_pwm_t * p_pwm_driver;
|
||||
pwm_signal_t signal;
|
||||
volatile nrf_pwm_values_common_t seq_values[1];
|
||||
} pwm_t; /// internal PWM instance support type
|
||||
|
||||
static pwm_t m_pwm[PWM_INSTANCE_COUNT] =
|
||||
{
|
||||
#if PWM0_ENABLED
|
||||
{.p_pwm_driver = NULL},
|
||||
#endif
|
||||
#if PWM1_ENABLED
|
||||
{.p_pwm_driver = NULL},
|
||||
#endif
|
||||
#if PWM2_ENABLED
|
||||
{.p_pwm_driver = NULL}
|
||||
#endif
|
||||
}; /// Array of internal PWM instances.
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t period_hwu; // unit related to pwm_clk
|
||||
uint16_t duty_hwu; // unit related to pwm_clk
|
||||
nrf_pwm_clk_t pwm_clk;
|
||||
} pulsewidth_set_t; /// helper type for timing calculations
|
||||
|
||||
|
||||
static void internal_pwmout_exe(pwmout_t *obj, bool new_period, bool initialization);
|
||||
|
||||
// extern PWM nIRQ handler implementations
|
||||
void PWM0_IRQHandler(void);
|
||||
void PWM1_IRQHandler(void);
|
||||
void PWM2_IRQHandler(void);
|
||||
|
||||
static const peripheral_handler_desc_t pwm_handlers[PWM_INSTANCE_COUNT] =
|
||||
{
|
||||
{
|
||||
PWM0_IRQn,
|
||||
(uint32_t)PWM0_IRQHandler
|
||||
},
|
||||
{
|
||||
PWM1_IRQn,
|
||||
(uint32_t)PWM1_IRQHandler
|
||||
},
|
||||
{
|
||||
PWM2_IRQn,
|
||||
(uint32_t)PWM2_IRQHandler
|
||||
}
|
||||
};
|
||||
|
||||
void pwmout_init(pwmout_t *obj, PinName pin)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; PWM_INSTANCE_COUNT; i++)
|
||||
{
|
||||
if (m_pwm[i].p_pwm_driver == NULL) // a driver instance not assigned to the obj?
|
||||
{
|
||||
NVIC_SetVector(pwm_handlers[i].IRQn, pwm_handlers[i].vector);
|
||||
|
||||
obj->pin = pin;
|
||||
|
||||
obj->pwm_channel = i;
|
||||
|
||||
m_pwm[i].p_pwm_driver = (nrf_drv_pwm_t *) &m_pwm_driver[i];
|
||||
m_pwm[i].signal.period_us = 200000; // 0.02 s
|
||||
m_pwm[i].signal.duty_us = 100000;
|
||||
m_pwm[i].signal.duty = 0.5f;
|
||||
|
||||
obj->pwm_struct = &m_pwm[i];
|
||||
|
||||
internal_pwmout_exe(obj, true, true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MBED_ASSERT(i != PWM_INSTANCE_COUNT); // assert if free instance was not found.
|
||||
}
|
||||
|
||||
void pwmout_free(pwmout_t *obj)
|
||||
{
|
||||
nrf_drv_pwm_uninit( (nrf_drv_pwm_t*) obj->pwm_struct );
|
||||
|
||||
m_pwm[obj->pwm_channel].p_pwm_driver = NULL;
|
||||
}
|
||||
|
||||
void pwmout_write(pwmout_t *obj, float percent)
|
||||
{
|
||||
|
||||
if (percent < 0)
|
||||
{
|
||||
percent = 0;
|
||||
}
|
||||
else if (percent > 1)
|
||||
{
|
||||
percent = 1;
|
||||
}
|
||||
|
||||
pwm_signal_t * p_pwm_signal = &(((pwm_t*)obj->pwm_struct)->signal);
|
||||
|
||||
p_pwm_signal->duty = percent;
|
||||
|
||||
int us = (((int)p_pwm_signal->period_us) * percent);
|
||||
|
||||
pwmout_pulsewidth_us(obj, us);
|
||||
}
|
||||
|
||||
float pwmout_read(pwmout_t *obj)
|
||||
{
|
||||
pwm_signal_t * p_pwm_signal = &(((pwm_t*)obj->pwm_struct)->signal);
|
||||
|
||||
return (float)p_pwm_signal->duty_us / (float)p_pwm_signal->period_us;
|
||||
}
|
||||
|
||||
void pwmout_period(pwmout_t *obj, float seconds)
|
||||
{
|
||||
// raught saturation < 0, quasi-max>
|
||||
if (seconds > MAX_PWM_PERIOD_S)
|
||||
{
|
||||
seconds = MAX_PWM_PERIOD_S;
|
||||
}
|
||||
else if (seconds < 0)
|
||||
{
|
||||
seconds = 0; // f. pwmout_period_us will set period to min. value
|
||||
}
|
||||
|
||||
int us = seconds * 1000000;
|
||||
|
||||
pwmout_period_us(obj, us);
|
||||
}
|
||||
|
||||
void pwmout_period_ms(pwmout_t *obj, int ms)
|
||||
{
|
||||
// reught saturation < 0, quasi-max>
|
||||
if (ms > MAX_PWM_PERIOD_MS)
|
||||
{
|
||||
ms = MAX_PWM_PERIOD_MS;
|
||||
}
|
||||
else if (ms < 0)
|
||||
{
|
||||
ms = 0; // f. pwmout_period_us will set period to min. value
|
||||
}
|
||||
|
||||
int us = ms * 1000;
|
||||
|
||||
pwmout_period_us(obj, us);
|
||||
}
|
||||
|
||||
|
||||
void pwmout_period_us(pwmout_t *obj, int us)
|
||||
{
|
||||
pwm_signal_t * p_pwm_signal = &(((pwm_t*)obj->pwm_struct)->signal);
|
||||
|
||||
// saturation <1, real-max>
|
||||
if (us > MAX_PWM_PERIOD_US)
|
||||
{
|
||||
us = MAX_PWM_PERIOD_US;
|
||||
}
|
||||
else if (us < 1)
|
||||
{
|
||||
us = 1;
|
||||
}
|
||||
|
||||
p_pwm_signal->duty_us = (int)((float)us * p_pwm_signal->duty);
|
||||
|
||||
p_pwm_signal->period_us = us;
|
||||
|
||||
internal_pwmout_exe(obj, true, false);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth(pwmout_t *obj, float seconds)
|
||||
{
|
||||
// raught saturation < 0, quasi-max>
|
||||
if (seconds > MAX_PWM_PERIOD_S)
|
||||
{
|
||||
seconds = MAX_PWM_PERIOD_S;
|
||||
}
|
||||
else if (seconds < 0)
|
||||
{
|
||||
seconds = 0;
|
||||
}
|
||||
|
||||
int us = seconds * 1000000;
|
||||
|
||||
pwmout_pulsewidth_us(obj,us);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth_ms(pwmout_t *obj, int ms)
|
||||
{
|
||||
// raught saturation < 0, quasi-max>
|
||||
if (ms > MAX_PWM_PERIOD_MS)
|
||||
{
|
||||
ms = MAX_PWM_PERIOD_MS;
|
||||
}
|
||||
else if (ms < 0)
|
||||
{
|
||||
ms = 0;
|
||||
}
|
||||
|
||||
int us = ms * 1000;
|
||||
|
||||
pwmout_pulsewidth_us(obj, us);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth_us(pwmout_t *obj, int us)
|
||||
{
|
||||
// saturation <0, real-max>
|
||||
if (us > MAX_PWM_PERIOD_US)
|
||||
{
|
||||
us = MAX_PWM_PERIOD_US;
|
||||
}
|
||||
else if (us < 0)
|
||||
{
|
||||
us = 0;
|
||||
}
|
||||
|
||||
pwm_signal_t * p_pwm_signal = &(((pwm_t*)obj->pwm_struct)->signal);
|
||||
|
||||
p_pwm_signal->duty_us = us;
|
||||
p_pwm_signal->duty = us / p_pwm_signal->period_us;
|
||||
|
||||
internal_pwmout_exe(obj, false, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static ret_code_t pulsewidth_us_set_get(int period_hwu, int duty_hwu, pulsewidth_set_t * p_settings)
|
||||
{
|
||||
uint16_t div;
|
||||
nrf_pwm_clk_t pwm_clk = NRF_PWM_CLK_16MHz;
|
||||
|
||||
for(div = 1; div <= 128 ; div <<= 1) // 128 is the maximum of clock prescaler for PWM peripherial
|
||||
{
|
||||
if (MAX_PWM_COUNTERTOP >= period_hwu)
|
||||
{
|
||||
p_settings->period_hwu = period_hwu; // unit [us/16 * div]
|
||||
p_settings->duty_hwu = duty_hwu; // unit [us/16 * div]
|
||||
p_settings->pwm_clk = pwm_clk;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
period_hwu >>= 1;
|
||||
duty_hwu >>= 1;
|
||||
pwm_clk++;
|
||||
}
|
||||
|
||||
return NRF_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
|
||||
static void internal_pwmout_exe(pwmout_t *obj, bool new_period, bool initialization)
|
||||
{
|
||||
pulsewidth_set_t pulsewidth_set;
|
||||
pwm_signal_t * p_pwm_signal;
|
||||
nrf_drv_pwm_t * p_pwm_driver;
|
||||
ret_code_t ret_code;
|
||||
|
||||
p_pwm_signal = &(((pwm_t*)obj->pwm_struct)->signal);
|
||||
|
||||
if (NRF_SUCCESS == pulsewidth_us_set_get(p_pwm_signal->period_us * 16, // base clk for PWM is 16 MHz
|
||||
p_pwm_signal->duty_us * 16, // base clk for PWM is 16 MHz
|
||||
&pulsewidth_set))
|
||||
{
|
||||
p_pwm_driver = (((pwm_t*)obj->pwm_struct)->p_pwm_driver);
|
||||
|
||||
const nrf_pwm_sequence_t seq =
|
||||
{
|
||||
.values.p_common = (nrf_pwm_values_common_t*) (((pwm_t*)obj->pwm_struct)->seq_values),
|
||||
.length = 1,
|
||||
.repeats = 0,
|
||||
.end_delay = 0
|
||||
};
|
||||
|
||||
(((pwm_t*)obj->pwm_struct)->seq_values)[0] = pulsewidth_set.duty_hwu | 0x8000;
|
||||
|
||||
if (new_period)
|
||||
{
|
||||
nrf_drv_pwm_config_t config0 =
|
||||
{
|
||||
.output_pins =
|
||||
{
|
||||
obj->pin | NRF_DRV_PWM_PIN_INVERTED, // channel 0
|
||||
NRF_DRV_PWM_PIN_NOT_USED, // channel 1
|
||||
NRF_DRV_PWM_PIN_NOT_USED, // channel 2
|
||||
NRF_DRV_PWM_PIN_NOT_USED, // channel 3
|
||||
},
|
||||
.irq_priority = PWM0_CONFIG_IRQ_PRIORITY,
|
||||
.base_clock = pulsewidth_set.pwm_clk,
|
||||
.count_mode = NRF_PWM_MODE_UP,
|
||||
.top_value = pulsewidth_set.period_hwu,
|
||||
.load_mode = NRF_PWM_LOAD_COMMON,
|
||||
.step_mode = NRF_PWM_STEP_AUTO
|
||||
};
|
||||
|
||||
if (!initialization)
|
||||
{
|
||||
nrf_drv_pwm_uninit(p_pwm_driver);
|
||||
}
|
||||
|
||||
ret_code = nrf_drv_pwm_init( p_pwm_driver, &config0, NULL);
|
||||
|
||||
MBED_ASSERT(ret_code == NRF_SUCCESS); // assert if free instance was not found.
|
||||
}
|
||||
|
||||
nrf_drv_pwm_simple_playback(p_pwm_driver, &seq, 0, NRF_DRV_PWM_FLAG_LOOP);
|
||||
}
|
||||
else
|
||||
{
|
||||
MBED_ASSERT(0); // force assertion
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // DEVICE_PWMOUT
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef _SDK_CONFIG_H_
|
||||
#define _SDK_CONFIG_H_
|
||||
|
||||
#include "nrf_drv_config.h"
|
||||
|
||||
#define UART_DEFAULT_CONFIG_BAUDRATE UART0_CONFIG_BAUDRATE
|
||||
#define UART_DEFAULT_CONFIG_PARITY UART0_CONFIG_PARITY
|
||||
#define UART_DEFAULT_CONFIG_HWFC UART0_CONFIG_HWFC
|
||||
#define CTS_PIN_NUMBER UART0_CONFIG_PSEL_CTS
|
||||
#define RTS_PIN_NUMBER UART0_CONFIG_PSEL_RTS
|
||||
|
||||
#define SPIS_DEFAULT_ORC NRF_DRV_SPIS_DEFAULT_ORC
|
||||
#define SPIS_DEFAULT_CONFIG_IRQ_PRIORITY SPIS1_CONFIG_IRQ_PRIORITY;
|
||||
#define SPIS_DEFAULT_ORC NRF_DRV_SPIS_DEFAULT_ORC
|
||||
#define SPIS_DEFAULT_DEF NRF_DRV_SPIS_DEFAULT_DEF
|
||||
|
||||
#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY SPI1_CONFIG_IRQ_PRIORITY
|
||||
|
||||
#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY PWM0_CONFIG_IRQ_PRIORITY
|
||||
|
||||
#endif
|
|
@ -49,13 +49,13 @@
|
|||
#ifndef BLE_H__
|
||||
#define BLE_H__
|
||||
|
||||
#include "ble_ranges.h"
|
||||
#include "ble_types.h"
|
||||
#include "ble_gap.h"
|
||||
#include "ble_l2cap.h"
|
||||
#include "ble_gatt.h"
|
||||
#include "ble_gattc.h"
|
||||
#include "ble_gatts.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_gap.h"
|
||||
#include "nrf_ble_l2cap.h"
|
||||
#include "nrf_ble_gatt.h"
|
||||
#include "nrf_ble_gattc.h"
|
||||
#include "nrf_ble_gatts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
|
@ -45,8 +45,8 @@
|
|||
#ifndef BLE_GAP_H__
|
||||
#define BLE_GAP_H__
|
||||
|
||||
#include "ble_types.h"
|
||||
#include "ble_ranges.h"
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_svc.h"
|
||||
|
||||
#ifdef __cplusplus
|
|
@ -45,8 +45,8 @@
|
|||
#ifndef BLE_GATT_H__
|
||||
#define BLE_GATT_H__
|
||||
|
||||
#include "ble_types.h"
|
||||
#include "ble_ranges.h"
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
|
@ -45,9 +45,9 @@
|
|||
#ifndef BLE_GATTC_H__
|
||||
#define BLE_GATTC_H__
|
||||
|
||||
#include "ble_gatt.h"
|
||||
#include "ble_types.h"
|
||||
#include "ble_ranges.h"
|
||||
#include "nrf_ble_gatt.h"
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_svc.h"
|
||||
#include "nrf_error.h"
|
||||
#include "nrf.h"
|
|
@ -45,11 +45,11 @@
|
|||
#ifndef BLE_GATTS_H__
|
||||
#define BLE_GATTS_H__
|
||||
|
||||
#include "ble_types.h"
|
||||
#include "ble_ranges.h"
|
||||
#include "ble_l2cap.h"
|
||||
#include "ble_gap.h"
|
||||
#include "ble_gatt.h"
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_ble_l2cap.h"
|
||||
#include "nrf_ble_gap.h"
|
||||
#include "nrf_ble_gatt.h"
|
||||
#include "nrf_svc.h"
|
||||
|
||||
#ifdef __cplusplus
|
|
@ -45,9 +45,9 @@
|
|||
#ifndef BLE_L2CAP_H__
|
||||
#define BLE_L2CAP_H__
|
||||
|
||||
#include "ble_types.h"
|
||||
#include "ble_ranges.h"
|
||||
#include "ble_err.h"
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_ble_err.h"
|
||||
#include "nrf_svc.h"
|
||||
|
||||
#ifdef __cplusplus
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue