提交 5a6e3423 编写于 作者: 杜庆泉's avatar 杜庆泉

connect wifi 实现中

上级 468396ab
......@@ -13,6 +13,7 @@
<button @tap="testStartWifi">初始化wifi模块</button>
<button @tap="testGetWifiList">获取当前wifi列表</button>
<button @tap="testGetConnnectWifi">获取当前连接的wifi</button>
<button @tap="testConnnectWifi">链接wifi</button>
<button @tap="testStopWifi">关闭wifi模块</button>
</view>
</template>
......@@ -33,6 +34,9 @@
onMemoryWarning:function(res){
console.log(res);
},
testConnnectWifi(){
uni.connectWifi({});
},
testGetConnnectWifi(){
uni.getConnectedWifi({
partialInfo:false,
......
......@@ -38,7 +38,8 @@
"stopWifi": "stopWifi",
"getWifiList":"getWifiList",
"onGetWifiList":"onGetWifiList",
"onWifiConnected":"onWifiConnected"
"onWifiConnected":"onWifiConnected",
"connectWifi":"connectWifi"
}
},
"dependencies": [],
......
......@@ -214,7 +214,8 @@ export function getWifiList(option: WifiOption) {
// 还没调用startWifi 提示报错
var result = {
errCode: 12000,
errMsg: "getWifiList:fail:not invoke startWifi"
errMsg: "getWifiList:fail:not invoke startWifi",
errSubject:"uni-wifi"
}
option.fail?.(result)
option.complete?.(result)
......@@ -236,6 +237,7 @@ export function getWifiList(option: WifiOption) {
}
/**
* wifi 链接成功的回调注册
*/
......@@ -270,9 +272,15 @@ export function offGetWifiList(callback: UTSCallback) {
}
}
export function connectWifi(_option: WifiOption) {
export function connectWifi(_option: WifiConnectOption) {
// todo
console.log(_option)
if(_option.maunal == true){
// 指定了手动模式
let manunalIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
getUniActivity()!!.startActivity(manunalIntent);
}
}
/**
......@@ -375,9 +383,6 @@ export function getConnectedWifi(option: GetConnectedWifiOptions) {
return
}
if (ActivityCompat.checkSelfPermission(getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// 尚不具备权限,返回错误
res.errCode = 12001
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册