changed timeout

This commit is contained in:
Niklas 2019-01-28 18:36:38 +01:00
parent 4eabcc96fc
commit 45d7a76c8b
7 changed files with 44 additions and 13 deletions

6
android/.classpath Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>

23
android/.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flutter_smartconfig</name>
<comment>Project android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
connection.project.dir=../example/android
eclipse.preferences.version=1

View File

@ -30,7 +30,7 @@ public class UDPSocketClient {
this.mIsClosed = false;
} catch (SocketException e) {
if (__IEsptouchTask.DEBUG) {
Log.e(TAG, "SocketException");
Log.w(TAG, "SocketException");
}
e.printStackTrace();
}
@ -85,7 +85,7 @@ public class UDPSocketClient {
String targetHostName, int targetPort, long interval) {
if ((data == null) || (data.length <= 0)) {
if (__IEsptouchTask.DEBUG) {
Log.e(TAG, "sendData(): data == null or length <= 0");
Log.w(TAG, "sendData(): data == null or length <= 0");
}
return;
}
@ -100,14 +100,14 @@ public class UDPSocketClient {
this.mSocket.send(localDatagramPacket);
} catch (UnknownHostException e) {
if (__IEsptouchTask.DEBUG) {
Log.e(TAG, "sendData(): UnknownHostException");
Log.w(TAG, "sendData(): UnknownHostException");
}
e.printStackTrace();
mIsStop = true;
break;
} catch (IOException e) {
if (__IEsptouchTask.DEBUG) {
Log.e(TAG, "sendData(): IOException, but just ignore it");
Log.w(TAG, "sendData(): IOException, but just ignore it");
}
// for the Ap will make some troubles when the phone send too many UDP packets,
// but we don't expect the UDP packet received by others, so just ignore it
@ -117,7 +117,7 @@ public class UDPSocketClient {
} catch (InterruptedException e) {
e.printStackTrace();
if (__IEsptouchTask.DEBUG) {
Log.e(TAG, "sendData is Interrupted");
Log.w(TAG, "sendData is Interrupted");
}
mIsStop = true;
break;

View File

@ -37,7 +37,7 @@ public class UDPSocketServer {
this.mServerSocket.bind(new InetSocketAddress(port));
this.mServerSocket.setSoTimeout(socketTimeout);
} catch (IOException e) {
Log.e(TAG, "IOException");
Log.w(TAG, "IOException");
e.printStackTrace();
}
this.mIsClosed = false;
@ -113,9 +113,9 @@ public class UDPSocketServer {
byte[] recDatas = Arrays.copyOf(mReceivePacket.getData(), mReceivePacket.getLength());
Log.d(TAG, "received len : " + recDatas.length);
for (int i = 0; i < recDatas.length; i++) {
Log.e(TAG, "recDatas[" + i + "]:" + recDatas[i]);
Log.w(TAG, "recDatas[" + i + "]:" + recDatas[i]);
}
Log.e(TAG, "receiveSpecLenBytes: " + new String(recDatas));
Log.w(TAG, "receiveSpecLenBytes: " + new String(recDatas));
if (recDatas.length != len) {
Log.w(TAG,
"received len is different from specific len, return null");
@ -135,7 +135,7 @@ public class UDPSocketServer {
public synchronized void close() {
if (!this.mIsClosed) {
Log.e(TAG, "mServerSocket is closed");
Log.w(TAG, "mServerSocket is closed");
mServerSocket.close();
releaseLock();
this.mIsClosed = true;

View File

@ -28,13 +28,13 @@ class FlutterSmartconfig {
}
static Future<dynamic> configureEsp(
{String ssid, String bssid, String password}) async {
{String ssid, String bssid, String password, bool multicast, Duration timeout}) async {
if (Platform.isAndroid) {
try {
// Change if required.
const String deviceCount = "1"; // the expect result count
const String broadcast = "1"; // broadcast or multicast
const Duration _kLongTimeout = const Duration(seconds: 20);
String broadcast = (multicast != null && multicast) ? "0" : "1"; // broadcast (1) or multicast (0)
Duration _kLongTimeout = timeout ?? const Duration(seconds: 20);
final String result =
await platform.invokeMethod('startSmartConfig', <String, dynamic>{

View File

@ -1,6 +1,6 @@
name: flutter_smartconfig
description: A new flutter plugin project.
version: 0.0.1
version: 0.0.3
author:
homepage: