Skip to content

Commit 6d71997

Browse files
author
Douglas Nassif Roma Junior
committed
Release 0.3.2
1 parent fe6d2f2 commit 6d71997

File tree

2 files changed

+88
-9
lines changed

2 files changed

+88
-9
lines changed

README.md

Lines changed: 88 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,98 @@
11
# AndroidBluetoothLibrary
22

3-
A Library for easy implementation Bluetooth Classic and Low Energy on Android.
3+
[![Licence MIT](https://img.shields.io/badge/licence-MIT-blue.svg)](https://github.com/douglasjunior/AndroidBluetoothLibrary/blob/master/LICENSE)
4+
[![Release](https://jitpack.io/v/douglasjunior/AndroidBluetoothLibrary.svg)](https://jitpack.io/#douglasjunior/AndroidBluetoothLibrary)
5+
[![Downloads](https://jitpack.io/v/douglasjunior/AndroidBluetoothLibrary/month.svg)](#download)
6+
7+
A Library for easy implementation of Serial Bluetooth Classic and Low Energy on Android.
48

59
## Use
610

7-
### Bluetooth Classic
11+
### Configuration
12+
13+
```java
14+
BluetoothConfiguration config = new BluetoothConfiguration();
15+
config.context = getApplicationContext();
16+
config.bluetoothServiceClass = BluetoothLeService.class; // BluetoothClassicService.class or BluetoothLeService.class
17+
config.bufferSize = 1024;
18+
config.characterDelimiter = '\n';
19+
config.deviceName = "Your App Name";
20+
config.callListenersInMainThread = true;
21+
22+
// Bluetooth Classic
23+
config.uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); // Set null to find all devices on scan.
24+
25+
// Bluetooth LE
26+
config.uuidService = UUID.fromString("e7810a71-73ae-499d-8c15-faa9aef0c3f2");
27+
config.uuidCharacteristic = UUID.fromString("bef8d6c9-9c21-4c9e-b632-bd58c1009f9f");
28+
config.transport = BluetoothDevice.TRANSPORT_LE; // Only for dual-mode devices
29+
30+
BluetoothService.init(config);
31+
```
32+
33+
### Getting BluetoothService
34+
35+
```java
36+
BluetoothService service = BluetoothService.getDefaultInstance();
37+
```
38+
39+
### Scanning
40+
41+
```java
42+
service.setOnScanCallback(new BluetoothService.OnBluetoothScanCallback() {
43+
@Override
44+
public void onDeviceDiscovered(BluetoothDevice device, int rssi) {
45+
}
846

9-
Soon
47+
@Override
48+
public void onStartScan() {
49+
}
1050

11-
### Bluetooth Low Energy
51+
@Override
52+
public void onStopScan() {
53+
}
54+
});
1255

13-
Soon
56+
service.startScan(); // See also service.stopScan();
57+
```
1458

59+
### Connecting
60+
61+
```java
62+
service.setOnEventCallback(new BluetoothService.OnBluetoothEventCallback() {
63+
@Override
64+
public void onDataRead(byte[] buffer, int length) {
65+
}
66+
67+
@Override
68+
public void onStatusChange(BluetoothStatus status) {
69+
}
70+
71+
@Override
72+
public void onDeviceName(String deviceName) {
73+
}
74+
75+
@Override
76+
public void onToast(String message) {
77+
}
78+
79+
@Override
80+
public void onDataWrite(byte[] buffer) {
81+
}
82+
});
83+
84+
service.connect(device); // See also service.disconnect();
85+
```
86+
87+
### Writing
88+
89+
```java
90+
BluetoothWriter writer = new BluetoothWriter(service);
91+
92+
writer.writeln("Your text here");
93+
```
1594

16-
## Install
95+
## Download
1796

1897
1. Add it in your root build.gradle at the end of repositories:
1998
```javascript
@@ -30,14 +109,14 @@ Soon
30109
2.1. Bluetooth Classic
31110
```javascript
32111
dependencies {
33-
compile 'com.github.douglasjunior.AndroidBluetoothLibrary:BluetoothClassicLibrary:0.3.1'
112+
compile 'com.github.douglasjunior.AndroidBluetoothLibrary:BluetoothClassicLibrary:0.3.2'
34113
}
35114
```
36115

37116
2.2. Bluetooth Low Energy
38117
```javascript
39118
dependencies {
40-
compile 'com.github.douglasjunior.AndroidBluetoothLibrary:BluetoothLowEnergyLibrary:0.3.1'
119+
compile 'com.github.douglasjunior.AndroidBluetoothLibrary:BluetoothLowEnergyLibrary:0.3.2'
41120
}
42121
```
43122

@@ -59,7 +138,7 @@ Soon
59138

60139
## Contribute
61140

62-
New features, bug fixes and improvements in the translation are welcome! For questions and suggestions use the [issues](https://github.com/douglasjunior/AndroidBluetoothLibrary/issues).
141+
New features, bug fixes and improvements are welcome! For questions and suggestions use the [issues](https://github.com/douglasjunior/AndroidBluetoothLibrary/issues).
63142

64143
Before submit your PR, run the gradle check.
65144
```bash

gradlew

100644100755
File mode changed.

0 commit comments

Comments
 (0)