mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 05:16:51 +01:00
BtClassic: generalize device initialization
Also override the new generic initialization for Nothing Ear (1)
This commit is contained in:
parent
bf8ee52cbb
commit
f8cc520ede
@ -170,12 +170,16 @@ public abstract class BtClassicIoThread extends GBDeviceIoThread {
|
||||
return false;
|
||||
}
|
||||
|
||||
write(mProtocol.encodeSetTime());
|
||||
setUpdateState(GBDevice.State.INITIALIZED);
|
||||
initialize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void initialize() {
|
||||
write(mProtocol.encodeSetTime());
|
||||
setUpdateState(GBDevice.State.INITIALIZED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the uuid to connect to.
|
||||
* Default implementation returns the first of the given uuids that were
|
||||
|
@ -29,6 +29,13 @@ public class NothingIOThread extends BtClassicIoThread {
|
||||
return mNothingProtocol.UUID_DEVICE_CTRL;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize() {
|
||||
write(mNothingProtocol.encodeBatteryStatusReq());
|
||||
write(mNothingProtocol.encodeAudioModeStatusReq());
|
||||
setUpdateState(GBDevice.State.INITIALIZED);
|
||||
}
|
||||
|
||||
public NothingIOThread(GBDevice device, Context context, NothingProtocol deviceProtocol,
|
||||
Ear1Support ear1Support, BluetoothAdapter bluetoothAdapter) {
|
||||
super(device, context, deviceProtocol, ear1Support, bluetoothAdapter);
|
||||
|
@ -218,14 +218,6 @@ public class NothingProtocol extends GBDeviceProtocol {
|
||||
return super.encodeSendConfiguration(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encodeSetTime() {
|
||||
// This are earphones, there is no time to set here. However this method gets called soon
|
||||
// after connecting, hence we use it to perform some initializations.
|
||||
// TODO: Find a way to send more requests during the first connection
|
||||
return encodeAudioModeStatusReq();
|
||||
}
|
||||
|
||||
private GBDeviceEvent handleBatteryInfo(byte[] payload) {
|
||||
//LOG.debug("Battery payload: " + hexdump(payload));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user