Browse Source

1.自动清洗厕所。
2.调试页数据的读取优化。

Tony 5 years ago
parent
commit
d6547ef0ac

+ 13 - 0
app/build.gradle

@@ -1,6 +1,14 @@
 apply plugin: 'com.android.application'
 
 android {
+    signingConfigs {
+        config {
+            storeFile file('..\\clean.jks')
+            storePassword '2967076020'
+            keyAlias 'zeng'
+            keyPassword '2967076020'
+        }
+    }
     compileSdkVersion 28
 
     defaultConfig {
@@ -25,6 +33,11 @@ android {
             jniLibs.srcDirs = ['libs']
         }
     }
+    buildTypes {
+        release {
+            signingConfig signingConfigs.debug
+        }
+    }
 }
 
 ext {

+ 7 - 3
app/src/main/java/com/sunzee/service/MyService.java

@@ -986,8 +986,10 @@ public class MyService extends Service {
                         ArrayList<String> result = new ArrayList(list);
                         result.remove(0);
                         if ("0".equals(result.get(0))) {
+                            //是否加入清洗
                             isClean(0);
                         } else if ("1".equals(result.get(0))) {
+                            //记录
                             addCleanTime(0);
                         }
                     } else {
@@ -1039,11 +1041,13 @@ public class MyService extends Service {
                 Log.d(TAG, "厕所event: " + System.currentTimeMillis());
                 if (System.currentTimeMillis() - holeInformation.getTimeDuration() > 20000) {
                     if (sCleaningLocationList.size() == 0) {
-                        //开始清洗厕所。
-                        sCleaningLocationList.add(0);//如果里面已经有了,那么就不需要在加入了。
+                        //开始清洗厕所。[往尾部添加]
+                        sCleaningLocationList.addLast(0);//如果里面已经有了,那么就需要在加入,并且添加
                         cleanPositionNumX20(number);
                     } else {
-
+                        //todo 这里存在一个问题,就是如果刚好,没有清洗,并且长度大于0呢?
+                        //那么我们就需要判断是否在清洗,通过一个标志位。清洗中,清洗完毕
+                        sCleaningLocationList.addLast(0);
                     }
                     holeInformation.setState(0);//改为2或者0都可以。
                 } else {

+ 18 - 10
serialport-api/src/main/java/com/hboxs/serialport/SerialPortManager.java

@@ -144,21 +144,27 @@ public final class SerialPortManager {
      */
     private Observable<Object> rxSendData(final byte[] data, final String name) {
 
+
         return Observable.create(new ObservableOnSubscribe<Object>() {
             @Override
             public void subscribe(ObservableEmitter<Object> emitter) throws Exception {
-                try {
-                    mReadThread.setmName(name);
-                    sendData(data);
-                    emitter.onComplete();
-                } catch (IOException e) {
-                    Log.e(TAG, "发送:" + ByteUtils.bytes2HexStr(data) + " 失败", e);
-                    if (!emitter.isDisposed()) {
-                        emitter.onError(e);
-                        return;
+                Log.d(TAG, "subscribe: "+emitter);
+                if (!emitter.equals("null")) {
+                    try {
+                        Log.d(TAG, "subscribe: "+emitter);
+                        mReadThread.setmName(name);
+                        sendData(data);
+                        emitter.onComplete();
+                    } catch (IOException e) {
+                        Log.e(TAG, "发送:" + ByteUtils.bytes2HexStr(data) + " 失败", e);
+                        if (!emitter.isDisposed()) {
+                            emitter.onError(e);
+                            return;
+                        }
                     }
+                    emitter.onComplete();
+                    Log.d(TAG, "subscribe: "+emitter);
                 }
-                emitter.onComplete();
             }
         });
     }
@@ -169,10 +175,12 @@ public final class SerialPortManager {
      */
     public void sendCommandFrame(final CommandFrame commandFrame, final String name) {
 //        Log.i(TAG, "发送命令(raw):" + Arrays.toString(commandFrame.getFrameData()));
+        Log.d(TAG, "sendCommandFrame: "+name);
         Log.i(TAG, name+"发送命令:" + commandFrame);
         //已经从我们的去读取出来转换成了字节数了。
         byte[] bytes = commandFrame.getFrameData();
         Log.d("log",new String(bytes).toString());
+
         rxSendData(bytes,name).subscribeOn(Schedulers.io()).subscribe(new Observer<Object>() {
             @Override
             public void onSubscribe(Disposable d) {