1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-21 04:20:27 +02:00

BtClassic: generalize device initialization

Also override the new generic initialization for Nothing Ear (1)
This commit is contained in:
Daniele Gobbetti 2021-10-31 15:48:36 +01:00
parent bf8ee52cbb
commit f8cc520ede
3 changed files with 13 additions and 10 deletions

View File

@ -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

View File

@ -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);

View File

@ -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));