add new function for send advData

Signed-off-by: wangjingen <wangjingen1@huawei.com>
This commit is contained in:
wangjingen 2022-11-24 17:56:15 +08:00
parent b11204fe4b
commit 8e0d07455e
2 changed files with 32 additions and 0 deletions

View File

@ -967,3 +967,33 @@ int SoftBusStopScan(int listenerId)
}
return SOFTBUS_ERR;
}
int SoftBusReplaceAdvertisingAdv(int advId, const SoftBusBleAdvData *data)
{
if (data == NULL) {
return SOFTBUS_INVALID_PARAM;
}
if (SoftBusMutexLock(&g_advLock) != 0) {
return SOFTBUS_LOCK_ERR;
}
if (!CheckAdvChannelInUsed(advId)) {
return SOFTBUS_ERR;
}
if (!g_advChannel[advId].isAdvertising) {
SoftBusLog(SOFTBUS_LOG_CONN, SOFTBUS_LOG_ERROR,
"SoftBusReplaceAdvertisingAdv failed: adv %d is not advertising", advId);
return SOFTBUS_LOG_ERROR;
}
int btAdvId = g_advChannel[advId].advId;
int ret = SetAdvData(advId, data);
SoftBusMutexUnlock(&g_advLock);
if (ret != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_CONN, SOFTBUS_LOG_ERROR,
"SoftBusReplaceAdvertisingAdv failed: SetAdvData failed, advId: %d, btadvId: %d", advId, btAdvId);
return SOFTBUS_LOG_ERROR;
}
StartAdvRawData advData = {0};
ConvertAdvData(data, &advData);
ret = BleOhosStatusToSoftBus(BleSetAdvData(btAdvId, advData));
return ret;
}

View File

@ -195,6 +195,8 @@ int SoftBusStopAdv(int advId);
int SoftBusUpdateAdv(int advId, const SoftBusBleAdvData *data, const SoftBusBleAdvParams *param);
int SoftBusReplaceAdvertisingAdv(int advId, const SoftBusBleAdvData *data);
#ifdef __cplusplus
#if __cplusplus
}