nimble/ll: Cleanup a bit conn initialization

X-Original-Commit: 464b066fd76b2d50acd32e0bc66afa99441b3a0a
This commit is contained in:
Andrzej Kaczmarek
2018-02-05 14:21:41 +01:00
parent 32ba8b3eab
commit 869b5a89c3
+15 -18
View File
@@ -4133,6 +4133,13 @@ err_slave_start:
return 0;
}
#define MAX_TIME_UNCODED(_maxbytes) \
ble_ll_pdu_tx_time_get(_maxbytes + BLE_LL_DATA_MIC_LEN, \
BLE_PHY_MODE_1M);
#define MAX_TIME_CODED(_maxbytes) \
ble_ll_pdu_tx_time_get(_maxbytes + BLE_LL_DATA_MIC_LEN, \
BLE_PHY_MODE_CODED_125KBPS);
/**
* Called to reset the connection module. When this function is called the
* scheduler has been stopped and the phy has been disabled. The LL should
@@ -4174,42 +4181,32 @@ ble_ll_conn_module_reset(void)
}
/* Get the maximum supported PHY PDU size from the PHY */
max_phy_pyld = ble_phy_max_data_pdu_pyld();
/* Configure the global LL parameters */
conn_params = &g_ble_ll_conn_params;
max_phy_pyld = ble_phy_max_data_pdu_pyld();
/* NOTE: this all assumes that the default phy is 1Mbps */
maxbytes = min(MYNEWT_VAL(BLE_LL_SUPP_MAX_RX_BYTES), max_phy_pyld);
conn_params->supp_max_rx_octets = maxbytes;
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CODED_PHY)
conn_params->supp_max_rx_time =
ble_ll_pdu_tx_time_get(maxbytes + BLE_LL_DATA_MIC_LEN,
BLE_PHY_MODE_CODED_125KBPS);
conn_params->supp_max_rx_time = MAX_TIME_CODED(maxbytes);
#else
conn_params->supp_max_rx_time =
ble_ll_pdu_tx_time_get(maxbytes + BLE_LL_DATA_MIC_LEN, BLE_PHY_MODE_1M);
conn_params->supp_max_rx_time = MAX_TIME_UNCODED(maxbytes);
#endif
maxbytes = min(MYNEWT_VAL(BLE_LL_SUPP_MAX_TX_BYTES), max_phy_pyld);
conn_params->supp_max_tx_octets = maxbytes;
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CODED_PHY)
conn_params->supp_max_tx_time =
ble_ll_pdu_tx_time_get(maxbytes + BLE_LL_DATA_MIC_LEN,
BLE_PHY_MODE_CODED_125KBPS);
conn_params->supp_max_tx_time = MAX_TIME_CODED(maxbytes);
#else
conn_params->supp_max_tx_time =
ble_ll_pdu_tx_time_get(maxbytes + BLE_LL_DATA_MIC_LEN, BLE_PHY_MODE_1M);
conn_params->supp_max_tx_time = MAX_TIME_UNCODED(maxbytes);
#endif
maxbytes = min(MYNEWT_VAL(BLE_LL_CONN_INIT_MAX_TX_BYTES), max_phy_pyld);
conn_params->conn_init_max_tx_octets = maxbytes;
conn_params->conn_init_max_tx_time =
ble_ll_pdu_tx_time_get(maxbytes + BLE_LL_DATA_MIC_LEN, BLE_PHY_MODE_1M);
conn_params->conn_init_max_tx_time_uncoded =
ble_ll_pdu_tx_time_get(maxbytes + BLE_LL_DATA_MIC_LEN, BLE_PHY_MODE_1M);
conn_params->conn_init_max_tx_time_coded =
ble_ll_pdu_tx_time_get(maxbytes + BLE_LL_DATA_MIC_LEN, BLE_PHY_MODE_CODED_125KBPS);
conn_params->conn_init_max_tx_time = MAX_TIME_UNCODED(maxbytes);
conn_params->conn_init_max_tx_time_uncoded = MAX_TIME_UNCODED(maxbytes);
conn_params->conn_init_max_tx_time_coded = MAX_TIME_CODED(maxbytes);
conn_params->sugg_tx_octets = BLE_LL_CONN_SUPP_BYTES_MIN;
conn_params->sugg_tx_time = BLE_LL_CONN_SUPP_TIME_MIN;