My fork of X_NUCLEO_IDB0XA1
Fork of X_NUCLEO_IDB0XA1 by
Revision 272:4639da7705e1, committed 2016-09-15
- Comitter:
- Vincent Coubard
- Date:
- Thu Sep 15 10:51:34 2016 +0100
- Branch:
- 83c30f290087a6f5a503812f507492e725a3b717
- Parent:
- 271:7dc6261c33e5
- Child:
- 273:00205952d841
- Child:
- 276:a20f4cad1d61
- Commit message:
- Sync with 83c30f290087a6f5a503812f507492e725a3b717
2016-07-18 18:14:06+02:00: Andrea Palmieri
Implement updateConnectionParams
Signed-off-by: Andrea Palmieri <andrea.palmieri@st.com>
Changed in this revision
--- a/source/BlueNRGGap.cpp Thu Sep 15 10:51:33 2016 +0100 +++ b/source/BlueNRGGap.cpp Thu Sep 15 10:51:34 2016 +0100 @@ -765,9 +765,36 @@ /**************************************************************************/ ble_error_t BlueNRGGap::updateConnectionParams(Handle_t handle, const ConnectionParams_t *params) { - /* avoid compiler warnings about unused variables */ - (void) handle; - (void)params; + tBleStatus ret = BLE_STATUS_SUCCESS; + + if(gapRole == Gap::CENTRAL) { + ret = aci_gap_start_connection_update(handle, + params->minConnectionInterval, + params->maxConnectionInterval, + params->slaveLatency, + params->connectionSupervisionTimeout, + CONN_L1, CONN_L2); + } else { + ret = aci_l2cap_connection_parameter_update_request(handle, + params->minConnectionInterval, + params->maxConnectionInterval, + params->slaveLatency, + params->connectionSupervisionTimeout); + } + + if (BLE_STATUS_SUCCESS != ret){ + PRINTF("updateConnectionParams failed (ret=0x%x)!!\n\r", ret) ; + switch (ret) { + case ERR_INVALID_HCI_CMD_PARAMS: + case BLE_STATUS_INVALID_PARAMETER: + return BLE_ERROR_INVALID_PARAM; + case ERR_COMMAND_DISALLOWED: + case BLE_STATUS_NOT_ALLOWED: + return BLE_ERROR_OPERATION_NOT_PERMITTED; + default: + return BLE_ERROR_UNSPECIFIED; + } + } return BLE_ERROR_NONE; } @@ -1265,7 +1292,12 @@ { /* avoid compiler warnings about unused variables */ (void)connectionParams; - (void)scanParams; + + setScanParams(scanParams->getInterval(), + scanParams->getWindow(), + scanParams->getTimeout(), + scanParams->getActiveScanning() + ); // Save the peer address for(int i=0; i<BDADDR_SIZE; i++) { @@ -1382,4 +1414,9 @@ void BlueNRGGap::setConnectionInterval(uint16_t interval) { conn_min_interval = interval; conn_max_interval = interval; -} \ No newline at end of file +} + +void BlueNRGGap::setGapRole(Role_t role) +{ + gapRole = role; +}
--- a/source/platform/btle.cpp Thu Sep 15 10:51:33 2016 +0100 +++ b/source/platform/btle.cpp Thu Sep 15 10:51:34 2016 +0100 @@ -426,7 +426,7 @@ BlueNRGGap::getInstance().setConnectionHandle(cc->handle); BlueNRGGap::ConnectionParams_t connectionParams = { /* minConnectionInterval = */ cc->interval, - /* maxConnectionInterval = */ cc->interval, + /* maxConnectionInterval = */ cc->interval, /* slaveLatency = */ cc->latency, /* connectionSupervisionTimeout = */ cc->supervision_timeout }; @@ -459,7 +459,9 @@ role = Gap::PERIPHERAL; break; } - //PRINTF("EVT_LE_CONN_COMPLETE GAP role=%d\n", role); + + BlueNRGGap::getInstance().setGapRole(role); + BlueNRGGap::getInstance().processConnectionEvent(cc->handle, role, peerAddrType, @@ -638,6 +640,36 @@ } break; + case EVT_BLUE_L2CAP_CONN_UPD_REQ: + { + PRINTF("EVT_BLUE_L2CAP_CONN_UPD_REQ\r\n"); + evt_l2cap_conn_upd_req *evt = (evt_l2cap_conn_upd_req*)blue_evt->data; + if(bnrg_expansion_board == IDB05A1) { + // we assume the application accepts the request from the slave + aci_l2cap_connection_parameter_update_response_IDB05A1(evt->conn_handle, + evt->interval_min, + evt->interval_max, + evt->slave_latency, + evt->timeout_mult, + CONN_L1, CONN_L2, + evt->identifier, + 0x0000); + } + } + break; + + case EVT_BLUE_L2CAP_CONN_UPD_RESP: + { + PRINTF("EVT_BLUE_L2CAP_CONN_UPD_RESP\r\n"); + } + break; + + case EVT_LE_CONN_UPDATE_COMPLETE: + { + PRINTF("EVT_LE_CONN_UPDATE_COMPLETE\r\n"); + } + break; + case EVT_BLUE_GAP_DEVICE_FOUND: { evt_gap_device_found *pr = (evt_gap_device_found*)blue_evt->data;
--- a/x-nucleo-idb0xa1/BlueNRGGap.h Thu Sep 15 10:51:33 2016 +0100 +++ b/x-nucleo-idb0xa1/BlueNRGGap.h Thu Sep 15 10:51:34 2016 +0100 @@ -150,9 +150,11 @@ virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams); void setConnectionInterval(uint16_t interval); + void setGapRole(Role_t role); private: uint16_t m_connectionHandle; + Role_t gapRole; AddressType_t addr_type; Address_t _peerAddr; AddressType_t _peerAddrType;