Bug:modify disc dfx and hilog

Signed-off-by: quyh <quyihao@huawei.com>
This commit is contained in:
quyh 2024-05-28 11:55:08 +08:00
parent 11a7e54023
commit cc35ef181c
3 changed files with 25 additions and 13 deletions

View File

@ -57,7 +57,6 @@ The DSoftBus directory structure is as follows:
>**NOTE**
>
>- The permissions ohos.permission.DISTRIBUTED_DATASYNC and ohos.permission.DISTRIBUTED_SOFTBUS_CENTER are required for remote procedure calls (RPCs) across devices.
>- To make a mobile phone visible to other devices, choose **Settings** > **Super Device** > **This device** > **Visible to**, and select **All nearby devices**.
**1. Discovery**
@ -74,14 +73,14 @@ The DSoftBus directory structure is as follows:
// Publish information.
typedef struct {
int publishId; // Publish ID.
DiscoverMode mode; // Discovery mode.
ExchangeMedium medium; // Medium used for device discovery.
ExchangeFreq freq; // Device discovery frequency.
const char *capability; // Capability of the device that can be discovered.
int publishId; // Publish ID.
DiscoverMode mode; // Publish mode.
ExchangeMedium medium; // Medium used for publishing the service.
ExchangeFreq freq; // Service publishing frequency.
const char *capability; // Capability of the device that can be discovered.
unsigned char *capabilityData; // Custom data for service publishing
unsigned int dataLen; // Length of the data.
bool ranging; // Whether to measure the distance.
unsigned int dataLen; // Length of the data.
bool ranging; // Whether to measure the distance.
} PublishInfo;
// Publish a service.

View File

@ -474,6 +474,16 @@ int32_t SoftbusRecordFirstDiscTime(SoftBusDiscMedium medium, uint64_t costTime)
return SOFTBUS_OK;
}
static inline uint32_t AddAndCheckOverflowUint32(uint32_t a, uint32_t b)
{
return (a > UINT32_MAX - b) ? UINT32_MAX : (a + b);
}
static inline uint64_t AddAndCheckOverflowUint64(uint64_t a, uint64_t b)
{
return (a > UINT64_MAX - b) ? UINT64_MAX : (a + b);
}
int32_t SoftbusRecordBleDiscDetails(char *moduleName, uint64_t duration, uint32_t repTimes, uint32_t devNum,
uint32_t discTimes)
{
@ -491,10 +501,11 @@ int32_t SoftbusRecordBleDiscDetails(char *moduleName, uint64_t duration, uint32_
return SOFTBUS_ERR;
}
}
discDetailNode->devNum += devNum;
discDetailNode->discTimes += discTimes;
discDetailNode->duration += duration;
discDetailNode->repTimes += repTimes;
discDetailNode->devNum = AddAndCheckOverflowUint32(discDetailNode->devNum, devNum);
discDetailNode->discTimes = AddAndCheckOverflowUint32(discDetailNode->discTimes, discTimes);
discDetailNode->duration = AddAndCheckOverflowUint64(discDetailNode->duration, duration);
discDetailNode->repTimes = AddAndCheckOverflowUint32(discDetailNode->repTimes, repTimes);
(void)SoftBusMutexUnlock(&g_discDetailLock);
return SOFTBUS_OK;
}

View File

@ -497,7 +497,9 @@ static void ProcessDisNonPacket(const BroadcastReportInfo *reportInfo, char rssi
add.medium = BLE;
if (ProcessHashAccount(foundInfo)) {
DISC_LOGI(DISC_BLE, "start report found device, callCount=%{public}u", callCount++);
DISC_LOGI(DISC_BLE, "start report found device, addrNum=%{public}u, addr[0].type=%{public}u,"
"capabilityBitmap=%{public}u, callCount=%{public}u", foundInfo->addrNum, foundInfo->addr[0].type,
foundInfo->capabilityBitmap[0], callCount++);
uint32_t tempCap = 0;
DeConvertBitMap(&tempCap, foundInfo->capabilityBitmap, foundInfo->capabilityBitmapNum);
if (tempCap == 0) {