250228:1.0AI新增deepseek master
authorxiewei <892331662@qq.com>
Fri, 28 Feb 2025 02:21:08 +0000 (10:21 +0800)
committerxiewei <892331662@qq.com>
Fri, 28 Feb 2025 02:21:08 +0000 (10:21 +0800)
hssdk/src/main/java/com/zhixun/blesdk/hssdk/bttools/BleHandle.java
hssdk/src/main/java/com/zhixun/blesdk/hssdk/data/ReceiverLooperThread.java

index c7085d4..138a30d 100644 (file)
@@ -104,9 +104,11 @@ public class BleHandle {
         return sInstance;
     }
 
         return sInstance;
     }
 
-
+    private boolean isInit = false;
     public void init(Context context) {
     public void init(Context context) {
-        Log.e(TAG, "Bluetooth Handle Start");
+        Log.e(TAG, "Bluetooth Handle Start---"+isInit);
+        if(isInit)return;
+        isInit = true;
         mContext = context;
         if (bleLooperThread == null) {
             bleLooperThread = new BleLooperThread();
         mContext = context;
         if (bleLooperThread == null) {
             bleLooperThread = new BleLooperThread();
@@ -332,6 +334,7 @@ public class BleHandle {
                     mBluetoothGatt.close();
                     mBluetoothGatt = null;
                 }
                     mBluetoothGatt.close();
                     mBluetoothGatt = null;
                 }
+                isRead = false;
             }
 
             if (newState != BluetoothProfile.STATE_CONNECTED) {
             }
 
             if (newState != BluetoothProfile.STATE_CONNECTED) {
@@ -804,8 +807,7 @@ public class BleHandle {
         //SobLog.d(TAG, "---btsend---over");
     }
 
         //SobLog.d(TAG, "---btsend---over");
     }
 
-
-
+    private boolean isRead = false;
     private void readInitMsg() {
         if (!mBluetoothDeviceConnected || !checkBluePermission()) return;
         gattService = mBluetoothGatt.getService(BleUuidUtil.getInstance().getServiceUUID());//对应server端的setService方法
     private void readInitMsg() {
         if (!mBluetoothDeviceConnected || !checkBluePermission()) return;
         gattService = mBluetoothGatt.getService(BleUuidUtil.getInstance().getServiceUUID());//对应server端的setService方法
@@ -815,6 +817,11 @@ public class BleHandle {
             connectStateChange(BtVtransferCallback.STATE_DISCONNECTED);
             return;
         }
             connectStateChange(BtVtransferCallback.STATE_DISCONNECTED);
             return;
         }
+        SobLog.d(TAG,"readInitMsg-isRead-"+isRead);
+        if(isRead){
+            return;
+        }
+        isRead = true;
         BluetoothGattCharacteristic characteristic = gattService.getCharacteristic(BleUuidUtil.getInstance().getReadUUID());
         if (characteristic != null) {
             // 读取特性的值
         BluetoothGattCharacteristic characteristic = gattService.getCharacteristic(BleUuidUtil.getInstance().getReadUUID());
         if (characteristic != null) {
             // 读取特性的值
index f8f579d..42a5680 100644 (file)
@@ -107,6 +107,10 @@ public class ReceiverLooperThread extends Thread {
                         byte[] content = revData.getContent();
                         MsgResponse response = new MsgResponse();
                         switch (revData.getType()) {
                         byte[] content = revData.getContent();
                         MsgResponse response = new MsgResponse();
                         switch (revData.getType()) {
+                            case -1:
+                                SobLog.d(TAG, "TYPE_SET_PHONEINFO--Timeout");
+                                BleHandle.getInstance().disconnectDevice();
+                                break;
                             case BleMsgSendHandler.TYPE_SET_PHONEINFO:
                                 SobLog.d(TAG, "TYPE_SET_PHONEINFO--" + ByteTools.byteArrToHex(content));
                                 int connectState = ByteTools.bytes2Int(content, 1);
                             case BleMsgSendHandler.TYPE_SET_PHONEINFO:
                                 SobLog.d(TAG, "TYPE_SET_PHONEINFO--" + ByteTools.byteArrToHex(content));
                                 int connectState = ByteTools.bytes2Int(content, 1);
@@ -118,9 +122,11 @@ public class ReceiverLooperThread extends Thread {
                                     BleHandle.getInstance().connectStateChange(BtVtransferCallback.STATE_BLE_ISBINDED);
                                 }
                                 response.setBody(connectState);
                                     BleHandle.getInstance().connectStateChange(BtVtransferCallback.STATE_BLE_ISBINDED);
                                 }
                                 response.setBody(connectState);
+                                mReceiverMsgHandle.sendEmptyMessageDelayed(-1,8000);
                                 break;
                             case TYPE_SURE_PAIR:
                                 //收到确认配对消息
                                 break;
                             case TYPE_SURE_PAIR:
                                 //收到确认配对消息
+                                mReceiverMsgHandle.removeMessages(-1);
                                 SobLog.d(TAG, "TYPE_SURE_PAIR--" + ByteTools.byteArrToHex(content));
                                 int pairState = ByteTools.bytes2Int(content, 1);
                                 if (pairState == 2) {
                                 SobLog.d(TAG, "TYPE_SURE_PAIR--" + ByteTools.byteArrToHex(content));
                                 int pairState = ByteTools.bytes2Int(content, 1);
                                 if (pairState == 2) {
@@ -132,6 +138,7 @@ public class ReceiverLooperThread extends Thread {
                                 }
                                 break;
                             case MsgBody.TYPE_SET_TIME:
                                 }
                                 break;
                             case MsgBody.TYPE_SET_TIME:
+                                mReceiverMsgHandle.removeMessages(-1);
                                 //时间同步
                                 int timeAnsyState = ByteTools.bytes2Int(content, 1);
                                 if (timeAnsyState == 1) {
                                 //时间同步
                                 int timeAnsyState = ByteTools.bytes2Int(content, 1);
                                 if (timeAnsyState == 1) {