smaho-engineering / esptouch_flutter

ESP-Touch Dart API for Flutter. Platform-specific implementation for Android (Java) and iOS (Objective-C).
https://pub.dev/packages/esptouch_flutter
MIT License
100 stars 34 forks source link

App not returning success message just loads #11

Closed CodeSyncr closed 3 years ago

CodeSyncr commented 3 years ago

i tried with multiple bauderate and diffrent code for smartconfig but success message is not returned

code for smart config i used :-

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

void setup() {
  int cnt = 0;  

  // put your setup code here, to run once:
  Serial.begin(115200);

  // set for STA mode
  WiFi.mode(WIFI_STA);

  // led status at pin16
  pinMode(16,OUTPUT);

  //configure pin0 
  pinMode(0, INPUT_PULLUP);

  // deplay for 2 sec for smartConfig
  Serial.println("2 sec before clear SmartConfig");
  delay(2000);

  // if wifi cannot connect start smartconfig
  while(WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    if(cnt++ >= 15){
       WiFi.beginSmartConfig();
       while(1){
           delay(500);
           if(WiFi.smartConfigDone()){
             Serial.println("SmartConfig Success");
             blinkSmartConfig();
             break;
           }
       }
    }
  }

  WiFi.printDiag(Serial);

  // Print the IP address
  Serial.println(WiFi.localIP());

}

void blinkSmartConfig() {
    digitalWrite(16, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(50);              // wait for a second 
    digitalWrite(16, LOW);    // turn the LED off by making the voltage LOW
    delay(50);
}

void blinkClearConfig() {
  int i=0;
  while(i<=10) {
    digitalWrite(16, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(100);              // wait for a second 
    digitalWrite(16, LOW);    // turn the LED off by making the voltage LOW
    delay(100);
    i++;
  }
}

void blinkStartConfig() {
  pinMode(16,OUTPUT);
  int i=0;
  digitalWrite(16, HIGH);   // turn the LED on (HIGH is the voltage level)
}

void loop() {
  // read pullup
  int isSmartConfig = digitalRead(0);
  if (isSmartConfig==0) {
    // bink for clear config
    blinkClearConfig();
    Serial.println("clear config");
    // reset default config
    WiFi.disconnect();
  }
}

Debug on console for app:-

D/ViewRootImpl(20831): [TouchInput][ViewRootImpl] KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x8, repeatCount=0, eventTime=14093543, downTime=14093543, deviceId=-1, source=0x101, displayId=-1 }
D/ViewRootImpl(20831): [TouchInput][ViewRootImpl] KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x8, repeatCount=0, eventTime=14093543, downTime=14093543, deviceId=-1, source=0x101, displayId=-1 }
W/IInputConnectionWrapper(20831): getTextBeforeCursor on inactive InputConnection
D/EsptouchPlugin(20831): Cancelling stream with configuration arguments{password=galaxy2020, bssid=58:d9:d5:ac:78:98, taskParameter={thresholdSucBroadcastCount=1, expectTaskResultCount=1, esptouchResultTotalLen=11, waitUdpReceivingMillisecond=15000, targetPort=7001, intervalDataCodeMillisecond=8, esptouchResultOneLen=1, esptouchResultMacLen=6, intervalGuideCodeMillisecond=8, timeoutDataCodeMillisecond=4000, waitUdpSendingMillisecond=45000, esptouchResultIpLen=4, totalRepeatTime=1, portListening=18266, timeoutGuideCodeMillisecond=2000}, packet=1, ssid=YashKumar}
D/EsptouchPlugin(20831): Task existed, cancelling manually
D/EspTouchTaskUtil(20831): cancel
D/EspTouchAsyncTask(20831): cancelEsptouch
D/EspTouchAsyncTask(20831): Task in cancelEsptouch has to be interrupted
D/__EsptouchTask(20831): interrupt()
D/EsptouchPlugin(20831): Event Listener is triggered
D/EsptouchPlugin(20831): Received stream configuration arguments: SSID: YashKumar, BBSID: 58:d9:d5:ac:78:98, Password: galaxy2020, Packet: 1, Task parameter: {thresholdSucBroadcastCount=1, expectTaskResultCount=1, esptouchResultTotalLen=11, waitUdpReceivingMillisecond=15000, targetPort=7001, intervalDataCodeMillisecond=8, esptouchResultOneLen=1, esptouchResultMacLen=6, intervalGuideCodeMillisecond=8, timeoutDataCodeMillisecond=4000, waitUdpSendingMillisecond=45000, esptouchResultIpLen=4, totalRepeatTime=1, portListening=18266, timeoutGuideCodeMillisecond=2000}
D/EsptouchPlugin(20831): Converted taskUtil parameter from map {thresholdSucBroadcastCount=1, expectTaskResultCount=1, esptouchResultTotalLen=11, waitUdpReceivingMillisecond=15000, targetPort=7001, intervalDataCodeMillisecond=8, esptouchResultOneLen=1, esptouchResultMacLen=6, intervalGuideCodeMillisecond=8, timeoutDataCodeMillisecond=4000, waitUdpSendingMillisecond=45000, esptouchResultIpLen=4, totalRepeatTime=1, portListening=18266, timeoutGuideCodeMillisecond=2000} to EsptouchTaskParameter com.espressif.iot.esptouch.task.EsptouchTaskParameter@47c706f.
I/__EsptouchTask(20831): Welcome Esptouch v0.3.7.0
D/UDPSocketServer(20831): mServerSocket is created, socket read timeout: 60000, port: 18266
D/EspTouchAsyncTask(20831): Expected task result count is : 1
D/__EsptouchTask(20831): execute()
I/__EsptouchTask(20831): localInetAddress: /192.168.0.103
D/__EsptouchTask(20831): send gc code 
D/__EsptouchTask(20831): __listenAsyn() start
I/__EsptouchTask(20831): expectOneByte: 28
D/UDPSocketServer(20831): receiveSpecLenBytes() entrance: len = 11
D/__EsptouchTask(20831): send gc code 
D/__EsptouchTask(20831): send gc code 
D/__EsptouchTask(20831): send gc code 
D/__EsptouchTask(20831): send gc code 
D/__EsptouchTask(20831): send gc code 
D/__EsptouchTask(20831): send gc code 
D/__EsptouchTask(20831): send gc code 
D/UDPSocketServer(20831): Poll timed out
I/__EsptouchTask(20831): receive rubbish message, just ignore
D/UDPSocketServer(20831): receiveSpecLenBytes() entrance: len = 11
I/UDPSocketClient(20831): USPSocketClient is interrupt
I/UDPSocketServer(20831): USPSocketServer is interrupt
D/UDPSocketServer(20831): mServerSocket is closed
D/UDPSocketServer(20831): recvfrom failed: EBADF (Bad file descriptor)
I/__EsptouchTask(20831): receive rubbish message, just ignore
D/__EsptouchTask(20831): __listenAsyn() finish

no success even with your example app please fix it or provide alternative solution

CodeSyncr commented 3 years ago

Mode: STA PHY mode: N Channel: 11 AP id: 0 Status: 5 Auto connect: 1 SSID (9): YashKumar Passphrase (10): galaxy2020 BSSID set: 0 192.168.0.105

this this the response in serial moniter wifi is configured but app not giving response

max-koehler commented 3 years ago

Sorry for the late response. It's hard to debug the issue remotely. In most cases, the used network might be the root cause and could also be in this case.

I'd recommend increasing the timeout in the Mobile-App to see if that solves your problem of not receiving the success message.