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

Zepp OS: Fix setting of unknown configuration values

Unknown configuration values are displayed in the UI as "Unknown (0x*)".
We can then attempt to parse them as hex and send the value.
This commit is contained in:
José Rebelo 2023-03-19 22:05:37 +00:00
parent f0a05ded91
commit 443f13c11d

View File

@ -52,6 +52,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
@ -1763,6 +1765,12 @@ public class ZeppOsConfigService extends AbstractZeppOsService {
}
}
// Byte doesn't match a known enum value, attempt to parse it as hex
final Matcher matcher = Pattern.compile("^0[xX]([0-9a-fA-F]{1,2})$").matcher(val);
if (matcher.find()) {
return (byte) Integer.parseInt(matcher.group(1), 16);
}
return null;
}