Garmin: various minor changes

remove message placeholders referring to legacy code,
remove try-catch from the weather data message building method
lower the frequency of music control messages
This commit is contained in:
Daniele Gobbetti 2024-05-20 18:15:12 +02:00
parent 9c4da444cf
commit ba9e5c8a77
2 changed files with 76 additions and 90 deletions

View File

@ -350,7 +350,6 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni
sendOutgoingMessage("send weather definitions", new nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.FitDefinitionMessage(weatherDefinitions)); sendOutgoingMessage("send weather definitions", new nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.FitDefinitionMessage(weatherDefinitions));
try {
RecordData today = new RecordData(recordDefinitionToday, recordDefinitionToday.getRecordHeader()); RecordData today = new RecordData(recordDefinitionToday, recordDefinitionToday.getRecordHeader());
today.setFieldByName("weather_report", 0); // 0 = current, 1 = hourly_forecast, 2 = daily_forecast today.setFieldByName("weather_report", 0); // 0 = current, 1 = hourly_forecast, 2 = daily_forecast
today.setFieldByName("timestamp", weather.timestamp); today.setFieldByName("timestamp", weather.timestamp);
@ -410,7 +409,7 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni
for (int day = 0; day < 4; day++) { for (int day = 0; day < 4; day++) {
if (day < weather.forecasts.size()) { if (day < weather.forecasts.size()) {
WeatherSpec.Daily daily = weather.forecasts.get(day); WeatherSpec.Daily daily = weather.forecasts.get(day);
int ts = weather.timestamp + (day + 1) * 24 * 60 * 60; //TODO: is this needed? int ts = weather.timestamp + (day + 1) * 24 * 60 * 60;
RecordData weatherDailyForecast = new RecordData(recordDefinitionDaily, recordDefinitionDaily.getRecordHeader()); RecordData weatherDailyForecast = new RecordData(recordDefinitionDaily, recordDefinitionDaily.getRecordHeader());
weatherDailyForecast.setFieldByName("weather_report", 2); // 0 = current, 1 = hourly_forecast, 2 = daily_forecast weatherDailyForecast.setFieldByName("weather_report", 2); // 0 = current, 1 = hourly_forecast, 2 = daily_forecast
weatherDailyForecast.setFieldByName("timestamp", weather.timestamp); weatherDailyForecast.setFieldByName("timestamp", weather.timestamp);
@ -427,9 +426,6 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni
} }
sendOutgoingMessage("send weather data", new nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.FitDataMessage(weatherData)); sendOutgoingMessage("send weather data", new nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.FitDataMessage(weatherData));
} catch (Exception e) {
LOG.error(e.getMessage());
}
} }
@ -620,7 +616,7 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni
stopMusicTimer(); stopMusicTimer();
musicStateTimer = new Timer(); musicStateTimer = new Timer();
int updatePeriod = 4000; //milliseconds int updatePeriod = 29000; //milliseconds
LOG.debug("onSetMusicState: {}", stateSpec.toString()); LOG.debug("onSetMusicState: {}", stateSpec.toString());
if (stateSpec.state == MusicStateSpec.STATE_PLAYING) { if (stateSpec.state == MusicStateSpec.STATE_PLAYING) {

View File

@ -19,16 +19,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.stat
import nodomain.freeyourgadget.gadgetbridge.util.GB; import nodomain.freeyourgadget.gadgetbridge.util.GB;
public abstract class GFDIMessage { public abstract class GFDIMessage {
public static final int MESSAGE_REQUEST = 5001;
public static final int MESSAGE_DIRECTORY_FILE_FILTER_REQUEST = 5007;
public static final int MESSAGE_FILE_READY = 5009;
public static final int MESSAGE_BATTERY_STATUS = 5023;
public static final int MESSAGE_NOTIFICATION_SOURCE = 5033;
public static final int MESSAGE_GNCS_CONTROL_POINT_REQUEST = 5034;
public static final int MESSAGE_GNCS_DATA_SOURCE = 5035;
public static final int MESSAGE_NOTIFICATION_SERVICE_SUBSCRIPTION = 5036;
public static final int MESSAGE_SYNC_REQUEST = 5037;
public static final int MESSAGE_AUTH_NEGOTIATION = 5101;
protected static final Logger LOG = LoggerFactory.getLogger(GFDIMessage.class); protected static final Logger LOG = LoggerFactory.getLogger(GFDIMessage.class);
private static int maxPacketSize = 375; //safe default? private static int maxPacketSize = 375; //safe default?
protected final ByteBuffer response = ByteBuffer.allocate(1000); protected final ByteBuffer response = ByteBuffer.allocate(1000);