Skip to content

Commit fe6d2f2

Browse files
author
Douglas Nassif Roma Junior
committed
Improving sample
1 parent e0febe6 commit fe6d2f2

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Sample/src/main/java/com/github/douglasjunior/bluetoothsample/DeviceActivity.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public void onDataRead(byte[] buffer, int length) {
5656
mEdRead.append("< " + new String(buffer, 0, length) + "\n");
5757
}
5858

59+
@Override
60+
protected void onDestroy() {
61+
super.onDestroy();
62+
mService.disconnect();
63+
}
64+
5965
@Override
6066
public void onStatusChange(BluetoothStatus status) {
6167
Log.d(TAG, "onStatusChange: " + status);

Sample/src/main/java/com/github/douglasjunior/bluetoothsample/MainActivity.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
import android.view.View;
1515
import android.widget.ProgressBar;
1616

17-
import com.github.douglasjunior.bluetoothclassiclibrary.BluetoothClassicService;
1817
import com.github.douglasjunior.bluetoothclassiclibrary.BluetoothConfiguration;
1918
import com.github.douglasjunior.bluetoothclassiclibrary.BluetoothDeviceDecorator;
2019
import com.github.douglasjunior.bluetoothclassiclibrary.BluetoothService;
2120
import com.github.douglasjunior.bluetoothclassiclibrary.BluetoothStatus;
21+
import com.github.douglasjunior.bluetoothlowenergylibrary.BluetoothLeService;
2222

2323
import java.util.Arrays;
2424
import java.util.UUID;
@@ -31,8 +31,8 @@ public class MainActivity extends AppCompatActivity implements BluetoothService.
3131
* Change for the UUID that you want.
3232
*/
3333
private static final UUID UUID_DEVICE = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
34-
private static final UUID UUID_SERVICE = UUID.fromString("35111C00001101-0000-1000-8000-00805F9B34FB");
35-
private static final UUID UUID_CHARACTERISTIC = UUID.fromString("35111C00001101-0000-1000-8000-00805F9B34FB");
34+
private static final UUID UUID_SERVICE = UUID.fromString("e7810a71-73ae-499d-8c15-faa9aef0c3f2");
35+
private static final UUID UUID_CHARACTERISTIC = UUID.fromString("bef8d6c9-9c21-4c9e-b632-bd58c1009f9f");
3636

3737
private ProgressBar pgBar;
3838
private Menu mMenu;
@@ -69,15 +69,15 @@ protected void onCreate(Bundle savedInstanceState) {
6969

7070
BluetoothConfiguration config = new BluetoothConfiguration();
7171
config.context = getApplicationContext();
72-
config.bluetoothServiceClass = BluetoothClassicService.class; // or BluetoothClassicService.class
72+
config.bluetoothServiceClass = BluetoothLeService.class; // BluetoothClassicService.class or BluetoothLeService.class
7373
config.bufferSize = 1024;
7474
config.characterDelimiter = '\n';
7575
config.deviceName = "Bluetooth Sample";
7676
config.transport = BluetoothDevice.TRANSPORT_LE; // Only for dual-mode devices
7777
//config.uuid = null; // When using BluetoothLeService.class set null to show all devices on scan.
78-
config.uuid = UUID_DEVICE;
79-
//config.uuidService = UUID_SERVICE; // For BLE
80-
//config.uuidCharacteristic = UUID_CHARACTERISTIC; // For BLE
78+
//config.uuid = UUID_DEVICE;
79+
config.uuidService = UUID_SERVICE; // For BLE
80+
config.uuidCharacteristic = UUID_CHARACTERISTIC; // For BLE
8181
config.callListenersInMainThread = true;
8282
BluetoothService.init(config);
8383

0 commit comments

Comments
 (0)