mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-28 18:47:32 +01:00
Soundcore Q30: Cleanup Code
This commit is contained in:
parent
4e765ad952
commit
eff6f57aa5
@ -55,7 +55,7 @@ public class SoundcoreLibertyProtocol extends AbstractSoundcoreProtocol {
|
|||||||
LOG.debug("Unknown incoming message - command: " + cmd + ", dump: " + hexdump(responseData));
|
LOG.debug("Unknown incoming message - command: " + cmd + ", dump: " + hexdump(responseData));
|
||||||
} else if (cmd == (short) 0x0105) {
|
} else if (cmd == (short) 0x0105) {
|
||||||
LOG.debug("Unknown incoming message - command: " + cmd + ", dump: " + hexdump(responseData));
|
LOG.debug("Unknown incoming message - command: " + cmd + ", dump: " + hexdump(responseData));
|
||||||
} else if (cmd == (short) 0x0106) { //Sound Mode Update
|
} else if (cmd == (short) 0x0106) { // ANC Mode Update
|
||||||
decodeAudioMode(payload);
|
decodeAudioMode(payload);
|
||||||
} else if (cmd == (short) 0x0301) { // Battery Update
|
} else if (cmd == (short) 0x0301) { // Battery Update
|
||||||
int batteryLeft = payload[0] * 20;
|
int batteryLeft = payload[0] * 20;
|
||||||
|
@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||||
@ -39,18 +40,24 @@ public class SoundcoreQ30Protocol extends AbstractSoundcoreProtocol {
|
|||||||
byte[] payload = packet.getPayload();
|
byte[] payload = packet.getPayload();
|
||||||
|
|
||||||
if (cmd == (short) 0x0101) {
|
if (cmd == (short) 0x0101) {
|
||||||
// a lot of other data is in here, anything interesting?
|
int battery = payload[0] * 20; // only 20% steps available here
|
||||||
|
devEvts.add(buildBatteryInfo(0, battery));
|
||||||
|
|
||||||
|
byte[] eq_data = Arrays.copyOfRange(payload, 2, 12);
|
||||||
|
decodeEqualizer(eq_data);
|
||||||
|
|
||||||
|
// a lot of zeros is in range 12 - 34
|
||||||
|
|
||||||
|
byte[] anc_data = Arrays.copyOfRange(payload, 35, 39);
|
||||||
|
decodeAudioMode(anc_data);
|
||||||
|
|
||||||
String firmware1 = readString(payload, 39, 5);
|
String firmware1 = readString(payload, 39, 5);
|
||||||
String firmware2 = "";
|
String firmware2 = "";
|
||||||
String serialNumber = readString(payload, 44, 16);
|
String serialNumber = readString(payload, 44, 16);
|
||||||
devEvts.add(buildVersionInfo(firmware1, firmware2, serialNumber));
|
devEvts.add(buildVersionInfo(firmware1, firmware2, serialNumber));
|
||||||
|
|
||||||
decodeEqualizer(payload); // payload[2] bis payload[11]
|
|
||||||
} else if (cmd == (short) 0x0106) { // ANC Mode Updated by Button
|
} else if (cmd == (short) 0x0106) { // ANC Mode Updated by Button
|
||||||
decodeAudioMode(payload);
|
decodeAudioMode(payload);
|
||||||
} else if (cmd == (short) 0x0301) { // Battery Update
|
|
||||||
int battery = payload[0] * 20; // untested
|
|
||||||
devEvts.add(buildBatteryInfo(0, battery));
|
|
||||||
} else if (cmd == (short) 0x8106) {
|
} else if (cmd == (short) 0x8106) {
|
||||||
// Acknowledgement for changed Ambient Mode
|
// Acknowledgement for changed Ambient Mode
|
||||||
// empty payload
|
// empty payload
|
||||||
@ -175,15 +182,15 @@ public class SoundcoreQ30Protocol extends AbstractSoundcoreProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void decodeEqualizer(byte[] payload) {
|
private void decodeEqualizer(byte[] payload) {
|
||||||
// payload[2] und payload[3] immer 0xfe ?
|
// payload[0] und payload[1] immer 0xfe ?
|
||||||
int band1 = Byte.toUnsignedInt(payload[4]);
|
int band1 = Byte.toUnsignedInt(payload[2]);
|
||||||
int band2 = Byte.toUnsignedInt(payload[5]);
|
int band2 = Byte.toUnsignedInt(payload[3]);
|
||||||
int band3 = Byte.toUnsignedInt(payload[6]);
|
int band3 = Byte.toUnsignedInt(payload[4]);
|
||||||
int band4 = Byte.toUnsignedInt(payload[7]);
|
int band4 = Byte.toUnsignedInt(payload[5]);
|
||||||
int band5 = Byte.toUnsignedInt(payload[8]);
|
int band5 = Byte.toUnsignedInt(payload[6]);
|
||||||
int band6 = Byte.toUnsignedInt(payload[9]);
|
int band6 = Byte.toUnsignedInt(payload[7]);
|
||||||
int band7 = Byte.toUnsignedInt(payload[10]);
|
int band7 = Byte.toUnsignedInt(payload[8]);
|
||||||
int band8 = Byte.toUnsignedInt(payload[11]);
|
int band8 = Byte.toUnsignedInt(payload[9]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user