Showing
4 changed files
with
32 additions
and
9 deletions
| @@ -46,7 +46,7 @@ public class Constant { | @@ -46,7 +46,7 @@ public class Constant { | ||
| 46 | 46 | ||
| 47 | public static final String DEFAULT_IP = BuildConfig.DEFAULT_IP; | 47 | public static final String DEFAULT_IP = BuildConfig.DEFAULT_IP; |
| 48 | public static final String DEFAULT_USER = "admin"; | 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 | public static final String DEFAULT_FOLDER = "root"; | 50 | public static final String DEFAULT_FOLDER = "root"; |
| 51 | public static final String DEFAULT_PATH = ""; | 51 | public static final String DEFAULT_PATH = ""; |
| 52 | public static boolean userOpen = false; | 52 | public static boolean userOpen = false; |
| @@ -78,7 +78,7 @@ public class SmartControlService extends BaseService implements EventListener<St | @@ -78,7 +78,7 @@ public class SmartControlService extends BaseService implements EventListener<St | ||
| 78 | private RoomStatusInfo roomStatusInfo; | 78 | private RoomStatusInfo roomStatusInfo; |
| 79 | private RoomInfo roomInfo; | 79 | private RoomInfo roomInfo; |
| 80 | private RoomQrCodeInfo info; | 80 | private RoomQrCodeInfo info; |
| 81 | - private String lockMac = "CA:EC:56:60:CA:79"; | 81 | + private String lockMac = ""; |
| 82 | private boolean needReport = false; | 82 | private boolean needReport = false; |
| 83 | //___________________________________________ | 83 | //___________________________________________ |
| 84 | private boolean initGetOderInfo; | 84 | private boolean initGetOderInfo; |
| @@ -226,8 +226,15 @@ public class SmartControlService extends BaseService implements EventListener<St | @@ -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 | @Subscribe(threadMode = ThreadMode.MAIN) | 240 | @Subscribe(threadMode = ThreadMode.MAIN) |
| @@ -164,6 +164,8 @@ public class SocketService1 extends BaseService { | @@ -164,6 +164,8 @@ public class SocketService1 extends BaseService { | ||
| 164 | }; | 164 | }; |
| 165 | 165 | ||
| 166 | private Context context = this; | 166 | private Context context = this; |
| 167 | + private InitSocketThread initSocketThread; | ||
| 168 | + private ReadThread readThread; | ||
| 167 | 169 | ||
| 168 | @Override | 170 | @Override |
| 169 | public IBinder onBind(Intent arg0) { | 171 | public IBinder onBind(Intent arg0) { |
| @@ -216,8 +218,20 @@ public class SocketService1 extends BaseService { | @@ -216,8 +218,20 @@ public class SocketService1 extends BaseService { | ||
| 216 | e.printStackTrace(); | 218 | e.printStackTrace(); |
| 217 | return super.onStartCommand(intent, flags, startId); | 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 | return START_STICKY; | 235 | return START_STICKY; |
| 222 | } | 236 | } |
| 223 | 237 | ||
| @@ -473,7 +487,9 @@ public class SocketService1 extends BaseService { | @@ -473,7 +487,9 @@ public class SocketService1 extends BaseService { | ||
| 473 | 487 | ||
| 474 | @Override | 488 | @Override |
| 475 | public void onDestroy() { | 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 | super.onDestroy(); | 493 | super.onDestroy(); |
| 478 | } | 494 | } |
| 479 | 495 |
Please
register
or
login
to post a comment