!7053 feat:ble support 50 75 scan freq

Merge pull request !7053 from 咚咚/master
This commit is contained in:
openharmony_ci 2024-08-01 08:15:26 +00:00 committed by Gitee
commit 21e67c2e61
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
19 changed files with 282 additions and 30 deletions

View File

@ -351,6 +351,12 @@ int GetBtScanMode(uint16_t scanInterval, uint16_t scanWindow)
if (scanInterval == SOFTBUS_BC_SCAN_INTERVAL_P25 && scanWindow == SOFTBUS_BC_SCAN_WINDOW_P25) {
return OHOS_BLE_SCAN_MODE_OP_P25_60_240;
}
if (scanInterval == SOFTBUS_BC_SCAN_INTERVAL_P50 && scanWindow == SOFTBUS_BC_SCAN_WINDOW_P50) {
return OHOS_BLE_SCAN_MODE_OP_P50_30_60;
}
if (scanInterval == SOFTBUS_BC_SCAN_INTERVAL_P75 && scanWindow == SOFTBUS_BC_SCAN_WINDOW_P75) {
return OHOS_BLE_SCAN_MODE_OP_P75_30_40;
}
if (scanInterval == SOFTBUS_BC_SCAN_INTERVAL_P100 && scanWindow == SOFTBUS_BC_SCAN_WINDOW_P100) {
return OHOS_BLE_SCAN_MODE_OP_P100_1000_1000;
}

View File

@ -44,11 +44,15 @@ extern "C"{
#define SOFTBUS_BC_SCAN_INTERVAL_P2_FAST 1500
#define SOFTBUS_BC_SCAN_INTERVAL_P10 300
#define SOFTBUS_BC_SCAN_INTERVAL_P25 240
#define SOFTBUS_BC_SCAN_INTERVAL_P50 60
#define SOFTBUS_BC_SCAN_INTERVAL_P75 40
#define SOFTBUS_BC_SCAN_INTERVAL_P100 1000
#define SOFTBUS_BC_SCAN_WINDOW_P2 60
#define SOFTBUS_BC_SCAN_WINDOW_P2_FAST 30
#define SOFTBUS_BC_SCAN_WINDOW_P10 30
#define SOFTBUS_BC_SCAN_WINDOW_P25 60
#define SOFTBUS_BC_SCAN_WINDOW_P50 30
#define SOFTBUS_BC_SCAN_WINDOW_P75 30
#define SOFTBUS_BC_SCAN_WINDOW_P100 1000
/**

View File

@ -64,6 +64,8 @@ typedef enum {
SCAN_FREQ_P2_30_1500,
SCAN_FREQ_P10_30_300,
SCAN_FREQ_P25_60_240,
SCAN_FREQ_P50_30_60,
SCAN_FREQ_P75_30_40,
SCAN_FREQ_P100_1000_1000,
SCAN_FREQ_BUTT,
} ScanFreq;
@ -1058,6 +1060,14 @@ static void GetScanIntervalAndWindow(int32_t freq, SoftBusBcScanParams *adapterP
adapterParam->scanInterval = SOFTBUS_BC_SCAN_INTERVAL_P25;
adapterParam->scanWindow = SOFTBUS_BC_SCAN_WINDOW_P25;
}
if (freq == SCAN_FREQ_P50_30_60) {
adapterParam->scanInterval = SOFTBUS_BC_SCAN_INTERVAL_P50;
adapterParam->scanWindow = SOFTBUS_BC_SCAN_WINDOW_P50;
}
if (freq == SCAN_FREQ_P75_30_40) {
adapterParam->scanInterval = SOFTBUS_BC_SCAN_INTERVAL_P75;
adapterParam->scanWindow = SOFTBUS_BC_SCAN_WINDOW_P75;
}
if (freq == SCAN_FREQ_P100_1000_1000) {
adapterParam->scanInterval = SOFTBUS_BC_SCAN_INTERVAL_P100;
adapterParam->scanWindow = SOFTBUS_BC_SCAN_WINDOW_P100;
@ -1497,6 +1507,12 @@ static int32_t GetScanFreq(uint16_t scanInterval, uint16_t scanWindow)
if (scanInterval == SOFTBUS_BC_SCAN_INTERVAL_P25 && scanWindow == SOFTBUS_BC_SCAN_WINDOW_P25) {
return SCAN_FREQ_P25_60_240;
}
if (scanInterval == SOFTBUS_BC_SCAN_INTERVAL_P50 && scanWindow == SOFTBUS_BC_SCAN_WINDOW_P50) {
return SCAN_FREQ_P50_30_60;
}
if (scanInterval == SOFTBUS_BC_SCAN_INTERVAL_P75 && scanWindow == SOFTBUS_BC_SCAN_WINDOW_P75) {
return SCAN_FREQ_P75_30_40;
}
if (scanInterval == SOFTBUS_BC_SCAN_INTERVAL_P100 && scanWindow == SOFTBUS_BC_SCAN_WINDOW_P100) {
return SCAN_FREQ_P100_1000_1000;
}

View File

@ -61,6 +61,7 @@
#define DEFAULT_DISC_FREQ_MID ((5 << 16) | 24)
#define DEFAULT_DISC_FREQ_HIGH ((5 << 16) | 36)
#define DEFAULT_DISC_FREQ_SUPER_HIGH ((10 << 16) | 48)
#define DEFAULT_DISC_FREQ_EXTREME_HIGH ((10 << 16) | 48)
#define DEFAULT_DISC_COAP_MAX_DEVICE_NUM 20
#ifdef SOFTBUS_LINUX
@ -179,6 +180,7 @@ static DiscConfigItem g_discConfig = {
DEFAULT_DISC_FREQ_MID,
DEFAULT_DISC_FREQ_HIGH,
DEFAULT_DISC_FREQ_SUPER_HIGH,
DEFAULT_DISC_FREQ_EXTREME_HIGH,
},
.discCoapMaxDeviceNum = DEFAULT_DISC_COAP_MAX_DEVICE_NUM
};

View File

@ -158,6 +158,7 @@ static ScanSetting g_scanTable[FREQ_BUTT] = {
{SOFTBUS_BC_SCAN_WINDOW_P2, SOFTBUS_BC_SCAN_INTERVAL_P2},
{SOFTBUS_BC_SCAN_WINDOW_P10, SOFTBUS_BC_SCAN_INTERVAL_P10},
{SOFTBUS_BC_SCAN_WINDOW_P25, SOFTBUS_BC_SCAN_INTERVAL_P25},
{SOFTBUS_BC_SCAN_WINDOW_P75, SOFTBUS_BC_SCAN_INTERVAL_P75},
{SOFTBUS_BC_SCAN_WINDOW_P100, SOFTBUS_BC_SCAN_INTERVAL_P100}
};

View File

@ -398,7 +398,7 @@ static int32_t CheckPublishInfo(const PublishInfo *info)
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "mode is invalid");
DISC_CHECK_AND_RETURN_RET_LOGW(info->medium >= AUTO && info->medium <= COAP,
SOFTBUS_DISCOVER_MANAGER_INVALID_MEDIUM, DISC_CONTROL, "mode is invalid");
DISC_CHECK_AND_RETURN_RET_LOGW(info->freq >= LOW && info->freq <= SUPER_HIGH,
DISC_CHECK_AND_RETURN_RET_LOGW(info->freq >= LOW && info->freq < FREQ_BUTT,
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "freq is invalid");
if (info->capabilityData == NULL) {
@ -438,7 +438,7 @@ static int32_t CheckSubscribeInfo(const SubscribeInfo *info)
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "mode is invalid");
DISC_CHECK_AND_RETURN_RET_LOGW(info->medium >= AUTO && info->medium <= COAP,
SOFTBUS_DISCOVER_MANAGER_INVALID_MEDIUM, DISC_CONTROL, "mode is invalid");
DISC_CHECK_AND_RETURN_RET_LOGW(info->freq >= LOW && info->freq <= SUPER_HIGH,
DISC_CHECK_AND_RETURN_RET_LOGW(info->freq >= LOW && info->freq < FREQ_BUTT,
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "freq is invalid");
if (info->capabilityData == NULL) {

View File

@ -340,6 +340,8 @@ typedef enum {
HIGH = 2,
/** Super-high */
SUPER_HIGH = 3,
/** Extreme-high */
EXTREME_HIGH = 4,
FREQ_BUTT
} ExchangeFreq;

View File

@ -82,7 +82,7 @@ static int32_t PublishInfoCheck(const PublishInfo *info)
LNN_LOGE(LNN_STATE, "medium is invalid");
return SOFTBUS_INVALID_PARAM;
}
if ((info->freq < LOW) || (info->freq > SUPER_HIGH)) {
if ((info->freq < LOW) || (info->freq >= FREQ_BUTT)) {
LNN_LOGE(LNN_STATE, "freq is invalid");
return SOFTBUS_INVALID_PARAM;
}
@ -116,7 +116,7 @@ static int32_t SubscribeInfoCheck(const SubscribeInfo *info)
LNN_LOGE(LNN_STATE, "medium is invalid");
return SOFTBUS_INVALID_PARAM;
}
if ((info->freq < LOW) || (info->freq > SUPER_HIGH)) {
if ((info->freq < LOW) || (info->freq >= FREQ_BUTT)) {
LNN_LOGE(LNN_STATE, "freq is invalid");
return SOFTBUS_INVALID_PARAM;
}

View File

@ -40,7 +40,7 @@ static int32_t PublishInfoCheck(const PublishInfo *info)
return SOFTBUS_INVALID_PARAM;
}
if ((info->freq < LOW) || (info->freq > SUPER_HIGH)) {
if ((info->freq < LOW) || (info->freq >= FREQ_BUTT)) {
DISC_LOGE(DISC_SDK, "freq is invalid");
return SOFTBUS_INVALID_PARAM;
}
@ -74,7 +74,7 @@ static int32_t SubscribeInfoCheck(const SubscribeInfo *info)
return SOFTBUS_INVALID_PARAM;
}
if ((info->freq < LOW) || (info->freq > SUPER_HIGH)) {
if ((info->freq < LOW) || (info->freq >= FREQ_BUTT)) {
DISC_LOGE(DISC_SDK, "freq is invalid");
return SOFTBUS_INVALID_PARAM;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -292,6 +292,12 @@ HWTEST_F(DiscNstackxAdapterTest, TestDiscCoapAdapterStartDisc002, TestSize.Level
ret = DiscCoapStopDiscovery();
EXPECT_EQ(ret, SOFTBUS_OK);
testOption.freq = EXTREME_HIGH;
ret = DiscCoapStartDiscovery(&testOption);
EXPECT_EQ(ret, SOFTBUS_NETWORK_NOT_FOUND);
ret = DiscCoapStopDiscovery();
EXPECT_EQ(ret, SOFTBUS_OK);
testOption.freq = LOW - 1;
ret = DiscCoapStartDiscovery(&testOption);
EXPECT_NE(ret, SOFTBUS_OK);

View File

@ -329,7 +329,7 @@ HWTEST_F(DiscManagerTest, DiscPublishTest002, TestSize.Level1)
TEST_ASSERT_TRUE(ret != 0);
testInfo.medium = COAP;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = DiscPublish(MODULE_LNN, &testInfo);
TEST_ASSERT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -441,6 +441,11 @@ void DiscPublishTestAbstract001(DiscModule module, PublishInfo *info)
TEST_ASSERT_TRUE(ret == 0);
DiscUnpublish(module, info->publishId);
info->freq = EXTREME_HIGH;
ret = DiscPublish(module, info);
TEST_ASSERT_TRUE(ret == 0);
DiscUnpublish(module, info->publishId);
info->freq = LOW;
DiscMgrDeinit();
}
@ -561,7 +566,7 @@ HWTEST_F(DiscManagerTest, DiscStartScanTest002, TestSize.Level1)
TEST_ASSERT_TRUE(ret != 0);
testInfo.medium = COAP;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = DiscStartScan(MODULE_LNN, &testInfo);
TEST_ASSERT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -728,7 +733,7 @@ HWTEST_F(DiscManagerTest, DiscStartAdvertiseTest002, TestSize.Level1)
TEST_ASSERT_TRUE(ret != 0);
testInfo.medium = COAP;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = DiscStartAdvertise(MODULE_LNN, &testInfo);
TEST_ASSERT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -874,6 +879,11 @@ void DiscStartAdvertiseTestAbstract002(DiscModule module, SubscribeInfo *info)
TEST_ASSERT_TRUE(ret == 0);
DiscStopAdvertise(MODULE_LNN, info->subscribeId);
info->freq = EXTREME_HIGH;
ret = DiscStartAdvertise(MODULE_LNN, info);
TEST_ASSERT_TRUE(ret == 0);
DiscStopAdvertise(MODULE_LNN, info->subscribeId);
info->freq = LOW;
DiscMgrDeinit();
}
@ -943,7 +953,7 @@ HWTEST_F(DiscManagerTest, DiscSubscribeTest002, TestSize.Level1)
TEST_ASSERT_TRUE(ret != 0);
testInfo.medium = COAP;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = DiscSubscribe(MODULE_LNN, &testInfo);
TEST_ASSERT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -1197,6 +1207,11 @@ void DiscUnpublishTestAbstract001(DiscModule module, PublishInfo *info)
ret = DiscUnpublish(module, info->publishId);
TEST_ASSERT_TRUE(ret == 0);
info->freq = EXTREME_HIGH;
DiscPublish(module, info);
ret = DiscUnpublish(module, info->publishId);
TEST_ASSERT_TRUE(ret == 0);
info->freq = LOW;
DiscMgrDeinit();
}
@ -1358,6 +1373,11 @@ void DiscStopAdvertiseTestAbstract001(DiscModule module, SubscribeInfo *info)
ret = DiscStopAdvertise(module, info->subscribeId);
TEST_ASSERT_TRUE(ret == 0);
info->freq = EXTREME_HIGH;
DiscStartAdvertise(module, info);
ret = DiscStopAdvertise(module, info->subscribeId);
TEST_ASSERT_TRUE(ret == 0);
info->freq = LOW;
DiscMgrDeinit();
}
@ -1441,7 +1461,7 @@ HWTEST_F(DiscManagerTest, PublishServiceTest002, TestSize.Level1)
TEST_ASSERT_TRUE(ret != 0);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = DiscPublishService("pkgname1", &testInfo);
TEST_ASSERT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -1631,6 +1651,11 @@ void PublishServiceTestAbstract001(PublishInfo *info)
TEST_ASSERT_TRUE(ret == 0);
DiscUnPublishService("pkgname1", info->publishId);
info->freq = EXTREME_HIGH;
ret = DiscPublishService("pkgname1", info);
TEST_ASSERT_TRUE(ret == 0);
DiscUnPublishService("pkgname1", info->publishId);
info->freq = LOW;
DiscMgrDeinit();
}
@ -1724,7 +1749,7 @@ HWTEST_F(DiscManagerTest, StartDiscoveryTest002, TestSize.Level1)
TEST_ASSERT_TRUE(ret != 0);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = DiscStartDiscovery("pkgname1", &testInfo, &g_subscribeCb);
TEST_ASSERT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -1867,6 +1892,11 @@ void StartDiscoveryTestAbstract001(SubscribeInfo *info)
TEST_ASSERT_TRUE(ret == 0);
DiscStopDiscovery("pkgname1", info->subscribeId);
info->freq = EXTREME_HIGH;
ret = DiscStartDiscovery("pkgname1", info, &g_subscribeCb);
TEST_ASSERT_TRUE(ret == 0);
DiscStopDiscovery("pkgname1", info->subscribeId);
DiscMgrDeinit();
}
@ -2005,6 +2035,11 @@ void UnPublishServiceTestAbstract001(PublishInfo *info)
ret = DiscUnPublishService("pkgname1", info->publishId);
TEST_ASSERT_TRUE(ret == 0);
info->freq = EXTREME_HIGH;
DiscPublishService("pkgname1", info);
ret = DiscUnPublishService("pkgname1", info->publishId);
TEST_ASSERT_TRUE(ret == 0);
DiscMgrDeinit();
}
@ -2155,6 +2190,11 @@ void StopDiscoveryTestAbstract001(SubscribeInfo *info)
ret = DiscStopDiscovery("pkgname1", info->subscribeId);
TEST_ASSERT_TRUE(ret == 0);
info->freq = EXTREME_HIGH;
DiscStartDiscovery("pkgname1", info, &g_subscribeCb);
ret = DiscStopDiscovery("pkgname1", info->subscribeId);
TEST_ASSERT_TRUE(ret == 0);
DiscMgrDeinit();
}

View File

@ -181,7 +181,7 @@ HWTEST_F(BusCenterSdkPublish, PublishLNNTest002, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = PublishLNN(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
@ -386,6 +386,12 @@ HWTEST_F(BusCenterSdkPublish, PublishLNNTest006, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
testInfo.freq = EXTREME_HIGH;
ret = PublishLNN(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/**
@ -432,6 +438,12 @@ HWTEST_F(BusCenterSdkPublish, PublishLNNTest007, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
testInfo.freq = EXTREME_HIGH;
ret = PublishLNN(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/**
@ -478,6 +490,12 @@ HWTEST_F(BusCenterSdkPublish, PublishLNNTest008, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
testInfo.freq = EXTREME_HIGH;
ret = PublishLNN(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/**
@ -524,6 +542,12 @@ HWTEST_F(BusCenterSdkPublish, PublishLNNTest009, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
testInfo.freq = EXTREME_HIGH;
ret = PublishLNN(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/**
@ -706,6 +730,11 @@ HWTEST_F(BusCenterSdkPublish, PublishLNNTest014, TestSize.Level1)
ret = PublishLNN(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
testInfo.freq = EXTREME_HIGH;
ret = PublishLNN(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
}
/**
@ -748,6 +777,11 @@ HWTEST_F(BusCenterSdkPublish, PublishLNNTest015, TestSize.Level1)
ret = PublishLNN(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
testInfo.freq = EXTREME_HIGH;
ret = PublishLNN(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, testInfo.publishId);
}
/**

View File

@ -156,7 +156,7 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest001, TestSize.Level1)
EXPECT_TRUE(ret != 0);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = RefreshLNN(TEST_PKG_NAME, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -213,7 +213,7 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest002, TestSize.Level1)
EXPECT_TRUE(ret != 0);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = RefreshLNN(TEST_PKG_NAME, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -270,7 +270,7 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest003, TestSize.Level1)
EXPECT_TRUE(ret != 0);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = RefreshLNN(PKG_NAME1, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -327,7 +327,7 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest004, TestSize.Level1)
EXPECT_TRUE(ret != 0);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = RefreshLNN(PKG_NAME1, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -384,7 +384,7 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest005, TestSize.Level1)
EXPECT_TRUE(ret != 0);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = RefreshLNN(PKG_NAME1, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -441,7 +441,7 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest006, TestSize.Level1)
EXPECT_TRUE(ret != 0);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = RefreshLNN(PKG_NAME1, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -498,7 +498,7 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest007, TestSize.Level1)
EXPECT_TRUE(ret != 0);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = RefreshLNN(PKG_NAME1, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -555,7 +555,7 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest008, TestSize.Level1)
EXPECT_TRUE(ret != 0);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = RefreshLNN(PKG_NAME1, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret != 0);
testInfo.freq = LOW;

View File

@ -182,6 +182,12 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest002, TestSize.Level1)
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == 0);
testInfo.freq = EXTREME_HIGH;
ret = RefreshLNN(g_pkgName, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == 0);
}
/**
@ -229,6 +235,12 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest003, TestSize.Level1)
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == 0);
testInfo.freq = EXTREME_HIGH;
ret = RefreshLNN(g_pkgName, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == 0);
}
/**
@ -360,6 +372,12 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest007, TestSize.Level1)
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == 0);
testInfo.freq = EXTREME_HIGH;
ret = RefreshLNN(g_pkgName, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == 0);
}
/**
@ -407,6 +425,12 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest008, TestSize.Level1)
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == 0);
testInfo.freq = EXTREME_HIGH;
ret = RefreshLNN(g_pkgName, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == 0);
}
/**
@ -451,7 +475,7 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest009, TestSize.Level1)
EXPECT_TRUE(ret != 0);
testInfo.mode = DISCOVER_MODE_ACTIVE;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = RefreshLNN(g_pkgName, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret != 0);
testInfo.freq = LOW;
@ -743,6 +767,11 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest018, TestSize.Level1)
ret = RefreshLNN(g_pkgName, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
testInfo.freq = EXTREME_HIGH;
ret = RefreshLNN(g_pkgName, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
}
/**
@ -786,6 +815,11 @@ HWTEST_F(BusCenterSdkRefresh, RefreshLNNTest019, TestSize.Level1)
ret = RefreshLNN(g_pkgName, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
testInfo.freq = EXTREME_HIGH;
ret = RefreshLNN(g_pkgName, &testInfo, &g_refreshCb1);
EXPECT_TRUE(ret == 0);
ret = StopRefreshLNN(g_pkgName, testInfo.subscribeId);
}
/**

View File

@ -394,7 +394,7 @@ HWTEST_F(BusCenterSdkTest, PublishLNNTest001, TestSize.Level0)
EXPECT_TRUE(ret != 0);
g_pInfo.mode = DISCOVER_MODE_ACTIVE;
g_pInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
g_pInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = PublishLNN(TEST_PKG_NAME, &g_pInfo, &g_publishCb);
EXPECT_TRUE(ret != 0);
g_pInfo.freq = LOW;
@ -480,7 +480,7 @@ HWTEST_F(BusCenterSdkTest, RefreshLNNTest001, TestSize.Level0)
EXPECT_TRUE(ret != 0);
g_sInfo.mode = DISCOVER_MODE_ACTIVE;
g_sInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
g_sInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = RefreshLNN(TEST_PKG_NAME, &g_sInfo, &g_refreshCb);
EXPECT_TRUE(ret != 0);
g_sInfo.freq = LOW;

View File

@ -19,6 +19,10 @@
#include <string>
#include "discovery_service.h"
#define MID_THRESHOLD (UINT8_MAX / FREQ_BUTT * 2)
#define HIGH_THRESHOLD (UINT8_MAX / FREQ_BUTT * 3)
#define SUPER_HIGH_THRESHOLD (UINT8_MAX / FREQ_BUTT * 4)
namespace OHOS {
static std::string TEST_PACKAGE_NAME = "TestPackageName";
@ -69,13 +73,16 @@ static ExchangeFreq GenerateFreq(uint8_t data)
if (data < UINT8_MAX / FREQ_BUTT) {
return LOW;
}
if (data < UINT8_MAX / FREQ_BUTT * 2) {
if (data < MID_THRESHOLD) {
return MID;
}
if (data < UINT8_MAX / FREQ_BUTT * 3) {
if (data < HIGH_THRESHOLD) {
return HIGH;
}
return SUPER_HIGH;
if (data < SUPER_HIGH_THRESHOLD) {
return SUPER_HIGH;
}
return EXTREME_HIGH;
}
static PublishInfo *GeneratePublishInfo(const uint8_t *data, size_t size)

View File

@ -190,6 +190,12 @@ HWTEST_F(DiscSdkAutoTest, PublishServiceTest001, TestSize.Level1)
EXPECT_TRUE(ret == SOFTBUS_OK);
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_TRUE(ret == SOFTBUS_OK);
testInfo.freq = EXTREME_HIGH;
ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
EXPECT_TRUE(ret == SOFTBUS_OK);
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_TRUE(ret == SOFTBUS_OK);
}
/**
@ -237,6 +243,12 @@ HWTEST_F(DiscSdkAutoTest, PublishServiceTest002, TestSize.Level1)
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
testInfo.freq = EXTREME_HIGH;
ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
}
/**
@ -332,6 +344,12 @@ HWTEST_F(DiscSdkAutoTest, PublishServiceTest005, TestSize.Level1)
EXPECT_TRUE(ret == SOFTBUS_OK);
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_TRUE(ret == SOFTBUS_OK);
testInfo.freq = EXTREME_HIGH;
ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
EXPECT_TRUE(ret == SOFTBUS_OK);
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_TRUE(ret == SOFTBUS_OK);
}
/**
@ -379,6 +397,12 @@ HWTEST_F(DiscSdkAutoTest, PublishServiceTest006, TestSize.Level1)
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
testInfo.freq = EXTREME_HIGH;
ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
}
/**
@ -540,6 +564,12 @@ HWTEST_F(DiscSdkAutoTest, StartDiscoveryTest001, TestSize.Level1)
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
testInfo.freq = EXTREME_HIGH;
ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
}
/**
@ -620,6 +650,12 @@ HWTEST_F(DiscSdkAutoTest, StartDiscoveryTest003, TestSize.Level1)
EXPECT_TRUE(ret == SOFTBUS_OK);
ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == SOFTBUS_OK);
testInfo.freq = EXTREME_HIGH;
ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
EXPECT_TRUE(ret == SOFTBUS_OK);
ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == SOFTBUS_OK);
}
/**
@ -804,6 +840,11 @@ HWTEST_F(DiscSdkAutoTest, UnPublishServiceTest004, TestSize.Level1)
PublishService(g_pkgName, &testInfo, &g_publishCb);
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
testInfo.freq = EXTREME_HIGH;
PublishService(g_pkgName, &testInfo, &g_publishCb);
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
}
/**
@ -845,6 +886,11 @@ HWTEST_F(DiscSdkAutoTest, UnPublishServiceTest005, TestSize.Level1)
PublishService(g_pkgName, &testInfo, &g_publishCb);
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_TRUE(ret == SOFTBUS_OK);
testInfo.freq = EXTREME_HIGH;
PublishService(g_pkgName, &testInfo, &g_publishCb);
ret = UnPublishService(g_pkgName, testInfo.publishId);
EXPECT_TRUE(ret == SOFTBUS_OK);
}
/**
@ -1027,6 +1073,11 @@ HWTEST_F(DiscSdkAutoTest, StopDiscoveryTest004, TestSize.Level1)
StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
testInfo.freq = EXTREME_HIGH;
StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
}
/**
@ -1069,6 +1120,11 @@ HWTEST_F(DiscSdkAutoTest, StopDiscoveryTest005, TestSize.Level1)
StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == SOFTBUS_OK);
testInfo.freq = EXTREME_HIGH;
StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
EXPECT_TRUE(ret == SOFTBUS_OK);
}
/**

View File

@ -232,7 +232,7 @@ HWTEST_F(DiscSdkTest, PublishLNNTest003, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
testInfo.medium = COAP;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = PublishLNN(g_pkgName, &testInfo, &g_publishCb);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
testInfo.freq = (ExchangeFreq)(LOW - 1);
@ -308,6 +308,12 @@ HWTEST_F(DiscSdkTest, PublishLNNTest005, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, g_publishInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
g_publishInfo.freq = EXTREME_HIGH;
ret = PublishLNN(g_pkgName, &g_publishInfo, &g_publishCb);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopPublishLNN(g_pkgName, g_publishInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/**
@ -347,6 +353,12 @@ HWTEST_F(DiscSdkTest, PublishLNNTest006, TestSize.Level1)
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
ret = StopPublishLNN(g_pkgName, g_publishInfo.publishId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
g_publishInfo.freq = EXTREME_HIGH;
ret = PublishLNN(g_pkgName, &g_publishInfo, &g_publishCb);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
ret = StopPublishLNN(g_pkgName, g_publishInfo.publishId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
}
/**
@ -507,7 +519,7 @@ HWTEST_F(DiscSdkTest, RefreshLNNTest003, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
testInfo.medium = COAP;
testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
testInfo.freq = (ExchangeFreq)(FREQ_BUTT);
ret = RefreshLNN(g_pkgName, &testInfo, &g_refreshCb);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
testInfo.freq = (ExchangeFreq)(LOW - 1);
@ -583,6 +595,12 @@ HWTEST_F(DiscSdkTest, RefreshLNNTest005, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopRefreshLNN(g_pkgName, g_subscribeInfo.subscribeId);
EXPECT_EQ(ret, SOFTBUS_OK);
g_subscribeInfo.freq = EXTREME_HIGH;
ret = RefreshLNN(g_pkgName, &g_subscribeInfo, &g_refreshCb);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = StopRefreshLNN(g_pkgName, g_subscribeInfo.subscribeId);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/**
@ -622,6 +640,12 @@ HWTEST_F(DiscSdkTest, RefreshLNNTest006, TestSize.Level1)
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
ret = StopRefreshLNN(g_pkgName, g_subscribeInfo.subscribeId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
g_subscribeInfo.freq = EXTREME_HIGH;
ret = RefreshLNN(g_pkgName, &g_subscribeInfo, &g_refreshCb);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
ret = StopRefreshLNN(g_pkgName, g_subscribeInfo.subscribeId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
}
/**
@ -794,6 +818,11 @@ HWTEST_F(DiscSdkTest, StopPublishLNNTest004, TestSize.Level1)
PublishLNN(g_pkgName, &g_publishInfo, &g_publishCb);
ret = StopPublishLNN(g_pkgName, g_publishInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
g_publishInfo.freq = EXTREME_HIGH;
PublishLNN(g_pkgName, &g_publishInfo, &g_publishCb);
ret = StopPublishLNN(g_pkgName, g_publishInfo.publishId);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/**
@ -829,6 +858,11 @@ HWTEST_F(DiscSdkTest, StopPublishLNNTest005, TestSize.Level1)
PublishLNN(g_pkgName, &g_publishInfo, &g_publishCb);
ret = StopPublishLNN(g_pkgName, g_publishInfo.publishId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
g_publishInfo.freq = EXTREME_HIGH;
PublishLNN(g_pkgName, &g_publishInfo, &g_publishCb);
ret = StopPublishLNN(g_pkgName, g_publishInfo.publishId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
}
/**
@ -917,6 +951,11 @@ HWTEST_F(DiscSdkTest, StopRefreshLNNTest004, TestSize.Level1)
RefreshLNN(g_pkgName, &g_subscribeInfo, &g_refreshCb);
ret = StopRefreshLNN(g_pkgName, g_subscribeInfo.subscribeId);
EXPECT_EQ(ret, SOFTBUS_OK);
g_subscribeInfo.freq = EXTREME_HIGH;
RefreshLNN(g_pkgName, &g_subscribeInfo, &g_refreshCb);
ret = StopRefreshLNN(g_pkgName, g_subscribeInfo.subscribeId);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/**
@ -952,6 +991,11 @@ HWTEST_F(DiscSdkTest, StopRefreshLNNTest005, TestSize.Level1)
RefreshLNN(g_pkgName, &g_subscribeInfo, &g_refreshCb);
ret = StopRefreshLNN(g_pkgName, g_subscribeInfo.subscribeId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
g_subscribeInfo.freq = EXTREME_HIGH;
RefreshLNN(g_pkgName, &g_subscribeInfo, &g_refreshCb);
ret = StopRefreshLNN(g_pkgName, g_subscribeInfo.subscribeId);
EXPECT_EQ(isBtOn, (ret == SOFTBUS_OK));
}
/**