ESA2GJK1DH1K Basics: SmartConfig transplant program source code to your own project

 

 

 

Preface:

  Description two places

  1. Click the Start button to place the SmartConfig

    

  2. Jump final place

 

    

 

 

 

 

Explanation

  This section explain how to put my source inside the SmartConfig porting to their own project

  All I want to come up with all concerned, so that we can easily put every function ported to their project.

 

Create a new project

  Home page just put a button and a text box

  Button to jump to the distribution network is responsible for binding the page, the text box displays the MAC information distribution network binding after the completion of the acquisition of Wi-Fi

    

 

 

 

 

Create a new page, with the binding of the distribution network

 

 

 

 

 

 Random name

 

 

 

 

Change layout

 

 

 

 

 

 

 

 

 

EditText which put a router name to display the connection we

EditText used to enter a password

A button to start the SmartConfig

 

 

 

 

 

 

 

Open source tutorials APP

Note: do not support the Chinese directory, copy the source code to the English directory and open software

 

 

 

Their new project select Import module

 

 

 

Select source inside esptouch

 

 

 

 

 

 

 

 

Add dependent

 

implementation project(':esptouch')

 

 

 

ActivityBindDevices to copy source code inside the new project we

 

 

 

 

 

 

 

 

 

 

 

This error may be inconsistent because the SDK version error, they can knock again

  I'm 28, if you use 29, the error will be used, including 29 start with Androidx.XXXXX

 

 

 

 

 

 

Modify the layout's name, under modified according to the ID of the control

 

 

 

 

 

In AndroidManifest inside with Activity

<activity
android:name=".ActivityBindDevices"
android:label="@string/app_name">
</activity>

 

 

 

In AndroidManifest inside with permission

I took the latter we used all added

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <!--读手机内容的权限 -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_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.REQUEST_INSTALL_PACKAGES"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

 

 

 

 

加上动态权限申请

    String[] PermissionString={//需要提醒用户申请的权限
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.CAMERA,
            Manifest.permission.ACCESS_FINE_LOCATION,
            Manifest.permission.READ_PHONE_STATE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.REQUEST_INSTALL_PACKAGES,
    };

 

https://www.cnblogs.com/yangfengwu/p/11909387.html    参考这节加上

 

 

 

 

 

 

 

 

 

主页面加上按钮点击跳转事件

 

 

主页面加上显示跳转过来传递的MAC数据

 

 

 

 

测试

  一,下载单片机程序

  "测试APP使用SmartConfig绑定Wi-Fi 设备通过MQTT控制设备"

    

 

  二,调整波动开关位置,STM32和Wi-Fi通信

    

 

  

 

  三,短接STM32的PB2和Wi-Fi模块的RST引脚(为了做项目稳定可靠,请使用单片机硬件复位Wi-Fi)

    

 

 

  四.长按PB5大约4S,等待指示灯快闪,松开PB5,Wi-Fi模块进入配网状态

    

 

 

  五.输入路由器密码,点击APP的"搜索设备"按钮,开始搜索设备

    

 

 

 

 

  六.配网以后自动跳转到主页面,显示配网获取的Wi-Fi的MAC地址

 

    

 

 

 

 

 

结语

反正APP的SmartConfig也就是这样使用,后期自己想优化程序和页面自己搞吧.

  

    

 

Guess you like

Origin www.cnblogs.com/yangfengwu/p/11925612.html