mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-30 12:20:43 +00:00
add new function for send advData
Signed-off-by: wangjingen <wangjingen1@huawei.com>
This commit is contained in:
parent
b11204fe4b
commit
8e0d07455e
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user