Skip to content

nRF52840 USB Implementation #10526

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
64a1f04
Baseline legacy build using 14.2 drivers.
TacoGrandeTX Jun 26, 2018
0a46ae1
Mods for baseline 15.0 support
TacoGrandeTX Jun 26, 2018
2e7f7da
Bringing in Softdevice but excluding BLE feature and improvements in …
TacoGrandeTX Jul 9, 2018
7ff1008
First porting effort covered by JIRA IOTDEV-1572:
TacoGrandeTX Jul 26, 2018
a03f3fb
Ported analogin and pwm_out for IOTDEV-1573.
TacoGrandeTX Aug 8, 2018
61b3f21
Updates to PWM for IOTDEV-1573
TacoGrandeTX Aug 23, 2018
331f2de
serial_api: Fixes to compile with SDK15.0
Aug 19, 2018
96b9e29
serial_api: add changes to port from Softdevice 14.2 to 15.0
Aug 16, 2018
5ce7ac3
Nordic sdk_config: Configure UART instances
Aug 24, 2018
fa616c7
serial_api: Fix the interrupt registration for Nordic Serial Device
Aug 24, 2018
351c993
Updates for IOTDEV-1575 and nRF52_DK builds
TacoGrandeTX Sep 21, 2018
4d67cd1
Updates for IOTDEV-1576 (only TRNG API)
TacoGrandeTX Oct 5, 2018
577d7f7
NRF52: spi_api: port from Softdevice 14.2 to 15.0
Aug 14, 2018
9b3cafe
NRF52: i2c_api: port from Softdevice 14.2 to 15.0
Aug 13, 2018
01ad7ed
NRF: enable PRS (Peripheral Resource Sharing) for NRF52832 and NRF52840
Sep 28, 2018
3ed6022
NRF52832: enable UART
Sep 27, 2018
72127f7
nRF52832 needs NRFX_RNG_ENABLED to use the legacy driver
TacoGrandeTX Oct 8, 2018
296ba1b
nRF52_DK: Use mbed_lib.json to set app_offset (MBED_APP_START)
TacoGrandeTX Oct 16, 2018
92a24c4
NRF52: Fix vector table
Sep 26, 2018
132ce06
Updates after rebase with Mbed master (circa OS v5.10.1)
TacoGrandeTX Oct 16, 2018
402762f
Fix build for nRF51 (fewer common files with nRF52)
TacoGrandeTX Oct 22, 2018
b04e687
Remove dead #define PORT_SHIFT
TacoGrandeTX Oct 22, 2018
dcccf9a
Add missing SoftDevice build support (MBR, NONE, OTA)
Oct 29, 2018
ac960d2
Revert "NRF52: Fix vector table"
TacoGrandeTX Nov 14, 2018
34b4515
Cleanup for feature release
TacoGrandeTX Nov 15, 2018
318a1e3
Enabling NRFX_PPI_ENABLED for serial_api updates
TacoGrandeTX Dec 6, 2018
f540be8
Changes required for rebase:
TacoGrandeTX Dec 6, 2018
1789053
Set the PWM clock prescaler back to default (1MHz clock)
TacoGrandeTX Dec 6, 2018
b24c636
NRF52: serial: fix build warnings
Dec 7, 2018
b1ec3f6
NRF52: Cleanup unused code
Dec 7, 2018
de20cc0
Fix timer1 irq configuration
desmond-blue Dec 13, 2018
3ebad3d
Update BLE SoftDevice from SDK14 to SDK15
desmond-blue Dec 9, 2018
48d4071
Fix SoftDevice configuration on NRF52_DK
desmond-blue Dec 14, 2018
4d4ae26
Remove duplicate file
TacoGrandeTX Dec 18, 2018
fcb3b9f
Remove RTC from nRF52840_DK and DELTA_DFCM_NNN50 (was testing)
TacoGrandeTX Dec 18, 2018
5273f8a
Update file header at TARGET_NRF52 level
TacoGrandeTX Dec 19, 2018
ce99981
Add BLE feature to mbed_lib.json of SoftDevice
desmond-blue Dec 19, 2018
63f594b
NRF52: reloc_vector_table: check the RTS pin settings in code
Jan 12, 2019
cf4856f
Fix nrf section iter macro check
desmond-blue Jan 24, 2019
05c62c0
Rebase to master in preparation for v5.12.0
TacoGrandeTX Mar 4, 2019
f8fc4d0
Update QSPI in the SDK to support long frame mode
TacoGrandeTX Mar 5, 2019
01765ff
Fix SOFTDEVICE_NONE builds and clean up
TacoGrandeTX Mar 5, 2019
5f0c77c
Fix preprocessor conditionals for AC6 build
TacoGrandeTX Mar 6, 2019
3e6d1c1
Fix dangling #endif from rebase
TacoGrandeTX Mar 7, 2019
57317e1
Remove redundant legacy files and definition of PACKED
TacoGrandeTX Mar 14, 2019
d2bada3
Fix targets.json for MTB_LAIRD_BL654
TacoGrandeTX Mar 15, 2019
a975a26
Merge pull request #10441 from j3hill/sdk15
0xc0170 Apr 29, 2019
644e12f
Configured sdk for enabling USB. Preliminary implementation of USB fo…
AGlass0fMilk Nov 12, 2018
b9d5ecf
Changed power handler to enable/start & disable/stop USBD driver in b…
AGlass0fMilk Nov 12, 2018
858f496
Changed driver to request hf and lf clock sources... not sure why USB…
AGlass0fMilk Nov 12, 2018
8d117ac
Added errata fixes (171, 187) from nRF SDK 15.2 that would prevent US…
AGlass0fMilk Nov 12, 2018
52cbdc6
working on making the mbed and nordic drivers compatible
AGlass0fMilk Nov 29, 2018
78b97c0
Non-working custom feeder. Modified nordic driver to disable automati…
AGlass0fMilk Dec 5, 2018
ba6067c
Added in triggers to synchronize control transfer stages with what th…
AGlass0fMilk Dec 6, 2018
9493eb5
Added EP0 stalls to setup event handler
AGlass0fMilk Dec 23, 2018
9ab2390
Removed disable from disconnect to see if it affects the success of t…
AGlass0fMilk Dec 27, 2018
f0d8a41
Reviewing functions. Added critical sections to some functions that a…
AGlass0fMilk Jan 10, 2019
f0e81e6
Fixed bug causing usb_control_stall_test to fail intermittently. Prep…
AGlass0fMilk Jan 15, 2019
c85f57e
Removed 0 max packet size assert for ISO endpoints. Ensured usbd_ep_a…
AGlass0fMilk Jan 19, 2019
adf4f61
Removed function call for SOF event -- frame counter is already inclu…
AGlass0fMilk Jan 19, 2019
69d89e2
Added code to ignore ZLP packets on the ISOOUT endpoint... not fixing…
AGlass0fMilk Jan 19, 2019
4aeb751
Changed a little formatting
AGlass0fMilk Jan 22, 2019
460fc03
Added data toggle clearing to removing endpoints. Reworked aborting e…
AGlass0fMilk Jan 30, 2019
a0ebe5e
Implemented USBPhyHw::unconfigure() as it was causing configuration c…
AGlass0fMilk Feb 2, 2019
4f90199
Added setup status enum and removed some old commented out code
AGlass0fMilk Feb 3, 2019
f3f50b9
Trying virtual status stage and generated interrupt
AGlass0fMilk Feb 9, 2019
2216ce9
Added simulated status stage interrupt
AGlass0fMilk Feb 22, 2019
86831f7
Added a return from the virtual status transfer software-triggered in…
AGlass0fMilk Feb 22, 2019
426f81e
Ignore events that happen when an endpoint is stalled/halted
AGlass0fMilk Feb 22, 2019
746fe87
Added in flag for preventing double IRQ triggering and added asserts …
AGlass0fMilk Feb 25, 2019
35b65f9
Removed unnecessary logic and changed round robin DMA scheduling
AGlass0fMilk Mar 12, 2019
497b95d
Added workaround for "unloading" IN endpoints after unstalling. Disab…
AGlass0fMilk Mar 14, 2019
707e3a7
Removed redundant virtual status transfer notifications.
AGlass0fMilk Mar 14, 2019
2f26982
Fixing compatibilities with new nrfx drivers
AGlass0fMilk Mar 15, 2019
91b7deb
Finished compatibility changes for nrfx renaming
AGlass0fMilk Mar 15, 2019
94e5669
Fixed IRQ_ENABLE call to IRQ_DISABLE (oops).
AGlass0fMilk Mar 15, 2019
f74bdaa
Fixed some comments
AGlass0fMilk Mar 15, 2019
4ea3dce
Autoformatted with astyle
AGlass0fMilk Mar 15, 2019
16d1342
Lock sleep when USB is initialized
AGlass0fMilk Mar 15, 2019
c8c1709
Added in code to fix deepsleep underflow. Nullify event handler membe…
AGlass0fMilk Mar 16, 2019
745923e
Fixed failure on endpoint test data toggle reset (under Windows): "Da…
AGlass0fMilk Mar 27, 2019
f0ac42d
Changed formatting, check if endpoint is stalled in unstall. Added er…
AGlass0fMilk May 2, 2019
cdb8514
Revert adding USB to STM32F407VG target
AGlass0fMilk May 2, 2019
e09b78f
Disabling systick
AGlass0fMilk May 2, 2019
0106b6d
Removing systick edit from sdk_config.h
AGlass0fMilk May 2, 2019
1ae4028
Astyle fixed USBPhy_Nordic.cpp
AGlass0fMilk May 2, 2019
1ce7660
Added spdx identifiers and fixed indentation in targets.json
AGlass0fMilk May 3, 2019
4637d07
Removed incorrect comment
AGlass0fMilk May 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ void btle_handler(const ble_evt_t *p_ble_evt)


#if (NRF_SD_BLE_API_VERSION >= 5)
#ifndef S140
// Handle PHY upgrade request
case BLE_GAP_EVT_PHY_UPDATE_REQUEST: {
gap.on_phy_update_request(
Expand Down Expand Up @@ -428,7 +427,7 @@ void btle_handler(const ble_evt_t *p_ble_evt)
}
break;
}
#endif

case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: {
Gap::Handle_t connection = p_ble_evt->evt.gap_evt.conn_handle;
const ble_gap_evt_conn_param_update_request_t *update_request =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ nRF5xGap::nRF5xGap() :
_connections_role()
{
m_connectionHandle = BLE_CONN_HANDLE_INVALID;
#if (NRF_SD_BLE_API_VERSION >= 6)
m_advHandle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
#endif
}
/**************************************************************************/
/*!
Expand Down Expand Up @@ -236,13 +239,37 @@ ble_error_t nRF5xGap::setAdvertisingData_(const GapAdvertisingData &advData, con
// }
//}

#if (NRF_SD_BLE_API_VERSION >= 6)
/* sd_ble_gap_adv_data_set has been decprecated */
if (m_advHandle != BLE_GAP_ADV_SET_HANDLE_NOT_SET) {
/* This is for updating advdata*/
ble_gap_adv_data_t adv_data = {0};
adv_data.adv_data.p_data = const_cast<uint8_t*>(advData.getPayload());
adv_data.adv_data.len = advData.getPayloadLen();
adv_data.scan_rsp_data.p_data = const_cast<uint8_t*>(scanResponse.getPayload());
adv_data.scan_rsp_data.len = scanResponse.getPayloadLen();

ASSERT_TRUE(ERROR_NONE ==
sd_ble_gap_adv_stop(m_advHandle),
BLE_ERROR_PARAM_OUT_OF_RANGE);

ASSERT_TRUE(ERROR_NONE ==
sd_ble_gap_adv_set_configure(&m_advHandle, &adv_data, NULL),
BLE_ERROR_PARAM_OUT_OF_RANGE);

ASSERT_TRUE(ERROR_NONE ==
sd_ble_gap_adv_start(m_advHandle, NRF_CONNECTION_TAG),
BLE_ERROR_PARAM_OUT_OF_RANGE);
}
#else
/* Send advertising data! */
ASSERT_TRUE(ERROR_NONE ==
sd_ble_gap_adv_data_set(advData.getPayload(),
advData.getPayloadLen(),
scanResponse.getPayload(),
scanResponse.getPayloadLen()),
BLE_ERROR_PARAM_OUT_OF_RANGE);
#endif

/* Make sure the GAP Service appearance value is aligned with the
*appearance from GapAdvertisingData */
Expand Down Expand Up @@ -373,14 +400,56 @@ ble_error_t nRF5xGap::startAdvertising_(const GapAdvertisingParams &params)

/* Start Advertising */

#if (NRF_SD_BLE_API_VERSION >= 6)

/* FIXME: Must be chanaged if extended paramters added into GapAdvertisingParams */
switch (params.getAdvertisingType()) {
case GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED:
adv_para.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
break;

case GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED:
adv_para.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED;
break;

case GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED:
adv_para.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED;
break;

case GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED:
adv_para.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
break;

default:
return BLE_ERROR_PARAM_OUT_OF_RANGE;
break;
}

adv_para.interval = params.getIntervalInADVUnits(); // advertising interval (in units of 0.625 ms)
adv_para.duration = params.getTimeout() * 100; // units have been changed from seconds to 10ms units.
memset(adv_para.channel_mask, 0, sizeof(adv_para.channel_mask));
adv_para.filter_policy = advertisingPolicyMode; // BLE_GAP_ADV_FP_ANY
adv_para.primary_phy = BLE_GAP_PHY_1MBPS; /* Use _preferred_tx_phys if validated */
adv_para.p_peer_addr = NULL;

m_adv_data.adv_data.p_data = const_cast<uint8_t*>(_advPayload.getPayload());
m_adv_data.adv_data.len = _advPayload.getPayloadLen();
m_adv_data.scan_rsp_data.p_data = const_cast<uint8_t*>(_scanResponse.getPayload());
m_adv_data.scan_rsp_data.len = _scanResponse.getPayloadLen();
#else
adv_para.type = params.getAdvertisingType();
adv_para.p_peer_addr = NULL; // Undirected advertisement
adv_para.fp = advertisingPolicyMode;
adv_para.interval = params.getIntervalInADVUnits(); // advertising interval (in units of 0.625 ms)
adv_para.timeout = params.getTimeout();
#endif

#if (NRF_SD_BLE_API_VERSION >= 5)

#if (NRF_SD_BLE_API_VERSION >= 6)
if ((err = sd_ble_gap_adv_set_configure(&m_advHandle, &m_adv_data, &adv_para) == ERROR_NONE)) {
err = sd_ble_gap_adv_start(m_advHandle, NRF_CONNECTION_TAG);
}
#elif (NRF_SD_BLE_API_VERSION == 5)
err = sd_ble_gap_adv_start(&adv_para, NRF_CONNECTION_TAG);
#else
err = sd_ble_gap_adv_start(&adv_para);
Expand Down Expand Up @@ -427,15 +496,29 @@ ble_error_t nRF5xGap::startRadioScan_(const GapScanningParams &scanningParams)
#else
/* For NRF_SD_BLE_API_VERSION >= 3 nRF5xGap::setWhitelist setups the whitelist. */

#if (NRF_SD_BLE_API_VERSION >= 6)
scanParams.filter_policy = scanningPolicyMode;
#else
scanParams.use_whitelist = scanningPolicyMode;
scanParams.adv_dir_report = 0;
#endif
#endif

#if (NRF_SD_BLE_API_VERSION >= 6)
scanParams.extended = 0;
memset(scanParams.channel_mask, 0, sizeof(scanParams.channel_mask));
scanParams.scan_phys = BLE_GAP_PHY_1MBPS; /* Use _preferred_rx_phys if validated */

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()*100; /**< Scan timeout between 0x0001 and 0xFFFF in 10 ms units, 0x0000 disables timeout. */
#else
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. */
#endif

if (_privacy_enabled) {
bool enable_resolution =
Expand All @@ -450,9 +533,20 @@ ble_error_t nRF5xGap::startRadioScan_(const GapScanningParams &scanningParams)
}
}

#if (NRF_SD_BLE_API_VERSION >= 6)
m_scan_buffer.p_data = m_raw_scan_buffer;
m_scan_buffer.len = sizeof(m_raw_scan_buffer);
m_resume_scanning = true;
//if (sd_ble_gap_scan_start(&scanParams, &m_scan_buffer) != NRF_SUCCESS) {
uint32_t res = sd_ble_gap_scan_start(&scanParams, &m_scan_buffer);
if (res != NRF_SUCCESS) {
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
#else
if (sd_ble_gap_scan_start(&scanParams) != NRF_SUCCESS) {
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
#endif

return BLE_ERROR_NONE;
}
Expand Down Expand Up @@ -485,7 +579,11 @@ ble_error_t nRF5xGap::stopScan_(void) {
ble_error_t nRF5xGap::stopAdvertising_(void)
{
/* Stop Advertising */
#if (NRF_SD_BLE_API_VERSION >= 6)
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_adv_stop(m_advHandle), BLE_ERROR_PARAM_OUT_OF_RANGE);
#else
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
#endif

state.advertising = 0;

Expand Down Expand Up @@ -631,8 +729,11 @@ ble_error_t nRF5xGap::connect(
}
#else
/* For NRF_SD_BLE_API_VERSION >= 3 nRF5xGap::setWhitelist setups the whitelist. */

#if (NRF_SD_BLE_API_VERSION >= 6)
scanParams.filter_policy |= (whitelistAddressesSize) ? 1 : 0;
#else
scanParams.use_whitelist = (whitelistAddressesSize) ? 1 : 0;
#endif

if (_privacy_enabled) {
bool enable_resolution =
Expand Down Expand Up @@ -661,6 +762,10 @@ ble_error_t nRF5xGap::connect(
scanParams.timeout = _scanningParams.getTimeout(); /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
}

#if NRF_SD_BLE_API_VERSION >= 6
m_resume_scanning = false;
#endif

#if NRF_SD_BLE_API_VERSION >= 5
uint32_t rc = sd_ble_gap_connect(addr_ptr, &scanParams, &connParams, NRF_CONNECTION_TAG);
#else
Expand Down Expand Up @@ -706,6 +811,9 @@ ble_error_t nRF5xGap::setPreferredPhys_(
uint8_t preferred_rx_phys = rxPhys? rxPhys->value() : 0;

#ifdef S140
#if (NRF_SD_BLE_API_VERSION) >= 6
/* Set _preferred_tx_phys and _preferred_rx_phys here, used when start advertising or scanning */
#else
ble_opt_t opt = { 0 };
opt.gap_opt.preferred_phys.tx_phys = preferred_tx_phys;
opt.gap_opt.preferred_phys.rx_phys = preferred_rx_phys;
Expand All @@ -726,7 +834,7 @@ ble_error_t nRF5xGap::setPreferredPhys_(
default:
return BLE_ERROR_UNSPECIFIED;
}

#endif
#endif

_preferred_tx_phys = preferred_tx_phys;
Expand All @@ -741,7 +849,7 @@ ble_error_t nRF5xGap::setPhy_(
const ble::phy_set_t* rxPhys,
CodedSymbolPerBit_t codedSymbol
) {
#ifdef S140
#if defined(S140) && ((NRF_SD_BLE_API_VERSION) < 6)
return BLE_ERROR_NOT_IMPLEMENTED;
#else
// TODO handle coded symbol once supported by the softdevice.
Expand Down Expand Up @@ -851,6 +959,9 @@ ble_error_t nRF5xGap::reset_(void)

/* Clear derived class members */
m_connectionHandle = BLE_CONN_HANDLE_INVALID;
#if (NRF_SD_BLE_API_VERSION >= 6)
m_advHandle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
#endif

/* Set the whitelist policy filter modes to IGNORE_WHITELIST */
advertisingPolicyMode = ADV_POLICY_IGNORE_WHITELIST;
Expand Down Expand Up @@ -1019,7 +1130,25 @@ ble_error_t nRF5xGap::getAppearance_(GapAdvertisingData::Appearance *appearanceP
ble_error_t nRF5xGap::setTxPower_(int8_t txPower)
{
unsigned rc;
#if (NRF_SD_BLE_API_VERSION >= 6)
/* FIXME: This has to change API for specified paramter */
uint16_t handle = 0;
rc = NRF_SUCCESS;
if ((handle = getConnectionHandle()) != BLE_CONN_HANDLE_INVALID) {
rc = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, handle, txPower);
}
if ((rc == NRF_SUCCESS) && (m_advHandle != BLE_GAP_ADV_SET_HANDLE_NOT_SET)) {
handle = (uint16_t)m_advHandle;
rc = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, handle, txPower);
}
if (rc == NRF_SUCCESS) {
rc = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_SCAN_INIT, 0 /* This is ingored for ROLE_SCAN_INIT*/, txPower);
}

if (rc != NRF_SUCCESS) {
#else
if ((rc = sd_ble_gap_tx_power_set(txPower)) != NRF_SUCCESS) {
#endif
switch (rc) {
case NRF_ERROR_BUSY:
return BLE_STACK_BUSY;
Expand Down Expand Up @@ -1564,6 +1693,34 @@ void nRF5xGap::on_advertising_packet(const ble_gap_evt_adv_report_t &evt) {
);
const uint8_t* peer_address = evt.peer_addr.addr;

#if (NRF_SD_BLE_API_VERSION >= 6)
GapAdvertisingParams::AdvertisingType_t type;
if (evt.type.connectable && !evt.type.directed) {
type = GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED;
} else if (evt.type.connectable && evt.type.directed) {
type = GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED;
} else if (evt.type.scannable && !evt.type.directed) {
type = GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED;
} else if (!evt.type.connectable && !evt.type.directed) {
type = GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED;
} else {
// wrong condition
}
processAdvertisementReport(
peer_address,
evt.rssi,
(evt.type.scan_response? 1 : 0),
type,
evt.data.len,
evt.data.p_data,
peer_addr_type
);

/* If no action for connecting, must call sd_ble_gap_scan_start() aging for resuming scanning */
if (m_resume_scanning) {
sd_ble_gap_scan_start(NULL, &m_scan_buffer);
}
#else
processAdvertisementReport(
peer_address,
evt.rssi,
Expand All @@ -1573,6 +1730,7 @@ void nRF5xGap::on_advertising_packet(const ble_gap_evt_adv_report_t &evt) {
evt.data,
peer_addr_type
);
#endif
}

ble_error_t nRF5xGap::get_role(ble::connection_handle_t connection, Role_t& role) {
Expand Down Expand Up @@ -1656,7 +1814,6 @@ void nRF5xGap::on_phy_update(
);
}

#ifndef S140
void nRF5xGap::on_phy_update_request(
Handle_t connection,
const ble_gap_evt_phy_update_request_t& evt
Expand All @@ -1676,7 +1833,6 @@ void nRF5xGap::on_phy_update_request(

sd_ble_gap_phy_update(connection, &phys);
}
#endif



Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,18 @@ class nRF5xGap :
void release_all_connections_role();

void on_phy_update(Handle_t connection, const ble_gap_evt_phy_update_t& evt);
// FIXME: remove guard when S140 updated
#ifndef S140
void on_phy_update_request(Handle_t connection, const ble_gap_evt_phy_update_request_t& evt);

#if (NRF_SD_BLE_API_VERSION) >= 6
uint8_t m_advHandle;
/*
Note: The advertising data must be kept alive in memory until advertising is terminated. Not doing so will lead to undefined behavior.
Note: Updating advertising data while advertising can only be done by providing new advertising data buffers.
*/
ble_gap_adv_data_t m_adv_data;
uint8_t m_raw_scan_buffer[BLE_GAP_SCAN_BUFFER_MIN];
ble_data_t m_scan_buffer;
bool m_resume_scanning; /* When the application receives a ble_gap_adv_report_t, it must now resume scanning by calling sd_ble_gap_scan_start() */
#endif

uint16_t m_connectionHandle;
Expand Down
Loading