mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-10-25 23:13:30 +00:00
Support for read and write suggested datalen cmds
This commit is contained in:
@@ -1889,17 +1889,57 @@ int ble_gap_update_params(uint16_t conn_handle,
|
||||
* Configure LE Data Length in controller (OGF = 0x08, OCF = 0x0022).
|
||||
*
|
||||
* @param conn_handle Connection handle.
|
||||
* @param tx_octets The preferred value of payload octets that the Controller
|
||||
* should use for a new connection (Range
|
||||
* 0x001B-0x00FB).
|
||||
* @param tx_time The preferred maximum number of microseconds that the local Controller
|
||||
* should use to transmit a single link layer packet
|
||||
* (Range 0x0148-0x4290).
|
||||
* @param tx_octets The preferred value of payload octets that the
|
||||
* Controller should use for a new connection
|
||||
* (Range 0x001B-0x00FB).
|
||||
* @param tx_time The preferred maximum number of microseconds that
|
||||
* the local Controller should use to transmit a single
|
||||
* link layer packet (Range 0x0148-0x4290).
|
||||
*
|
||||
* @return 0 on success,
|
||||
* other error code on failure.
|
||||
*/
|
||||
int ble_gap_set_data_len(uint16_t conn_handle, uint16_t tx_octets, uint16_t tx_time);
|
||||
int ble_gap_set_data_len(uint16_t conn_handle, uint16_t tx_octets,
|
||||
uint16_t tx_time);
|
||||
|
||||
/**
|
||||
* Read LE Suggested Default Data Length in controller
|
||||
* (OGF = 0x08, OCF = 0x0024).
|
||||
*
|
||||
* @param out_sugg_max_tx_octets The Host's suggested value for the
|
||||
* Controller's maximum transmitted number of
|
||||
* payload octets in LL Data PDUs to be used
|
||||
* for new connections. (Range 0x001B-0x00FB).
|
||||
* @param out_sugg_max_tx_time The Host's suggested value for the
|
||||
* Controller's maximum packet transmission
|
||||
* time for packets containing LL Data PDUs to
|
||||
* be used for new connections.
|
||||
* (Range 0x0148-0x4290).
|
||||
*
|
||||
* @return 0 on success,
|
||||
* other error code on failure.
|
||||
*/
|
||||
int ble_gap_read_sugg_def_data_len(uint16_t *out_sugg_max_tx_octets,
|
||||
uint16_t *out_sugg_max_tx_time);
|
||||
|
||||
/**
|
||||
* Configure LE Suggested Default Data Length in controller
|
||||
* (OGF = 0x08, OCF = 0x0024).
|
||||
*
|
||||
* @param sugg_max_tx_octets The Host's suggested value for the Controller's
|
||||
* maximum transmitted number of payload octets in
|
||||
* LL Data PDUs to be used for new connections.
|
||||
* (Range 0x001B-0x00FB).
|
||||
* @param sugg_max_tx_time The Host's suggested value for the Controller's
|
||||
* maximum packet transmission time for packets
|
||||
* containing LL Data PDUs to be used for new
|
||||
* connections. (Range 0x0148-0x4290).
|
||||
*
|
||||
* @return 0 on success,
|
||||
* other error code on failure.
|
||||
*/
|
||||
int ble_gap_write_sugg_def_data_len(uint16_t sugg_max_tx_octets,
|
||||
uint16_t sugg_max_tx_time);
|
||||
|
||||
/**
|
||||
* Initiates the GAP security procedure.
|
||||
|
||||
@@ -5590,14 +5590,32 @@ done:
|
||||
#endif
|
||||
}
|
||||
|
||||
int ble_gap_set_data_len(uint16_t conn_handle, uint16_t tx_octets, uint16_t tx_time)
|
||||
int
|
||||
ble_gap_set_data_len(uint16_t conn_handle, uint16_t tx_octets,
|
||||
uint16_t tx_time)
|
||||
{
|
||||
return ble_hs_hci_util_set_data_len(conn_handle, tx_octets, tx_time);
|
||||
}
|
||||
|
||||
int
|
||||
ble_gap_read_sugg_def_data_len(uint16_t *out_sugg_max_tx_octets,
|
||||
uint16_t *out_sugg_max_tx_time)
|
||||
{
|
||||
return ble_hs_hci_util_read_sugg_def_data_len(out_sugg_max_tx_octets,
|
||||
out_sugg_max_tx_time);
|
||||
}
|
||||
|
||||
int
|
||||
ble_gap_write_sugg_def_data_len(uint16_t sugg_max_tx_octets,
|
||||
uint16_t sugg_max_tx_time)
|
||||
{
|
||||
return ble_hs_hci_util_write_sugg_def_data_len(sugg_max_tx_octets,
|
||||
sugg_max_tx_time);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* $security *
|
||||
*****************************************************************************/
|
||||
* $security *
|
||||
*****************************************************************************/
|
||||
int
|
||||
ble_gap_security_initiate(uint16_t conn_handle)
|
||||
{
|
||||
|
||||
@@ -103,6 +103,10 @@ int ble_hs_hci_util_read_rssi(uint16_t conn_handle, int8_t *out_rssi);
|
||||
int ble_hs_hci_util_set_random_addr(const uint8_t *addr);
|
||||
int ble_hs_hci_util_set_data_len(uint16_t conn_handle, uint16_t tx_octets,
|
||||
uint16_t tx_time);
|
||||
int ble_hs_hci_util_read_sugg_def_data_len(uint16_t *out_sugg_max_tx_octets,
|
||||
uint16_t *out_sugg_max_tx_time);
|
||||
int ble_hs_hci_util_write_sugg_def_data_len(uint16_t sugg_max_tx_octets,
|
||||
uint16_t sugg_max_tx_time);
|
||||
int ble_hs_hci_util_data_hdr_strip(struct os_mbuf *om,
|
||||
struct hci_data_hdr *out_hdr);
|
||||
int ble_hs_hci_evt_process(struct ble_hci_ev *ev);
|
||||
|
||||
@@ -157,6 +157,62 @@ ble_hs_hci_util_set_data_len(uint16_t conn_handle, uint16_t tx_octets,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ble_hs_hci_util_read_sugg_def_data_len(uint16_t *out_sugg_max_tx_octets,
|
||||
uint16_t *out_sugg_max_tx_time)
|
||||
{
|
||||
struct ble_hci_le_rd_sugg_def_data_len_rp rsp;
|
||||
int rc;
|
||||
|
||||
rc = ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_LE,
|
||||
BLE_HCI_OCF_LE_RD_SUGG_DEF_DATA_LEN),
|
||||
NULL, 0, &rsp, sizeof(rsp));
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
*out_sugg_max_tx_octets = le16toh(rsp.max_tx_octets);
|
||||
*out_sugg_max_tx_time = le16toh(rsp.max_tx_time);
|
||||
|
||||
if (*out_sugg_max_tx_octets < BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MIN ||
|
||||
*out_sugg_max_tx_octets > BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MAX) {
|
||||
BLE_HS_LOG(WARN,
|
||||
"received suggested maximum tx octets is out of range\n");
|
||||
}
|
||||
|
||||
if (*out_sugg_max_tx_time < BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MIN ||
|
||||
*out_sugg_max_tx_time > BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MAX) {
|
||||
BLE_HS_LOG(WARN,
|
||||
"received suggested maximum tx time is out of range\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ble_hs_hci_util_write_sugg_def_data_len(uint16_t sugg_max_tx_octets,
|
||||
uint16_t sugg_max_tx_time)
|
||||
{
|
||||
struct ble_hci_le_wr_sugg_def_data_len_cp cmd;
|
||||
|
||||
if (sugg_max_tx_octets < BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MIN ||
|
||||
sugg_max_tx_octets > BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MAX) {
|
||||
return BLE_HS_EINVAL;
|
||||
}
|
||||
|
||||
if (sugg_max_tx_time < BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MIN ||
|
||||
sugg_max_tx_time > BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MAX) {
|
||||
return BLE_HS_EINVAL;
|
||||
}
|
||||
|
||||
cmd.max_tx_octets = htole16(sugg_max_tx_octets);
|
||||
cmd.max_tx_time = htole16(sugg_max_tx_time);
|
||||
|
||||
return ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_LE,
|
||||
BLE_HCI_OCF_LE_WR_SUGG_DEF_DATA_LEN),
|
||||
&cmd, sizeof(cmd), NULL, 0);
|
||||
}
|
||||
|
||||
int
|
||||
ble_hs_hci_util_data_hdr_strip(struct os_mbuf *om,
|
||||
struct hci_data_hdr *out_hdr)
|
||||
|
||||
@@ -1320,6 +1320,12 @@ struct ble_hci_le_set_transmit_power_report_enable_cp {
|
||||
#define BLE_HCI_SET_DATALEN_TX_TIME_MIN (0x0148)
|
||||
#define BLE_HCI_SET_DATALEN_TX_TIME_MAX (0x4290)
|
||||
|
||||
/* --- LE read/write suggested default data length (OCF 0x0023 and 0x0024) */
|
||||
#define BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MIN (0x001b)
|
||||
#define BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MAX (0x00fb)
|
||||
#define BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MIN (0x0148)
|
||||
#define BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MAX (0x4290)
|
||||
|
||||
/* --- LE read maximum default PHY (OCF 0x0030) */
|
||||
#define BLE_HCI_LE_PHY_1M (1)
|
||||
#define BLE_HCI_LE_PHY_2M (2)
|
||||
|
||||
Reference in New Issue
Block a user