Code Monkey home page Code Monkey logo

andesptouch's Introduction

AndEsptouch

基于最新的乐鑫8266的配网项目进行封装。

使用

集成

implementation 'com.rairmmd:andesptouch:1.0.5'

需要的权限

需要一下权限,库文件中已添加好了。

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

** ⚠️请注意适配高版本安卓,获取WiFi信息需要动态请求定位权限。

AndEsptouch

AndEsptouch andEsptouch = new AndEsptouch.Builder(this)
    .setSSID(ssid)//WiFi名字 可通过AndEsptouchHelper获得
    .setBSSID(bssid)//路由器mac地址 可通过AndEsptouchHelper获得
    .setPassWord(password)//WiFi密码
    .build();
andEsptouch.startConfig();

//停止配置
andEsptouch.stopConfig();

设置回调监听

andEsptouch.setOnEsptouchTaskListener(new AndEsptouch.OnEsptouchTaskListener() {
    @Override
    public void onEsptouchTaskCallback(int code, String message) {
        Log.d(TAG, "code:" + code + "\nmessage:" + message);
        dismissProgressDialog();
        if (code == AndEsptouch.RESULT_CONFIG_SUCCESS) {
            Toast.makeText(MainActivity.this, "配网成功", Toast.LENGTH_SHORT).show();
        } else if (code == AndEsptouch.RESULT_CONFIG_TIMEOUT) {
            Toast.makeText(MainActivity.this, "配网超时", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(MainActivity.this, "配网失败", Toast.LENGTH_SHORT).show();
        }
    }
});

code有一下几个值:

RESULT_CONFIG_SUCCESS; 表示成功配网,接着看message的信息 ;

RESULT_CONFIG_MULTI_SUCCESS ; 为多个配网信息,刚刚配对成功的设备 ;

RESULT_CONFIG_FAILURE; 表示配网失败;

RESULT_CONFIG_RECEIVE_SUCCESS; 表示成功接受到设备的信息

RESULT_CONFIG_TIMEOUT; 表示超时

AndEsptouchHelper

WiFi操作工具类

//获取当前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 判断是否可用。。。

Apk体验

apk下载

1

说明

基于EsptouchForAndroid: https://github.com/EspressifApp/EsptouchForAndroid

参考XSmartConfig: https://github.com/xuhongv/XSmartConfig

IOS友好封装(一句代码调用):https://github.com/obama901/HDEspTouch

andesptouch's People

Contributors

reathin avatar

Stargazers

xieqi avatar WangLuo avatar  avatar  avatar  avatar  avatar Jack avatar

Watchers

James Cloos avatar  avatar

andesptouch's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.