mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-25 00:30:37 +02:00
Zepp OS: Improve logging
- Do not log characteristic changes handled by parent class - Log discovered service names - Request and log supported config groups
This commit is contained in:
parent
aa4a7912ef
commit
dbfb8e5c38
@ -2272,9 +2272,12 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
@Override
|
||||
public boolean onCharacteristicChanged(BluetoothGatt gatt,
|
||||
BluetoothGattCharacteristic characteristic) {
|
||||
super.onCharacteristicChanged(gatt, characteristic);
|
||||
if (super.onCharacteristicChanged(gatt, characteristic)) {
|
||||
// handled upstream
|
||||
return true;
|
||||
}
|
||||
|
||||
UUID characteristicUUID = characteristic.getUuid();
|
||||
final UUID characteristicUUID = characteristic.getUuid();
|
||||
if (HuamiService.UUID_CHARACTERISTIC_6_BATTERY_INFO.equals(characteristicUUID)) {
|
||||
handleBatteryInfo(characteristic.getValue(), BluetoothGatt.GATT_SUCCESS);
|
||||
return true;
|
||||
@ -2317,7 +2320,10 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
@Override
|
||||
public boolean onCharacteristicRead(BluetoothGatt gatt,
|
||||
BluetoothGattCharacteristic characteristic, int status) {
|
||||
super.onCharacteristicRead(gatt, characteristic, status);
|
||||
if (super.onCharacteristicRead(gatt, characteristic, status)) {
|
||||
// handled upstream
|
||||
return true;
|
||||
}
|
||||
|
||||
UUID characteristicUUID = characteristic.getUuid();
|
||||
if (GattCharacteristic.UUID_CHARACTERISTIC_DEVICE_NAME.equals(characteristicUUID)) {
|
||||
|
@ -107,6 +107,10 @@ public class ZeppOsConfigService extends AbstractZeppOsService {
|
||||
@Override
|
||||
public void handlePayload(final byte[] payload) {
|
||||
switch (payload[0]) {
|
||||
case CMD_CAPABILITIES_RESPONSE:
|
||||
handleCapabilitiesResponse(payload);
|
||||
return;
|
||||
|
||||
case CMD_ACK:
|
||||
LOG.info("Configuration ACK, status = {}", payload[1]);
|
||||
return;
|
||||
@ -125,7 +129,8 @@ public class ZeppOsConfigService extends AbstractZeppOsService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(TransactionBuilder builder) {
|
||||
public void initialize(final TransactionBuilder builder) {
|
||||
write(builder, CMD_CAPABILITIES_REQUEST);
|
||||
requestAllConfigs(builder);
|
||||
}
|
||||
|
||||
@ -152,6 +157,27 @@ public class ZeppOsConfigService extends AbstractZeppOsService {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleCapabilitiesResponse(final byte[] payload) {
|
||||
final int version = payload[1] & 0xFF;
|
||||
LOG.info("Got config service version={}", version);
|
||||
if (version > 3) {
|
||||
LOG.error("Unsupported config service version {}", version);
|
||||
return;
|
||||
}
|
||||
final int numGroups = payload[2] & 0xFF;
|
||||
if (payload.length != numGroups + 3) {
|
||||
LOG.error("Unexpected config capabilities response length {} for {} groups", payload.length, numGroups);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < numGroups; i++) {
|
||||
final ConfigGroup configGroup = ConfigGroup.fromValue(payload[3 + i]);
|
||||
LOG.debug("Got supported config group {}: {}", String.format("0x%02x", payload[3 + i]), configGroup);
|
||||
}
|
||||
|
||||
// TODO: We should only request supported config groups
|
||||
}
|
||||
|
||||
private boolean sentFitnessGoal = false;
|
||||
|
||||
private void handle2021ConfigResponse(final byte[] payload) {
|
||||
|
@ -72,7 +72,12 @@ public class ZeppOsServicesService extends AbstractZeppOsService {
|
||||
|
||||
final AbstractZeppOsService service = getSupport().getService(endpoint);
|
||||
|
||||
LOG.debug("Service: endpoint={} encrypted={} known={}", String.format("%04x", endpoint), encrypted, service != null);
|
||||
LOG.debug(
|
||||
"Zepp OS Service: endpoint={} encrypted={} name={}",
|
||||
String.format("%04x", endpoint),
|
||||
encrypted,
|
||||
service != null ? service.getClass().getSimpleName() : "unknown"
|
||||
);
|
||||
|
||||
if (service != null && encrypted != null) {
|
||||
service.setEncrypted(encrypted);
|
||||
|
Loading…
Reference in New Issue
Block a user