From 17d97f58265510ceda0b38959a90424ee07b6910 Mon Sep 17 00:00:00 2001
From: 陈奇 <1650699704@qq.com>
Date: Tue, 13 Nov 2018 11:42:07 +0800
Subject: [PATCH] 1.0.3-1测试版本 [*]修改重新连接的方式 [*]修改商城连接 [*]修改心跳机制 [*]主要针对oppo和vivo机型添加开启定位服务
---
FastBleLib/src/main/java/com/clj/fastble/conn/BleConnector.java | 37 +++++++++++++++++--------------------
1 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/FastBleLib/src/main/java/com/clj/fastble/conn/BleConnector.java b/FastBleLib/src/main/java/com/clj/fastble/conn/BleConnector.java
index 33a3d7a..e97e782 100644
--- a/FastBleLib/src/main/java/com/clj/fastble/conn/BleConnector.java
+++ b/FastBleLib/src/main/java/com/clj/fastble/conn/BleConnector.java
@@ -102,7 +102,6 @@
descriptor = characteristic.getDescriptor(descriptorUUID);
}
-
return this;
}
@@ -118,7 +117,7 @@
- /*------------------------------- main operation ----------------------------------- */
+ /*------------------------------- main operation ----------------------------------- */
/**
@@ -342,39 +341,36 @@
final String uuid_notify) {
if (bleCallback != null) {
-// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-// bluetoothGatt.requestMtu(10);
-// }
listenAndTimer(bleCallback, MSG_NOTIFY_CHA, uuid_notify, new BluetoothGattCallback() {
AtomicBoolean msgRemoved = new AtomicBoolean(false);
-
-
- @Override
- public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
- super.onConnectionStateChange(gatt, status, newState);
- }
@Override
public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic) {
+
if (!msgRemoved.getAndSet(true)) {
handler.removeMessages(MSG_NOTIFY_CHA, this);
}
-
if (characteristic.getUuid().equals(UUID.fromString(uuid_notify))) {
+ System.out.println("chenqi Hex ->" + dumpHex(characteristic.getValue()));
bleCallback.onSuccess(characteristic);
}
}
-
- @Override
- public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
- super.onMtuChanged(gatt, mtu, status);
- System.out.println(String.format("onMtuChanged���mtu = %s", mtu));
- }
});
-
-
}
+ }
+
+ public String dumpHex(byte[] src) {
+ String num = "0123456789ABCDEF";
+ StringBuilder sb = new StringBuilder();
+// sb.append("[ ");
+ for (byte aSrc : src) {
+ int high = aSrc >> 4 & 0x0f;
+ int low = aSrc & 0x0f;
+ sb.append(num.charAt(high)).append(num.charAt(low)).append(" ");
+ }
+// sb.append(" ]");
+ return sb.toString();
}
/**
@@ -390,6 +386,7 @@
@Override
public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic) {
+
if (!msgRemoved.getAndSet(true)) {
handler.removeMessages(MSG_INDICATE_DES, this);
}
--
Gitblit v1.8.0