Git Product home page Git Product logo

esp-smartconfig-dart's Introduction

I'm Alija.

Here you'll find exciting projects on electronics, home automation, the auto industry, software CI/CD, solution architecture, and more. I also maintain a YouTube channel where I create detailed videos for each project.

YouTube Channel Subscribers

For more about me and to get in touch, visit abobija.com

esp-smartconfig-dart's People

Contributors

abobija avatar paulgrotzke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

esp-smartconfig-dart's Issues

Trouble Provisoning On Android

I am using ESP32s, and am trying to setup a smartconfig provisioning process using the esp_smartconfig flutter package

I had previously used ESPTOUCH_SMARTCONFIG package and had that working however have decided for a rewrite in this package.

When running esp_smartconfig_get_version() on the ESP32 I am getting
ESP SMARTCONFIG VERSION: V3.0.1

In order to start the provisioning on the arduino I am doing

DEBUG_PRINT("Starting Smartconfig");

WiFi.mode(WIFI_AP_STA);
WiFi.beginSmartConfig(SC_TYPE_ESPTOUCH_V2, "1234567890123456");
DEBUG_PRINT("ESP SMARTCONFIG VERSION: " + String());

  

//Wait for SmartConfig packet from mobile
DEBUG_PRINT("Waiting for SmartConfig.");
while (!WiFi.smartConfigDone()) {
delay(500);
Serial.print(".");
}

  

DEBUG_PRINT("");
DEBUG_PRINT("SmartConfig received.");

if (waitForWifi(50, "SmartConfig")) {
	writeToEEPROM();
	return true;
}

DEBUG_PRINT("");

On the Flutter Side I am running on a Stateful Loading Widget

@override  
void initState() {  
  super.initState();  
  provisioner.listen((response) {  
    Navigator.of(context).pushReplacementNamed(  
      "/configurenewdevice",  
      arguments: CurrentDevice(  
          (supabase.auth.currentUser != null  
              ? supabase.auth.currentUser!.id  
              : ""),  
          response.bssidText),  
    );  
  });  
  startProvisioning(widget.ssid, widget.password);  
}  
  
Future<void> startProvisioning(ssid, password) async {  
  print("Started Provisioning");  
  setState(() {  
    isSearching = true;  
  });  
  
  try {  
    await provisioner.start(ProvisioningRequest.fromStrings(  
      ssid: ssid,  
      password: password,  
    ));  
  } catch (e, s) {  
    print(e);  
    showUserError(context, e.toString());  
    setState(() {  
      isSearching = false;  
    });  
  }  
}

Console log wise I am receiving [14:50:09.312] [esp_smartconfig] [INFO] Provisioning started From the Flutter app.

and on the ESP I am getting

Starting Smartconfig
[  1059][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 9 - WIFI_READY
[  1298][V][STA.cpp:184] _onStaEvent(): STA Started
[  1353][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 11 - STA_START
[  1440][V][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 11 - STA_START
ESP SMARTCONFIG VERSION: V3.0.1
Waiting for SmartConfig.
..........[  6410][V][WiFiGeneric.cpp:109] _arduino_event_cb(): SC Scan Done
[  6481][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 32 - SC_SCAN_DONE
[  6410][V][WiFiGeneric.cpp:109] _arduino_event_cb(): SC Scan Done
[  6481][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 32 - SC_SCAN_DONE
............................................[ 28461][V][WiFiGeneric.cpp:112] _arduino_event_cb(): SC Found Channel
[ 28537][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 33 - SC_FOUND_CHANNEL
...[ 29692][V][WiFiGeneric.cpp:117] _arduino_event_cb(): SC: SSID: SNET-MZC2KX", Password: ************
[ 29801][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 34 - SC_GOT_SSID_PSWD
.....[ 32310][V][STA.cpp:214] _onStaEvent(): STA Disconnected: SSID: SNET-MZC2KX", BSSID: 00:00:00:00:00:00, Reason: 201

It seems that the ESP32 is receiving from the app but somewhere along the way the ssid is getting chopped.on the ESP32 Console log it is showing as SNET-MZC2KX when it should be PLUSNET-MZC2KX

provisioner.listen can not get any data

Hello everyone,
below is my code, my esp can receive wifi information , but my app can not receive any data that esp is connected.
Does there anyone face the same issue as me?

provisioner.listen((response) {
debugPrint('SSID:${response.ipAddressText}');
debugPrint("\n"
"\n------------------------------------------------------------------------\n"
"Device ($response) is connected to WiFi!"
"\n------------------------------------------------------------------------\n");
});

empty password

Hi, seems to me doesn't like empty password or empty bssid. There is a way to. fix?

flutter: \^[[35m[08:59:33.728] [esp_smartconfig] [DEBUG] EspTouch povisioning<…>
flutter: \^[[35m[08:59:33.800] [esp_smartconfig] [DEBUG] ---------- Request ----------<…>
flutter: \^[[35m[08:59:33.806] [esp_smartconfig] [DEBUG] ssid [70, 82, 65, 78, 67, 69, 83, 67, 79]<…>
flutter: \^[[35m[08:59:33.807] [esp_smartconfig] [DEBUG] bssid [-8, -47, 17, -65, 40, 92]<…>
flutter: \^[[35m[08:59:33.808] [esp_smartconfig] [DEBUG] pwd []<…>
flutter: \^[[35m[08:59:33.821] [esp_smartconfig] [DEBUG] rData null<…>
flutter: \^[[35m[08:59:33.825] [esp_smartconfig] [DEBUG] encriptionKey null<…>
flutter: \^[[35m[08:59:33.827] [esp_smartconfig] [DEBUG] -----------------------------<…>
flutter: \^[[35m[08:59:33.828] [esp_smartconfig] [DEBUG] Creating UDP socket on port 18266<…>
flutter: \^[[35m[08:59:33.931] [esp_smartconfig] [DEBUG] UDP socket on port 18266 successfully created<…>
[VERBOSE-2:dart_isolate.cc(1148)] Unhandled exception:
RangeError: Invalid value: Not in inclusive range 0..69: 75
#0      List.insertAll (dart:core-patch/growable_array.dart:44:7)
#1      EspTouch._dataCodes.<anonymous closure> (package:esp_smartconfig/src/protocols/esptouch.dart:58:17)
#2      _IntListMixin.forEach (dart:typed_data-patch/typed_data_patch.dart:215:8)
#3      EspTouch._dataCodes (package:esp_smartconfig/src/protocols/esptouch.dart:57:19)
#4      EspTouch.prepare (package:esp_smartconfig/src/protocols/esptouch.dart:27:19)
#5      Provisioner._startProvisioning (package:esp_smartconfig/src/provisioner.dart:199:9)

ESP pairing response issue

once the device is connected to network .. after that if device is reset after that if we try to connect that again at that time there is no response from the network whether device is connected or not.

RangeError on short password Length

I tried using a 3-characters password and it throws the range error.
image

If the password is long enough, the error is not thrown. I haven't tried how many characters in maximum that could cause the error.

E/flutter ( 5454): [ERROR:flutter/runtime/dart_isolate.cc(1098)] Unhandled exception:
E/flutter ( 5454): RangeError: Invalid value: Not in inclusive range 0..72: 75
E/flutter ( 5454): #0      List.insertAll (dart:core-patch/growable_array.dart:44:7)
E/flutter ( 5454): #1      EspTouch._dataCodes.<anonymous closure> (package:esp_smartconfig/src/protocols/esptouch.dart:58:17)
E/flutter ( 5454): #2      _IntListMixin.forEach (dart:typed_data-patch/typed_data_patch.dart:215:8)
E/flutter ( 5454): #3      EspTouch._dataCodes (package:esp_smartconfig/src/protocols/esptouch.dart:57:19)
E/flutter ( 5454): #4      EspTouch.prepare (package:esp_smartconfig/src/protocols/esptouch.dart:27:19)
E/flutter ( 5454): #5      Provisioner._startProvisioning (package:esp_smartconfig/src/provisioner.dart:199:9)
E/flutter ( 5454): <asynchronous suspension>

esp provisioning v2 not working

I'm trying to send custom data to the esp using the espTouchV2 protocol, but it's not working.
there is no error message also no logs in the app or in the Arduino code, so it's not connected but also there is no error message
await provisioner.start(ProvisioningRequest.fromStrings( ssid: "my network", bssid: "v3:s6:24:6v:61:9o", password: "mynetworkpassword", reservedData: "568", encryptionKey: "MyEncryptionKey0" )

esp smartconfig provisioning fails on ios

The plugin is working fine with android but trying it with ios returns error message "Socket error: SocketException: Send failed(OS Error : No route to host, errno =65), address = 0.0.0.0, port = 18266"

Fails on iOS 16.x in flutter app

Has anyone successfully used this package on iOS 16.x? Running a simple Flutter App causes the following persistent socket send error, details below.

The error (OS Error: No route to host, errno = 65) seems to point to a Local Network access issue, however the App does have Local Network Access enabled in Settings.

flutter: ^[[35m[10:47:47.236] [esp_smartconfig] [DEBUG] Creating UDP socket on port 18266<…>
flutter: ^[[35m[10:47:47.261] [esp_smartconfig] [DEBUG] UDP socket on port 18266 successfully created<…>
flutter: ^[[32m[10:47:47.274] [esp_smartconfig] [INFO] Provisioning started<…>
flutter: ^[[31m[10:47:47.283] [esp_smartconfig] [ERROR] Socket error^[[0m
^[[31m[exception] SocketException: Send failed (OS Error: No route to host, errno = 65), address = 0.0.0.0, port = 18266^[[0m
^[[31m[stacktrace]^[[0m
#0 _NativeSocket.send (dart:io-patch/socket_patch.dart:1213:34)
#1 RawDatagramSocket.send (dart:io-patch/socket_patch.dart:2460:15)
#2 Protocol.send (package:esp_smartconfig/src/protocol.dart:129:20)
#3 Protocol.sendBlock.
(package:esp_smartconfig/src/protocol.dart:63:7)
#4 Bottleneck.flow (package:esp_smartconfig/src/bottleneck.dart:22:7)
#5 Protocol.sendBlock (package:esp_smartconfig/src/protocol.dart:75:18)
#6 Protocol.loop (package:esp_smartconfig/src/protocol.dart:98:5)
#7 Provisioner._startProvisioning. (package:esp_smartconfig/src/provisioner.dart:204:38)
#8 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
#9 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
#10 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.d<…>
flutter: ^[[31m[10:47:47.285] [esp_smartconfig] [ERROR] Socket error: SocketException: Send failed (OS Error: No route to host, errno = 65), address = 0.0.0.0, port = 18266<…>
flutter: ^[[35m[10:47:47.288] [esp_smartconfig] [DEBUG] Destroying isolate<…>
flutter: ^[[32m[10:47:47.289] [esp_smartconfig] [INFO] Provisioning stopped<…>

app ones with a blank screen and then closes automatically.

Launching lib\main.dart on M2003J15SC in debug mode...
Parameter format not correct -
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:65262/WFRlBwRoS_8=/ws
I/fi_provisionin(11240): Compiler allocated 4563KB to compile void android.view.ViewRootImpl.performTraversals()
I/flutter (11240): [17:50:46.601] [esp_smartconfig] [DEBUG] EspTouch povisioning
I/flutter (11240): [17:50:46.642] [esp_smartconfig] [DEBUG] ---------- Request ----------
I/flutter (11240): [17:50:46.645] [esp_smartconfig] [DEBUG] ssid [66, 65, 66, 89, 83, 79, 70, 84, 50]
I/flutter (11240): [17:50:46.646] [esp_smartconfig] [DEBUG] bssid [-8, -47, 17, -65, 40, 92]
I/flutter (11240): [17:50:46.656] [esp_smartconfig] [DEBUG] pwd [101, 110, 103, 108, 105, 115, 104, 64, 49, 50, 51]
I/flutter (11240): [17:50:46.659] [esp_smartconfig] [DEBUG] rData null
I/flutter (11240): [17:50:46.660] [esp_smartconfig] [DEBUG] encriptionKey null
I/flutter (11240): [17:50:46.660] [esp_smartconfig] [DEBUG] -----------------------------
I/flutter (11240): [17:50:46.662] [esp_smartconfig] [DEBUG] Creating UDP socket on port 18266
I/flutter (11240): [17:50:46.743] [esp_smartconfig] [DEBUG] UDP socket on port 18266 successfully created
I/flutter (11240): [17:50:46.771] [esp_smartconfig] [INFO] Provisioning started
I/flutter (11240): [17:50:56.810] [esp_smartconfig] [DEBUG] Destroying isolate
I/flutter (11240): [17:50:56.818] [esp_smartconfig] [INFO] Provisioning stopped
D/RefBase (11240): RefBase: Explicit destruction, weak count = 0 (in 0x752b14f5a8)
D/RefBase (11240): #00 pc 00000000000f04d8 /apex/com.android.runtime/lib64/bionic/libc.so (__cxa_finalize+288)
D/RefBase (11240): #1 pc 00000000000e1808 /apex/com.android.runtime/lib64/bionic/libc.so (exit+24)
D/RefBase (11240): #2 pc 0000000001a2d674 /data/app/~~ZCSVnq69RHW-I-RvpX9Uig==/com.example.wifi_provisioning-epSSh5d3KnGBK1uZtPlMag==/lib/arm64/libflutter.so
D/RefBase (11240): #3 pc 0000000001a2e0dc /data/app/~~ZCSVnq69RHW-I-RvpX9Uig==/com.example.wifi_provisioning-epSSh5d3KnGBK1uZtPlMag==/lib/arm64/libflutter.so
D/RefBase (11240): #4 pc 0000000001b49764 /data/app/~~ZCSVnq69RHW-I-RvpX9Uig==/com.example.wifi_provisioning-epSSh5d3KnGBK1uZtPlMag==/lib/arm64/libflutter.so
D/RefBase (11240): #5 pc 00000000000031fc [anon:dart-code:000000740c900000]
Lost connection to device.
Exited (sigterm)

provisioner.listen((response)

provisioner.stop() not cancel subscription provisioner.listen((response)

When I do another scan when reporting the status of an exception:

An exception occurred.
StateError (Bad state: Stream has already been listened to.)

SmartConfig is not working on Android

I used ESP-32 WIFI + Bluetooth run on Arduino.
Code Arduino:

    WiFi.mode(WIFI_AP_STA);
    WiFi.beginSmartConfig();

    //Wait for SmartConfig packet from mobile
    Serial.println("Waiting for SmartConfig.");
    while (!WiFi.smartConfigDone()) {
      delay(500);
      Serial.print(".");
    }

    Serial.println("");
    Serial.println("SmartConfig received.");

Code Flutter:

init() {
      provisioner = Provisioner.espTouch();
      provisioner.listen((response) {}, onError: (e) {});
}

onClick() async {
        await provisioner.start(ProvisioningRequest.fromStrings(
                      ssid: "123 12345",
                      bssid: "c8:e7:d8:a6:80:d6",
                      password: "12345678",
                    ));
}

There is no error in Android side but WiFi.smartConfigDone() in the Arduino is not working.
Do you know what did I do wrong?

ESPTOUCH_V2 does not send acknolwdgement correctly to Flutter

Hello!

I am running my ESP32 IDF code with "esp-smartconfig-dart" which works fine for ESPTOUCH protocol. However, switching to protocol ESPTOUCH_V2 , the device recieved the SSID, password and reserved data correctly and can connect to Wifi. However, it cannot send the acknowlegedment data back the Java app from

https://github.com/EspressifApp/EsptouchForAndroid/tree/master

and it works fine.

My code below. Do I miss something to configure?

  final provisioner = Provisioner.espTouchV2();
  final ssidController = ref.read(ssidControllerProvider);
  final passwordController = ref.read(passwordControllerProvider);
  final wifiCredentialsNotifier =
      ref.read(wifiCredentialsProvider.notifier);

  provisioner.listen((response) {
    Navigator.of(context).pop(response);
  });

  provisioner.start(ProvisioningRequest.fromStrings(
    ssid: ssidController.text,
    bssid: '00:00:00:00:00:00',
    password: passwordController.text,
    reservedData:
        "Hello from Dart123665656565688994643976464564646464646549876544654---",
    encryptionKey: "MySecretKey!6754",
  ));

difference between protocols

Hello,

What is the difference between EspTouch vs EspTouch V2? Which one should i use and why? Could you please explain this

ssid length error

Hi I found a problem on the plugin.
In case the SSID length is less than 9 characters it trow this error:
[VERBOSE-2:dart_isolate.cc(1111)] Unhandled exception:
RangeError: Invalid value: Not in inclusive range 0..72: 75
#0 List.insertAll (dart:core-patch/growable_array.dart:44:7)
#1 EspTouch._dataCodes. (package:esp_smartconfig/src/protocols/esptouch.dart:62:17)
#2 _IntListMixin.forEach (dart:typed_data-patch/typed_data_patch.dart:215:8)
#3 EspTouch._dataCodes (package:esp_smartconfig/src/protocols/esptouch.dart:60:19)
#4 EspTouch.prepare (package:esp_smartconfig/src/protocols/esptouch.dart:27:19)
#5 Provisioner._startProvisioning (package:esp_smartconfig/src/provisioner.dart:201:9)

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.