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

Lefun: Use proper handler for firmware info

This commit is contained in:
Yukai Li 2020-10-05 06:24:57 -06:00 committed by Gitea
parent a2090eeccb
commit 2c1167b1b3

View File

@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.requests;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
import nodomain.freeyourgadget.gadgetbridge.devices.lefun.LefunConstants;
import nodomain.freeyourgadget.gadgetbridge.devices.lefun.commands.GetFirmwareInfoCommand;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -41,13 +42,18 @@ public class GetFirmwareInfoRequest extends Request {
GetFirmwareInfoCommand cmd = new GetFirmwareInfoCommand();
cmd.deserialize(data);
GBDevice device = getSupport().getDevice();
// Last character is a \x1f? Not printable either way.
device.setModel(cmd.getTypeCode().substring(0, 3));
int hardwareVersion = cmd.getHardwareVersion() & 0xffff;
int softwareVersion = cmd.getSoftwareVersion() & 0xffff;
device.setFirmwareVersion(String.format("%d.%d", softwareVersion >> 8, softwareVersion & 0xff));
GBDeviceEventVersionInfo versionInfo = new GBDeviceEventVersionInfo();
versionInfo.fwVersion = String.format("%d.%d", softwareVersion >> 8, softwareVersion & 0xff);
// Last character is a \x1f? Not printable either way.
versionInfo.hwVersion = cmd.getTypeCode().substring(0, 3);
getSupport().evaluateGBDeviceEvent(versionInfo);
GBDevice device = getSupport().getDevice();
device.setFirmwareVersion2(String.format("%d.%d", hardwareVersion >> 8, hardwareVersion & 0xff));
getSupport().completeInitialization();
operationStatus = OperationStatus.FINISHED;