You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2023/10/03 11:15:20 UTC
[mynewt-nimble] branch master updated: nimble/host: Set length correctly in periodic_set_adv_data
This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new 05dd20cc nimble/host: Set length correctly in periodic_set_adv_data
05dd20cc is described below
commit 05dd20cc4a0fca78f9a7b0bff9b10b4addd5b306
Author: Rahul Tank <ra...@espressif.com>
AuthorDate: Thu Jun 29 16:10:02 2023 +0530
nimble/host: Set length correctly in periodic_set_adv_data
This change sets length field only if data is non NULL, else sets
length to zero.
---
nimble/host/src/ble_gap.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 4736415a..6cf612db 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -3711,18 +3711,25 @@ ble_gap_periodic_adv_set(uint8_t instance, struct os_mbuf **data)
static uint8_t buf[sizeof(struct ble_hci_le_set_periodic_adv_data_cp) +
MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)];
struct ble_hci_le_set_periodic_adv_data_cp *cmd = (void *) buf;
- uint16_t len = OS_MBUF_PKTLEN(*data);
+ uint16_t len = 0;
uint16_t opcode;
+ if (*data) {
+ len = OS_MBUF_PKTLEN(*data);
+ }
+
opcode = BLE_HCI_OP(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_PERIODIC_ADV_DATA);
cmd->adv_handle = instance;
cmd->operation = BLE_HCI_LE_SET_DATA_OPER_COMPLETE;
cmd->adv_data_len = len;
- os_mbuf_copydata(*data, 0, len, cmd->adv_data);
- os_mbuf_adj(*data, len);
- *data = os_mbuf_trim_front(*data);
+ if (len) {
+ os_mbuf_copydata(*data, 0, len, cmd->adv_data);
+
+ os_mbuf_adj(*data, len);
+ *data = os_mbuf_trim_front(*data);
+ }
return ble_hs_hci_cmd_tx(opcode, cmd, sizeof(*cmd) + cmd->adv_data_len,
NULL, 0);
@@ -3730,11 +3737,15 @@ ble_gap_periodic_adv_set(uint8_t instance, struct os_mbuf **data)
static uint8_t buf[sizeof(struct ble_hci_le_set_periodic_adv_data_cp) +
BLE_HCI_MAX_PERIODIC_ADV_DATA_LEN];
struct ble_hci_le_set_periodic_adv_data_cp *cmd = (void *) buf;
- uint16_t len = OS_MBUF_PKTLEN(*data);
+ uint16_t len = 0;
uint16_t opcode;
uint8_t op;
int rc;
+ if (*data) {
+ len = OS_MBUF_PKTLEN(*data);
+ }
+
opcode = BLE_HCI_OP(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_PERIODIC_ADV_DATA);
cmd->adv_handle = instance;
@@ -3742,10 +3753,13 @@ ble_gap_periodic_adv_set(uint8_t instance, struct os_mbuf **data)
if (len <= BLE_HCI_MAX_PERIODIC_ADV_DATA_LEN) {
cmd->operation = BLE_HCI_LE_SET_DATA_OPER_COMPLETE;
cmd->adv_data_len = len;
- os_mbuf_copydata(*data, 0, len, cmd->adv_data);
- os_mbuf_adj(*data, len);
- *data = os_mbuf_trim_front(*data);
+ if (len) {
+ os_mbuf_copydata(*data, 0, len, cmd->adv_data);
+
+ os_mbuf_adj(*data, len);
+ *data = os_mbuf_trim_front(*data);
+ }
return ble_hs_hci_cmd_tx(opcode, cmd, sizeof(*cmd) + cmd->adv_data_len,
NULL, 0);