Coder Social home page Coder Social logo

esptouch_smartconfig's Introduction

esptouch_smartconfig

Espressif’s ESP-TOUCH protocol implements the Smart Config technology to help users connect ESP8266EX- and ESP32-embedded devices (hereinafter referred to as the device) to a Wi-Fi network through simple configuration on a smartphone flutter app.

Getting Started

Android

Add Permission android/app/src/main/AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

iOS

image

Add ios/Info.plist

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Used to Location's Info always for Using Beacon.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Used to Location's Info always for Using Beacon.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Used to Location's Info for Using Beacon when In Use.</string>

Usage

late Stream<ESPTouchResult>? _stream;
final Set<ESPTouchResult> _results = Set();

@override
  void initState() {
    _stream = EsptouchSmartconfig.run(widget.ssid, widget.bssid,
        widget.password, widget.deviceCount, widget.isBroadcast);
    super.initState();
  }
  
@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
            icon: Icon(Icons.arrow_back),
            onPressed: () {
              Navigator.of(context).pop(_results);
            }),
        backgroundColor: Colors.red,
        title: Text(
          'Task',
        ),
      ),
      body: Container(
        child: StreamBuilder<ESPTouchResult>(
          stream: _stream,
          builder: (context, AsyncSnapshot<ESPTouchResult> snapshot) {
            if (snapshot.hasError) {
              return error(context, 'Error in StreamBuilder');
            }
            switch (snapshot.connectionState) {
              case ConnectionState.active:
                _results.add(snapshot.data!);
                return resultList(context, ConnectionState.active);
              case ConnectionState.none:
                return noneState(context);
              case ConnectionState.done:
                if (snapshot.hasData) {
                  _results.add(snapshot.data!);
                  return resultList(context, ConnectionState.done);
                } else
                  return noneState(context);
              case ConnectionState.waiting:
                return waitingState(context);
            }
          },
        ),
      ),
    );
  } 

Reference

ESP Touch

https://github.com/smaho-engineering/esptouch_flutter
https://github.com/kittenbot/flutter_smartconfig
https://github.com/EspressifApp/EsptouchForIOS
https://github.com/EspressifApp/EsptouchForAndroid

Wifi Info

https://github.com/flutter/plugins

Version

iOS Version v2.2.0

Android Version v2.0.0

esptouch_smartconfig's People

Contributors

jpoh281 avatar vante08081009 avatar

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.