A lightweight Bluetooth scan/connect client for Android applications.
dependencies {
...
implementation 'com.eric.hydra:hydra:1.0.0'
...
}
Please use the lastest release。
Request request = Request.Builder()
.timeout(1000)
.build();
HydraClient client = new HydraClient();
client.scan(request, new Callback() {
@Override
public void onInterrupt(Error error) {
}
@Override
public void onResponse(Response response) {
}
});
client.removeScan(request)
Session session = new Session(response.getDevice());
session.connect(context);
session.registerCallback(new SessionCallback() {
@Override
public void onCharacteristicWrite(Session session, BluetoothGattCharacteristic characteristic, int status) {
}
});
session.writeCharacteristic(characteristic);