From ebf9ec963d543f8442a3ef1f5200b2711c393d55 Mon Sep 17 00:00:00 2001 From: Paul Szczeanek Date: Tue, 9 Jun 2020 08:46:43 +0100 Subject: [PATCH] copy advertising data into the message --- .../TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.c | 4 ++-- .../TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.h | 4 ++-- .../TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv_ae.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.c b/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.c index b3431909a9..933092c0ee 100644 --- a/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.c +++ b/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.c @@ -155,14 +155,14 @@ void DmAdvSetData(uint8_t advHandle, uint8_t op, uint8_t location, uint8_t len, WSF_ASSERT((location == DM_DATA_LOC_SCAN) || (location == DM_DATA_LOC_ADV)); WSF_ASSERT(advHandle < DM_NUM_ADV_SETS); - if ((pMsg = WsfMsgAlloc(sizeof(dmAdvApiSetData_t))) != NULL) + if ((pMsg = WsfMsgAlloc(sizeof(dmAdvApiSetData_t) + len)) != NULL) { pMsg->hdr.event = DM_ADV_MSG_API_SET_DATA; pMsg->advHandle = advHandle; pMsg->op = op; pMsg->location = location; pMsg->len = len; - pMsg->pData = pData; + memcpy(pMsg->pData, pData, len); WsfMsgSend(dmCb.handlerId, pMsg); } } diff --git a/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.h b/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.h index 7fca43289a..d7d1ed1d9b 100644 --- a/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.h +++ b/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv.h @@ -106,7 +106,7 @@ typedef struct uint8_t op; uint8_t location; uint8_t len; - uint8_t *pData; + uint8_t pData[]; } dmAdvApiSetData_t; /* Data structure for DM_ADV_MSG_API_START */ @@ -156,7 +156,7 @@ typedef struct uint8_t advHandle; uint8_t op; uint8_t len; - uint8_t *pData; + uint8_t pData[]; } dmAdvPerApiSetData_t; /* Data structure for DM_ADV_PER_MSG_API_START */ diff --git a/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv_ae.c b/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv_ae.c index 635daf02f7..9f7c956740 100644 --- a/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv_ae.c +++ b/features/FEATURE_BLE/targets/TARGET_CORDIO/stack/ble-host/sources/stack/dm/dm_adv_ae.c @@ -1669,13 +1669,13 @@ void DmPerAdvSetData(uint8_t advHandle, uint8_t op, uint8_t len, uint8_t *pData) WSF_ASSERT(advHandle < DM_NUM_ADV_SETS); WSF_ASSERT(len <= HCI_PER_ADV_DATA_LEN); - if ((pMsg = WsfMsgAlloc(sizeof(dmAdvPerApiSetData_t))) != NULL) + if ((pMsg = WsfMsgAlloc(sizeof(dmAdvPerApiSetData_t) + len)) != NULL) { pMsg->hdr.event = DM_ADV_PER_MSG_API_SET_DATA; pMsg->advHandle = advHandle; pMsg->op = op; pMsg->len = len; - pMsg->pData = pData; + memcpy(pMsg->pData, pData, len); WsfMsgSend(dmCb.handlerId, pMsg); } }