mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-24 09:35:50 +01:00
Oppo Enco Air2: Fix firmware parsing
This commit is contained in:
parent
6e3ce50221
commit
12671fb1e0
@ -150,11 +150,18 @@ public class OppoHeadphonesProtocol extends GBDeviceProtocol {
|
||||
if (payload[payload.length - 1] == 0) {
|
||||
fwString = new String(ArrayUtils.subarray(payload, 2, payload.length - 1)).strip();
|
||||
} else {
|
||||
fwString = new String(ArrayUtils.subarray(payload, 2, payload.length - 2)).strip();
|
||||
fwString = new String(ArrayUtils.subarray(payload, 2, payload.length)).strip();
|
||||
}
|
||||
final String[] parts = fwString.split(",");
|
||||
if (parts.length % 3 != 0) {
|
||||
LOG.warn("Fw parts length {} from '{}' is not divisible by 3", parts.length, fwString);
|
||||
|
||||
// We need to persist something, otherwise Gb misbehaves
|
||||
final GBDeviceEventVersionInfo eventVersionInfo = new GBDeviceEventVersionInfo();
|
||||
eventVersionInfo.fwVersion = fwString;
|
||||
eventVersionInfo.hwVersion = GBApplication.getContext().getString(R.string.n_a);
|
||||
events.add(eventVersionInfo);
|
||||
|
||||
break;
|
||||
}
|
||||
final String[] fwVersionParts = new String[3];
|
||||
|
@ -3,8 +3,6 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.oppo;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.test.TestBase;
|
||||
@ -14,11 +12,17 @@ public class OppoHeadphonesProtocolTest extends TestBase {
|
||||
@Test
|
||||
public void testHandleFirmware() {
|
||||
final OppoHeadphonesProtocol protocol = new OppoHeadphonesProtocol(null);
|
||||
|
||||
GBDeviceEvent[] oppoEvents = protocol.decodeResponse(GB.hexStringToByteArray("aa4f00000581f34800000a312c312c312c312c322c3136302c312c332c3838382c312c342c302c322c312c312c322c322c3136302c322c332c3838382c322c342c302c332c312c312c332c322c38323700"));
|
||||
Assert.assertEquals(1, oppoEvents.length);
|
||||
GBDeviceEventVersionInfo oppoEvent = (GBDeviceEventVersionInfo) oppoEvents[0];
|
||||
Assert.assertEquals("160.160.827", oppoEvent.fwVersion);
|
||||
|
||||
GBDeviceEvent[] air2Events = protocol.decodeResponse(GB.hexStringToByteArray("AA4500000581003E000009312C312C302C312C322C3134322C312C342C302C322C312C382C322C322C3134322C322C342C302C332C312C33332C332C322C3132392C332C342C30"));
|
||||
Assert.assertEquals(1, air2Events.length);
|
||||
GBDeviceEventVersionInfo air2event = (GBDeviceEventVersionInfo) air2Events[0];
|
||||
Assert.assertEquals("142.142.129", air2event.fwVersion);
|
||||
|
||||
GBDeviceEvent[] realme = protocol.decodeResponse(GB.hexStringToByteArray("aa2a040005810e23000003312c322c312e312e302e37352c322c322c312e312e302e37352c332c322c303031"));
|
||||
Assert.assertEquals(1, realme.length);
|
||||
GBDeviceEventVersionInfo realmeEvent = (GBDeviceEventVersionInfo) realme[0];
|
||||
|
Loading…
Reference in New Issue
Block a user