Showing
4 changed files
with
32 additions
and
9 deletions
| ... | ... | @@ -46,7 +46,7 @@ public class Constant { |
| 46 | 46 | |
| 47 | 47 | public static final String DEFAULT_IP = BuildConfig.DEFAULT_IP; |
| 48 | 48 | public static final String DEFAULT_USER = "admin"; |
| 49 | - public static final String DEFAULT_PWD = "zxc123456"; | |
| 49 | + public static final String DEFAULT_PWD = "Asd123456"; | |
| 50 | 50 | public static final String DEFAULT_FOLDER = "root"; |
| 51 | 51 | public static final String DEFAULT_PATH = ""; |
| 52 | 52 | public static boolean userOpen = false; | ... | ... |
| ... | ... | @@ -78,7 +78,7 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 78 | 78 | private RoomStatusInfo roomStatusInfo; |
| 79 | 79 | private RoomInfo roomInfo; |
| 80 | 80 | private RoomQrCodeInfo info; |
| 81 | - private String lockMac = "CA:EC:56:60:CA:79"; | |
| 81 | + private String lockMac = ""; | |
| 82 | 82 | private boolean needReport = false; |
| 83 | 83 | //___________________________________________ |
| 84 | 84 | private boolean initGetOderInfo; |
| ... | ... | @@ -226,8 +226,15 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | }); |
| 229 | - String openCMD = "Open the door"; | |
| 230 | - GREENBLE.send(this, lockMac, openCMD.getBytes()); | |
| 229 | + if (!TextUtils.isEmpty(lockMac)) { | |
| 230 | + String openCMD = "Open the door"; | |
| 231 | + GREENBLE.send(this, lockMac, openCMD.getBytes()); | |
| 232 | + } else { | |
| 233 | + if (needReport) { | |
| 234 | + mHandler.postDelayed(reportRunnable, 2 * 1000); | |
| 235 | + LogUtils.i("room-info", "user open door ,report the open success status"); | |
| 236 | + } | |
| 237 | + } | |
| 231 | 238 | } |
| 232 | 239 | |
| 233 | 240 | @Subscribe(threadMode = ThreadMode.MAIN) | ... | ... |
| ... | ... | @@ -164,6 +164,8 @@ public class SocketService1 extends BaseService { |
| 164 | 164 | }; |
| 165 | 165 | |
| 166 | 166 | private Context context = this; |
| 167 | + private InitSocketThread initSocketThread; | |
| 168 | + private ReadThread readThread; | |
| 167 | 169 | |
| 168 | 170 | @Override |
| 169 | 171 | public IBinder onBind(Intent arg0) { |
| ... | ... | @@ -216,8 +218,20 @@ public class SocketService1 extends BaseService { |
| 216 | 218 | e.printStackTrace(); |
| 217 | 219 | return super.onStartCommand(intent, flags, startId); |
| 218 | 220 | } |
| 219 | - new InitSocketThread().start(); | |
| 220 | - new ReadThread().start(); | |
| 221 | + if (initSocketThread == null) { | |
| 222 | + LogUtils.i("initSocketThread is null"); | |
| 223 | + initSocketThread = new InitSocketThread(); | |
| 224 | + initSocketThread.start(); | |
| 225 | + } else { | |
| 226 | + LogUtils.i("initSocketThread is not null"); | |
| 227 | + } | |
| 228 | + if (readThread == null) { | |
| 229 | + LogUtils.i("readThread is null"); | |
| 230 | + readThread = new ReadThread(); | |
| 231 | + readThread.start(); | |
| 232 | + } else { | |
| 233 | + LogUtils.i("readThread is not null"); | |
| 234 | + } | |
| 221 | 235 | return START_STICKY; |
| 222 | 236 | } |
| 223 | 237 | |
| ... | ... | @@ -473,7 +487,9 @@ public class SocketService1 extends BaseService { |
| 473 | 487 | |
| 474 | 488 | @Override |
| 475 | 489 | public void onDestroy() { |
| 476 | - LogUtils.i(TAG, "socket service destroy"); | |
| 490 | + LogUtils.i(TAG, "socket service destroy,reset initSocketThread readThread"); | |
| 491 | + initSocketThread = null; | |
| 492 | + readThread = null; | |
| 477 | 493 | super.onDestroy(); |
| 478 | 494 | } |
| 479 | 495 | ... | ... |
Please
register
or
login
to post a comment