tripflex / WifiWizard2

A Cordova plugin for managing Wifi networks (new version of WiFiWizard) - Latest is version 3+
https://www.npmjs.com/package/cordova-plugin-wifiwizard2
Apache License 2.0
123 stars 146 forks source link

not getting connected wifi : (android) #5

Closed bhumin3i closed 6 years ago

bhumin3i commented 6 years ago
ionViewDidLoad() {
    console.log("ionViewDidLoad AdvanceMeetingBookingPage");
    this.platform.ready().then(() => {
      this.startScan();
      console.log('networks',this.networks);
  });

    this.getFacilityList();
  }
  startScan() {
    if (typeof WifiWizard2 !== 'undefined') {
            console.log("WifiWizard loaded: ");
            console.log(WifiWizard2);
    } else {
        console.warn('WifiWizard not loaded.');
    }              

    let successNetwork = (e: any) => {
      console.log('e',e);
      WifiWizard2.getConnectedSSID(listHandler, failNetwork);
    }

    let failNetwork = (e: any) => {
        console.log("fail : " + e);
    }

    let listHandler = (a: any) => {
        this.networks = [];
        console.log('a',a);
        for (let x in a) {
          console.log('ssid',a[x].SSID);                    
            console.log(a[x].SSID + ", " + a[x].BSSID + ", " + a[x].level);  
            this.networks.push({
                ssid: a[x].SSID,
                bssid: a[x].BSSID,
                level: a[x].level});                
        } 
        console.log('listHandler networks',this.networks);
    }
    WifiWizard2.startScan(successNetwork, failNetwork);
}

result in console : WifiWizard loaded: Object {getCurrentSSID: function, getCurrentBSSID: function, iOSConnectNetwork: function, iOSDisconnectNetwork: function, formatWifiConfig: function…} networks [] e OK a [] listHandler networks []

kaichancoder commented 6 years ago

Your GPS turned on?

tripflex commented 6 years ago

@bhumin3i yeah there's a chance it may be a permissions issue, or the handling of callbacks with async, i'm working on a rebuild and will let you know for sure. I do have some updates I made for checking permissions though I will go ahead and push that here shortly, just need to clean up the code some and remove some of the testing for different versions of android

@bhumin3i what version of Android are you testing this on?

I'm going to build a project too to use for testing and will get that setup as well so you guys have some example code to build off of and test with as well

bigt11 commented 6 years ago

Using v2.1.1 I was playing with 3.0 and also could not connect, so I decided to try 2.1.1 because 3.0 might be a bit glitchie. I cant seem to get connected on 2.1.1 using android 7.1.1.

Here is my code

function TAOconnectToWifi2()
    {
        console.log("inside TAOconnectToWifi2 function");

        WifiWizard2.setWifiEnabled(true,
        function(){
            console.log("WiFi is enabled");
            //var of the SSID
            TAOsewingServerSSID = "myssid";
            //var of the password
            TAOsewingServerPassword = "1234567890";     

            TAOwifiConfig = WifiWizard2.formatWPAConfig(TAOsewingServerSSID,TAOsewingServerPassword);

            WifiWizard2.addNetwork(TAOwifiConfig,
                //success
                function(){
                    console.log("addNetwork is a success");
                    console.log("connecting to SSID = " + TAOsewingServerSSID);

                    WifiWizard2.androidConnectNetwork(TAOsewingServerSSID,
                        //success
                        function(){
                            console.log("Connect to SSID = " + TAOsewingServerSSID + " is a success");
                        },
                        //fail
                        function(){
                            console.log("Connect to SSID = " + TAOsewingServerSSID + " is a fail");
                        }

                    );

                },
                //fail
                function(){
                    console.log("addNetwork FAILED");
                }
            );

        },
        function(){
            console.log("WiFi enable failed");
        });
    }

OUTPUT OF CONSOLE

inside TAOconnectToWifi2 function
WiFi is enabled
addNetwork is a success
connecting to SSID = myssid
Connect to SSID = myssid is a fail

LOGCAT

01-25 15:30:47.868 12654 12654 I chromium: [INFO:CONSOLE(682)] "inside TAOconnectToWifi2 function", 
01-25 15:30:47.869 12654 12731 D WifiWizard2: WifiWizard2: verifyWifiEnabled entered.
01-25 15:30:47.870 12654 12731 I WifiWizard2: Enabling wi-fi...
01-25 15:30:47.870    66    73 D WifiService: Trying to set WiFi to: true
01-25 15:30:47.875 12654 12731 I WifiWizard2: Wi-fi enabled
01-25 15:30:47.891    66    76 D WifiService: wifiEnabled: 1 -> 3
01-25 15:30:48.876    66 18370 D WifiService: Trying to set WiFi to: true
01-25 15:30:48.881 12654 12731 W PluginManager: THREAD WARNING: exec() call to WifiWizard2.setWifiEnabled blocked the main thread for 1013ms. Plugin should use CordovaInterface.getThreadPool().
01-25 15:30:48.885 12654 12654 D SystemWebChromeClient:  : WiFi is enabled
01-25 15:30:48.885 12654 12654 I chromium: [INFO:CONSOLE(686)] "WiFi is enabled", 
01-25 15:30:48.886 12654 12731 D WifiWizard2: WifiWizard2: verifyWifiEnabled entered.
01-25 15:30:48.886 12654 12731 D WifiWizard2: WifiWizard2: addNetwork entered.
01-25 15:30:48.892    66 18382 D WifiService: Updating Id:Guid 0:3b4b046e-49bc-48d2-a6b7-98515415e3e2
01-25 15:30:48.892    66 18382 D WifiService: SSID: "myssid" StrippedSSID: myssid
01-25 15:30:48.917    66 18382 D WifiService: Host returned Guid: fddae30d-7e0e-41cb-bf1e-b2ff1cead083 for Ssid: "myssid"
01-25 15:30:48.917    66 18382 D WifiService: Trying to remove network with Id: 0
01-25 15:30:48.925    66 18382 E WifiService: Error removing configured network in the Host 3b4b046e-49bc-48d2-a6b7-98515415e3e2
01-25 15:30:48.925    66 18382 D WifiService: Remove network failed for Guid: 3b4b046e-49bc-48d2-a6b7-98515415e3e2
01-25 15:30:48.925    66 18382 E WifiService: Removing old configuration failed while updating Guid: 3b4b046e-49bc-48d2-a6b7-98515415e3e2
01-25 15:30:48.925    66 18382 D WifiService: Trying to remove network with Id: 21
01-25 15:30:49.001    66 18382 I ArcNetworkIdMap: Removed GUID:Id fddae30d-7e0e-41cb-bf1e-b2ff1cead083:21
01-25 15:30:49.002 12654 12731 W PluginManager: THREAD WARNING: exec() call to WifiWizard2.addNetwork blocked the main thread for 116ms. Plugin should use CordovaInterface.getThreadPool().
01-25 15:30:49.005 12654 12654 D SystemWebChromeClient: f : addNetwork is a success
01-25 15:30:49.005 12654 12654 I chromium: [INFO:CONSOLE(697)] "addNetwork is a success",  (697)
01-25 15:30:49.006 12654 12654 D SystemWebChromeClient: : connecting to SSID = myssid
01-25 15:30:49.006 12654 12654 I chromium: [INFO:CONSOLE(698)] "connecting to SSID = myssid",  (698)
01-25 15:30:49.009 12654 12731 D WifiWizard2: WifiWizard2: verifyWifiEnabled entered.
01-25 15:30:49.011 12654 12731 D WifiWizard2: WifiWizard2: connectNetwork entered.
01-25 15:30:49.013 12654 12731 D WifiWizard2: No currently connected net id found
01-25 15:30:49.013 12654 12731 D WifiWizard2: Valid networkIdToConnect: attempting connection
01-25 15:30:49.014    66 18387 D WifiService: Not connected to any network currently
01-25 15:30:49.015    66  1896 D WifiService: Disabling Id : Guid 0 : 3b4b046e-49bc-48d2-a6b7-98515415e3e2
01-25 15:30:49.015    66  9912 D WifiService: Trying to connect to Guid: 3b4b046e-49bc-48d2-a6b7-98515415e3e2
01-25 15:30:49.016    66 18389 D WifiService: Trying to reconnect to Id : Guid 0 : 3b4b046e-49bc-48d2-a6b7-98515415e3e2
01-25 15:30:49.016    66 18389 D WifiService: Trying to connect to Guid: 3b4b046e-49bc-48d2-a6b7-98515415e3e2
01-25 15:30:49.016    66    76 E WifiService: Error connecting to network 1
01-25 15:30:49.017    66    76 E WifiService: Error connecting to network 1
01-25 15:30:49.019 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 1 out of 30
01-25 15:30:50.020 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 2 out of 30
01-25 15:30:50.915    66    76 D WifiService: Scan Completed
01-25 15:30:51.021 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 3 out of 30
01-25 15:30:52.025 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 4 out of 30
01-25 15:30:53.026 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 5 out of 30
01-25 15:30:54.030 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 6 out of 30
01-25 15:30:55.032 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 7 out of 30
01-25 15:30:56.033 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 8 out of 30
01-25 15:30:57.034 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 9 out of 30
01-25 15:30:57.393    66    76 D WifiService: Scan Completed
01-25 15:30:58.035 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 10 out of 30
01-25 15:30:59.040 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 11 out of 30
01-25 15:30:59.443   683   890 W MDM     : DataUsageCollector - planConfig == null. getIsWifiConnected: false. getIsMobileConnected: false
01-25 15:30:59.514   683   890 W MDM     : StatsFactory - Interface [arc0] => Type [Mobile]
01-25 15:30:59.514   683   890 W MDM     : StatsFactory - Interface [lo] => Type [LoopBack]
01-25 15:30:59.538   683   890 W MDM     : StatsFactory - Interface [arc0] => Type [Mobile]
01-25 15:30:59.538   683   890 W MDM     : StatsFactory - Interface [lo] => Type [LoopBack]
01-25 15:31:00.045 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 12 out of 30
01-25 15:31:01.049 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 13 out of 30
01-25 15:31:02.052 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 14 out of 30
01-25 15:31:03.055 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 15 out of 30
01-25 15:31:04.058 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 16 out of 30
01-25 15:31:05.060 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 17 out of 30
01-25 15:31:06.061 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 18 out of 30
01-25 15:31:07.062 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 19 out of 30
01-25 15:31:07.334    66    76 D WifiService: Scan Completed
01-25 15:31:08.064 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 20 out of 30
01-25 15:31:09.067 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 21 out of 30
01-25 15:31:10.072 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 22 out of 30
01-25 15:31:11.073 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 23 out of 30
01-25 15:31:12.077 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 24 out of 30
01-25 15:31:13.078 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 25 out of 30
01-25 15:31:14.082 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 26 out of 30
01-25 15:31:14.439   683   890 W MDM     : DataUsageCollector - planConfig == null. getIsWifiConnected: false. getIsMobileConnected: false
01-25 15:31:14.484   683   890 W MDM     : StatsFactory - Interface [arc0] => Type [Mobile]
01-25 15:31:14.484   683   890 W MDM     : StatsFactory - Interface [lo] => Type [LoopBack]
01-25 15:31:14.559   683   890 W MDM     : StatsFactory - Interface [arc0] => Type [Mobile]
01-25 15:31:14.559   683   890 W MDM     : StatsFactory - Interface [lo] => Type [LoopBack]
01-25 15:31:14.580   683   890 W MDM     : StatsFactory - Interface [arc0] => Type [Mobile]
01-25 15:31:14.580   683   890 W MDM     : StatsFactory - Interface [lo] => Type [LoopBack]
01-25 15:31:14.599   683   890 W MDM     : StatsFactory - Interface [arc0] => Type [Mobile]
01-25 15:31:14.599   683   890 W MDM     : StatsFactory - Interface [lo] => Type [LoopBack]
01-25 15:31:14.619   683   890 W MDM     : StatsFactory - Interface [arc0] => Type [Mobile]
01-25 15:31:14.619   683   890 W MDM     : StatsFactory - Interface [lo] => Type [LoopBack]
01-25 15:31:15.084 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 27 out of 30
01-25 15:31:15.480    66    66 V BackupManagerService: Scheduling immediate backup pass
01-25 15:31:15.482    66    66 W BackupManagerService: Backup pass but e=false p=true
01-25 15:31:16.084 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 28 out of 30
01-25 15:31:17.085 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 29 out of 30
01-25 15:31:17.363    66    76 D WifiService: Scan Completed
01-25 15:31:18.086 12654 12731 D WifiWizard2: WifiWizard: Got IDLE on 30 out of 30
01-25 15:31:19.087 12654 12731 D WifiWizard2: WifiWizard: Network failed to finish connecting within the timeout
01-25 15:31:19.088 12654 12731 W PluginManager: THREAD WARNING: exec() call to WifiWizard2.androidConnectNetwork blocked the main thread for 30079ms. Plugin should use CordovaInterface.getThreadPool().
01-25 15:31:19.111 12654 12654 D SystemWebChromeClient:  : Connect to SSID = myssid is a fail
01-25 15:31:19.112 12654 12654 I chromium: [INFO:CONSOLE(707)] "Connect to SSID = myssid is a fail", (707)
tripflex commented 6 years ago

Please try the demo project link you can find in README on the 3.0.0 branch and let me know if you still have issues: https://github.com/tripflex/WifiWizard2/tree/3.0.0

bhumin3i commented 6 years ago

@tripflex
when i update plugin to 3.1.0 error show

WifiWizard loaded:
2018-10-08 15:55:42.189555+0530 @RTI[3679:343741] ERROR: ERROR TypeError: WifiWizard2.getConnectedBSSID is not a function.