Skip to content

Commit

Permalink
update 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasonchenlijian committed Sep 13, 2021
1 parent 384e7ce commit 9e18f1f
Show file tree
Hide file tree
Showing 22 changed files with 67 additions and 982 deletions.
Binary file added FastBLE-2.4.0.aar
Binary file not shown.
20 changes: 14 additions & 6 deletions FastBleLib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion

defaultConfig {
minSdkVersion 14
targetSdkVersion 30
versionCode 234
versionName "2.3.4"
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.versionControl.versionCode
versionName rootProject.ext.versionControl.versonName
}
buildTypes {
release {
Expand All @@ -21,3 +21,11 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}

task makeAAR(type: Copy) {
from('build/outputs/aar/')
into('build/aarFloder/')
include('FastBleLib-release.aar')
rename ('FastBleLib-release.aar', 'FastBLE-' + rootProject.ext.versionControl.versonName + '.aar' )
}
makeAAR.dependsOn(build)
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ public class BleBluetooth {
private BleGattCallback bleGattCallback;
private BleRssiCallback bleRssiCallback;
private BleMtuChangedCallback bleMtuChangedCallback;
private HashMap<String, BleNotifyCallback> bleNotifyCallbackHashMap = new HashMap<>();
private HashMap<String, BleIndicateCallback> bleIndicateCallbackHashMap = new HashMap<>();
private HashMap<String, BleWriteCallback> bleWriteCallbackHashMap = new HashMap<>();
private HashMap<String, BleReadCallback> bleReadCallbackHashMap = new HashMap<>();
private final HashMap<String, BleNotifyCallback> bleNotifyCallbackHashMap = new HashMap<>();
private final HashMap<String, BleIndicateCallback> bleIndicateCallbackHashMap = new HashMap<>();
private final HashMap<String, BleWriteCallback> bleWriteCallbackHashMap = new HashMap<>();
private final HashMap<String, BleReadCallback> bleReadCallbackHashMap = new HashMap<>();

private LastState lastState;
private boolean isActiveDisconnect = false;
private BleDevice bleDevice;
private final BleDevice bleDevice;
private BluetoothGatt bluetoothGatt;
private MainHandler mainHandler = new MainHandler(Looper.getMainLooper());
private final MainHandler mainHandler = new MainHandler(Looper.getMainLooper());
private int connectRetryCount = 0;

public BleBluetooth(BleDevice bleDevice) {
Expand Down Expand Up @@ -106,14 +106,10 @@ public synchronized void removeReadCallback(String uuid) {
}

public synchronized void clearCharacterCallback() {
if (bleNotifyCallbackHashMap != null)
bleNotifyCallbackHashMap.clear();
if (bleIndicateCallbackHashMap != null)
bleIndicateCallbackHashMap.clear();
if (bleWriteCallbackHashMap != null)
bleWriteCallbackHashMap.clear();
if (bleReadCallbackHashMap != null)
bleReadCallbackHashMap.clear();
bleNotifyCallbackHashMap.clear();
bleIndicateCallbackHashMap.clear();
bleWriteCallbackHashMap.clear();
bleReadCallbackHashMap.clear();
}

public synchronized void addRssiCallback(BleRssiCallback callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,32 +125,6 @@ private void release() {
mHandler.removeCallbacksAndMessages(null);
}

// private static Queue<byte[]> splitByte(byte[] data, int count) {
// if (count > 20) {
// BleLog.w("Be careful: split count beyond 20! Ensure MTU higher than 23!");
// }
// Queue<byte[]> byteQueue = new LinkedList<>();
// if (data != null) {
// int index = 0;
// do {
// byte[] rawData = new byte[data.length - index];
// byte[] newData;
// System.arraycopy(data, index, rawData, 0, data.length - index);
// if (rawData.length <= count) {
// newData = new byte[rawData.length];
// System.arraycopy(rawData, 0, newData, 0, rawData.length);
// index += rawData.length;
// } else {
// newData = new byte[count];
// System.arraycopy(data, index, newData, 0, count);
// index += count;
// }
// byteQueue.offer(newData);
// } while (index < data.length);
// }
// return byteQueue;
// }

private static Queue<byte[]> splitByte(byte[] data, int count) {
if (count > 20) {
BleLog.w("Be careful: split count beyond 20! Ensure MTU higher than 23!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class BleConnectStateParameter {
private int status;
private boolean isActive;


public BleConnectStateParameter(int status) {
this.status = status;
}
Expand Down
9 changes: 6 additions & 3 deletions FastBleLib/src/main/java/com/clj/fastble/data/BleDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,23 @@ public BleDevice[] newArray(int size) {
};

public String getName() {
if (mDevice != null)
if (mDevice != null) {
return mDevice.getName();
}
return null;
}

public String getMac() {
if (mDevice != null)
if (mDevice != null) {
return mDevice.getAddress();
}
return null;
}

public String getKey() {
if (mDevice != null)
if (mDevice != null) {
return mDevice.getName() + mDevice.getAddress();
}
return "";
}

Expand Down
1 change: 0 additions & 1 deletion FastBleLib/src/main/java/com/clj/fastble/data/BleMsg.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

public class BleMsg {


// Scan
public static final int MSG_SCAN_DEVICE = 0X00;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.clj.fastble.data;



public enum BleScanState {

STATE_IDLE(-1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public abstract class BleScanPresenter implements BluetoothAdapter.LeScanCallbac
private long mScanTimeout;
private BleScanPresenterImp mBleScanPresenterImp;

private List<BleDevice> mBleDeviceList = new ArrayList<>();
private final List<BleDevice> mBleDeviceList = new ArrayList<>();

private Handler mMainHandler = new Handler(Looper.getMainLooper());
private final Handler mMainHandler = new Handler(Looper.getMainLooper());
private HandlerThread mHandlerThread;
private Handler mHandler;
private boolean mHandling;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private static class BleScannerHolder {

private BleScanState mBleScanState = BleScanState.STATE_IDLE;

private BleScanPresenter mBleScanPresenter = new BleScanPresenter() {
private final BleScanPresenter mBleScanPresenter = new BleScanPresenter() {

@Override
public void onScanStarted(boolean success) {
Expand Down
2 changes: 1 addition & 1 deletion FastBleLib/src/main/java/com/clj/fastble/utils/BleLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public final class BleLog {

public static boolean isPrint = true;
private static String defaultTag = "FastBle";
private static final String defaultTag = "FastBle";

public static void d(String msg) {
if (isPrint && msg != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public static String formatHexString(byte[] data, boolean addSpace) {
}

public static byte[] decodeHex(char[] data) {

int len = data.length;

if ((len & 0x01) != 0) {
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Android Bluetooth Low Energy
- Support configuration timeout for conncet or operation


# Preview
### Preview
![Preview_1](https://github.com/Jasonchenlijian/FastBle/raw/master/preview/new_1.png)
![Preview_2](https://github.com/Jasonchenlijian/FastBle/raw/master/preview/new_2.png)
![Preview_3](https://github.com/Jasonchenlijian/FastBle/raw/master/preview/new_3.png)
Expand Down Expand Up @@ -42,7 +42,7 @@ If you want to quickly preview all the functions, you can download APK as a test

### Jar

[FastBLE-2.3.4.jar](https://github.com/Jasonchenlijian/FastBle/raw/master/FastBLE-2.3.4.jar)
[FastBLE-2.4.0.jar](https://github.com/Jasonchenlijian/FastBle/raw/master/FastBLE-2.4.0.jar)


## Wiki
Expand All @@ -53,7 +53,7 @@ If you want to quickly preview all the functions, you can download APK as a test



# Usage
## Usage

- #### Init

Expand Down Expand Up @@ -533,7 +533,7 @@ If you want to quickly preview all the functions, you can download APK as a test
## Contact
If you have problems and ideas to communicate with me, you can contact me in the following ways.

QQ: 1033526540
WeChat: chenlijian1216

Email: [email protected]

Expand Down
Loading

0 comments on commit 9e18f1f

Please sign in to comment.