添加c变量,与c++保持一致

Signed-off-by: zhaoxu <xuzhaor@isoftstone.com>
This commit is contained in:
zhaoxu 2024-08-02 15:44:31 +08:00
parent 30b6247c62
commit a06d5ce978
4 changed files with 17 additions and 3 deletions

View File

@ -149,8 +149,8 @@ static bool GetHotspotconfigFromJs(const napi_env& env, const napi_value& object
value = 0;
JsObjectToInt(env, object, "leaseTime", value);
ClearJsLastException(env);
if (value < (int)DHCP_LEASE_TIME_MIN) {
value = (int)DHCP_LEASE_TIME;
if (value < static_cast<int>(DHCP_LEASE_TIME_MIN)) {
value = static_cast<int>(DHCP_LEASE_TIME);
}
config.SetLeaseTime(value);
return true;

View File

@ -106,6 +106,13 @@ static WifiErrorCode GetHotspotConfigFromC(const HotspotConfig *config, OHOS::Wi
return ERROR_WIFI_INVALID_ARGS;
}
hotspotConfig.SetIpAddress(config->ipAddress);
hotspotConfig.SetMaxConn(config->maxConn);
int value = config->leaseTime;
if (value < static_cast<int>(DHCP_LEASE_TIME_MIN)) {
value = static_cast<int>(DHCP_LEASE_TIME);
}
hotspotConfig.SetLeaseTime(value);
hotspotConfig.SetBandWidth(config->apBandWidth);
return WIFI_SUCCESS;
}

View File

@ -24,6 +24,7 @@ namespace OHOS {
namespace Wifi {
#define AP_CHANNEL_INVALID (-1)
#define AP_CHANNEL_DEFAULT 6
#define AP_MAX_CONN_DEFAULT (-1)
#define AP_CHANNEL_5G_DEFAULT 149
#define AP_CHANNEL_5G_NOT_RECOMMEND (165) // cannot group bandwidth of 40M or above
#define WIFI_BSSID_LENGTH 18
@ -78,7 +79,7 @@ struct HotspotConfig {
securityType = KeyMgmt::WPA2_PSK;
band = BandType::BAND_2GHZ;
channel = AP_CHANNEL_DEFAULT;
maxConn = -1;
maxConn = AP_MAX_CONN_DEFAULT;
leaseTime = DHCP_LEASE_TIME;
apBandWidth = AP_BANDWIDTH_DEFAULT;
}

View File

@ -97,6 +97,12 @@ typedef struct {
char preSharedKey[WIFI_MAX_KEY_LEN];
/* dhcp server ipv4 address */
char ipAddress[WIFI_MAX_IPV4_LEN];
/* maximum number of allowed connections */
int maxConn;
/* lease time */
int leaseTime;
/* band width */
int apBandWidth;
} HotspotConfig;
/**