esptouch_flutter
Flutter plugin for ESP-Touch to configure network for ESP-8266 and ESP-32 devices. Runs on iOS and Android.
esptouch_flutter
is Flutter plugin package which contains an API for ESP-Touch written in Dart combined with
platform-specific implementation for Android using Java and iOS using Objective-C.
This package provides a high customizability to the ESP Touch tasks and an idiomatic Dart interface for launching tasks. Custom task parameters lets the users of this plugin change how long the task runs, you could set it to hours, if this is what your workflow requires.
pub.dev
For a complete example app, see the example
folder in the repository.
The example app lets you configure WiFi SSID, BSSID, password, the duration of the task, expected task count and many more.
For a simplest possible app, see the smaho-engineering/esptouch_flutter_kotlin_example
repository.
import 'package:esptouch_flutter/esptouch_flutter.dart';
// Somewhere in your widget...
final ESPTouchTask task = ESPTouchTask(
ssid: 'My WiFi network',
bssid: 'ab:cd:ef:12:23:34',
password: 'I love SMAHO',
);
final Stream<ESPTouchResult> stream = task.execute();
final printResult = (ESPTouchResult result) {
print('IP: ${result.ip} MAC: ${result.bssid}');
};
StreamSubscription<ESPTouchResult> streamSubscription = stream.listen(printResult);
// Don't forget to cancel your stream subscription.
// You might cancel after the UDP wait+send time has passed (default 1 min)
// or you could cancel when the user asked to cancel
// for example, either via X button, or popping a route off the stack.
streamSubscription.cancel();
If you would like to customize the task, provide an ESPTouchTaskParameter
instance as taskParameter
to ESPTouchTask
. In the code example, I specify the types for clarity but you can omit the types as Dart can infer them.
final ESPTouchTask task = ESPTouchTask(
ssid: 'My WiFi network',
bssid: 'ab:cd:ef:12:23:34',
password: 'I love Flutter and ESP-Touch, too',
// Tweak the task using task parameters
taskParameter: ESPTouchTaskParameter(waitUdpReceiving: Duration(hour: 12)),
);
// You can still stop the task at any point by calling .cancel on the stream subscription:
streamSubscription.cancel();
In a real world example, you'd get the WiFi credentials from the user and you could either display the configured device, save it locally in SQLite or send it to your backend.
Use a real phone for development. The plugin will not work in emulators and simulators, so you need real phones for development. Run flutter devices
to verify.
Prepare your embedded devices. To verify that the ESP-Touch app works, you need some hardware with ESP8266 and ESP32 to connect to your WiFi network.
connectivity
You may to provide an easy way for getting the current WiFi network's SSID and BSSID. Use the connectivity
plugin for discovering the state of the network (WiFi & mobile/cellular) connectivity on Android and iOS.
Using ESP-Touch, you can configure network for ESP8266 and ESP32 devices.
Espressif’s ESP-Touch protocol implements the Smart Config technology to help users connect ESP8266EX- and ESP32-embedded devices to a Wi-Fi network through simple configuration on a smartphone.
You can read more about ESP-Touch here:
.pdf
)EspressifApp/EsptouchForIOS
ESP-Touch for iOS using Objective-CEspressifApp/EsptouchForAndroid
ESP-Touch for Android using JavaThe original iOS and Android modules had to be heavily customized and tweaked in order to support custom task parameters.
Starting with iOS 14.6 the com.apple.developer.networking.multicast
entitlement is required, to allow the broadcasting of IP packages on iOS, which is used by esptouch.
In order ot enable it, you need to request the entitlemant as an account holder here.
Once you are enrolled, you can configure it here
This is an open-source project built by the SMAHO Engineering team from Munich to wrap Espressif's ESP-Touch mobile app kits.
If you are coming from IoT background, you might not know what Flutter is.
Flutter is Google's UI toolkit for creating beautiful, native experiences for iOS and Android from a single codebase. For help getting started with Flutter, view the online documentation. This repository contains a Flutter plugin package for ESP-Touch. A plugin package is a specialized package that includes platform-specific implementation code for Android and iOS. The Flutter portion of the app sends messages to its host (iOS or Android) over a platform channel. This plugin relies on platform channels (event channels) heavily.