flutternetwork / WiFiFlutter

Flutter plugin suite for various WiFi services.
https://wifi.flutternetwork.dev
289 stars 182 forks source link

ESP8266 in AP mode - No connection #319

Open laguierre opened 1 year ago

laguierre commented 1 year ago

I am using wifi_scan explample to list all the near by WiFi network. My idea is when I tap on the network ESP8266 in AP mode, next connect the selected WiFi. An pop up "Do you want to conect....", tap on "connect" and ESP8266 "is conected" throught WiFi. However I have not been successful. The final idea is select an WiFi AP made with ESP8266 and access the info throght 192.168.4.1... Thank!

1 2


ListTile(
      visualDensity: VisualDensity.compact,
      leading: Icon(signalIcon),
      title: Text(title),
      subtitle: Text(widget.accessPoint.capabilities),
      onTap: () async {
          print(widget.accessPoint.ssid);
          bool connect = await WiFiForIoTPlugin.connect(
          widget.accessPoint.ssid,
          joinOnce: true,
          isHidden: false,
          withInternet: false,
          //password: 'none',
          security: NetworkSecurity.NONE,
        );
       print('Conected: $connect');
        await WiFiForIoTPlugin.forceWifiUsage(true);
        await WiFiForIoTPlugin.setEnabled(true);//, shouldOpenSettings: true);

        print(await WiFiForIoTPlugin.isConnected());
        setState(() {});
      },
    );
Gobink6 commented 1 year ago

WiFiForIoTPlugin.connect(SSID, bssid: bssid, password: password, security: network security.WPA) Try this API, If you need to create a connection, you need bssid and security

laguierre commented 1 year ago

I try the API... in my case the connection is open and it doesn't have password. My question is, will I be able to use the API? Also if I use security.WPA the APP crashed. Any other idea?

I/flutter ( 8669): EM E/AndroidRuntime( 8669): FATAL EXCEPTION: Thread-6 E/AndroidRuntime( 8669): Process: com.example.wifi, PID: 8669 E/AndroidRuntime( 8669): java.lang.NullPointerException E/AndroidRuntime( 8669): at com.android.wifi.x.com.android.internal.util.Preconditions.checkNotNull(Preconditions.java:147) E/AndroidRuntime( 8669): at android.net.wifi.WifiNetworkSpecifier$Builder.setWpa2Passphrase(WifiNetworkSpecifier.java:280) E/AndroidRuntime( 8669): at com.alternadom.wifiiot.WifiIotPlugin.connectTo(WifiIotPlugin.java:1389) E/AndroidRuntime( 8669): at com.alternadom.wifiiot.WifiIotPlugin.access$400(WifiIotPlugin.java:54) E/AndroidRuntime( 8669): at com.alternadom.wifiiot.WifiIotPlugin$7.run(WifiIotPlugin.java:903) I/Process ( 8669): Sending signal. PID: 8669 SIG: 9 Lost connection to device.

laguierre commented 1 year ago

Hi, Still can't connect. My source (https://github.com/laguierre/wifi) bool connect = await WiFiForIoTPlugin.connect(  widget.accessPoint.ssid,  bssid: widget.accessPoint.bssid,  joinOnce: true,  isHidden: false,  withInternet: false,  //password: '',  security: NetworkSecurity.NONE,  //withInternet: true,);//bool connect = await WiFiForIoTPlugin.connect(SSID, bssid: bssid, password: password, security: network security.WPA)print('Conected: $connect');await WiFiForIoTPlugin.forceWifiUsage(true);await WiFiForIoTPlugin.setEnabled(true); //, shouldOpenSettings: true);  Regards   Enviado desde Correo para Windows 

De: Gobink6Enviado: martes, 3 de enero de 2023 06:37Para: flutternetwork/WiFiFlutterCC: Leandro Aguierre; AuthorAsunto: Re: [flutternetwork/WiFiFlutter] ESP8266 in AP mode - No connection (Issue #319) 

Try connection use this comment for make API callawait _wifiHandler.forceWifiUage(true);

kadarpik commented 1 year ago

This plugin just fails with ESP AP mode, tried with encrypted and without, the phone Android 11 just claims about unsecure wifi policy. I I enable ESP SSID manually from android wifi setup, everything works as it should be, the plugin forceWifiUsage does not help either. Seems to be a bug somewhere.