add some logs.
authorTrillGates <williamtrillgates@gmail.com>
Sat, 16 Jan 2021 06:06:06 +0000 (14:06 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Sat, 16 Jan 2021 06:06:06 +0000 (14:06 +0800)
13 files changed:
app/release/ICSer_V752_2101151444_release.apk [moved from app/release/ICSer_V751_2101141810_release.apk with 78% similarity]
app/release/output.json
app/src/main/aidl/com/ic/work/IHeartRateSensorService.aidl
app/src/main/aidl/com/ic/work/ITempSensorService.aidl
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/bean/Runtime.java
app/src/main/java/com/enqualcomm/support/service/Deliver.java
app/src/main/java/com/enqualcomm/support/service/HeartRateManager.java
app/src/main/java/com/enqualcomm/support/utils/NettyConnection.java
app/src/main/java/com/enqualcomm/support/utils/RxSocket.java
app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java
app/src/main/java/com/enqualcomm/support/utils/mqttConnection.java
app/version_code.properties

similarity index 78%
rename from app/release/ICSer_V751_2101141810_release.apk
rename to app/release/ICSer_V752_2101151444_release.apk
index ae8df78..4b896e1 100644 (file)
Binary files a/app/release/ICSer_V751_2101141810_release.apk and b/app/release/ICSer_V752_2101151444_release.apk differ
index 4a90c63..2918b18 100644 (file)
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":751,"versionName":"2101141810","enabled":true,"outputFile":"ICSer_V751_2101141810_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V751_2101141810_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":752,"versionName":"2101151444","enabled":true,"outputFile":"ICSer_V752_2101151444_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V752_2101151444_release.apk","properties":{}}]
\ No newline at end of file
index 6f63d6e..e4b5e7e 100644 (file)
@@ -10,5 +10,5 @@ interface IHeartRateSensorService {
     //取消接口注册
     void unRegisterCallback(in IHeartRateSensorCallback callback);
     //获取心率相关数据0表示Alarm,1表示客户端用户发出的,3表示服务端发出的单次获取指令
-    oneway void getHeartRateInfo(int from,in String callbackTag);
+    void getHeartRateInfo(int from,in String callbackTag);
 }
\ No newline at end of file
index 3d1847e..8a210e6 100644 (file)
@@ -9,5 +9,5 @@ interface ITempSensorService {
     void unRegisterCallback(in ITempSensorCallback callback);
     //获取体温:0表示Alarm,1表示客户端用户发出的,3表示服务端发出的单次获取指令
     //callbackTag,可以使用报名+类名的字符串组合
-    oneway void getTemperatureInfo(int from,in String callbackTag);
+    void getTemperatureInfo(int from,in String callbackTag);
 }
\ No newline at end of file
index 64f0c04..4a6fab8 100644 (file)
@@ -190,15 +190,10 @@ public class CoreService extends Service {
                 runtime.getLocationInstance().setWorkingMod(EMERGNECY_MOD);
                 //runtime.setPpgTestCycle(1);
                 setLocationAlarm(runtime.getLocationInstance().getWorkingMod());
-
                 //触发一次心率检测
                 setHeartRateDetectAlarm(1);
-
-
                 setEmegencyLocationSTOPAlarm(5);
             } else if (ACTION_LOCAL_SOS_ACTION.endsWith(param1Intent.getAction())) {
-
-
                 VibrateUtil.getInstance(runtime.getContextProxy().context).VibrateOn(true);
 //               if( param1Intent.getIntExtra("type", 1) == 1) {
                 boolean needHRSTestOnSOS = Util.getSystemProperties("persist.sys.needHRSOnSOS", "false").equals("true");
@@ -1449,6 +1444,7 @@ public class CoreService extends Service {
             ICLogger.i("setTempAlarm noTempSensor");
             return;
         }
+        ICLogger.e("setTempAlarm cycle == > " + cycle);
         if (cycle > 1) {
             AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context, cycle, TEMP_ALARM);
             sb.append(" setTempAlarm  " + TEMP_ALARM + ", cycle " + cycle + " seconds");
index d42b5ab..787df89 100644 (file)
@@ -116,6 +116,7 @@ public class Runtime {
     }
 
     public boolean isServerProtocolConnected() {
+        ICLogger.d("ServerHeartBeadReceived == > " + ServerHeartBeadReceived);
         return ServerHeartBeadReceived;
     }
 
index 58aa453..ebc67e7 100644 (file)
@@ -133,7 +133,9 @@ public class Deliver extends AbstractConnectionService {
 //        //如果信号不好,把msg放回去
 //        ret = false;
 //      }
-            if (connection.isServerConnected() == false || !mRuntime.isServerProtocolConnected()) {
+            boolean serverConnected = connection.isServerConnected();
+            ICLogger.d("serverConnected == > " + serverConnected);
+            if (!serverConnected || !mRuntime.isServerProtocolConnected()) {
                 ICLogger.i("服务器无法访问,或者协议状态失常");
                 ret = false;
             }
index fa10295..448ffd6 100644 (file)
@@ -300,17 +300,19 @@ public class HeartRateManager extends AbstractInvokeHandlerService {
         if (CoreService.getInstance() != null) {
             if (CoreService.getInstance().getRuntime().Anti_off_flag == 1) {
                 ICLogger.i("未佩戴,取消 triggerPPGtest!");
-                //return;
+                return;
             }
         }
         //开始去测试
-        try {
-            ICLogger.d("from == >  " + from + " HeartRateManager ");
-            heartRateSensorService.getHeartRateInfo(from, HeartRateManager.class.getName());
-        } catch (Exception e) {
-            e.printStackTrace();
-            ICLogger.e("exception -- > ", e);
-        }
+        ICLogger.d("from == >  " + from + " HeartRateManager ");
+        new Thread(() -> {
+            try {
+                heartRateSensorService.getHeartRateInfo(from, HeartRateManager.class.getName());
+            } catch (Exception e) {
+                e.printStackTrace();
+                ICLogger.e("exception -- > ", e);
+            }
+        }).start();
     }
 
 
index b544795..e6a2b18 100644 (file)
@@ -8,7 +8,6 @@ import android.os.SystemClock;
 import android.util.Log;
 
 import com.enqualcomm.support.Config;
-import com.enqualcomm.support.bean.EventLooperHandlerThread;
 import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.StringMessage;
 import com.ic.protocols.protocolAPIHelper;
@@ -146,7 +145,7 @@ public class NettyConnection implements Connection {
 
 
     public boolean isServerConnected() {
-        return (RxSocket.getInstance().getSocketStatus() == CONNECTED) ? true : false;
+        return RxSocket.getInstance().getSocketStatus() == CONNECTED;
     }
 
     public boolean sendMsg(String cmd) {
index 213526b..0a27dbe 100644 (file)
@@ -1,8 +1,6 @@
 package com.enqualcomm.support.utils;
 
 import java.net.InetSocketAddress;
-import java.net.SocketOptions;
-import java.net.StandardSocketOptions;
 import java.nio.ByteBuffer;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
@@ -10,7 +8,6 @@ import java.nio.channels.SocketChannel;
 import java.util.Iterator;
 import java.util.concurrent.TimeUnit;
 
-//import chestnut.utils.LogUtils;
 import rx.Observable;
 import rx.Subscriber;
 import rx.schedulers.Schedulers;
@@ -18,6 +15,8 @@ import rx.subjects.PublishSubject;
 import rx.subjects.SerializedSubject;
 import rx.subjects.Subject;
 
+//import chestnut.utils.LogUtils;
+
 /**
  * <pre>
  *     author: 栗子酱
@@ -36,22 +35,24 @@ import rx.subjects.Subject;
 public class RxSocket {
 
     /*  常量
-    * */
+     * */
     private String TAG = "RxSocket";
     private boolean OpenLog = true;
     private long WRITE_TIME_OUT = 3000;
     private long CONNECT_TIME_OUT = 3000;
 
     /*  单例
-    * */
-    private Subject<Object,byte[]> readSubject;
-    private Subject<Object,SocketStatus> connectStatus;
+     * */
+    private Subject<Object, byte[]> readSubject;
+    private Subject<Object, SocketStatus> connectStatus;
     private static volatile RxSocket defaultInstance;
+
     private RxSocket() {
         readSubject = new SerializedSubject(PublishSubject.create());
         connectStatus = new SerializedSubject(PublishSubject.create());
     }
-    public synchronized static  RxSocket getInstance() {
+
+    public synchronized static RxSocket getInstance() {
         RxSocket rxSocket = defaultInstance;
         if (defaultInstance == null) {
             synchronized (chestnut.RxSocket.RxSocket.class) {
@@ -66,7 +67,7 @@ public class RxSocket {
     }
 
     /*  变量
-    * */
+     * */
     private SocketStatus socketStatus = SocketStatus.DIS_CONNECT;
     private Selector selector = null;
     private SocketChannel socketChannel = null;
@@ -74,30 +75,34 @@ public class RxSocket {
     private ReadThread readThread = null;
     private boolean isReadThreadAlive = true;
     private SocketReconnectCallback socketReconnectCallback = null;
-    private SocketReadCallback socketReadCallback=null;
+    private SocketReadCallback socketReadCallback = null;
 //    private SocketConnectionListener conectionListener = null;
 
     /*  方法
-    * */
+     * */
+
     /**
      * 监听Socket的状态
+     *
      * @return Rx SocketStatus 状态
      */
-    public Observable<SocketStatus> socketStatusListener () {
+    public Observable<SocketStatus> socketStatusListener() {
         return connectStatus;
     }
 
-    public void setSocketReadCallback(SocketReadCallback callback){
-        socketReadCallback=callback;
+    public void setSocketReadCallback(SocketReadCallback callback) {
+        socketReadCallback = callback;
     }
 //    public void setConnectionListener(SocketConnectionListener callback){
 //        conectionListener=callback;
 //    }
+
     /**
      * 建立Socket连接,只是尝试建立一次
-     * @param ip    IP or 域名
-     * @param port  端口
-     * @return  Rx true or false
+     *
+     * @param ip   IP or 域名
+     * @param port 端口
+     * @return Rx true or false
      */
     public Observable<Boolean> connectRx(String ip, int port) {
         return Observable
@@ -105,47 +110,46 @@ public class RxSocket {
                     @Override
                     public void call(Subscriber<? super Boolean> subscriber) {
 
-                        ICLogger.log(TAG,"connectRx:"+"status:"+socketStatus.name());
-
+                        ICLogger.log(TAG, "connectRx:" + "status:" + socketStatus.name());
                         //正在连接
                         if (socketStatus == SocketStatus.CONNECTING) {
                             subscriber.onNext(false);
                             subscriber.onCompleted();
                             return;
                         }
-
+                        ICLogger.d("connectRx == > socketStatus = SocketStatus.DIS_CONNECT 未连接 | 已经连接,关闭Socket");
                         //未连接 | 已经连接,关闭Socket
                         socketStatus = SocketStatus.DIS_CONNECT;
                         isReadThreadAlive = false;
                         readThread = null;
-                        if (selector!=null)
+                        if (selector != null)
                             try {
                                 selector.close();
                             } catch (Exception e) {
-                                 ICLogger.log(TAG,"selector.close");
+                                ICLogger.log(TAG, "selector.close");
                             }
-                        if (selectionKey!=null)
+                        if (selectionKey != null)
                             try {
                                 selectionKey.cancel();
                             } catch (Exception e) {
-                                 ICLogger.log(TAG,"selectionKey.cancel");
+                                ICLogger.log(TAG, "selectionKey.cancel");
                             }
-                        if (socketChannel!=null)
+                        if (socketChannel != null)
                             try {
                                 socketChannel.close();
                             } catch (Exception e) {
-                                 ICLogger.log(TAG,"socketChannel.close");
+                                ICLogger.log(TAG, "socketChannel.close");
                             }
 
                         //重启Socket
                         isReadThreadAlive = true;
-                        readThread = new ReadThread(ip,port);
+                        readThread = new ReadThread(ip, port);
                         readThread.start();
 
                         socketReconnectCallback = new SocketReconnectCallback() {
                             @Override
                             public void onSuccess() {
-                                 ICLogger.log( TAG, "connectRx:" + "CONNECTED");
+                                ICLogger.log(TAG, "connectRx:" + "CONNECTED");
                                 socketStatus = SocketStatus.CONNECTED;
                                 subscriber.onNext(true);
                                 subscriber.onCompleted();
@@ -153,7 +157,7 @@ public class RxSocket {
 
                             @Override
                             public void onFail(String msg) {
-                                 ICLogger.log( TAG, "connectRx:" + msg);
+                                ICLogger.log(TAG, "connectRx:" + msg);
                                 subscriber.onNext(false);
                                 subscriber.onCompleted();
                             }
@@ -171,7 +175,8 @@ public class RxSocket {
 
     /**
      * 断开当前的Socket
-     *  还能再继续连接
+     * 还能再继续连接
+     *
      * @return Rx true or false
      */
     public Observable<Boolean> disConnect() {
@@ -179,31 +184,31 @@ public class RxSocket {
             @Override
             public void call(Subscriber<? super Boolean> subscriber) {
                 try {
-                    if (socketStatus == SocketStatus.DIS_CONNECT  || socketStatus == SocketStatus.DIS_CONNECT_BY_SERVERSIDE) {
+                    if (socketStatus == SocketStatus.DIS_CONNECT || socketStatus == SocketStatus.DIS_CONNECT_BY_SERVERSIDE) {
                         subscriber.onNext(true);
                         subscriber.onCompleted();
-                    }
-                    else {
+                    } else {
+                        ICLogger.d("disconnected === > DIS_CONNECT");
                         socketStatus = SocketStatus.DIS_CONNECT;
                         isReadThreadAlive = false;
                         readThread = null;
-                        if (selector!=null)
+                        if (selector != null)
                             try {
                                 selector.close();
                             } catch (Exception e) {
-                                 ICLogger.log(TAG,"selector.close");
+                                ICLogger.log(TAG, "selector.close");
                             }
-                        if (selectionKey!=null)
+                        if (selectionKey != null)
                             try {
                                 selectionKey.cancel();
                             } catch (Exception e) {
-                                 ICLogger.log(TAG,"selectionKey.cancel");
+                                ICLogger.log(TAG, "selectionKey.cancel");
                             }
-                        if (socketChannel!=null)
+                        if (socketChannel != null)
                             try {
                                 socketChannel.close();
                             } catch (Exception e) {
-                                 ICLogger.log(TAG,"socketChannel.close");
+                                ICLogger.log(TAG, "socketChannel.close");
                             }
                         subscriber.onNext(true);
                         subscriber.onCompleted();
@@ -218,7 +223,8 @@ public class RxSocket {
 
     /**
      * 读取Socket的消息
-     * @return  Rx error 或者 有数据
+     *
+     * @return Rx error 或者 有数据
      */
     public Observable<byte[]> read() {
         return readSubject;
@@ -226,8 +232,9 @@ public class RxSocket {
 
     /**
      * 向Socket写消息
-     * @param buffer    数据包
-     * @return  Rx true or false
+     *
+     * @param buffer 数据包
+     * @return Rx true or false
      */
     public Observable<Boolean> write(ByteBuffer buffer) {
         return Observable
@@ -235,33 +242,30 @@ public class RxSocket {
                     @Override
                     public void call(Subscriber<? super Boolean> subscriber) {
                         if (socketStatus != SocketStatus.CONNECTED) {
-                             ICLogger.log( TAG, "write." + "SocketStatus.DISCONNECTED");
+                            ICLogger.log(TAG, "write." + "SocketStatus.DISCONNECTED");
                             subscriber.onNext(false);
                             subscriber.onCompleted();
-                        }
-                        else {
-                            if (socketChannel!=null && socketChannel.isConnected()) {
+                        } else {
+                            if (socketChannel != null && socketChannel.isConnected()) {
                                 try {
                                     int result = socketChannel.write(buffer);
-                                    if (result<0) {
-                                         ICLogger.log( TAG, "write." + "发送出错");
+                                    if (result < 0) {
+                                        ICLogger.log(TAG, "write." + "发送出错");
                                         subscriber.onNext(false);
                                         subscriber.onCompleted();
-                                    }
-                                    else {
-                                         ICLogger.log( TAG, "write." + "success!");
+                                    } else {
+                                        ICLogger.log(TAG, "write." + "success!");
                                         subscriber.onNext(true);
                                         subscriber.onCompleted();
                                     }
                                 } catch (Exception e) {
-                                     ICLogger.log(TAG,"write exception ."+e.getMessage());
-                                     e.printStackTrace();
+                                    ICLogger.log(TAG, "write exception ." + e.getMessage());
+                                    e.printStackTrace();
                                     subscriber.onNext(false);
                                     subscriber.onCompleted();
                                 }
-                            }
-                            else {
-                                 ICLogger.log(TAG,"write."+"close");
+                            } else {
+                                ICLogger.log(TAG, "write." + "close");
                                 subscriber.onNext(false);
                                 subscriber.onCompleted();
                             }
@@ -274,24 +278,28 @@ public class RxSocket {
 
     /**
      * 获取Socket的链接状态
-     * @return  状态
+     *
+     * @return 状态
      */
     public SocketStatus getSocketStatus() {
+        ICLogger.d("getSocketStatus == > " + socketStatus);
         return socketStatus;
     }
 
     /*  类 && 枚举 && 接口
-        * */
+     * */
     private class ReadThread extends Thread {
         private String ip;
         private int port;
+
         ReadThread(String ip, int port) {
             this.ip = ip;
             this.port = port;
         }
+
         @Override
         public void run() {
-             ICLogger.log(TAG,"ReadThread:"+"start");
+            ICLogger.log(TAG, "ReadThread:" + "start");
             while (isReadThreadAlive) {
                 //连接
                 if (socketStatus == SocketStatus.DIS_CONNECT || socketStatus == SocketStatus.DIS_CONNECT_BY_SERVERSIDE) {
@@ -309,17 +317,17 @@ public class RxSocket {
                         connectStatus.onNext(SocketStatus.CONNECTING);
                     } catch (Exception e) {
                         isReadThreadAlive = false;
+                        ICLogger.d("exception so disconnected state.");
                         socketStatus = SocketStatus.DIS_CONNECT;
                         connectStatus.onNext(SocketStatus.DIS_CONNECT);
-                         ICLogger.log( TAG, "ReadThread:init exception:" + e);
-                         e.printStackTrace();
-                        if (socketReconnectCallback!=null)
+                        ICLogger.log(TAG, "ReadThread:init exception:" + e);
+                        e.printStackTrace();
+                        if (socketReconnectCallback != null)
                             socketReconnectCallback.onFail("SocketConnectFail1");
-
                     }
                 }
                 //读取
-                else if (socketStatus == SocketStatus.CONNECTING || socketStatus  == SocketStatus.CONNECTED) {
+                else if (socketStatus == SocketStatus.CONNECTING || socketStatus == SocketStatus.CONNECTED) {
                     try {
                         selector.select();
                         Iterator<SelectionKey> it = selector.selectedKeys().iterator();
@@ -338,6 +346,7 @@ public class RxSocket {
 
                                     } catch (Exception e) {
                                         isReadThreadAlive = false;
+                                        ICLogger.d("exception socket disconnected");
                                         socketStatus = SocketStatus.DIS_CONNECT;
                                         connectStatus.onNext(SocketStatus.DIS_CONNECT);
                                         ICLogger.log(TAG, "ReadThread:finish exception:" + e);
@@ -351,8 +360,8 @@ public class RxSocket {
                                 ByteBuffer buf = ByteBuffer.allocate(10000);
                                 int length = socketChannel.read(buf);
                                 if (length <= 0) {
-                                    ICLogger.log(TAG, "服务器主动断开链接!");
                                     isReadThreadAlive = false;
+                                    ICLogger.log(TAG, "服务器主动断开链接!");
                                     socketStatus = SocketStatus.DIS_CONNECT_BY_SERVERSIDE;
                                     connectStatus.onNext(SocketStatus.DIS_CONNECT_BY_SERVERSIDE);
                                     if (socketReconnectCallback != null)
@@ -373,12 +382,13 @@ public class RxSocket {
                         it.remove();
                     } catch (Exception e) {
                         isReadThreadAlive = false;
+                        ICLogger.d("disconnected in exception.");
                         socketStatus = SocketStatus.DIS_CONNECT;
                         connectStatus.onNext(SocketStatus.DIS_CONNECT);
-                         ICLogger.log( TAG, "ReadThread:read exception :" + e);
-                         e.printStackTrace();
+                        ICLogger.log(TAG, "ReadThread:read exception :" + e);
+                        e.printStackTrace();
 
-                        if (socketReconnectCallback!=null)
+                        if (socketReconnectCallback != null)
                             socketReconnectCallback.onFail("SocketConnectFail4");
 
                     }
@@ -396,10 +406,11 @@ public class RxSocket {
 
     private interface SocketReconnectCallback {
         void onSuccess();
+
         void onFail(String msg);
     }
 
-    public interface SocketReadCallback{
+    public interface SocketReadCallback {
         void onRecvMsg(byte[] bytes);
     }
 
index 89ae10a..3fa9fc1 100644 (file)
@@ -155,24 +155,6 @@ public class TemperatureUtil {
         ThreadPool.getInstance().submitThreadPool(() -> DoTempTest(from));
     }
 
-    public static final String ACTION_TEMP_RESULT = "com.ic.action.temp_result";
-    public static final String KEY_TEMP_BODY = "body";  // double 体温
-    public static final String KEY_TEMP_WRIST = "wrist";  //  double 腕温
-    public static final String KEY_TEMP_OUT = "out"; //temp out
-    public static final String KEY_TEMP_BYPROTOCOL = "protocol"; //temp out
-
-    private void sendTempBroadcast(double value, double animal, double tempOut) {
-        Intent pedIntent = new Intent();
-        pedIntent.setAction(ACTION_TEMP_RESULT);
-        pedIntent.putExtra(KEY_TEMP_WRIST, value);
-        pedIntent.putExtra(KEY_TEMP_BODY, animal);
-        pedIntent.putExtra(KEY_TEMP_OUT, tempOut);
-        pedIntent.putExtra(KEY_TEMP_BYPROTOCOL, true);
-        if (CoreService.getInstance() != null)
-            CoreService.getInstance().sendBroadcast(pedIntent);
-    }
-
-
     /**
      * 不管是什么测试,后台指令,还是定时的,都会走这里。
      * 那这个地方,不再走本地进行测试,而是走远程IcWorkService进行测试
@@ -186,13 +168,16 @@ public class TemperatureUtil {
             ICLogger.i("未佩戴,取消TempTest!" + from);
             return;
         }
-        try {
-            if (temperatureRemoteService != null) {
-                ICLogger.d("get temperature info...");
-                temperatureRemoteService.getTemperatureInfo(from, TemperatureUtil.class.getName());
+        new Thread(() -> {
+            try {
+                if (temperatureRemoteService != null) {
+                    ICLogger.d("get temperature info...");
+                    temperatureRemoteService.getTemperatureInfo(from, TemperatureUtil.class.getName());
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+                ICLogger.e("exception  -- > ", e);
             }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+        }).start();
     }
 }
index b8d4d78..00cf02e 100644 (file)
@@ -1,81 +1,81 @@
 package com.enqualcomm.support.utils;\r
 \r
-import android.util.Log;\r
-\r
-import com.enqualcomm.support.Config;\r
 import com.enqualcomm.support.bean.Runtime;\r
 import com.enqualcomm.support.bean.StringMessage;\r
 import com.ic.protocols.protocolAPIHelper;\r
 import com.ic.protocols.protocol_mqtt_client;\r
 \r
 public class mqttConnection implements Connection {\r
-    private String topic_header="";\r
-    private protocol_mqtt_client.MqttCallbackInterface mqttcallback=new protocol_mqtt_client.MqttCallbackInterface() {\r
+    private String topic_header = "";\r
+    private protocol_mqtt_client.MqttCallbackInterface mqttcallback = new protocol_mqtt_client.MqttCallbackInterface() {\r
         @Override\r
         public void onMqttConnected() {\r
-            ICLogger.i( "onMqttConnected");\r
-            topic_header="WBG100/v1/"+mRuntime.IMEI()+"/";\r
-            ICLogger.i( "topic_header "+topic_header);\r
+            ICLogger.i("onMqttConnected");\r
+            topic_header = "WBG100/v1/" + mRuntime.IMEI() + "/";\r
+            ICLogger.i("topic_header " + topic_header);\r
             mqtt_client.setSubscriptTopicHeader(topic_header);\r
-            mqtt_client.attemptSubscribeToTopic(topic_header+"+");\r
-            isServerconnected=true;\r
+            mqtt_client.attemptSubscribeToTopic(topic_header + "+");\r
+            isServerconnected = true;\r
 //            mRuntime.setServerProtocolConnected(true);\r
-            if (listener!=null)\r
+            if (listener != null)\r
                 listener.onConnectionOpen();\r
 \r
         }\r
 \r
         @Override\r
         public void onMqttDisconnected() {\r
-            ICLogger.i( "onMqttDisconnected");\r
-            isServerconnected=false;\r
+            ICLogger.i("onMqttDisconnected");\r
+            isServerconnected = false;\r
             mRuntime.setServerProtocolConnected(false);\r
-            if (listener!=null)\r
+            if (listener != null)\r
                 listener.onConnectionClose("");\r
         }\r
 \r
         @Override\r
         public void handleMqttMessage(String cmdtype, byte[] msgdata) {\r
-            ICLogger.i( "handleMqttMessage "+cmdtype+" " +new String(msgdata));\r
-            API.parserCmd(cmdtype,msgdata);\r
+            ICLogger.i("handleMqttMessage " + cmdtype + " " + new String(msgdata));\r
+            API.parserCmd(cmdtype, msgdata);\r
         }\r
 \r
         @Override\r
         public void handleMqttMessage(String cmdtype, String msgdata) {\r
-            ICLogger.i( "handleMqttMessage "+cmdtype+" "+ msgdata);\r
-            API.parserCmd(cmdtype,msgdata.getBytes());\r
+            ICLogger.i("handleMqttMessage " + cmdtype + " " + msgdata);\r
+            API.parserCmd(cmdtype, msgdata.getBytes());\r
         }\r
     };\r
+\r
     public mqttConnection(ConnectionListener paramConnectionListener, Runtime runtime) {\r
         ICLogger.i("mqttConnection ");\r
-        mqtt_client=new protocol_mqtt_client(runtime.getContextProxy().context,mqttcallback);\r
-        listener=paramConnectionListener;\r
-        mRuntime=runtime;\r
-        if (API == null) API=new protocolAPIHelper(this,runtime );\r
+        mqtt_client = new protocol_mqtt_client(runtime.getContextProxy().context, mqttcallback);\r
+        listener = paramConnectionListener;\r
+        mRuntime = runtime;\r
+        if (API == null) API = new protocolAPIHelper(this, runtime);\r
 \r
     }\r
-    private Runtime mRuntime=null;\r
-    private protocol_mqtt_client mqtt_client=null;\r
 \r
-    private static boolean isServerconnected=false;\r
-    private protocolAPIHelper API=null;\r
-    private ConnectionListener listener=null;\r
+    private Runtime mRuntime = null;\r
+    private protocol_mqtt_client mqtt_client = null;\r
+\r
+    private static boolean isServerconnected = false;\r
+    private protocolAPIHelper API = null;\r
+    private ConnectionListener listener = null;\r
+\r
     @Override\r
-    public void close(){\r
+    public void close() {\r
 \r
     }\r
 \r
     @Override\r
-    public void connect(String serverip, int serverport){\r
+    public void connect(String serverip, int serverport) {\r
 //        mqtt_client.attemptConnectMqtt(paramString,"IC_"+mRuntime.IMEI(),paramInt);\r
-        ICLogger.i("mqttconnect " +serverip+" "+serverport+" cycle "+mRuntime.getHeartBeatCycle()*60+" as "+"IC_"+mRuntime.IMEI());\r
-        mqtt_client.configMqtt(serverip,serverport, mRuntime.getHeartBeatCycle()*60,"IC_"+mRuntime.IMEI());\r
+        ICLogger.i("mqttconnect " + serverip + " " + serverport + " cycle " + mRuntime.getHeartBeatCycle() * 60 + " as " + "IC_" + mRuntime.IMEI());\r
+        mqtt_client.configMqtt(serverip, serverport, mRuntime.getHeartBeatCycle() * 60, "IC_" + mRuntime.IMEI());\r
         mqtt_client.connectservice();\r
-       // if(isServerconnected) mqtt_client.attemptConnectMqtt();\r
+        // if(isServerconnected) mqtt_client.attemptConnectMqtt();\r
     }\r
 \r
     @Override\r
-    public void disconnect(){\r
+    public void disconnect() {\r
         disconnectServer();\r
     }\r
 \r
@@ -86,58 +86,58 @@ public class mqttConnection implements Connection {
     }\r
 \r
     @Override\r
-    public int getTimeout(){\r
+    public int getTimeout() {\r
 \r
         return 0;\r
     }\r
 \r
     @Override\r
-    public void open(){\r
+    public void open() {\r
 \r
     }\r
 \r
     @Override\r
-    public void send(StringMessage paramStringMessage){\r
+    public void send(StringMessage paramStringMessage) {\r
 \r
-        if(paramStringMessage==null)\r
-        {\r
+        if (paramStringMessage == null) {\r
             ICLogger.i("mqtt send StringMessage Null skip!");\r
             return;\r
         }\r
-        String topci=paramStringMessage.cmd();\r
-        String msgdata=paramStringMessage.isFromCache();\r
-        ICLogger.i("mqtt send "+topci+" "+msgdata);\r
+        String topci = paramStringMessage.cmd();\r
+        String msgdata = paramStringMessage.isFromCache();\r
+        ICLogger.i("mqtt send " + topci + " " + msgdata);\r
         if (topci.startsWith("WBG100/v1")) {\r
             mqtt_client.sendMessage(topci, msgdata);\r
-            ICLogger.logToFile("APILog","mqtt send "+topci+" "+msgdata);\r
-        }else{\r
-            ICLogger.i("mqtt topci foramt error "+topci);\r
+            ICLogger.logToFile("APILog", "mqtt send " + topci + " " + msgdata);\r
+        } else {\r
+            ICLogger.i("mqtt topci foramt error " + topci);\r
         }\r
     }\r
 \r
     @Override\r
-    public boolean sendBlocking(StringMessage paramStringMessage){\r
+    public boolean sendBlocking(StringMessage paramStringMessage) {\r
         send(paramStringMessage);\r
         return true;\r
     }\r
 \r
     @Override\r
-    public void setTimeout(int paramInt){\r
+    public void setTimeout(int paramInt) {\r
 \r
     }\r
 \r
     @Override\r
     public void DeliverCMDMessageToSystem(String cmd, String msg) {\r
-        if (this.listener!=null){\r
-            String[] msgArr=new String[]{cmd,msg};\r
-            StringMessage stringMessage=new StringMessage(msgArr);\r
+        if (this.listener != null) {\r
+            String[] msgArr = new String[]{cmd, msg};\r
+            StringMessage stringMessage = new StringMessage(msgArr);\r
             stringMessage.refresh(msg);\r
-            this.listener.onReceive(stringMessage );\r
+            this.listener.onReceive(stringMessage);\r
         }\r
     }\r
 \r
     @Override\r
     public boolean isServerConnected() {\r
+        ICLogger.d("isServerconnected == > " + isServerconnected);\r
         return isServerconnected;\r
     }\r
 \r
index 1961391..d5a7bfa 100644 (file)
@@ -1,2 +1,2 @@
-#Thu Jan 14 18:10:27 CST 2021
-VERSION_CODE=751
+#Fri Jan 15 14:44:00 CST 2021
+VERSION_CODE=752