Protocol Compatibility: EspTouch vs EspTouchV2
masterEspTouch and EspTouchV2. Note that these two protocols are not compatible with each other. When integrating, ensure you are using the correct protocol version required by your target hardware.repository·master·Indexed 22 days ago
https://github.com/espressifapp/esptouchforandroidLibraries and an application for configuring ESP8266 and ESP32 devices to connect to Wi-Fi Access Points using the Smart Config protocol. Includes support for the original EspTouch and EspTouch V2, providing APIs for synchronization via EspSyncListener and provisioning via EspProvisioningRequest and IEspProvisioner.
EspTouch and EspTouchV2. Note that these two protocols are not compatible with each other. When integrating, ensure you are using the correct protocol version required by your target hardware.ESP-TOUCH uses Smart Config technology to provision Wi-Fi credentials (SSID and password) to ESP8266 and ESP32 devices via a smartphone.
Because the device is not yet connected to a network, the smartphone cannot communicate with it directly via IP. Instead, the smartphone sends a series of UDP packets to the Wi-Fi Access Point (AP). The SSID and password are encoded into the Length field of these UDP packets. The device, operating in a specific mode, listens to these packets to extract and parse the credentials.
UDP Packet Structure:
| Field | Length (Bytes) | Description |
|---|---|---|
| DA | 6 | Destination MAC Address |
| SA | 6 | Source MAC Address |
| Length | 2 | Encodes SSID and password |
| LLC | 3 | Logical Link Control |
| SNAP | 5 | Subnetwork Access Protocol |
| DATA | Variable | Payload |
| FCS | 4 | Frame Check Sequence |
The operational mode of the ESP chip affects how it handles the Wi-Fi connection during configuration:
Once configuration is successful, the smartphone obtains the device's IP address, and the device returns the smartphone's IP address. This enables custom local area network (LAN) communication between the two.
ESP-TOUCH uses Smart Config technology to connect ESP8266 and ESP32 devices to a Wi-Fi network. Since the device is not yet connected to the internet, a Wi-Fi-enabled device (like a smartphone) sends a series of UDP data packets to the Wi-Fi Access Point (AP).
The SSID and password are encoded within the Length field of the UDP packet. The device listens for these packets and parses them to obtain the network credentials.
| Field | Length (Bytes) | Description |
|---|---|---|
| DA | 6 | Destination MAC address |
| SA | 6 | Source MAC address |
| Length | 2 | Contains SSID and Key |
| LLC | 3 | Logical Link Control |
| SNAP | 5 | Subnetwork Access Protocol |
| DATA | Variable | Payload |
| FCS | 4 | Frame Check Sequence |
For the EspTouch Android application or libraries to successfully configure your ESP device to connect to a target Access Point (AP), the device must be running a Smart Config implementation.
Supported implementations include:
To start a provisioning task, instantiate EsptouchTask with the Access Point (AP) credentials and the application context. You can optionally configure the communication method using setPackageBroadcast.
setPackageBroadcast(true): Sends broadcast packets.setPackageBroadcast(false): Sends multicast packets.Context context; // Set Application context
byte[] apSsid = {}; // Set AP's SSID
byte[] apBssid = {}; // Set AP's BSSID
byte[] apPassword = {}; // Set AP's password
EsptouchTask task = new EsptouchTask(apSsid, apBssid, apPassword, context);
task.setPackageBroadcast(true); // if true send broadcast packets, else send multicast packetsTo provision a device using the ESP-TOUCH app, follow these steps:
Operational Requirements & Limitations:
To use the EspTouch libraries in your Android project, you must first add the JitPack repository to your root build.gradle file, and then add the specific library dependency to your app module's build.gradle file.
Important Compatibility Note: EspTouchV2 is not compatible with the original EspTouch. Choose the version that matches the Smart Config implementation running on your ESP device.
// 1. In your root build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
// 2. In your app module's build.gradle
// For original EspTouch:
implementation 'com.github.EspressifApp:lib-esptouch-android:1.1.1'
// OR for EspTouchV2:
implementation 'com.github.EspressifApp:lib-esptouch-v2-android:2.2.1'To connect an ESP8266 or ESP32 device to a Wi-Fi network using the ESP-TOUCH app, follow these steps:
To initiate the provisioning process, you must provide an EspProvisioningRequest object to the EspProvisioningParams constructor. The EspProvisioningParams class internally parses this request to generate the necessary data packets for the EspTouch protocol.
Key fields in the request that influence the provisioning payload include:
ssid: The target Wi-Fi SSID.password: The Wi-Fi password.reservedData: Additional custom data to be sent during provisioning.aesKey: If provided, the provisioning process will use AES encryption for the password and reserved data.securityVer: Specifies the security version (e.g., 2 for AES IV generation).address: The target device address (determines if IPv4 or IPv6 flags are set in the header).bssid: Used to calculate the BSSID CRC in the packet header.If provisioning fails, check the following common causes: