abobija / esp-smartconfig-dart

EspTouch and EspTouchV2 implementations of SmartConfig provisioning protocols. Plain Dart. All platforms.
https://pub.dev/packages/esp_smartconfig
MIT License
45 stars 11 forks source link

Trouble Provisoning On Android #30

Open MarleyPlant opened 1 month ago

MarleyPlant commented 1 month ago

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

MarleyPlant commented 1 month ago

Solved my problem was with the SSID I was using on flutter end, however now I am still not receiving a response on the listener even though ESP is connecting to the internet.

webaddicted commented 1 month ago

@MarleyPlant ,

I have an iOT project. Where I need to send home wifi credentials on iOT device.

Firstly, I have to connect the mobile app to the iOT device hotspot. Then send wifi credentials to the iOT device without internet. then the device automatically connects to WiFi.

I already try lots of package but not been able to achieve this task.

I tried Following package wifi_iot flutter_iot_wifi flutter_esp_ble_prov esp_provisioning_ble esp_provisioning_softap

Can you tell me how I can achieve this?

My contact details is deepaksharmatheboss@gmail.com

Please help me