wifidirectplugin 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,11 +33,18 @@ public class WifiDirectPlugin extends Plugin {
|
|
|
33
33
|
|
|
34
34
|
@PluginMethod
|
|
35
35
|
public void scanWifiPeers(PluginCall call) {
|
|
36
|
-
Log.d(TAG, "scanWifiPeers
|
|
36
|
+
Log.d(TAG, "scanWifiPeers Called");
|
|
37
|
+
if(manager == null || channel == null) {
|
|
38
|
+
Log.e(TAG, "WifiP2pManager or Channel is null");
|
|
39
|
+
call.reject("WifiP2pManager or Channel not initialized");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
37
42
|
manager.discoverPeers(channel, new WifiP2pManager.ActionListener() {
|
|
38
43
|
@Override
|
|
39
44
|
public void onSuccess() {
|
|
40
45
|
manager.requestPeers(channel, peerList -> {
|
|
46
|
+
Log.d(TAG, "scanWifi onSuccess Called");
|
|
47
|
+
|
|
41
48
|
peerWifiDirDevices.clear();
|
|
42
49
|
peerWifiDirDevices.addAll(peerList.getDeviceList());
|
|
43
50
|
JSONArray devicesJson = new JSONArray();
|
|
@@ -49,7 +56,7 @@ public class WifiDirectPlugin extends Plugin {
|
|
|
49
56
|
deviceJson.put("deviceName", device.deviceName);
|
|
50
57
|
deviceJson.put("deviceAddress", device.deviceAddress);
|
|
51
58
|
deviceJson.put("status", device.status);
|
|
52
|
-
deviceJson.put("connected", device.status == WifiP2pDevice.CONNECTED);
|
|
59
|
+
// deviceJson.put("connected", device.status == WifiP2pDevice.CONNECTED);
|
|
53
60
|
devicesJson.put(deviceJson);
|
|
54
61
|
} catch (JSONException e) {
|
|
55
62
|
Log.e(TAG, "JSON error: ", e);
|
|
@@ -63,6 +70,7 @@ public class WifiDirectPlugin extends Plugin {
|
|
|
63
70
|
|
|
64
71
|
@Override
|
|
65
72
|
public void onFailure(int reason) {
|
|
73
|
+
Log.e(TAG, "scanWifi onFailure: " + reason);
|
|
66
74
|
call.reject("Peer discovery failed: " + reason);
|
|
67
75
|
}
|
|
68
76
|
});
|