diff --git a/README.md b/README.md
index 871babd..f8f7270 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
#### 集成
```
-implementation 'com.rairmmd:andesptouch:1.0.4'
+implementation 'com.rairmmd:andesptouch:1.0.5'
```
#### 需要的权限
需要一下权限,库文件中已添加好了。
@@ -15,19 +15,22 @@ implementation 'com.rairmmd:andesptouch:1.0.4'
```
-** ⚠️请注意适配高版本安卓,获取WiFi信息需要动态请求定位权限
+** ⚠️请注意适配高版本安卓,获取WiFi信息需要动态请求定位权限。
#### AndEsptouch
-```
+```java
AndEsptouch andEsptouch = new AndEsptouch.Builder(this)
- .setSsid(ssid)//WiFi名字 可通过AndEsptouchHelper获得
- .setBssid(bssid)//路由器mac地址 可通过AndEsptouchHelper获得
+ .setSSID(ssid)//WiFi名字 可通过AndEsptouchHelper获得
+ .setBSSID(bssid)//路由器mac地址 可通过AndEsptouchHelper获得
.setPassWord(password)//WiFi密码
.build();
-andEsptouch.startEsptouchConfig();
+andEsptouch.startConfig();
+
+//停止配置
+andEsptouch.stopConfig();
```
设置回调监听
-```
+```java
andEsptouch.setOnEsptouchTaskListener(new AndEsptouch.OnEsptouchTaskListener() {
@Override
public void onEsptouchTaskCallback(int code, String message) {
@@ -56,11 +59,13 @@ andEsptouch.setOnEsptouchTaskListener(new AndEsptouch.OnEsptouchTaskListener() {
#### AndEsptouchHelper
WiFi操作工具类
-```
+```java
//获取当前WiFi
String ssid = AndEsptouchHelper.getInstance(this).getWifiSsid();
+String ssid = AndEsptouchHelper.getSSID(this);
//获取mac地址
String bssid = AndEsptouchHelper.getInstance(this).getBSSID();
+String bssid = AndEsptouchHelper.getBSSID(this);
```
还有其他例如:打开 关闭wifi 判断是否可用。。。
diff --git a/andesptouch/build.gradle b/andesptouch/build.gradle
index 8dc8ca5..4fa676f 100644
--- a/andesptouch/build.gradle
+++ b/andesptouch/build.gradle
@@ -7,7 +7,7 @@ def siteUrl = 'https://github.com/Rairmmd/AndEsptouch'
def gitUrl = 'https://github.com/Rairmmd/AndEsptouch.git'
group = "com.rairmmd"
-version = "1.0.4"
+version = "1.0.5"
android {
compileSdkVersion 30
diff --git a/andesptouch/src/main/java/com/rairmmd/andesptouch/AndEsptouchHelper.java b/andesptouch/src/main/java/com/rairmmd/andesptouch/AndEsptouchHelper.java
index 1cd3e35..52dc801 100644
--- a/andesptouch/src/main/java/com/rairmmd/andesptouch/AndEsptouchHelper.java
+++ b/andesptouch/src/main/java/com/rairmmd/andesptouch/AndEsptouchHelper.java
@@ -56,6 +56,32 @@ private AndEsptouchHelper(Context context) {
mWifiInfo = mWifiManager.getConnectionInfo();
}
+ /**
+ * 获取SSID
+ */
+ public static String getSSID(Context context) {
+ WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+ WifiInfo wifiInfo = wifiManager.getConnectionInfo();
+ String info = wifiInfo.toString();
+ String ssid = wifiInfo.getSSID();
+ if (info.contains(ssid)) {
+ return ssid;
+ } else if (ssid.startsWith("\"") && ssid.endsWith("\"")) {
+ return ssid.substring(1, ssid.length() - 1);
+ } else {
+ return ssid;
+ }
+ }
+
+ /**
+ * 获取BSSID
+ */
+ public static String getBSSID(Context context) {
+ WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+ WifiInfo wifiInfo = wifiManager.getConnectionInfo();
+ return wifiInfo.getBSSID();
+ }
+
/**
* 获取WifiManager
*/
diff --git a/app/build.gradle b/app/build.gradle
index 7ea09ae..f9bb1fd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -26,5 +26,5 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// implementation project(':andesptouch')
- implementation 'com.rairmmd:andesptouch:1.0.4'
+ implementation 'com.rairmmd:andesptouch:1.0.5'
}
diff --git a/app/src/main/java/com/rair/andesptouch/MainActivity.java b/app/src/main/java/com/rair/andesptouch/MainActivity.java
index f3b0042..5b1c7cb 100644
--- a/app/src/main/java/com/rair/andesptouch/MainActivity.java
+++ b/app/src/main/java/com/rair/andesptouch/MainActivity.java
@@ -52,9 +52,9 @@ public void onClick(View v) {
Log.i(TAG, "(MainActivity.java:51)-onClick:->"+ssid);
Log.i(TAG, "(MainActivity.java:51)-onClick:->"+bssid);
Log.i(TAG, "(MainActivity.java:51)-onClick:->"+password);
- andEsptouch = new AndEsptouch.Builder(this).setSsid(ssid)
- .setBssid(bssid).setPassWord(password).build();
- andEsptouch.startEsptouchConfig();
+ andEsptouch = new AndEsptouch.Builder(this).setSSID(ssid)
+ .setBSSID(bssid).setPassWord(password).build();
+ andEsptouch.startConfig();
andEsptouch.setOnEsptouchTaskListener(this);
if (countDownTimer != null) {
countDownTimer = null;
@@ -99,7 +99,7 @@ private void showProgressDialog(String message) {
@Override
public void onDismiss(DialogInterface dialog) {
if (andEsptouch != null) {
- andEsptouch.stopEsptouchConfig();
+ andEsptouch.stopConfig();
}
}
});
@@ -116,7 +116,7 @@ private void dismissProgressDialog() {
protected void onDestroy() {
super.onDestroy();
if (andEsptouch != null) {
- andEsptouch.stopEsptouchConfig();
+ andEsptouch.stopConfig();
}
}
}