Ver Fonte

关门回调,只发送一次

DESKTOP-SADJPBG\47462 há 5 anos atrás
pai
commit
4ed927262d

+ 9 - 3
app/src/main/java/com/siwei/recyclebox/ui/main/MainViewModel.java

xqd xqd
@@ -628,6 +628,7 @@ public class MainViewModel extends BaseViewModel implements SerialPortHelper.OnS
     * */
     private IConnectNotifyListener notifyListener = new IConnectNotifyListener() {
         //物联网平台发送指令,接收并且响应
+        int closeTimeOver=1;
         @Override
         public void onNotify(String connectId, String topic, AMessage aMessage) {
             System.out.println("收到云端下行的数据:connectId:"+connectId+"  topic :"+topic+"  aMessage data:"+ aMessage.getData().getClass().getSimpleName());
@@ -674,20 +675,25 @@ public class MainViewModel extends BaseViewModel implements SerialPortHelper.OnS
                                     reportProperty();
                                 }
                             if(numInt==82){
-                                pushRodMethod();//82秒后关门
+                                if(closeTimeOver==1){
+                                    pushRodMethod();//82秒后关门
+                                    closeTimeOver=2;
+                                }
                                 break;
                             }
                         } catch (InterruptedException e) {
                             e.printStackTrace();
                         }
                     }
-
                 });
                 thread.start();
             }
             if(topic.endsWith("thing/service/RemoteClose")){
                 Log.i(TAG,"收到云端关门========================");
-                pushRodMethod();
+                if(closeTimeOver==1){
+                    pushRodMethod();
+                    closeTimeOver=2;
+                }
             }
             if(topic.endsWith("thing/service/RemoteAgentOpen")){//开收运门
                 Log.i(TAG,"收到云端开运收门");