From db8d0d6eb1ab85d5ce7a836bfdf24990ac0e42df Mon Sep 17 00:00:00 2001 From: guoyuefeng0929 Date: Sun, 24 Jul 2022 19:00:21 -0700 Subject: [PATCH] adapter the wifi interface for 3566B Signed-off-by: guoyuefeng0929 --- .../component/WifiConnectedComponent.ets | 3 + .../ets/MainAbility/pages/WifiConnectPage.ets | 55 +++++++++++-------- .../main/resources/base/element/string.json | 2 +- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/FA/WiFiScanner/entry/src/main/ets/MainAbility/component/WifiConnectedComponent.ets b/FA/WiFiScanner/entry/src/main/ets/MainAbility/component/WifiConnectedComponent.ets index 52c82ce..91db890 100755 --- a/FA/WiFiScanner/entry/src/main/ets/MainAbility/component/WifiConnectedComponent.ets +++ b/FA/WiFiScanner/entry/src/main/ets/MainAbility/component/WifiConnectedComponent.ets @@ -35,6 +35,7 @@ export default struct WifiConnectedComponent { } if (result.ssid === "" || result.ssid === undefined) { this.linkedApInfo = undefined; + LogUtil.info('gyf scan get linked info succeed is null'); } else { this.linkedApInfo = result; LogUtil.info('gyf scan get linked info succeed ssid = ' + result.ssid); @@ -97,6 +98,7 @@ export default struct WifiConnectedComponent { Column() { Button('刷新数据').onClick(() => { + LogUtil.info('gyf refrash data button click!'); wifi.getLinkedInfo((err, result) => { if (err) { LogUtil.info('gyf get linked info failed'); @@ -104,6 +106,7 @@ export default struct WifiConnectedComponent { } if (result.ssid === "" || result.ssid === undefined) { this.linkedApInfo = undefined; + LogUtil.info('gyf scan get linked info succeed is null'); } else { this.linkedApInfo = result; LogUtil.info('gyf scan get linked info succeed ssid = ' + result.ssid); diff --git a/FA/WiFiScanner/entry/src/main/ets/MainAbility/pages/WifiConnectPage.ets b/FA/WiFiScanner/entry/src/main/ets/MainAbility/pages/WifiConnectPage.ets index 09acbb0..bd28828 100755 --- a/FA/WiFiScanner/entry/src/main/ets/MainAbility/pages/WifiConnectPage.ets +++ b/FA/WiFiScanner/entry/src/main/ets/MainAbility/pages/WifiConnectPage.ets @@ -100,15 +100,6 @@ struct WifiConnectPage { }) }); - Divider() - .color($r("sys.color.ohos_id_color_primary")) - .strokeWidth('1vp') - .opacity($r('sys.float.ohos_id_alpha_content_secondary')) - .padding({ - left: $r('sys.float.ohos_id_max_padding_start'), - right: $r('sys.float.ohos_id_max_padding_end') - }) - Row() { Row() { Button() { @@ -164,7 +155,7 @@ struct WifiConnectPage { } aboutToAppear(): void { - LogUtil.info('about to appear'); + LogUtil.info('about to appear WifiConnectPage'); let params = router.getParams(); if (typeof params === 'undefined' || params === null) { LogUtil.info('pass invalid params from other page'); @@ -174,13 +165,16 @@ struct WifiConnectPage { } // this.initTextInputHint(); this.isConnectedBefore = wifi.isConnected(); - if (this.isConnectedBefore) { - LogUtil.info('start task'); -// this.startLinkedInfoTask(); - } else { - LogUtil.info('start observer'); - this.registerObserver(); - } + + this.registerObserver(); + +// if (this.isConnectedBefore) { +// LogUtil.info('start task'); +//// this.startLinkedInfoTask(); +// } else { +// LogUtil.info('start observer'); +// this.registerObserver(); +// } this.tobeConnectedAp = params.apInfo; this.tobeConnectedSSID = this.tobeConnectedAp.ssid; @@ -210,21 +204,38 @@ struct WifiConnectPage { } registerObserver() { - LogUtil.info('start to register observer'); - WifiModel.registerWiFiConnectionObserver((code: Number) => { - LogUtil.info('wifi connection code : ' + code); + LogUtil.info('gyf start to register observer'); + WifiModel.registerWiFiConnectionObserver((data) => { + // 0: disconnected, 1: connected - if (code === 0) { + if (data === 0) { this.connectDialog.close() this.failedDialog.open() WifiModel.removeDeviceConfig(this.tobeConnectedAp); } - if (code === 1) { + if (data === 1) { this.connectDialog.close(); router.back({ uri: 'pages/MainPage', }); } + + //适配3566B + if (data.connectState === 6) { + //连接失败 + this.connectDialog.close() + this.failedDialog.open() + WifiModel.removeDeviceConfig(this.tobeConnectedAp); + } + + if (data.connectState === 4) { + //连接成功 + this.connectDialog.close(); + router.back({ + uri: 'pages/MainPage', + }); + } + WifiModel.refreshApScanResults(); }); } diff --git a/FA/WiFiScanner/entry/src/main/resources/base/element/string.json b/FA/WiFiScanner/entry/src/main/resources/base/element/string.json index 498a833..62a3f79 100755 --- a/FA/WiFiScanner/entry/src/main/resources/base/element/string.json +++ b/FA/WiFiScanner/entry/src/main/resources/base/element/string.json @@ -50,7 +50,7 @@ }, { "name": "wifiTipValidWLAN", - "value": "可用WLAN" + "value": "WLAN扫描中。。。" }, { "name": "wifiButtonCancel", -- Gitee