Skip to content

Commit

Permalink
nimble/host: Set length correctly in periodic_set_adv_data
Browse files Browse the repository at this point in the history
   This change sets length field only if data is non NULL, else sets
   length to zero.
  • Loading branch information
rahult-github committed Jun 29, 2023
1 parent 326fb77 commit 898af6f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nimble/host/src/ble_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3711,9 +3711,12 @@ 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;
Expand All @@ -3730,11 +3733,14 @@ 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;

Expand Down

0 comments on commit 898af6f

Please sign in to comment.