Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of nRF51822 by
Revision 268:3a0047106213, committed 2015-06-19
- Comitter:
- rgrover1
- Date:
- Fri Jun 19 15:55:24 2015 +0100
- Parent:
- 267:b310cade274e
- Child:
- 269:9d7eb76bf65d
- Commit message:
- Synchronized with git rev 2ab53ac0
Author: Rohit Grover
nRF51Gap::connect() takes pointers instead of references.
Changed in this revision
| nRF51Gap.cpp | Show annotated file Show diff for this revision Revisions of this file |
| nRF51Gap.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/nRF51Gap.cpp Fri Jun 19 15:55:24 2015 +0100
+++ b/nRF51Gap.cpp Fri Jun 19 15:55:24 2015 +0100
@@ -206,30 +206,41 @@
return BLE_ERROR_NONE;
}
-ble_error_t nRF51Gap::connect(const Address_t peerAddr,
- Gap::AddressType_t peerAddrType,
- const GapScanningParams& scanParamsIn,
- const ConnectionParams_t& connectionParams)
+ble_error_t nRF51Gap::connect(const Address_t peerAddr,
+ Gap::AddressType_t peerAddrType,
+ const ConnectionParams_t *connectionParams,
+ const GapScanningParams *scanParamsIn)
{
ble_gap_addr_t addr;
addr.addr_type = peerAddrType;
memcpy(addr.addr, peerAddr, Gap::ADDR_LEN);
- ble_gap_scan_params_t scanParams = {
- .active = 0, /**< If 1, perform active scanning (scan requests). */
- .selective = 0, /**< If 1, ignore unknown devices (non whitelisted). */
- .p_whitelist = NULL, /**< Pointer to whitelist, NULL if none is given. */
- .interval = scanParamsIn.getInterval(), /**< Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
- .window = scanParamsIn.getWindow(), /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
- .timeout = scanParamsIn.getTimeout(), /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
- };
+ ble_gap_conn_params_t connParams;
+ if (connectionParams != NULL) {
+ connParams.min_conn_interval = connectionParams->minConnectionInterval;
+ connParams.max_conn_interval = connectionParams->maxConnectionInterval;
+ connParams.slave_latency = connectionParams->slaveLatency;
+ connParams.conn_sup_timeout = connectionParams->connectionSupervisionTimeout;
+ } else {
+ connParams.min_conn_interval = 50;
+ connParams.max_conn_interval = 1000;
+ connParams.slave_latency = 0;
+ connParams.conn_sup_timeout = 600;
+ }
- ble_gap_conn_params_t connParams = {
- .min_conn_interval = connectionParams.minConnectionInterval,
- .max_conn_interval = connectionParams.maxConnectionInterval,
- .slave_latency = connectionParams.slaveLatency,
- .conn_sup_timeout = connectionParams.connectionSupervisionTimeout,
- };
+ ble_gap_scan_params_t scanParams;
+ scanParams.active = 0; /**< If 1, perform active scanning (scan requests). */
+ scanParams.selective = 0; /**< If 1, ignore unknown devices (non whitelisted). */
+ scanParams.p_whitelist = NULL; /**< Pointer to whitelist, NULL if none is given. */
+ if (scanParamsIn != NULL) {
+ scanParams.interval = scanParamsIn->getInterval(); /**< Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
+ scanParams.window = scanParamsIn->getWindow(); /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
+ scanParams.timeout = scanParamsIn->getTimeout(); /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
+ } else {
+ scanParams.interval = 500; /**< Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
+ scanParams.window = 200; /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
+ scanParams.timeout = 0; /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
+ }
uint32_t rc = sd_ble_gap_connect(&addr, &scanParams, &connParams);
if (rc == NRF_SUCCESS) {
--- a/nRF51Gap.h Fri Jun 19 15:55:24 2015 +0100
+++ b/nRF51Gap.h Fri Jun 19 15:55:24 2015 +0100
@@ -51,7 +51,7 @@
virtual ble_error_t startAdvertising(const GapAdvertisingParams &);
virtual ble_error_t stopAdvertising(void);
- virtual ble_error_t connect(const Address_t, Gap::AddressType_t peerAddrType, const GapScanningParams &scanParams, const ConnectionParams_t& connectionParams);
+ virtual ble_error_t connect(const Address_t, Gap::AddressType_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams);
virtual ble_error_t disconnect(DisconnectionReason_t reason);
virtual ble_error_t purgeAllBondingState(void) {return btle_purgeAllBondingState();}
