implement #80, add requestPHY/getPHY support
update prph and central throuhgput example.
This commit is contained in:
1 parent
4e95f95722
commit
cbcd9eb324
6 files changed
+179
-122
No files matched your search
@@ -779,7 +779,7 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
|
||||
uint16_t const conn_hdl = evt->evt.common_evt.conn_handle;
|
||||
BLEConnection* conn = this->Connection(conn_hdl);
|
||||
|
||||
LOG_LV1("BLE", "%s : Conn Handle = %d", dbg_ble_event_str(evt->header.evt_id), conn_hdl);
|
||||
LOG_LV2("BLE", "%s : Conn Handle = %d", dbg_ble_event_str(evt->header.evt_id), conn_hdl);
|
||||
|
||||
// GAP handler
|
||||
if ( conn ) conn->_eventHandler(evt);
|
||||
@@ -852,60 +852,6 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
|
||||
{
|
||||
ble_gap_data_length_params_t* param = &evt->evt.gap_evt.params.data_length_update_request.peer_params;
|
||||
(void) param;
|
||||
|
||||
LOG_LV2("GAP", "Data Length Req is (tx, rx) octets = (%d, %d), (tx, rx) time = (%d, %d) us",
|
||||
param->max_tx_octets, param->max_rx_octets, param->max_tx_time_us, param->max_rx_time_us);
|
||||
|
||||
// Let Softdevice decide the data length
|
||||
VERIFY_STATUS( sd_ble_gap_data_length_update(conn_hdl, NULL, NULL), );
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_DATA_LENGTH_UPDATE:
|
||||
{
|
||||
ble_gap_data_length_params_t* datalen = &evt->evt.gap_evt.params.data_length_update.effective_params;
|
||||
(void) datalen;
|
||||
|
||||
LOG_LV2("GAP", "Data Length is (tx, rx) octets = (%d, %d), (tx, rx) time = (%d, %d) us",
|
||||
datalen->max_tx_octets, datalen->max_rx_octets, datalen->max_tx_time_us, datalen->max_rx_time_us);
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
|
||||
{
|
||||
ble_gap_phys_t* req_phy = &evt->evt.gap_evt.params.phy_update_request.peer_preferred_phys;
|
||||
char const *phy_str[] = { "Auto", "1 Mbps", "2 Mbps", "Coded" };
|
||||
|
||||
(void) req_phy;
|
||||
(void) phy_str;
|
||||
LOG_LV1("GAP", "PHY request tx: %s, rx: %s", phy_str[req_phy->tx_phys], phy_str[req_phy->rx_phys]);
|
||||
|
||||
// Tell SoftDevice to choose PHY automatically
|
||||
ble_gap_phys_t phy = { BLE_GAP_PHY_AUTO, BLE_GAP_PHY_AUTO };
|
||||
(void) sd_ble_gap_phy_update(conn_hdl, &phy);
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_PHY_UPDATE:
|
||||
{
|
||||
ble_gap_evt_phy_update_t* active_phy = &evt->evt.gap_evt.params.phy_update;
|
||||
|
||||
if ( active_phy->status != BLE_HCI_STATUS_CODE_SUCCESS )
|
||||
{
|
||||
LOG_LV1("GAP", "Failed HCI status = 0x%02X", active_phy->status);
|
||||
}else
|
||||
{
|
||||
char const *phy_str[] = { "Auto", "1 Mbps", "2 Mbps", "Coded" };
|
||||
(void) phy_str;
|
||||
LOG_LV1("GAP", "PHY active tx: %s, rx: %s", phy_str[active_phy->tx_phy], phy_str[active_phy->rx_phy]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_EVT_USER_MEM_REQUEST:
|
||||
// We will handle Long Write sequence (RW Authorize PREP_WRITE_REQ)
|
||||
sd_ble_user_mem_reply(conn_hdl, NULL);
|
||||
|
||||
Reference in new issue
Block a user