|
@@ -4,22 +4,24 @@ import android.content.Context; |
|
@@ -4,22 +4,24 @@ import android.content.Context; |
|
4
|
import android.content.Intent;
|
4
|
import android.content.Intent;
|
|
5
|
import android.os.AsyncTask;
|
5
|
import android.os.AsyncTask;
|
|
6
|
import android.support.v4.content.LocalBroadcastManager;
|
6
|
import android.support.v4.content.LocalBroadcastManager;
|
|
7
|
-
|
7
|
+import android.text.TextUtils;
|
|
|
|
8
|
+import android.util.Log;
|
|
8
|
import com.adroplat.fist_switch.SwitchApplication;
|
9
|
import com.adroplat.fist_switch.SwitchApplication;
|
|
9
|
import com.adroplat.fist_switch.config.GlobalVar;
|
10
|
import com.adroplat.fist_switch.config.GlobalVar;
|
|
10
|
import com.adroplat.fist_switch.utils.ToastUtils;
|
11
|
import com.adroplat.fist_switch.utils.ToastUtils;
|
|
11
|
import com.adroplat.fist_switch.utils.WifiUtils;
|
12
|
import com.adroplat.fist_switch.utils.WifiUtils;
|
|
12
|
import com.adroplat.fist_switch.utils.protocol.one.FistProtocol;
|
13
|
import com.adroplat.fist_switch.utils.protocol.one.FistProtocol;
|
|
13
|
import com.google.gson.Gson;
|
14
|
import com.google.gson.Gson;
|
|
|
|
15
|
+import io.realm.Realm;
|
|
14
|
|
16
|
|
|
15
|
import java.util.ArrayList;
|
17
|
import java.util.ArrayList;
|
|
16
|
|
18
|
|
|
17
|
-import io.realm.Realm;
|
|
|
|
18
|
-
|
|
|
|
19
|
/**
|
19
|
/**
|
|
20
|
* Created by WLJ on 2016/1/14.
|
20
|
* Created by WLJ on 2016/1/14.
|
|
21
|
*/
|
21
|
*/
|
|
22
|
public class FistJni {
|
22
|
public class FistJni {
|
|
|
|
23
|
+ private static final String TAG = FistJni.class.getSimpleName();
|
|
|
|
24
|
+
|
|
23
|
static {
|
25
|
static {
|
|
24
|
System.loadLibrary("fist_ndk");
|
26
|
System.loadLibrary("fist_ndk");
|
|
25
|
}
|
27
|
}
|
|
@@ -119,16 +121,21 @@ public class FistJni { |
|
@@ -119,16 +121,21 @@ public class FistJni { |
|
119
|
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
121
|
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
|
120
|
}
|
122
|
}
|
|
121
|
|
123
|
|
|
|
|
124
|
+ static String deviceJsonAA;
|
|
|
|
125
|
+
|
|
122
|
public static void fistListener(String jsonDevice) {
|
126
|
public static void fistListener(String jsonDevice) {
|
|
123
|
if (null == jsonDevice || jsonDevice.isEmpty()) return;
|
127
|
if (null == jsonDevice || jsonDevice.isEmpty()) return;
|
|
124
|
- GlobalVar.getLogUtils().i("fistListener jsonDevice =" + jsonDevice);
|
128
|
+// GlobalVar.getLogUtils().i("fistListener jsonDevice =" + jsonDevice);
|
|
|
|
129
|
+ Log.d(TAG, jsonDevice);
|
|
125
|
Gson gson = getGson();
|
130
|
Gson gson = getGson();
|
|
126
|
Device device = gson.fromJson(jsonDevice, Device.class);
|
131
|
Device device = gson.fromJson(jsonDevice, Device.class);
|
|
127
|
char cmdTpye = (char) device.getCmdType();
|
132
|
char cmdTpye = (char) device.getCmdType();
|
|
128
|
-
|
133
|
+ if (TextUtils.isEmpty(deviceJsonAA)) {
|
|
|
|
134
|
+ deviceJsonAA = jsonDevice;
|
|
|
|
135
|
+ }
|
|
129
|
if (FistProtocol.CommondType.CMD_TYPE_SEARCH_RESPONSE == cmdTpye) {//查询响应
|
136
|
if (FistProtocol.CommondType.CMD_TYPE_SEARCH_RESPONSE == cmdTpye) {//查询响应
|
|
130
|
removeId(device);
|
137
|
removeId(device);
|
|
131
|
- online(device, jsonDevice);
|
138
|
+// online(device, jsonDevice);
|
|
132
|
sendJsonDevice(SEARCH_RESPONSE, device);
|
139
|
sendJsonDevice(SEARCH_RESPONSE, device);
|
|
133
|
|
140
|
|
|
134
|
} else if (FistProtocol.CommondType.CMD_TYPE_CONFIG_DONE == cmdTpye) {//配置完成处理
|
141
|
} else if (FistProtocol.CommondType.CMD_TYPE_CONFIG_DONE == cmdTpye) {//配置完成处理
|
|
@@ -143,7 +150,7 @@ public class FistJni { |
|
@@ -143,7 +150,7 @@ public class FistJni { |
|
143
|
sendJsonDevice(ADD_DONE, device);
|
150
|
sendJsonDevice(ADD_DONE, device);
|
|
144
|
ArrayList<SubDevice> subDevices = device.getSubDevices();
|
151
|
ArrayList<SubDevice> subDevices = device.getSubDevices();
|
|
145
|
if (!subDevices.isEmpty()) {//查询结果不为空
|
152
|
if (!subDevices.isEmpty()) {//查询结果不为空
|
|
146
|
- Realm realm = Realm.getDefaultInstance();
|
153
|
+// Realm realm = Realm.getDefaultInstance();
|
|
147
|
// long hostNum = device.getLongDeviceNum();
|
154
|
// long hostNum = device.getLongDeviceNum();
|
|
148
|
// RealmResults<Hub> hubs = realm.where(Hub.class)
|
155
|
// RealmResults<Hub> hubs = realm.where(Hub.class)
|
|
149
|
// .equalTo(Hub.Companion.getDEVICE_NUM(), hostNum)
|
156
|
// .equalTo(Hub.Companion.getDEVICE_NUM(), hostNum)
|
|
@@ -175,7 +182,7 @@ public class FistJni { |
|
@@ -175,7 +182,7 @@ public class FistJni { |
|
175
|
// }
|
182
|
// }
|
|
176
|
// }
|
183
|
// }
|
|
177
|
|
184
|
|
|
178
|
- realm.close();
|
185
|
+// realm.close();
|
|
179
|
}
|
186
|
}
|
|
180
|
// sendJsonDevice(LightingGroupAdapter.REFRESH, device);
|
187
|
// sendJsonDevice(LightingGroupAdapter.REFRESH, device);
|
|
181
|
|
188
|
|
|
@@ -254,6 +261,7 @@ public class FistJni { |
|
@@ -254,6 +261,7 @@ public class FistJni { |
|
254
|
@Override
|
261
|
@Override
|
|
255
|
protected Void doInBackground(Void... params) {
|
262
|
protected Void doInBackground(Void... params) {
|
|
256
|
start();
|
263
|
start();
|
|
|
|
264
|
+ Log.d(TAG, "start sdk");
|
|
257
|
return null;
|
265
|
return null;
|
|
258
|
}
|
266
|
}
|
|
259
|
}.execute();
|
267
|
}.execute();
|
|
@@ -298,6 +306,19 @@ public class FistJni { |
|
@@ -298,6 +306,19 @@ public class FistJni { |
|
298
|
}.execute();
|
306
|
}.execute();
|
|
299
|
}
|
307
|
}
|
|
300
|
|
308
|
|
|
|
|
309
|
+ public void query( ) {
|
|
|
|
310
|
+// if (!HeService.isConn()) {
|
|
|
|
311
|
+// return;
|
|
|
|
312
|
+// }
|
|
|
|
313
|
+ new AsyncTask<Void, Void, Void>() {
|
|
|
|
314
|
+ @Override
|
|
|
|
315
|
+ protected Void doInBackground(Void... params) {
|
|
|
|
316
|
+ querySubDevice(deviceJsonAA);
|
|
|
|
317
|
+ return null;
|
|
|
|
318
|
+ }
|
|
|
|
319
|
+ }.execute();
|
|
|
|
320
|
+ }
|
|
|
|
321
|
+
|
|
301
|
/**
|
322
|
/**
|
|
302
|
* 开始添加子设备
|
323
|
* 开始添加子设备
|
|
303
|
*/
|
324
|
*/
|
|
@@ -470,6 +491,7 @@ public class FistJni { |
|
@@ -470,6 +491,7 @@ public class FistJni { |
|
470
|
@Override
|
491
|
@Override
|
|
471
|
protected Void doInBackground(Void... params) {
|
492
|
protected Void doInBackground(Void... params) {
|
|
472
|
searchDevice();
|
493
|
searchDevice();
|
|
|
|
494
|
+ Log.d(TAG, "search local device");
|
|
473
|
return null;
|
495
|
return null;
|
|
474
|
}
|
496
|
}
|
|
475
|
}.execute();
|
497
|
}.execute();
|