mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-02 15:02:56 +01:00
Rename DaFit references to Moyoung to reflect the protocol used
This commit is contained in:
parent
d24fdf44fb
commit
918fa8bedc
@ -150,6 +150,7 @@ public class GBDaoGenerator {
|
||||
addColmiSleepStageSample(schema, user, device);
|
||||
addColmiHrvValueSample(schema, user, device);
|
||||
addColmiHrvSummarySample(schema, user, device);
|
||||
addMoyoungActivitySample(schema, user, device);
|
||||
|
||||
addHuaweiActivitySample(schema, user, device);
|
||||
|
||||
@ -1036,8 +1037,8 @@ public class GBDaoGenerator {
|
||||
return activitySample;
|
||||
}
|
||||
|
||||
private static Entity addDaFitActivitySample(Schema schema, Entity user, Entity device) {
|
||||
Entity activitySample = addEntity(schema, "DaFitActivitySample");
|
||||
private static Entity addMoyoungActivitySample(Schema schema, Entity user, Entity device) {
|
||||
Entity activitySample = addEntity(schema, "MoyoungActivitySample");
|
||||
activitySample.implementsSerializable();
|
||||
addCommonActivitySampleProperties("AbstractActivitySample", activitySample, user, device);
|
||||
activitySample.addIntProperty(SAMPLE_STEPS).notNull().codeBeforeGetterAndSetter(OVERRIDE).codeBeforeGetter("@Override\n public int getRawIntensity() {\n return getSteps();\n }\n\n");
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -25,7 +25,7 @@ import java.util.UUID;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
|
||||
|
||||
public class DaFitConstants {
|
||||
public class MoyoungConstants {
|
||||
// (*) - based only on static reverse engineering of the original app code,
|
||||
// not supported by my watch so not implemented
|
||||
// (or at least I didn't manage to get any response out of it)
|
||||
@ -97,7 +97,7 @@ public class DaFitConstants {
|
||||
// * 20 - protocol version (queries manufacturer name, see description above)
|
||||
|
||||
|
||||
public static final UUID UUID_SERVICE_DAFIT = UUID.fromString(String.format(AbstractBTLEDeviceSupport.BASE_UUID, "feea"));
|
||||
public static final UUID UUID_SERVICE_MOYOUNG = UUID.fromString(String.format(AbstractBTLEDeviceSupport.BASE_UUID, "feea"));
|
||||
public static final UUID UUID_CHARACTERISTIC_STEPS = UUID.fromString(String.format(AbstractBTLEDeviceSupport.BASE_UUID, "fee1"));
|
||||
public static final UUID UUID_CHARACTERISTIC_DATA_OUT = UUID.fromString(String.format(AbstractBTLEDeviceSupport.BASE_UUID, "fee2"));
|
||||
public static final UUID UUID_CHARACTERISTIC_DATA_IN = UUID.fromString(String.format(AbstractBTLEDeviceSupport.BASE_UUID, "fee3"));
|
||||
@ -365,36 +365,36 @@ public class DaFitConstants {
|
||||
public static final byte WEATHER_HAZE = 7; // it's basically very big fog :P
|
||||
// NOTE: values > 7 give random glitchy crap as images :D
|
||||
|
||||
public static byte openWeatherConditionToDaFitConditionId(int openWeatherMapCondition) {
|
||||
public static byte openWeatherConditionToMoyoungConditionId(int openWeatherMapCondition) {
|
||||
int openWeatherMapGroup = openWeatherMapCondition / 100;
|
||||
switch (openWeatherMapGroup) {
|
||||
case 2: // thunderstorm
|
||||
case 3: // drizzle
|
||||
case 5: // rain
|
||||
return DaFitConstants.WEATHER_RAINY;
|
||||
return MoyoungConstants.WEATHER_RAINY;
|
||||
case 6: // snow
|
||||
return DaFitConstants.WEATHER_SNOWY;
|
||||
return MoyoungConstants.WEATHER_SNOWY;
|
||||
case 7: // fog
|
||||
return DaFitConstants.WEATHER_FOGGY;
|
||||
return MoyoungConstants.WEATHER_FOGGY;
|
||||
case 8: // clear / clouds
|
||||
if (openWeatherMapCondition <= 801) // few clouds
|
||||
return DaFitConstants.WEATHER_SUNNY;
|
||||
return MoyoungConstants.WEATHER_SUNNY;
|
||||
if (openWeatherMapCondition >= 804) // overcast clouds
|
||||
return DaFitConstants.WEATHER_CLOUDY;
|
||||
return DaFitConstants.WEATHER_OVERCAST;
|
||||
return MoyoungConstants.WEATHER_CLOUDY;
|
||||
return MoyoungConstants.WEATHER_OVERCAST;
|
||||
case 9: // extreme
|
||||
default:
|
||||
if (openWeatherMapCondition == 905) // windy
|
||||
return DaFitConstants.WEATHER_SANDSTORM;
|
||||
return DaFitConstants.WEATHER_HAZE;
|
||||
return MoyoungConstants.WEATHER_SANDSTORM;
|
||||
return MoyoungConstants.WEATHER_HAZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final String PREF_WATCH_FACE = "dafit_watch_face";
|
||||
public static final String PREF_LANGUAGE = "dafit_language";
|
||||
public static final String PREF_LANGUAGE_SUPPORT = "dafit_language_supported";
|
||||
public static final String PREF_DEVICE_VERSION = "dafit_device_version";
|
||||
public static final String PREF_WATCH_FACE = "moyoung_watch_face";
|
||||
public static final String PREF_LANGUAGE = "moyoung_language";
|
||||
public static final String PREF_LANGUAGE_SUPPORT = "moyoung_language_supported";
|
||||
public static final String PREF_DEVICE_VERSION = "moyoung_device_version";
|
||||
public static final String PREF_SEDENTARY_REMINDER = "sedentary_reminder";
|
||||
public static final String PREF_SEDENTARY_REMINDER_PERIOD = "sedentary_reminder_period";
|
||||
public static final String PREF_SEDENTARY_REMINDER_STEPS = "sedentary_reminder_steps";
|
@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
@ -35,18 +35,18 @@ import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumDeviceVersion;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumMetricSystem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumTimeSystem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSetting;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingBool;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingByte;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingEnum;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingInt;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingLanguage;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingRemindersToMove;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingTimeRange;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingUserInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumDeviceVersion;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumMetricSystem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumTimeSystem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSetting;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingBool;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingByte;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingEnum;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingInt;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingLanguage;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingRemindersToMove;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingTimeRange;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingUserInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
@ -54,7 +54,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
|
||||
public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
public class MoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
|
||||
@Override
|
||||
public DeviceType getDeviceType() {
|
||||
@ -70,7 +70,7 @@ public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public Collection<? extends ScanFilter> createBLEScanFilters() {
|
||||
ParcelUuid service = new ParcelUuid(DaFitConstants.UUID_SERVICE_DAFIT);
|
||||
ParcelUuid service = new ParcelUuid(MoyoungConstants.UUID_SERVICE_MOYOUNG);
|
||||
ScanFilter filter = new ScanFilter.Builder().setServiceUuid(service).build();
|
||||
return Collections.singletonList(filter);
|
||||
}
|
||||
@ -79,7 +79,7 @@ public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
@Override
|
||||
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
|
||||
// TODO: It would be nice to also filter on "manufacturer" (which is used as a protocol version) being MOYOUNG-V2 or MOYOUNG but I have no idea if it's possible to do that at this point
|
||||
if (candidate.supportsService(DaFitConstants.UUID_SERVICE_DAFIT)) {
|
||||
if (candidate.supportsService(MoyoungConstants.UUID_SERVICE_MOYOUNG)) {
|
||||
return DeviceType.DAFIT;
|
||||
}
|
||||
return DeviceType.UNKNOWN;
|
||||
@ -113,7 +113,7 @@ public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
|
||||
@Override
|
||||
public SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
|
||||
return new DaFitSampleProvider(device, session);
|
||||
return new MoyoungSampleProvider(device, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -200,31 +200,31 @@ public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
@Override
|
||||
public boolean supportsUnicodeEmojis() { return false; }
|
||||
|
||||
private static final DaFitSetting[] DAFIT_SETTINGS = new DaFitSetting[] {
|
||||
new DaFitSettingUserInfo("USER_INFO", DaFitConstants.CMD_SET_USER_INFO),
|
||||
new DaFitSettingByte("STEP_LENGTH", (byte)-1, DaFitConstants.CMD_SET_STEP_LENGTH),
|
||||
// (*) new DaFitSettingEnum<>("DOMINANT_HAND", DaFitConstants.CMD_QUERY_DOMINANT_HAND, DaFitConstants.CMD_SET_DOMINANT_HAND, DaFitEnumDominantHand.class),
|
||||
new DaFitSettingInt("GOAL_STEP", DaFitConstants.CMD_QUERY_GOAL_STEP, DaFitConstants.CMD_SET_GOAL_STEP),
|
||||
private static final MoyoungSetting[] MOYOUNG_SETTINGS = new MoyoungSetting[] {
|
||||
new MoyoungSettingUserInfo("USER_INFO", MoyoungConstants.CMD_SET_USER_INFO),
|
||||
new MoyoungSettingByte("STEP_LENGTH", (byte)-1, MoyoungConstants.CMD_SET_STEP_LENGTH),
|
||||
// (*) new MoyoungSettingEnum<>("DOMINANT_HAND", MoyoungConstants.CMD_QUERY_DOMINANT_HAND, MoyoungConstants.CMD_SET_DOMINANT_HAND, MoyoungEnumDominantHand.class),
|
||||
new MoyoungSettingInt("GOAL_STEP", MoyoungConstants.CMD_QUERY_GOAL_STEP, MoyoungConstants.CMD_SET_GOAL_STEP),
|
||||
|
||||
new DaFitSettingEnum<>("DEVICE_VERSION", DaFitConstants.CMD_QUERY_DEVICE_VERSION, DaFitConstants.CMD_SET_DEVICE_VERSION, DaFitEnumDeviceVersion.class),
|
||||
new DaFitSettingLanguage("DEVICE_LANGUAGE", DaFitConstants.CMD_QUERY_DEVICE_LANGUAGE, DaFitConstants.CMD_SET_DEVICE_LANGUAGE),
|
||||
new DaFitSettingEnum<>("TIME_SYSTEM", DaFitConstants.CMD_QUERY_TIME_SYSTEM, DaFitConstants.CMD_SET_TIME_SYSTEM, DaFitEnumTimeSystem.class),
|
||||
new DaFitSettingEnum<>("METRIC_SYSTEM", DaFitConstants.CMD_QUERY_METRIC_SYSTEM, DaFitConstants.CMD_SET_METRIC_SYSTEM, DaFitEnumMetricSystem.class),
|
||||
new MoyoungSettingEnum<>("DEVICE_VERSION", MoyoungConstants.CMD_QUERY_DEVICE_VERSION, MoyoungConstants.CMD_SET_DEVICE_VERSION, MoyoungEnumDeviceVersion.class),
|
||||
new MoyoungSettingLanguage("DEVICE_LANGUAGE", MoyoungConstants.CMD_QUERY_DEVICE_LANGUAGE, MoyoungConstants.CMD_SET_DEVICE_LANGUAGE),
|
||||
new MoyoungSettingEnum<>("TIME_SYSTEM", MoyoungConstants.CMD_QUERY_TIME_SYSTEM, MoyoungConstants.CMD_SET_TIME_SYSTEM, MoyoungEnumTimeSystem.class),
|
||||
new MoyoungSettingEnum<>("METRIC_SYSTEM", MoyoungConstants.CMD_QUERY_METRIC_SYSTEM, MoyoungConstants.CMD_SET_METRIC_SYSTEM, MoyoungEnumMetricSystem.class),
|
||||
|
||||
// (*) new DaFitSetting("DISPLAY_DEVICE_FUNCTION", DaFitConstants.CMD_QUERY_DISPLAY_DEVICE_FUNCTION, DaFitConstants.CMD_SET_DISPLAY_DEVICE_FUNCTION),
|
||||
// (*) new DaFitSetting("SUPPORT_WATCH_FACE", DaFitConstants.CMD_QUERY_SUPPORT_WATCH_FACE, (byte)-1),
|
||||
// (*) new DaFitSetting("WATCH_FACE_LAYOUT", DaFitConstants.CMD_QUERY_WATCH_FACE_LAYOUT, DaFitConstants.CMD_SET_WATCH_FACE_LAYOUT),
|
||||
new DaFitSettingByte("DISPLAY_WATCH_FACE", DaFitConstants.CMD_QUERY_DISPLAY_WATCH_FACE, DaFitConstants.CMD_SET_DISPLAY_WATCH_FACE),
|
||||
new DaFitSettingBool("OTHER_MESSAGE_STATE", DaFitConstants.CMD_QUERY_OTHER_MESSAGE_STATE, DaFitConstants.CMD_SET_OTHER_MESSAGE_STATE),
|
||||
// (*) new MoyoungSetting("DISPLAY_DEVICE_FUNCTION", MoyoungConstants.CMD_QUERY_DISPLAY_DEVICE_FUNCTION, MoyoungConstants.CMD_SET_DISPLAY_DEVICE_FUNCTION),
|
||||
// (*) new MoyoungSetting("SUPPORT_WATCH_FACE", MoyoungConstants.CMD_QUERY_SUPPORT_WATCH_FACE, (byte)-1),
|
||||
// (*) new MoyoungSetting("WATCH_FACE_LAYOUT", MoyoungConstants.CMD_QUERY_WATCH_FACE_LAYOUT, MoyoungConstants.CMD_SET_WATCH_FACE_LAYOUT),
|
||||
new MoyoungSettingByte("DISPLAY_WATCH_FACE", MoyoungConstants.CMD_QUERY_DISPLAY_WATCH_FACE, MoyoungConstants.CMD_SET_DISPLAY_WATCH_FACE),
|
||||
new MoyoungSettingBool("OTHER_MESSAGE_STATE", MoyoungConstants.CMD_QUERY_OTHER_MESSAGE_STATE, MoyoungConstants.CMD_SET_OTHER_MESSAGE_STATE),
|
||||
|
||||
new DaFitSettingBool("QUICK_VIEW", DaFitConstants.CMD_QUERY_QUICK_VIEW, DaFitConstants.CMD_SET_QUICK_VIEW),
|
||||
new DaFitSettingTimeRange("QUICK_VIEW_TIME", DaFitConstants.CMD_QUERY_QUICK_VIEW_TIME, DaFitConstants.CMD_SET_QUICK_VIEW_TIME),
|
||||
new DaFitSettingBool("SEDENTARY_REMINDER", DaFitConstants.CMD_QUERY_SEDENTARY_REMINDER, DaFitConstants.CMD_SET_SEDENTARY_REMINDER),
|
||||
new DaFitSettingRemindersToMove("REMINDERS_TO_MOVE_PERIOD", DaFitConstants.CMD_QUERY_REMINDERS_TO_MOVE_PERIOD, DaFitConstants.CMD_SET_REMINDERS_TO_MOVE_PERIOD),
|
||||
new DaFitSettingTimeRange("DO_NOT_DISTURB_TIME", DaFitConstants.CMD_QUERY_DO_NOT_DISTURB_TIME, DaFitConstants.CMD_SET_DO_NOT_DISTURB_TIME),
|
||||
// (*) new DaFitSetting("PSYCHOLOGICAL_PERIOD", DaFitConstants.CMD_QUERY_PSYCHOLOGICAL_PERIOD, DaFitConstants.CMD_SET_PSYCHOLOGICAL_PERIOD),
|
||||
new MoyoungSettingBool("QUICK_VIEW", MoyoungConstants.CMD_QUERY_QUICK_VIEW, MoyoungConstants.CMD_SET_QUICK_VIEW),
|
||||
new MoyoungSettingTimeRange("QUICK_VIEW_TIME", MoyoungConstants.CMD_QUERY_QUICK_VIEW_TIME, MoyoungConstants.CMD_SET_QUICK_VIEW_TIME),
|
||||
new MoyoungSettingBool("SEDENTARY_REMINDER", MoyoungConstants.CMD_QUERY_SEDENTARY_REMINDER, MoyoungConstants.CMD_SET_SEDENTARY_REMINDER),
|
||||
new MoyoungSettingRemindersToMove("REMINDERS_TO_MOVE_PERIOD", MoyoungConstants.CMD_QUERY_REMINDERS_TO_MOVE_PERIOD, MoyoungConstants.CMD_SET_REMINDERS_TO_MOVE_PERIOD),
|
||||
new MoyoungSettingTimeRange("DO_NOT_DISTURB_TIME", MoyoungConstants.CMD_QUERY_DO_NOT_DISTURB_TIME, MoyoungConstants.CMD_SET_DO_NOT_DISTURB_TIME),
|
||||
// (*) new MoyoungSetting("PSYCHOLOGICAL_PERIOD", MoyoungConstants.CMD_QUERY_PSYCHOLOGICAL_PERIOD, MoyoungConstants.CMD_SET_PSYCHOLOGICAL_PERIOD),
|
||||
|
||||
new DaFitSettingBool("BREATHING_LIGHT", DaFitConstants.CMD_QUERY_BREATHING_LIGHT, DaFitConstants.CMD_SET_BREATHING_LIGHT)
|
||||
new MoyoungSettingBool("BREATHING_LIGHT", MoyoungConstants.CMD_QUERY_BREATHING_LIGHT, MoyoungConstants.CMD_SET_BREATHING_LIGHT)
|
||||
};
|
||||
|
||||
@Override
|
||||
@ -232,20 +232,20 @@ public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
return new int[]{
|
||||
R.xml.devicesettings_personalinfo,
|
||||
//R.xml.devicesettings_steplength, // TODO is this needed? does it work? write-only so hard to tell
|
||||
R.xml.devicesettings_dafit_device_version,
|
||||
R.xml.devicesettings_dafit_language,
|
||||
R.xml.devicesettings_moyoung_device_version,
|
||||
R.xml.devicesettings_moyoung_language,
|
||||
R.xml.devicesettings_timeformat,
|
||||
R.xml.devicesettings_measurementsystem,
|
||||
R.xml.devicesettings_dafit_watchface,
|
||||
//R.xml.devicesettings_dafit_othermessage, // not implemented because this doesn't really do anything on the watch side, only enables/disables sending of "other" notifications in the app (no idea why they store the setting on the watch)
|
||||
R.xml.devicesettings_moyoung_watchface,
|
||||
//R.xml.devicesettings_moyoung_othermessage, // not implemented because this doesn't really do anything on the watch side, only enables/disables sending of "other" notifications in the app (no idea why they store the setting on the watch)
|
||||
R.xml.devicesettings_liftwrist_display,
|
||||
R.xml.devicesettings_dafit_sedentary_reminder,
|
||||
R.xml.devicesettings_moyoung_sedentary_reminder,
|
||||
R.xml.devicesettings_donotdisturb_no_auto_v2,
|
||||
//R.xml.devicesettings_dafit_breathinglight, // No idea what this does but it doesn't seem to change anything
|
||||
//R.xml.devicesettings_moyoung_breathinglight, // No idea what this does but it doesn't seem to change anything
|
||||
};
|
||||
}
|
||||
|
||||
public DaFitSetting[] getSupportedSettings() {
|
||||
return DAFIT_SETTINGS;
|
||||
public MoyoungSetting[] getSupportedSettings() {
|
||||
return MOYOUNG_SETTINGS;
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -31,13 +31,13 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaFitActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaFitActivitySampleDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.MoyoungActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.MoyoungActivitySampleDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||
|
||||
public class DaFitSampleProvider extends AbstractSampleProvider<DaFitActivitySample> {
|
||||
public class MoyoungSampleProvider extends AbstractSampleProvider<MoyoungActivitySample> {
|
||||
public static final int SOURCE_NOT_MEASURED = -1;
|
||||
public static final int SOURCE_STEPS_REALTIME = 1; // steps gathered at realtime from the steps characteristic
|
||||
public static final int SOURCE_STEPS_SUMMARY = 2; // steps gathered from the daily summary
|
||||
@ -48,53 +48,53 @@ public class DaFitSampleProvider extends AbstractSampleProvider<DaFitActivitySam
|
||||
public static final int SOURCE_BATTERY = 7; // battery report
|
||||
|
||||
public static final int ACTIVITY_NOT_MEASURED = -1;
|
||||
public static final int ACTIVITY_TRAINING_WALK = DaFitConstants.TRAINING_TYPE_WALK;
|
||||
public static final int ACTIVITY_TRAINING_RUN = DaFitConstants.TRAINING_TYPE_RUN;
|
||||
public static final int ACTIVITY_TRAINING_BIKING = DaFitConstants.TRAINING_TYPE_BIKING;
|
||||
public static final int ACTIVITY_TRAINING_ROPE = DaFitConstants.TRAINING_TYPE_ROPE;
|
||||
public static final int ACTIVITY_TRAINING_BADMINTON = DaFitConstants.TRAINING_TYPE_BADMINTON;
|
||||
public static final int ACTIVITY_TRAINING_BASKETBALL = DaFitConstants.TRAINING_TYPE_BASKETBALL;
|
||||
public static final int ACTIVITY_TRAINING_FOOTBALL = DaFitConstants.TRAINING_TYPE_FOOTBALL;
|
||||
public static final int ACTIVITY_TRAINING_SWIM = DaFitConstants.TRAINING_TYPE_SWIM;
|
||||
public static final int ACTIVITY_TRAINING_MOUNTAINEERING = DaFitConstants.TRAINING_TYPE_MOUNTAINEERING;
|
||||
public static final int ACTIVITY_TRAINING_TENNIS = DaFitConstants.TRAINING_TYPE_TENNIS;
|
||||
public static final int ACTIVITY_TRAINING_RUGBY = DaFitConstants.TRAINING_TYPE_RUGBY;
|
||||
public static final int ACTIVITY_TRAINING_GOLF = DaFitConstants.TRAINING_TYPE_GOLF;
|
||||
public static final int ACTIVITY_TRAINING_WALK = MoyoungConstants.TRAINING_TYPE_WALK;
|
||||
public static final int ACTIVITY_TRAINING_RUN = MoyoungConstants.TRAINING_TYPE_RUN;
|
||||
public static final int ACTIVITY_TRAINING_BIKING = MoyoungConstants.TRAINING_TYPE_BIKING;
|
||||
public static final int ACTIVITY_TRAINING_ROPE = MoyoungConstants.TRAINING_TYPE_ROPE;
|
||||
public static final int ACTIVITY_TRAINING_BADMINTON = MoyoungConstants.TRAINING_TYPE_BADMINTON;
|
||||
public static final int ACTIVITY_TRAINING_BASKETBALL = MoyoungConstants.TRAINING_TYPE_BASKETBALL;
|
||||
public static final int ACTIVITY_TRAINING_FOOTBALL = MoyoungConstants.TRAINING_TYPE_FOOTBALL;
|
||||
public static final int ACTIVITY_TRAINING_SWIM = MoyoungConstants.TRAINING_TYPE_SWIM;
|
||||
public static final int ACTIVITY_TRAINING_MOUNTAINEERING = MoyoungConstants.TRAINING_TYPE_MOUNTAINEERING;
|
||||
public static final int ACTIVITY_TRAINING_TENNIS = MoyoungConstants.TRAINING_TYPE_TENNIS;
|
||||
public static final int ACTIVITY_TRAINING_RUGBY = MoyoungConstants.TRAINING_TYPE_RUGBY;
|
||||
public static final int ACTIVITY_TRAINING_GOLF = MoyoungConstants.TRAINING_TYPE_GOLF;
|
||||
public static final int ACTIVITY_SLEEP_LIGHT = 16;
|
||||
public static final int ACTIVITY_SLEEP_RESTFUL = 17;
|
||||
public static final int ACTIVITY_SLEEP_START = 18;
|
||||
public static final int ACTIVITY_SLEEP_END = 19;
|
||||
|
||||
public DaFitSampleProvider(GBDevice device, DaoSession session) {
|
||||
public MoyoungSampleProvider(GBDevice device, DaoSession session) {
|
||||
super(device, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractDao<DaFitActivitySample, ?> getSampleDao() {
|
||||
return getSession().getDaFitActivitySampleDao();
|
||||
public AbstractDao<MoyoungActivitySample, ?> getSampleDao() {
|
||||
return getSession().getMoyoungActivitySampleDao();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Property getTimestampSampleProperty() {
|
||||
return DaFitActivitySampleDao.Properties.Timestamp;
|
||||
return MoyoungActivitySampleDao.Properties.Timestamp;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected Property getRawKindSampleProperty() {
|
||||
return DaFitActivitySampleDao.Properties.RawKind;
|
||||
return MoyoungActivitySampleDao.Properties.RawKind;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Property getDeviceIdentifierSampleProperty() {
|
||||
return DaFitActivitySampleDao.Properties.DeviceId;
|
||||
return MoyoungActivitySampleDao.Properties.DeviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaFitActivitySample createActivitySample() {
|
||||
return new DaFitActivitySample();
|
||||
public MoyoungActivitySample createActivitySample() {
|
||||
return new MoyoungActivitySample();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -163,12 +163,12 @@ public class DaFitSampleProvider extends AbstractSampleProvider<DaFitActivitySam
|
||||
throw new IllegalStateException();
|
||||
Property deviceProperty = getDeviceIdentifierSampleProperty();
|
||||
|
||||
/*QueryBuilder<DaFitActivitySample> qb = getSampleDao().queryBuilder();
|
||||
/*QueryBuilder<MoyoungActivitySample> qb = getSampleDao().queryBuilder();
|
||||
qb.where(deviceProperty.eq(dbDevice.getId()))
|
||||
.where(timestampProperty.ge(timestamp_from), timestampProperty.le(timestamp_to))
|
||||
.where(getRawKindSampleProperty().eq(ACTIVITY_NOT_MEASURED));
|
||||
List<DaFitActivitySample> samples = qb.build().list();
|
||||
for (DaFitActivitySample sample : samples) {
|
||||
List<MoyoungActivitySample> samples = qb.build().list();
|
||||
for (MoyoungActivitySample sample : samples) {
|
||||
sample.setProvider(this);
|
||||
sample.setRawKind(new_raw_activity_kind);
|
||||
sample.update();
|
@ -14,24 +14,24 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
|
||||
public class DaFitWeatherForecast {
|
||||
public class MoyoungWeatherForecast {
|
||||
public final byte conditionId;
|
||||
public final byte minTemp;
|
||||
public final byte maxTemp;
|
||||
|
||||
public DaFitWeatherForecast(byte conditionId, byte minTemp, byte maxTemp) {
|
||||
public MoyoungWeatherForecast(byte conditionId, byte minTemp, byte maxTemp) {
|
||||
this.conditionId = conditionId;
|
||||
this.minTemp = minTemp;
|
||||
this.maxTemp = maxTemp;
|
||||
}
|
||||
|
||||
public DaFitWeatherForecast(WeatherSpec.Forecast forecast)
|
||||
public MoyoungWeatherForecast(WeatherSpec.Forecast forecast)
|
||||
{
|
||||
conditionId = DaFitConstants.openWeatherConditionToDaFitConditionId(forecast.conditionCode);
|
||||
conditionId = MoyoungConstants.openWeatherConditionToMoyoungConditionId(forecast.conditionCode);
|
||||
minTemp = (byte)(forecast.minTemp - 273); // Kelvin -> Celcius
|
||||
maxTemp = (byte)(forecast.maxTemp - 273); // Kelvin -> Celcius
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -22,14 +22,14 @@ import androidx.annotation.Nullable;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
|
||||
|
||||
public class DaFitWeatherToday {
|
||||
public class MoyoungWeatherToday {
|
||||
public final byte conditionId;
|
||||
public final byte currentTemp;
|
||||
public final Short pm25; // (*)
|
||||
public final String lunar_or_festival; // (*)
|
||||
public final String city; // (*)
|
||||
|
||||
public DaFitWeatherToday(byte conditionId, byte currentTemp, @Nullable Short pm25, @NonNull String lunar_or_festival, @NonNull String city) {
|
||||
public MoyoungWeatherToday(byte conditionId, byte currentTemp, @Nullable Short pm25, @NonNull String lunar_or_festival, @NonNull String city) {
|
||||
if (lunar_or_festival.length() != 4)
|
||||
throw new IllegalArgumentException("lunar_or_festival");
|
||||
if (city.length() != 4)
|
||||
@ -41,9 +41,9 @@ public class DaFitWeatherToday {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public DaFitWeatherToday(WeatherSpec weatherSpec)
|
||||
public MoyoungWeatherToday(WeatherSpec weatherSpec)
|
||||
{
|
||||
conditionId = DaFitConstants.openWeatherConditionToDaFitConditionId(weatherSpec.currentConditionCode);
|
||||
conditionId = MoyoungConstants.openWeatherConditionToMoyoungConditionId(weatherSpec.currentConditionCode);
|
||||
currentTemp = (byte)(weatherSpec.currentTemp - 273); // Kelvin -> Celcius
|
||||
pm25 = null;
|
||||
lunar_or_festival = StringUtils.pad("", 4);
|
@ -14,8 +14,8 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
public interface DaFitEnum {
|
||||
public interface MoyoungEnum {
|
||||
byte value();
|
||||
}
|
@ -14,15 +14,15 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
public enum DaFitEnumDeviceVersion implements DaFitEnum {
|
||||
public enum MoyoungEnumDeviceVersion implements MoyoungEnum {
|
||||
CHINESE_EDITION((byte)0),
|
||||
INTERNATIONAL_EDITION((byte)1);
|
||||
|
||||
public final byte value;
|
||||
|
||||
DaFitEnumDeviceVersion(byte value) {
|
||||
MoyoungEnumDeviceVersion(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
@ -14,15 +14,15 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
public enum DaFitEnumDominantHand implements DaFitEnum {
|
||||
public enum MoyoungEnumDominantHand implements MoyoungEnum {
|
||||
LEFT_HAND((byte)0),
|
||||
RIGHT_HAND((byte)1);
|
||||
|
||||
public final byte value;
|
||||
|
||||
DaFitEnumDominantHand(byte value) {
|
||||
MoyoungEnumDominantHand(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
@ -14,9 +14,9 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
public enum DaFitEnumLanguage implements DaFitEnum {
|
||||
public enum MoyoungEnumLanguage implements MoyoungEnum {
|
||||
LANGUAGE_ENGLISH((byte)0),
|
||||
LANGUAGE_CHINESE((byte)1),
|
||||
LANGUAGE_JAPANESE((byte)2),
|
||||
@ -45,7 +45,7 @@ public enum DaFitEnumLanguage implements DaFitEnum {
|
||||
|
||||
public final byte value;
|
||||
|
||||
DaFitEnumLanguage(byte value) {
|
||||
MoyoungEnumLanguage(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
@ -14,15 +14,15 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
public enum DaFitEnumMetricSystem implements DaFitEnum {
|
||||
public enum MoyoungEnumMetricSystem implements MoyoungEnum {
|
||||
METRIC_SYSTEM((byte)0),
|
||||
IMPERIAL_SYSTEM((byte)1);
|
||||
|
||||
public final byte value;
|
||||
|
||||
DaFitEnumMetricSystem(byte value) {
|
||||
MoyoungEnumMetricSystem(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
@ -14,15 +14,15 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
public enum DaFitEnumTimeSystem implements DaFitEnum {
|
||||
public enum MoyoungEnumTimeSystem implements MoyoungEnum {
|
||||
TIME_SYSTEM_12((byte)0),
|
||||
TIME_SYSTEM_24((byte)1);
|
||||
|
||||
public final byte value;
|
||||
|
||||
DaFitEnumTimeSystem(byte value) {
|
||||
MoyoungEnumTimeSystem(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
@ -14,14 +14,14 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
public abstract class DaFitSetting<T> {
|
||||
public abstract class MoyoungSetting<T> {
|
||||
public final String name;
|
||||
public final byte cmdQuery;
|
||||
public final byte cmdSet;
|
||||
|
||||
public DaFitSetting(String name, byte cmdQuery, byte cmdSet) {
|
||||
public MoyoungSetting(String name, byte cmdQuery, byte cmdSet) {
|
||||
this.name = name;
|
||||
this.cmdQuery = cmdQuery;
|
||||
this.cmdSet = cmdSet;
|
@ -14,10 +14,10 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
public class DaFitSettingBool extends DaFitSetting<Boolean> {
|
||||
public DaFitSettingBool(String name, byte cmdQuery, byte cmdSet) {
|
||||
public class MoyoungSettingBool extends MoyoungSetting<Boolean> {
|
||||
public MoyoungSettingBool(String name, byte cmdQuery, byte cmdSet) {
|
||||
super(name, cmdQuery, cmdSet);
|
||||
}
|
||||
|
@ -14,10 +14,10 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
public class DaFitSettingByte extends DaFitSetting<Byte> {
|
||||
public DaFitSettingByte(String name, byte cmdQuery, byte cmdSet) {
|
||||
public class MoyoungSettingByte extends MoyoungSetting<Byte> {
|
||||
public MoyoungSettingByte(String name, byte cmdQuery, byte cmdSet) {
|
||||
super(name, cmdQuery, cmdSet);
|
||||
}
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
public class DaFitSettingEnum<T extends Enum <?> & DaFitEnum> extends DaFitSetting<T> {
|
||||
public class MoyoungSettingEnum<T extends Enum <?> & MoyoungEnum> extends MoyoungSetting<T> {
|
||||
protected final Class<T> clazz;
|
||||
|
||||
public DaFitSettingEnum(String name, byte cmdQuery, byte cmdSet, Class<T> clazz) {
|
||||
public MoyoungSettingEnum(String name, byte cmdQuery, byte cmdSet, Class<T> clazz) {
|
||||
super(name, cmdQuery, cmdSet);
|
||||
this.clazz = clazz;
|
||||
}
|
@ -14,13 +14,13 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class DaFitSettingInt extends DaFitSetting<Integer> {
|
||||
public DaFitSettingInt(String name, byte cmdQuery, byte cmdSet) {
|
||||
public class MoyoungSettingInt extends MoyoungSetting<Integer> {
|
||||
public MoyoungSettingInt(String name, byte cmdQuery, byte cmdSet) {
|
||||
super(name, cmdQuery, cmdSet);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
import android.util.Pair;
|
||||
|
||||
@ -22,12 +22,12 @@ import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DaFitSettingLanguage extends DaFitSettingEnum<DaFitEnumLanguage> {
|
||||
public DaFitSettingLanguage(String name, byte cmdQuery, byte cmdSet) {
|
||||
super(name, cmdQuery, cmdSet, DaFitEnumLanguage.class);
|
||||
public class MoyoungSettingLanguage extends MoyoungSettingEnum<MoyoungEnumLanguage> {
|
||||
public MoyoungSettingLanguage(String name, byte cmdQuery, byte cmdSet) {
|
||||
super(name, cmdQuery, cmdSet, MoyoungEnumLanguage.class);
|
||||
}
|
||||
|
||||
private Pair<DaFitEnumLanguage, DaFitEnumLanguage[]> decodeData(byte[] data) {
|
||||
private Pair<MoyoungEnumLanguage, MoyoungEnumLanguage[]> decodeData(byte[] data) {
|
||||
if (data.length != 5)
|
||||
throw new IllegalArgumentException("Wrong data length, should be 5, was " + data.length);
|
||||
|
||||
@ -38,26 +38,26 @@ public class DaFitSettingLanguage extends DaFitSettingEnum<DaFitEnumLanguage> {
|
||||
int supportedNum = buffer.getInt();
|
||||
String supportedStr = new StringBuffer(Integer.toBinaryString(supportedNum)).reverse().toString();
|
||||
|
||||
DaFitEnumLanguage currentLanguage = super.decode(current);
|
||||
List<DaFitEnumLanguage> supportedLanguages = new ArrayList<>();
|
||||
for (DaFitEnumLanguage e : clazz.getEnumConstants()) {
|
||||
MoyoungEnumLanguage currentLanguage = super.decode(current);
|
||||
List<MoyoungEnumLanguage> supportedLanguages = new ArrayList<>();
|
||||
for (MoyoungEnumLanguage e : clazz.getEnumConstants()) {
|
||||
if (e.value() >= supportedStr.length())
|
||||
continue;
|
||||
if (Integer.parseInt(supportedStr.substring(e.value(), e.value() + 1)) != 0)
|
||||
supportedLanguages.add(e);
|
||||
}
|
||||
|
||||
DaFitEnumLanguage[] supportedLanguagesArr = new DaFitEnumLanguage[supportedLanguages.size()];
|
||||
MoyoungEnumLanguage[] supportedLanguagesArr = new MoyoungEnumLanguage[supportedLanguages.size()];
|
||||
return Pair.create(currentLanguage, supportedLanguages.toArray(supportedLanguagesArr));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaFitEnumLanguage decode(byte[] data) {
|
||||
public MoyoungEnumLanguage decode(byte[] data) {
|
||||
return decodeData(data).first;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaFitEnumLanguage[] decodeSupportedValues(byte[] data) {
|
||||
public MoyoungEnumLanguage[] decodeSupportedValues(byte[] data) {
|
||||
return decodeData(data).second;
|
||||
}
|
||||
}
|
@ -14,11 +14,11 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class DaFitSettingRemindersToMove extends DaFitSetting<DaFitSettingRemindersToMove.RemindersToMove> {
|
||||
public class MoyoungSettingRemindersToMove extends MoyoungSetting<MoyoungSettingRemindersToMove.RemindersToMove> {
|
||||
public static class RemindersToMove {
|
||||
public byte period;
|
||||
public byte steps;
|
||||
@ -46,7 +46,7 @@ public class DaFitSettingRemindersToMove extends DaFitSetting<DaFitSettingRemind
|
||||
}
|
||||
}
|
||||
|
||||
public DaFitSettingRemindersToMove(String name, byte cmdQuery, byte cmdSet) {
|
||||
public MoyoungSettingRemindersToMove(String name, byte cmdQuery, byte cmdSet) {
|
||||
super(name, cmdQuery, cmdSet);
|
||||
}
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class DaFitSettingTimeRange extends DaFitSetting<DaFitSettingTimeRange.TimeRange> {
|
||||
public class MoyoungSettingTimeRange extends MoyoungSetting<MoyoungSettingTimeRange.TimeRange> {
|
||||
public static class TimeRange {
|
||||
public byte start_h;
|
||||
public byte start_m;
|
||||
@ -47,7 +47,7 @@ public class DaFitSettingTimeRange extends DaFitSetting<DaFitSettingTimeRange.Ti
|
||||
}
|
||||
}
|
||||
|
||||
public DaFitSettingTimeRange(String name, byte cmdQuery, byte cmdSet) {
|
||||
public MoyoungSettingTimeRange(String name, byte cmdQuery, byte cmdSet) {
|
||||
super(name, cmdQuery, cmdSet);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings;
|
||||
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
||||
@ -22,8 +22,8 @@ import java.nio.ByteBuffer;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||
|
||||
public class DaFitSettingUserInfo extends DaFitSetting<ActivityUser> {
|
||||
public DaFitSettingUserInfo(String name, byte cmdSet) {
|
||||
public class MoyoungSettingUserInfo extends MoyoungSetting<ActivityUser> {
|
||||
public MoyoungSettingUserInfo(String name, byte cmdSet) {
|
||||
super(name, (byte)-1, cmdSet);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
@ -29,13 +29,13 @@ import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.Logging;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class FetchDataOperation extends AbstractBTLEOperation<DaFitDeviceSupport> {
|
||||
public class FetchDataOperation extends AbstractBTLEOperation<MoyoungDeviceSupport> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FetchDataOperation.class);
|
||||
|
||||
@ -43,9 +43,9 @@ public class FetchDataOperation extends AbstractBTLEOperation<DaFitDeviceSupport
|
||||
private boolean[] receivedSleep = new boolean[3];
|
||||
private boolean receivedTrainingData = false;
|
||||
|
||||
private DaFitPacketIn packetIn = new DaFitPacketIn();
|
||||
private MoyoungPacketIn packetIn = new MoyoungPacketIn();
|
||||
|
||||
public FetchDataOperation(DaFitDeviceSupport support) {
|
||||
public FetchDataOperation(MoyoungDeviceSupport support) {
|
||||
super(support);
|
||||
}
|
||||
|
||||
@ -58,13 +58,13 @@ public class FetchDataOperation extends AbstractBTLEOperation<DaFitDeviceSupport
|
||||
@Override
|
||||
protected void doPerform() throws IOException {
|
||||
TransactionBuilder builder = performInitialized("FetchDataOperation");
|
||||
getSupport().sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SYNC_PAST_SLEEP_AND_STEP, new byte[] { DaFitConstants.ARG_SYNC_YESTERDAY_SLEEP }));
|
||||
getSupport().sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SYNC_PAST_SLEEP_AND_STEP, new byte[] { DaFitConstants.ARG_SYNC_DAY_BEFORE_YESTERDAY_SLEEP }));
|
||||
getSupport().sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SYNC_SLEEP, new byte[0]));
|
||||
getSupport().sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SYNC_PAST_SLEEP_AND_STEP, new byte[] { DaFitConstants.ARG_SYNC_YESTERDAY_STEPS }));
|
||||
getSupport().sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SYNC_PAST_SLEEP_AND_STEP, new byte[] { DaFitConstants.ARG_SYNC_DAY_BEFORE_YESTERDAY_STEPS }));
|
||||
builder.read(getCharacteristic(DaFitConstants.UUID_CHARACTERISTIC_STEPS));
|
||||
getSupport().sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_QUERY_MOVEMENT_HEART_RATE, new byte[] { }));
|
||||
getSupport().sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SYNC_PAST_SLEEP_AND_STEP, new byte[] { MoyoungConstants.ARG_SYNC_YESTERDAY_SLEEP }));
|
||||
getSupport().sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SYNC_PAST_SLEEP_AND_STEP, new byte[] { MoyoungConstants.ARG_SYNC_DAY_BEFORE_YESTERDAY_SLEEP }));
|
||||
getSupport().sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SYNC_SLEEP, new byte[0]));
|
||||
getSupport().sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SYNC_PAST_SLEEP_AND_STEP, new byte[] { MoyoungConstants.ARG_SYNC_YESTERDAY_STEPS }));
|
||||
getSupport().sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SYNC_PAST_SLEEP_AND_STEP, new byte[] { MoyoungConstants.ARG_SYNC_DAY_BEFORE_YESTERDAY_STEPS }));
|
||||
builder.read(getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_STEPS));
|
||||
getSupport().sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_QUERY_MOVEMENT_HEART_RATE, new byte[] { }));
|
||||
builder.queue(getQueue());
|
||||
|
||||
updateProgressAndCheckFinish();
|
||||
@ -79,7 +79,7 @@ public class FetchDataOperation extends AbstractBTLEOperation<DaFitDeviceSupport
|
||||
else
|
||||
{
|
||||
UUID charUuid = characteristic.getUuid();
|
||||
if (charUuid.equals(DaFitConstants.UUID_CHARACTERISTIC_STEPS)) {
|
||||
if (charUuid.equals(MoyoungConstants.UUID_CHARACTERISTIC_STEPS)) {
|
||||
byte[] data = characteristic.getValue();
|
||||
Log.i("TODAY STEPS", "data: " + Logging.formatBytes(data));
|
||||
decodeSteps(0, data);
|
||||
@ -99,11 +99,11 @@ public class FetchDataOperation extends AbstractBTLEOperation<DaFitDeviceSupport
|
||||
else
|
||||
{
|
||||
UUID charUuid = characteristic.getUuid();
|
||||
if (charUuid.equals(DaFitConstants.UUID_CHARACTERISTIC_DATA_IN))
|
||||
if (charUuid.equals(MoyoungConstants.UUID_CHARACTERISTIC_DATA_IN))
|
||||
{
|
||||
if (packetIn.putFragment(characteristic.getValue())) {
|
||||
Pair<Byte, byte[]> packet = DaFitPacketIn.parsePacket(packetIn.getPacket());
|
||||
packetIn = new DaFitPacketIn();
|
||||
Pair<Byte, byte[]> packet = MoyoungPacketIn.parsePacket(packetIn.getPacket());
|
||||
packetIn = new MoyoungPacketIn();
|
||||
if (packet != null) {
|
||||
byte packetType = packet.first;
|
||||
byte[] payload = packet.second;
|
||||
@ -119,12 +119,12 @@ public class FetchDataOperation extends AbstractBTLEOperation<DaFitDeviceSupport
|
||||
}
|
||||
|
||||
private boolean handlePacket(byte packetType, byte[] payload) {
|
||||
if (packetType == DaFitConstants.CMD_SYNC_SLEEP) {
|
||||
if (packetType == MoyoungConstants.CMD_SYNC_SLEEP) {
|
||||
Log.i("TODAY SLEEP", "data: " + Logging.formatBytes(payload));
|
||||
decodeSleep(0, payload);
|
||||
return true;
|
||||
}
|
||||
if (packetType == DaFitConstants.CMD_SYNC_PAST_SLEEP_AND_STEP) {
|
||||
if (packetType == MoyoungConstants.CMD_SYNC_PAST_SLEEP_AND_STEP) {
|
||||
byte dataType = payload[0];
|
||||
byte[] data = new byte[payload.length - 1];
|
||||
System.arraycopy(payload, 1, data, 0, data.length);
|
||||
@ -134,28 +134,28 @@ public class FetchDataOperation extends AbstractBTLEOperation<DaFitDeviceSupport
|
||||
// (and yes, you can see that data from yesterday appears as two days ago
|
||||
// in the app itself and all past data is getting messed up because of it)
|
||||
|
||||
if (dataType == DaFitConstants.ARG_SYNC_YESTERDAY_STEPS) {
|
||||
if (dataType == MoyoungConstants.ARG_SYNC_YESTERDAY_STEPS) {
|
||||
Log.i("2 DAYS AGO STEPS", "data: " + Logging.formatBytes(data));
|
||||
decodeSteps(2, data);
|
||||
return true;
|
||||
}
|
||||
else if (dataType == DaFitConstants.ARG_SYNC_DAY_BEFORE_YESTERDAY_STEPS) {
|
||||
else if (dataType == MoyoungConstants.ARG_SYNC_DAY_BEFORE_YESTERDAY_STEPS) {
|
||||
Log.i("YESTERDAY STEPS", "data: " + Logging.formatBytes(data));
|
||||
decodeSteps(1, data);
|
||||
return true;
|
||||
}
|
||||
else if (dataType == DaFitConstants.ARG_SYNC_YESTERDAY_SLEEP) {
|
||||
else if (dataType == MoyoungConstants.ARG_SYNC_YESTERDAY_SLEEP) {
|
||||
Log.i("2 DAYS AGO SLEEP", "data: " + Logging.formatBytes(data));
|
||||
decodeSleep(2, data);
|
||||
return true;
|
||||
}
|
||||
else if (dataType == DaFitConstants.ARG_SYNC_DAY_BEFORE_YESTERDAY_SLEEP) {
|
||||
else if (dataType == MoyoungConstants.ARG_SYNC_DAY_BEFORE_YESTERDAY_SLEEP) {
|
||||
Log.i("YESTERDAY SLEEP", "data: " + Logging.formatBytes(data));
|
||||
decodeSleep(1, data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (packetType == DaFitConstants.CMD_QUERY_MOVEMENT_HEART_RATE) {
|
||||
if (packetType == MoyoungConstants.CMD_QUERY_MOVEMENT_HEART_RATE) {
|
||||
decodeTrainingData(payload);
|
||||
return true;
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
@ -60,26 +60,26 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallContro
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventConfigurationRead;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitWeatherForecast;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitWeatherToday;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumDeviceVersion;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumLanguage;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumMetricSystem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumTimeSystem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSetting;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingEnum;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingLanguage;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingRemindersToMove;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingTimeRange;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungWeatherForecast;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungWeatherToday;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumDeviceVersion;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumLanguage;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumMetricSystem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumTimeSystem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSetting;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingEnum;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingLanguage;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingRemindersToMove;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingTimeRange;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummaryDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaFitActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.MoyoungActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.User;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||
@ -113,14 +113,14 @@ import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
|
||||
|
||||
public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DaFitDeviceSupport.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MoyoungDeviceSupport.class);
|
||||
private static final long IDLE_STEPS_INTERVAL = 5 * 60 * 1000;
|
||||
|
||||
private final DeviceInfoProfile<DaFitDeviceSupport> deviceInfoProfile;
|
||||
private final BatteryInfoProfile<DaFitDeviceSupport> batteryInfoProfile;
|
||||
private final HeartRateProfile<DaFitDeviceSupport> heartRateProfile;
|
||||
private final DeviceInfoProfile<MoyoungDeviceSupport> deviceInfoProfile;
|
||||
private final BatteryInfoProfile<MoyoungDeviceSupport> batteryInfoProfile;
|
||||
private final HeartRateProfile<MoyoungDeviceSupport> heartRateProfile;
|
||||
private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo();
|
||||
private final GBDeviceEventBatteryInfo batteryCmd = new GBDeviceEventBatteryInfo();
|
||||
private final IntentListener mListener = new IntentListener() {
|
||||
@ -139,11 +139,11 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
private Handler idleUpdateHandler = new Handler();
|
||||
|
||||
public static final int MTU = 20; // TODO: there seems to be some way to change this value...?
|
||||
private DaFitPacketIn packetIn = new DaFitPacketIn();
|
||||
private MoyoungPacketIn packetIn = new MoyoungPacketIn();
|
||||
|
||||
private boolean realTimeHeartRate;
|
||||
|
||||
public DaFitDeviceSupport() {
|
||||
public MoyoungDeviceSupport() {
|
||||
super(LOG);
|
||||
batteryCmd.level = ActivitySample.NOT_MEASURED;
|
||||
|
||||
@ -152,7 +152,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
addSupportedService(GattService.UUID_SERVICE_DEVICE_INFORMATION);
|
||||
addSupportedService(GattService.UUID_SERVICE_BATTERY_SERVICE);
|
||||
addSupportedService(GattService.UUID_SERVICE_HEART_RATE);
|
||||
addSupportedService(DaFitConstants.UUID_SERVICE_DAFIT);
|
||||
addSupportedService(MoyoungConstants.UUID_SERVICE_MOYOUNG);
|
||||
|
||||
deviceInfoProfile = new DeviceInfoProfile<>(this);
|
||||
deviceInfoProfile.addListener(mListener);
|
||||
@ -168,7 +168,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
@Override
|
||||
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
|
||||
builder.notify(getCharacteristic(DaFitConstants.UUID_CHARACTERISTIC_DATA_IN), true);
|
||||
builder.notify(getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_DATA_IN), true);
|
||||
deviceInfoProfile.requestDeviceInfo(builder);
|
||||
setTime(builder);
|
||||
sendSetting(builder, getSetting("USER_INFO"), new ActivityUser()); // these settings are write-only, so write them just in case because there is no way to know if they desynced somehow
|
||||
@ -176,11 +176,11 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
batteryInfoProfile.requestBatteryInfo(builder);
|
||||
batteryInfoProfile.enableNotify(builder);
|
||||
heartRateProfile.enableNotify(builder);
|
||||
builder.notify(getCharacteristic(DaFitConstants.UUID_CHARACTERISTIC_STEPS), true);
|
||||
builder.notify(getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_STEPS), true);
|
||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
|
||||
|
||||
// TODO: I would prefer this to be done when the alarms screen is open, not on initialization...
|
||||
sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_QUERY_ALARM_CLOCK, new byte[0]));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_QUERY_ALARM_CLOCK, new byte[0]));
|
||||
|
||||
return builder;
|
||||
}
|
||||
@ -194,16 +194,16 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
private BluetoothGattCharacteristic getTargetCharacteristicForPacketType(byte packetType)
|
||||
{
|
||||
if (packetType == 1)
|
||||
return getCharacteristic(DaFitConstants.UUID_CHARACTERISTIC_DATA_SPECIAL_1);
|
||||
return getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_DATA_SPECIAL_1);
|
||||
else if (packetType == 2)
|
||||
return getCharacteristic(DaFitConstants.UUID_CHARACTERISTIC_DATA_SPECIAL_2);
|
||||
return getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_DATA_SPECIAL_2);
|
||||
else
|
||||
return getCharacteristic(DaFitConstants.UUID_CHARACTERISTIC_DATA_OUT);
|
||||
return getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_DATA_OUT);
|
||||
}
|
||||
|
||||
public void sendPacket(TransactionBuilder builder, byte[] packet)
|
||||
{
|
||||
DaFitPacketOut packetOut = new DaFitPacketOut(packet);
|
||||
MoyoungPacketOut packetOut = new MoyoungPacketOut(packet);
|
||||
|
||||
byte[] fragment = new byte[MTU];
|
||||
while(packetOut.getFragment(fragment))
|
||||
@ -215,18 +215,18 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
@Override
|
||||
public boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
|
||||
UUID charUuid = characteristic.getUuid();
|
||||
if (charUuid.equals(DaFitConstants.UUID_CHARACTERISTIC_STEPS))
|
||||
if (charUuid.equals(MoyoungConstants.UUID_CHARACTERISTIC_STEPS))
|
||||
{
|
||||
byte[] payload = characteristic.getValue();
|
||||
Log.i("AAAAAAAAAAAAAAAA", "Update step count: " + Logging.formatBytes(characteristic.getValue()));
|
||||
handleStepsHistory(0, payload, true);
|
||||
return true;
|
||||
}
|
||||
if (charUuid.equals(DaFitConstants.UUID_CHARACTERISTIC_DATA_IN))
|
||||
if (charUuid.equals(MoyoungConstants.UUID_CHARACTERISTIC_DATA_IN))
|
||||
{
|
||||
if (packetIn.putFragment(characteristic.getValue())) {
|
||||
Pair<Byte, byte[]> packet = DaFitPacketIn.parsePacket(packetIn.getPacket());
|
||||
packetIn = new DaFitPacketIn();
|
||||
Pair<Byte, byte[]> packet = MoyoungPacketIn.parsePacket(packetIn.getPacket());
|
||||
packetIn = new MoyoungPacketIn();
|
||||
if (packet != null) {
|
||||
byte packetType = packet.first;
|
||||
byte[] payload = packet.second;
|
||||
@ -244,16 +244,16 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
private boolean handlePacket(byte packetType, byte[] payload)
|
||||
{
|
||||
if (packetType == DaFitConstants.CMD_TRIGGER_MEASURE_HEARTRATE)
|
||||
if (packetType == MoyoungConstants.CMD_TRIGGER_MEASURE_HEARTRATE)
|
||||
{
|
||||
int heartRate = payload[0];
|
||||
Log.i("XXXXXXXX", "Measure heart rate finished: " + heartRate + " BPM");
|
||||
|
||||
DaFitActivitySample sample = new DaFitActivitySample();
|
||||
MoyoungActivitySample sample = new MoyoungActivitySample();
|
||||
sample.setTimestamp((int) (System.currentTimeMillis() / 1000));
|
||||
|
||||
sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(DaFitSampleProvider.SOURCE_SINGLE_MEASURE);
|
||||
sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(MoyoungSampleProvider.SOURCE_SINGLE_MEASURE);
|
||||
|
||||
sample.setBatteryLevel(ActivitySample.NOT_MEASURED);
|
||||
sample.setSteps(ActivitySample.NOT_MEASURED);
|
||||
@ -273,16 +273,16 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
return true;
|
||||
}
|
||||
if (packetType == DaFitConstants.CMD_TRIGGER_MEASURE_BLOOD_OXYGEN)
|
||||
if (packetType == MoyoungConstants.CMD_TRIGGER_MEASURE_BLOOD_OXYGEN)
|
||||
{
|
||||
int percent = payload[0];
|
||||
Log.i("XXXXXXXX", "Measure blood oxygen finished: " + percent + "%");
|
||||
|
||||
DaFitActivitySample sample = new DaFitActivitySample();
|
||||
MoyoungActivitySample sample = new MoyoungActivitySample();
|
||||
sample.setTimestamp((int) (System.currentTimeMillis() / 1000));
|
||||
|
||||
sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(DaFitSampleProvider.SOURCE_SINGLE_MEASURE);
|
||||
sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(MoyoungSampleProvider.SOURCE_SINGLE_MEASURE);
|
||||
|
||||
sample.setBatteryLevel(ActivitySample.NOT_MEASURED);
|
||||
sample.setSteps(ActivitySample.NOT_MEASURED);
|
||||
@ -299,7 +299,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
return true;
|
||||
}
|
||||
if (packetType == DaFitConstants.CMD_TRIGGER_MEASURE_BLOOD_PRESSURE)
|
||||
if (packetType == MoyoungConstants.CMD_TRIGGER_MEASURE_BLOOD_PRESSURE)
|
||||
{
|
||||
int dataUnknown = payload[0];
|
||||
int data1 = payload[1];
|
||||
@ -307,11 +307,11 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
Log.i("XXXXXXXX", "Measure blood pressure finished: " + data1 + "/" + data2 + " (" + dataUnknown + ")");
|
||||
|
||||
|
||||
DaFitActivitySample sample = new DaFitActivitySample();
|
||||
MoyoungActivitySample sample = new MoyoungActivitySample();
|
||||
sample.setTimestamp((int) (System.currentTimeMillis() / 1000));
|
||||
|
||||
sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(DaFitSampleProvider.SOURCE_SINGLE_MEASURE);
|
||||
sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(MoyoungSampleProvider.SOURCE_SINGLE_MEASURE);
|
||||
|
||||
sample.setBatteryLevel(ActivitySample.NOT_MEASURED);
|
||||
sample.setSteps(ActivitySample.NOT_MEASURED);
|
||||
@ -329,7 +329,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (packetType == DaFitConstants.CMD_QUERY_LAST_DYNAMIC_RATE)
|
||||
if (packetType == MoyoungConstants.CMD_QUERY_LAST_DYNAMIC_RATE)
|
||||
{
|
||||
// Training on the watch just finished and it wants us to fetch the details
|
||||
LOG.info("Starting training fetch");
|
||||
@ -340,31 +340,31 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
if (packetType == DaFitConstants.CMD_NOTIFY_PHONE_OPERATION)
|
||||
if (packetType == MoyoungConstants.CMD_NOTIFY_PHONE_OPERATION)
|
||||
{
|
||||
byte operation = payload[0];
|
||||
if (operation == DaFitConstants.ARG_OPERATION_PLAY_PAUSE)
|
||||
if (operation == MoyoungConstants.ARG_OPERATION_PLAY_PAUSE)
|
||||
{
|
||||
GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl();
|
||||
musicCmd.event = GBDeviceEventMusicControl.Event.PLAYPAUSE;
|
||||
evaluateGBDeviceEvent(musicCmd);
|
||||
return true;
|
||||
}
|
||||
if (operation == DaFitConstants.ARG_OPERATION_PREV_SONG)
|
||||
if (operation == MoyoungConstants.ARG_OPERATION_PREV_SONG)
|
||||
{
|
||||
GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl();
|
||||
musicCmd.event = GBDeviceEventMusicControl.Event.PREVIOUS;
|
||||
evaluateGBDeviceEvent(musicCmd);
|
||||
return true;
|
||||
}
|
||||
if (operation == DaFitConstants.ARG_OPERATION_NEXT_SONG)
|
||||
if (operation == MoyoungConstants.ARG_OPERATION_NEXT_SONG)
|
||||
{
|
||||
GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl();
|
||||
musicCmd.event = GBDeviceEventMusicControl.Event.NEXT;
|
||||
evaluateGBDeviceEvent(musicCmd);
|
||||
return true;
|
||||
}
|
||||
if (operation == DaFitConstants.ARG_OPERATION_DROP_INCOMING_CALL)
|
||||
if (operation == MoyoungConstants.ARG_OPERATION_DROP_INCOMING_CALL)
|
||||
{
|
||||
GBDeviceEventCallControl callCmd = new GBDeviceEventCallControl();
|
||||
callCmd.event = GBDeviceEventCallControl.Event.REJECT;
|
||||
@ -373,20 +373,20 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
if (packetType == DaFitConstants.CMD_SWITCH_CAMERA_VIEW)
|
||||
if (packetType == MoyoungConstants.CMD_SWITCH_CAMERA_VIEW)
|
||||
{
|
||||
// TODO: trigger camera photo
|
||||
return true;
|
||||
}
|
||||
|
||||
if (packetType == DaFitConstants.CMD_NOTIFY_WEATHER_CHANGE)
|
||||
if (packetType == MoyoungConstants.CMD_NOTIFY_WEATHER_CHANGE)
|
||||
{
|
||||
LOG.info("The watch really wants us to transmit the weather data for some reason...");
|
||||
// TODO: transmit weather
|
||||
return true;
|
||||
}
|
||||
|
||||
for (DaFitSetting setting : queriedSettings)
|
||||
for (MoyoungSetting setting : queriedSettings)
|
||||
{
|
||||
if (setting.cmdQuery == packetType)
|
||||
{
|
||||
@ -397,7 +397,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
if (packetType == DaFitConstants.CMD_QUERY_ALARM_CLOCK)
|
||||
if (packetType == MoyoungConstants.CMD_QUERY_ALARM_CLOCK)
|
||||
{
|
||||
handleGetAlarmsResponse(payload);
|
||||
return true;
|
||||
@ -407,18 +407,18 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void addGBActivitySample(DaFitActivitySample sample) {
|
||||
addGBActivitySamples(new DaFitActivitySample[] { sample });
|
||||
private void addGBActivitySample(MoyoungActivitySample sample) {
|
||||
addGBActivitySamples(new MoyoungActivitySample[] { sample });
|
||||
}
|
||||
|
||||
private void addGBActivitySamples(DaFitActivitySample[] samples) {
|
||||
private void addGBActivitySamples(MoyoungActivitySample[] samples) {
|
||||
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
||||
User user = DBHelper.getUser(dbHandler.getDaoSession());
|
||||
Device device = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession());
|
||||
|
||||
DaFitSampleProvider provider = new DaFitSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
MoyoungSampleProvider provider = new MoyoungSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
|
||||
for (DaFitActivitySample sample : samples) {
|
||||
for (MoyoungActivitySample sample : samples) {
|
||||
sample.setDevice(device);
|
||||
sample.setUser(user);
|
||||
sample.setProvider(provider);
|
||||
@ -431,7 +431,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastSample(DaFitActivitySample sample) {
|
||||
private void broadcastSample(MoyoungActivitySample sample) {
|
||||
Intent intent = new Intent(DeviceService.ACTION_REALTIME_SAMPLES)
|
||||
.putExtra(DeviceService.EXTRA_REALTIME_SAMPLE, sample)
|
||||
.putExtra(DeviceService.EXTRA_TIMESTAMP, sample.getTimestamp());
|
||||
@ -450,11 +450,11 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
batteryCmd.level = (short) info.getPercentCharged();
|
||||
handleGBDeviceEvent(batteryCmd);
|
||||
|
||||
DaFitActivitySample sample = new DaFitActivitySample();
|
||||
MoyoungActivitySample sample = new MoyoungActivitySample();
|
||||
sample.setTimestamp((int) (System.currentTimeMillis() / 1000));
|
||||
|
||||
sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(DaFitSampleProvider.SOURCE_BATTERY);
|
||||
sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(MoyoungSampleProvider.SOURCE_BATTERY);
|
||||
|
||||
sample.setBatteryLevel(batteryCmd.level);
|
||||
sample.setSteps(ActivitySample.NOT_MEASURED);
|
||||
@ -483,7 +483,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
byte[] payload = new byte[str.length + 1];
|
||||
payload[0] = type;
|
||||
System.arraycopy(str, 0, payload, 1, str.length);
|
||||
sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SEND_MESSAGE, payload));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SEND_MESSAGE, payload));
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@ -501,7 +501,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
text = StringUtils.getFirstOf(StringUtils.getFirstOf(notificationSpec.title, notificationSpec.subject), notificationSpec.body);
|
||||
|
||||
// The notification is split at first : into sender and text
|
||||
sendNotification(DaFitConstants.notificationType(notificationSpec.type), sender + ":" + text);
|
||||
sendNotification(MoyoungConstants.notificationType(notificationSpec.type), sender + ":" + text);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -512,9 +512,9 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
@Override
|
||||
public void onSetCallState(CallSpec callSpec) {
|
||||
if (callSpec.command == CallSpec.CALL_INCOMING)
|
||||
sendNotification(DaFitConstants.NOTIFICATION_TYPE_CALL, NotificationUtils.getPreferredTextFor(callSpec));
|
||||
sendNotification(MoyoungConstants.NOTIFICATION_TYPE_CALL, NotificationUtils.getPreferredTextFor(callSpec));
|
||||
else
|
||||
sendNotification(DaFitConstants.NOTIFICATION_TYPE_CALL_OFF_HOOK, "");
|
||||
sendNotification(MoyoungConstants.NOTIFICATION_TYPE_CALL_OFF_HOOK, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -524,9 +524,9 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
private void setTime(TransactionBuilder builder) {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(5);
|
||||
buffer.putInt(DaFitConstants.LocalTimeToWatchTime(new Date())); // The watch is hardcoded to GMT+8 internally...
|
||||
buffer.putInt(MoyoungConstants.LocalTimeToWatchTime(new Date())); // The watch is hardcoded to GMT+8 internally...
|
||||
buffer.put((byte)8); // I guess this means GMT+8 but changing it has no effect at all (it was hardcoded in the original app too)
|
||||
sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SYNC_TIME, buffer.array()));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SYNC_TIME, buffer.array()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -623,7 +623,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
else
|
||||
repeat = 2;
|
||||
buffer.put(repeat);
|
||||
sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SET_ALARM_CLOCK, buffer.array()));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SET_ALARM_CLOCK, buffer.array()));
|
||||
}
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
@ -715,18 +715,18 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
User user = DBHelper.getUser(dbHandler.getDaoSession());
|
||||
Device device = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession());
|
||||
|
||||
DaFitSampleProvider provider = new DaFitSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
MoyoungSampleProvider provider = new MoyoungSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
|
||||
int currentSampleTimestamp = (int)(Calendar.getInstance().getTimeInMillis() / 1000);
|
||||
|
||||
DaFitActivitySample sample = new DaFitActivitySample();
|
||||
MoyoungActivitySample sample = new MoyoungActivitySample();
|
||||
sample.setDevice(device);
|
||||
sample.setUser(user);
|
||||
sample.setProvider(provider);
|
||||
sample.setTimestamp(currentSampleTimestamp);
|
||||
|
||||
sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(DaFitSampleProvider.SOURCE_STEPS_IDLE);
|
||||
sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(MoyoungSampleProvider.SOURCE_STEPS_IDLE);
|
||||
|
||||
sample.setBatteryLevel(batteryCmd.level);
|
||||
sample.setSteps(0);
|
||||
@ -768,7 +768,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
User user = DBHelper.getUser(dbHandler.getDaoSession());
|
||||
Device device = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession());
|
||||
|
||||
DaFitSampleProvider provider = new DaFitSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
MoyoungSampleProvider provider = new MoyoungSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
|
||||
Calendar thisSample = Calendar.getInstance();
|
||||
if (daysAgo != 0)
|
||||
@ -796,7 +796,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
int previousSteps = 0;
|
||||
int previousDistance = 0;
|
||||
int previousCalories = 0;
|
||||
for (DaFitActivitySample sample : provider.getAllActivitySamples(startOfDayTimestamp, thisSampleTimestamp))
|
||||
for (MoyoungActivitySample sample : provider.getAllActivitySamples(startOfDayTimestamp, thisSampleTimestamp))
|
||||
{
|
||||
if (sample.getSteps() != ActivitySample.NOT_MEASURED)
|
||||
previousSteps += sample.getSteps();
|
||||
@ -816,14 +816,14 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
else if (newSteps != 0 || newDistance != 0 || newCalories != 0 || daysAgo == 0)
|
||||
{
|
||||
DaFitActivitySample sample = new DaFitActivitySample();
|
||||
MoyoungActivitySample sample = new MoyoungActivitySample();
|
||||
sample.setDevice(device);
|
||||
sample.setUser(user);
|
||||
sample.setProvider(provider);
|
||||
sample.setTimestamp(thisSampleTimestamp);
|
||||
|
||||
sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(daysAgo == 0 ? DaFitSampleProvider.SOURCE_STEPS_REALTIME : DaFitSampleProvider.SOURCE_STEPS_SUMMARY);
|
||||
sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED);
|
||||
sample.setDataSource(daysAgo == 0 ? MoyoungSampleProvider.SOURCE_STEPS_REALTIME : MoyoungSampleProvider.SOURCE_STEPS_SUMMARY);
|
||||
|
||||
sample.setBatteryLevel(ActivitySample.NOT_MEASURED);
|
||||
sample.setSteps(newSteps);
|
||||
@ -857,7 +857,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
if (data.length % 3 != 0)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
int prevActivityType = DaFitSampleProvider.ACTIVITY_SLEEP_START;
|
||||
int prevActivityType = MoyoungSampleProvider.ACTIVITY_SLEEP_START;
|
||||
int prevSampleTimestamp = -1;
|
||||
|
||||
for(int i = 0; i < data.length / 3; i++)
|
||||
@ -897,7 +897,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
User user = DBHelper.getUser(dbHandler.getDaoSession());
|
||||
Device device = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession());
|
||||
|
||||
DaFitSampleProvider provider = new DaFitSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
MoyoungSampleProvider provider = new MoyoungSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
|
||||
Calendar thisSample = Calendar.getInstance();
|
||||
thisSample.add(Calendar.HOUR_OF_DAY, 4); // the clock assumes the sleep day changes at 20:00, so move the time forward to make the day correct
|
||||
@ -911,24 +911,24 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
int thisSampleTimestamp = (int) (thisSample.getTimeInMillis() / 1000);
|
||||
|
||||
int activityType;
|
||||
if (type == DaFitConstants.SLEEP_SOBER)
|
||||
activityType = DaFitSampleProvider.ACTIVITY_SLEEP_END;
|
||||
else if (type == DaFitConstants.SLEEP_LIGHT)
|
||||
activityType = DaFitSampleProvider.ACTIVITY_SLEEP_LIGHT;
|
||||
else if (type == DaFitConstants.SLEEP_RESTFUL)
|
||||
activityType = DaFitSampleProvider.ACTIVITY_SLEEP_RESTFUL;
|
||||
if (type == MoyoungConstants.SLEEP_SOBER)
|
||||
activityType = MoyoungSampleProvider.ACTIVITY_SLEEP_END;
|
||||
else if (type == MoyoungConstants.SLEEP_LIGHT)
|
||||
activityType = MoyoungSampleProvider.ACTIVITY_SLEEP_LIGHT;
|
||||
else if (type == MoyoungConstants.SLEEP_RESTFUL)
|
||||
activityType = MoyoungSampleProvider.ACTIVITY_SLEEP_RESTFUL;
|
||||
else
|
||||
throw new IllegalArgumentException("Invalid sleep type");
|
||||
|
||||
// Insert the end of previous segment sample
|
||||
DaFitActivitySample prevSegmentSample = new DaFitActivitySample();
|
||||
MoyoungActivitySample prevSegmentSample = new MoyoungActivitySample();
|
||||
prevSegmentSample.setDevice(device);
|
||||
prevSegmentSample.setUser(user);
|
||||
prevSegmentSample.setProvider(provider);
|
||||
prevSegmentSample.setTimestamp(thisSampleTimestamp - 1);
|
||||
|
||||
prevSegmentSample.setRawKind(prevActivityType);
|
||||
prevSegmentSample.setDataSource(DaFitSampleProvider.SOURCE_SLEEP_SUMMARY);
|
||||
prevSegmentSample.setDataSource(MoyoungSampleProvider.SOURCE_SLEEP_SUMMARY);
|
||||
|
||||
prevSegmentSample.setBatteryLevel(ActivitySample.NOT_MEASURED);
|
||||
prevSegmentSample.setSteps(ActivitySample.NOT_MEASURED);
|
||||
@ -943,14 +943,14 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
addGBActivitySampleIfNotExists(provider, prevSegmentSample);
|
||||
|
||||
// Insert the start of new segment sample
|
||||
DaFitActivitySample nextSegmentSample = new DaFitActivitySample();
|
||||
MoyoungActivitySample nextSegmentSample = new MoyoungActivitySample();
|
||||
nextSegmentSample.setDevice(device);
|
||||
nextSegmentSample.setUser(user);
|
||||
nextSegmentSample.setProvider(provider);
|
||||
nextSegmentSample.setTimestamp(thisSampleTimestamp);
|
||||
|
||||
nextSegmentSample.setRawKind(activityType);
|
||||
nextSegmentSample.setDataSource(DaFitSampleProvider.SOURCE_SLEEP_SUMMARY);
|
||||
nextSegmentSample.setDataSource(MoyoungSampleProvider.SOURCE_SLEEP_SUMMARY);
|
||||
|
||||
nextSegmentSample.setBatteryLevel(ActivitySample.NOT_MEASURED);
|
||||
nextSegmentSample.setSteps(ActivitySample.NOT_MEASURED);
|
||||
@ -965,12 +965,12 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
addGBActivitySampleIfNotExists(provider, nextSegmentSample);
|
||||
|
||||
// Set the activity type on all samples in this time period
|
||||
if (prevActivityType != DaFitSampleProvider.ACTIVITY_SLEEP_START)
|
||||
if (prevActivityType != MoyoungSampleProvider.ACTIVITY_SLEEP_START)
|
||||
provider.updateActivityInRange(prevSampleTimestamp, thisSampleTimestamp, prevActivityType);
|
||||
|
||||
prevActivityType = activityType;
|
||||
if (prevActivityType == DaFitSampleProvider.ACTIVITY_SLEEP_END)
|
||||
prevActivityType = DaFitSampleProvider.ACTIVITY_SLEEP_START;
|
||||
if (prevActivityType == MoyoungSampleProvider.ACTIVITY_SLEEP_END)
|
||||
prevActivityType = MoyoungSampleProvider.ACTIVITY_SLEEP_START;
|
||||
prevSampleTimestamp = thisSampleTimestamp;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@ -992,8 +992,8 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
ByteBuffer buffer = ByteBuffer.wrap(data, 24 * i, 24);
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
Date startTime = DaFitConstants.WatchTimeToLocalTime(buffer.getInt());
|
||||
Date endTime = DaFitConstants.WatchTimeToLocalTime(buffer.getInt());
|
||||
Date startTime = MoyoungConstants.WatchTimeToLocalTime(buffer.getInt());
|
||||
Date endTime = MoyoungConstants.WatchTimeToLocalTime(buffer.getInt());
|
||||
int validTime = buffer.getShort();
|
||||
byte num = buffer.get(); // == i
|
||||
byte type = buffer.get();
|
||||
@ -1011,7 +1011,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
User user = DBHelper.getUser(dbHandler.getDaoSession());
|
||||
Device device = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession());
|
||||
|
||||
DaFitSampleProvider provider = new DaFitSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
MoyoungSampleProvider provider = new MoyoungSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
BaseActivitySummaryDao summaryDao = provider.getSession().getBaseActivitySummaryDao();
|
||||
|
||||
QueryBuilder<BaseActivitySummary> qb = summaryDao.queryBuilder();
|
||||
@ -1033,21 +1033,21 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
int gbType = provider.normalizeType(type);
|
||||
String name;
|
||||
if (type == DaFitSampleProvider.ACTIVITY_TRAINING_ROPE)
|
||||
if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_ROPE)
|
||||
name = "Rope";
|
||||
else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_BADMINTON)
|
||||
else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_BADMINTON)
|
||||
name = "Badminton";
|
||||
else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_BASKETBALL)
|
||||
else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_BASKETBALL)
|
||||
name = "Basketball";
|
||||
else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_FOOTBALL)
|
||||
else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_FOOTBALL)
|
||||
name = "Football";
|
||||
else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_MOUNTAINEERING)
|
||||
else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_MOUNTAINEERING)
|
||||
name = "Mountaineering";
|
||||
else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_TENNIS)
|
||||
else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_TENNIS)
|
||||
name = "Tennis";
|
||||
else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_RUGBY)
|
||||
else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_RUGBY)
|
||||
name = "Rugby";
|
||||
else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_GOLF)
|
||||
else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_GOLF)
|
||||
name = "Golf";
|
||||
else
|
||||
name = ActivityKind.asString(gbType, getContext());
|
||||
@ -1070,10 +1070,10 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
private void addGBActivitySampleIfNotExists(DaFitSampleProvider provider, DaFitActivitySample sample)
|
||||
private void addGBActivitySampleIfNotExists(MoyoungSampleProvider provider, MoyoungActivitySample sample)
|
||||
{
|
||||
boolean alreadyHaveThisSample = false;
|
||||
for (DaFitActivitySample sample2 : provider.getAllActivitySamples(sample.getTimestamp() - 1, sample.getTimestamp() + 1))
|
||||
for (MoyoungActivitySample sample2 : provider.getAllActivitySamples(sample.getTimestamp() - 1, sample.getTimestamp() + 1))
|
||||
{
|
||||
if (sample2.getTimestamp() == sample2.getTimestamp() && sample2.getRawKind() == sample.getRawKind())
|
||||
alreadyHaveThisSample = true;
|
||||
@ -1093,7 +1093,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("shutdown");
|
||||
sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SHUTDOWN, new byte[] { -1 }));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SHUTDOWN, new byte[] { -1 }));
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@ -1104,7 +1104,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
{
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("onHeartRateTest");
|
||||
sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_TRIGGER_MEASURE_HEARTRATE, new byte[] { start ? (byte)0 : (byte)-1 }));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_TRIGGER_MEASURE_HEARTRATE, new byte[] { start ? (byte)0 : (byte)-1 }));
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@ -1154,7 +1154,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
{
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("onFindDevice");
|
||||
sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_FIND_MY_WATCH, new byte[0]));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_FIND_MY_WATCH, new byte[0]));
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@ -1187,9 +1187,9 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends DaFitSetting> T getSetting(String id) {
|
||||
DaFitDeviceCoordinator coordinator = (DaFitDeviceCoordinator) DeviceHelper.getInstance().getCoordinator(getDevice());
|
||||
for(DaFitSetting setting : coordinator.getSupportedSettings())
|
||||
private <T extends MoyoungSetting> T getSetting(String id) {
|
||||
MoyoungDeviceCoordinator coordinator = (MoyoungDeviceCoordinator) DeviceHelper.getInstance().getCoordinator(getDevice());
|
||||
for(MoyoungSetting setting : coordinator.getSupportedSettings())
|
||||
{
|
||||
if (setting.name.equals(id))
|
||||
return (T) setting;
|
||||
@ -1210,12 +1210,12 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
return cal;
|
||||
}
|
||||
|
||||
private <T> void sendSetting(TransactionBuilder builder, DaFitSetting<T> setting, T newValue)
|
||||
private <T> void sendSetting(TransactionBuilder builder, MoyoungSetting<T> setting, T newValue)
|
||||
{
|
||||
sendPacket(builder, DaFitPacketOut.buildPacket(setting.cmdSet, setting.encode(newValue)));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(setting.cmdSet, setting.encode(newValue)));
|
||||
}
|
||||
|
||||
private <T> void sendSetting(DaFitSetting<T> setting, T newValue)
|
||||
private <T> void sendSetting(MoyoungSetting<T> setting, T newValue)
|
||||
{
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("sendSetting");
|
||||
@ -1226,16 +1226,16 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
private Set<DaFitSetting> queriedSettings = new HashSet<>();
|
||||
private Set<MoyoungSetting> queriedSettings = new HashSet<>();
|
||||
|
||||
private void querySetting(DaFitSetting setting)
|
||||
private void querySetting(MoyoungSetting setting)
|
||||
{
|
||||
if (queriedSettings.contains(setting))
|
||||
return;
|
||||
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("querySetting");
|
||||
sendPacket(builder, DaFitPacketOut.buildPacket(setting.cmdQuery, new byte[0]));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(setting.cmdQuery, new byte[0]));
|
||||
builder.queue(getQueue());
|
||||
queriedSettings.add(setting);
|
||||
} catch (IOException e) {
|
||||
@ -1263,11 +1263,11 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
case DeviceSettingsPreferenceConst.PREF_TIMEFORMAT:
|
||||
String timeSystemPref = prefs.getString(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, getContext().getString(R.string.p_timeformat_24h));
|
||||
|
||||
DaFitEnumTimeSystem timeSystem;
|
||||
MoyoungEnumTimeSystem timeSystem;
|
||||
if (timeSystemPref.equals(getContext().getString(R.string.p_timeformat_24h)))
|
||||
timeSystem = DaFitEnumTimeSystem.TIME_SYSTEM_24;
|
||||
timeSystem = MoyoungEnumTimeSystem.TIME_SYSTEM_24;
|
||||
else if (timeSystemPref.equals(getContext().getString(R.string.p_timeformat_am_pm)))
|
||||
timeSystem = DaFitEnumTimeSystem.TIME_SYSTEM_12;
|
||||
timeSystem = MoyoungEnumTimeSystem.TIME_SYSTEM_12;
|
||||
else
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
@ -1277,36 +1277,36 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
case DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM:
|
||||
String metricSystemPref = prefs.getString(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_metric));
|
||||
|
||||
DaFitEnumMetricSystem metricSystem;
|
||||
MoyoungEnumMetricSystem metricSystem;
|
||||
if (metricSystemPref.equals(getContext().getString(R.string.p_unit_metric)))
|
||||
metricSystem = DaFitEnumMetricSystem.METRIC_SYSTEM;
|
||||
metricSystem = MoyoungEnumMetricSystem.METRIC_SYSTEM;
|
||||
else if (metricSystemPref.equals(getContext().getString(R.string.p_unit_imperial)))
|
||||
metricSystem = DaFitEnumMetricSystem.IMPERIAL_SYSTEM;
|
||||
metricSystem = MoyoungEnumMetricSystem.IMPERIAL_SYSTEM;
|
||||
else
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
sendSetting(getSetting("METRIC_SYSTEM"), metricSystem);
|
||||
break;
|
||||
|
||||
case DaFitConstants.PREF_WATCH_FACE:
|
||||
String watchFacePref = prefs.getString(DaFitConstants.PREF_WATCH_FACE, String.valueOf(1));
|
||||
case MoyoungConstants.PREF_WATCH_FACE:
|
||||
String watchFacePref = prefs.getString(MoyoungConstants.PREF_WATCH_FACE, String.valueOf(1));
|
||||
byte watchFace = Byte.valueOf(watchFacePref);
|
||||
sendSetting(getSetting("DISPLAY_WATCH_FACE"), watchFace);
|
||||
break;
|
||||
|
||||
case DaFitConstants.PREF_LANGUAGE:
|
||||
String languagePref = prefs.getString(DaFitConstants.PREF_LANGUAGE,
|
||||
String.valueOf(DaFitEnumLanguage.LANGUAGE_ENGLISH.value()));
|
||||
case MoyoungConstants.PREF_LANGUAGE:
|
||||
String languagePref = prefs.getString(MoyoungConstants.PREF_LANGUAGE,
|
||||
String.valueOf(MoyoungEnumLanguage.LANGUAGE_ENGLISH.value()));
|
||||
byte languageNum = Byte.valueOf(languagePref);
|
||||
DaFitSettingEnum<DaFitEnumLanguage> languageSetting = getSetting("DEVICE_LANGUAGE");
|
||||
MoyoungSettingEnum<MoyoungEnumLanguage> languageSetting = getSetting("DEVICE_LANGUAGE");
|
||||
sendSetting(languageSetting, languageSetting.findByValue(languageNum));
|
||||
break;
|
||||
|
||||
case DaFitConstants.PREF_DEVICE_VERSION:
|
||||
String versionPref = prefs.getString(DaFitConstants.PREF_DEVICE_VERSION,
|
||||
String.valueOf(DaFitEnumDeviceVersion.INTERNATIONAL_EDITION.value()));
|
||||
case MoyoungConstants.PREF_DEVICE_VERSION:
|
||||
String versionPref = prefs.getString(MoyoungConstants.PREF_DEVICE_VERSION,
|
||||
String.valueOf(MoyoungEnumDeviceVersion.INTERNATIONAL_EDITION.value()));
|
||||
byte versionNum = Byte.valueOf(versionPref);
|
||||
DaFitSettingEnum<DaFitEnumDeviceVersion> versionSetting = getSetting("DEVICE_VERSION");
|
||||
MoyoungSettingEnum<MoyoungEnumDeviceVersion> versionSetting = getSetting("DEVICE_VERSION");
|
||||
sendSetting(versionSetting, versionSetting.findByValue(versionNum));
|
||||
break;
|
||||
|
||||
@ -1319,13 +1319,13 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
Calendar doNotDisturbStart = getTimePref(prefs, MiBandConst.PREF_DO_NOT_DISTURB_START, "01:00");
|
||||
Calendar doNotDisturbEnd = getTimePref(prefs, MiBandConst.PREF_DO_NOT_DISTURB_END, "06:00");
|
||||
|
||||
DaFitSettingTimeRange.TimeRange doNotDisturb;
|
||||
MoyoungSettingTimeRange.TimeRange doNotDisturb;
|
||||
if (doNotDisturbEnabled)
|
||||
doNotDisturb = new DaFitSettingTimeRange.TimeRange(
|
||||
doNotDisturb = new MoyoungSettingTimeRange.TimeRange(
|
||||
(byte) doNotDisturbStart.get(Calendar.HOUR_OF_DAY), (byte) doNotDisturbStart.get(Calendar.MINUTE),
|
||||
(byte) doNotDisturbEnd.get(Calendar.HOUR_OF_DAY), (byte) doNotDisturbEnd.get(Calendar.MINUTE));
|
||||
else
|
||||
doNotDisturb = new DaFitSettingTimeRange.TimeRange((byte)0, (byte)0, (byte)0, (byte)0);
|
||||
doNotDisturb = new MoyoungSettingTimeRange.TimeRange((byte)0, (byte)0, (byte)0, (byte)0);
|
||||
|
||||
sendSetting(getSetting("DO_NOT_DISTURB_TIME"), doNotDisturb);
|
||||
break;
|
||||
@ -1340,34 +1340,34 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
Calendar quickViewStart = getTimePref(prefs, HuamiConst.PREF_DISPLAY_ON_LIFT_START, "00:00");
|
||||
Calendar quickViewEnd = getTimePref(prefs, HuamiConst.PREF_DISPLAY_ON_LIFT_END, "00:00");
|
||||
|
||||
DaFitSettingTimeRange.TimeRange quickViewTime;
|
||||
MoyoungSettingTimeRange.TimeRange quickViewTime;
|
||||
if (quickViewEnabled && quickViewScheduled)
|
||||
quickViewTime = new DaFitSettingTimeRange.TimeRange(
|
||||
quickViewTime = new MoyoungSettingTimeRange.TimeRange(
|
||||
(byte) quickViewStart.get(Calendar.HOUR_OF_DAY), (byte) quickViewStart.get(Calendar.MINUTE),
|
||||
(byte) quickViewEnd.get(Calendar.HOUR_OF_DAY), (byte) quickViewEnd.get(Calendar.MINUTE));
|
||||
else
|
||||
quickViewTime = new DaFitSettingTimeRange.TimeRange((byte)0, (byte)0, (byte)0, (byte)0);
|
||||
quickViewTime = new MoyoungSettingTimeRange.TimeRange((byte)0, (byte)0, (byte)0, (byte)0);
|
||||
|
||||
sendSetting(getSetting("QUICK_VIEW"), quickViewEnabled);
|
||||
sendSetting(getSetting("QUICK_VIEW_TIME"), quickViewTime);
|
||||
break;
|
||||
|
||||
case DaFitConstants.PREF_SEDENTARY_REMINDER:
|
||||
String sedentaryReminderPref = prefs.getString(DaFitConstants.PREF_SEDENTARY_REMINDER, "off");
|
||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER:
|
||||
String sedentaryReminderPref = prefs.getString(MoyoungConstants.PREF_SEDENTARY_REMINDER, "off");
|
||||
boolean sedentaryReminderEnabled = !sedentaryReminderPref.equals("off");
|
||||
sendSetting(getSetting("SEDENTARY_REMINDER"), sedentaryReminderEnabled);
|
||||
break;
|
||||
|
||||
case DaFitConstants.PREF_SEDENTARY_REMINDER_PERIOD:
|
||||
case DaFitConstants.PREF_SEDENTARY_REMINDER_STEPS:
|
||||
case DaFitConstants.PREF_SEDENTARY_REMINDER_START:
|
||||
case DaFitConstants.PREF_SEDENTARY_REMINDER_END:
|
||||
byte sedentaryPeriod = (byte) prefs.getInt(DaFitConstants.PREF_SEDENTARY_REMINDER_PERIOD, 30);
|
||||
byte sedentarySteps = (byte) prefs.getInt(DaFitConstants.PREF_SEDENTARY_REMINDER_STEPS, 100);
|
||||
byte sedentaryStart = (byte) prefs.getInt(DaFitConstants.PREF_SEDENTARY_REMINDER_START, 10);
|
||||
byte sedentaryEnd = (byte) prefs.getInt(DaFitConstants.PREF_SEDENTARY_REMINDER_END, 22);
|
||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER_PERIOD:
|
||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER_STEPS:
|
||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER_START:
|
||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER_END:
|
||||
byte sedentaryPeriod = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_PERIOD, 30);
|
||||
byte sedentarySteps = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_STEPS, 100);
|
||||
byte sedentaryStart = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_START, 10);
|
||||
byte sedentaryEnd = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_END, 22);
|
||||
sendSetting(getSetting("REMINDERS_TO_MOVE_PERIOD"),
|
||||
new DaFitSettingRemindersToMove.RemindersToMove(sedentaryPeriod, sedentarySteps, sedentaryStart, sedentaryEnd));
|
||||
new MoyoungSettingRemindersToMove.RemindersToMove(sedentaryPeriod, sedentarySteps, sedentaryStart, sedentaryEnd));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1401,15 +1401,15 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
querySetting(getSetting("METRIC_SYSTEM"));
|
||||
break;
|
||||
|
||||
case DaFitConstants.PREF_WATCH_FACE:
|
||||
case MoyoungConstants.PREF_WATCH_FACE:
|
||||
querySetting(getSetting("DISPLAY_WATCH_FACE"));
|
||||
break;
|
||||
|
||||
case DaFitConstants.PREF_LANGUAGE:
|
||||
case MoyoungConstants.PREF_LANGUAGE:
|
||||
querySetting(getSetting("DEVICE_LANGUAGE"));
|
||||
break;
|
||||
|
||||
case DaFitConstants.PREF_DEVICE_VERSION:
|
||||
case MoyoungConstants.PREF_DEVICE_VERSION:
|
||||
querySetting(getSetting("DEVICE_VERSION"));
|
||||
break;
|
||||
|
||||
@ -1426,14 +1426,14 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
querySetting(getSetting("QUICK_VIEW_TIME"));
|
||||
break;
|
||||
|
||||
case DaFitConstants.PREF_SEDENTARY_REMINDER:
|
||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER:
|
||||
querySetting(getSetting("SEDENTARY_REMINDER"));
|
||||
break;
|
||||
|
||||
case DaFitConstants.PREF_SEDENTARY_REMINDER_PERIOD:
|
||||
case DaFitConstants.PREF_SEDENTARY_REMINDER_STEPS:
|
||||
case DaFitConstants.PREF_SEDENTARY_REMINDER_START:
|
||||
case DaFitConstants.PREF_SEDENTARY_REMINDER_END:
|
||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER_PERIOD:
|
||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER_STEPS:
|
||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER_START:
|
||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER_END:
|
||||
querySetting(getSetting("REMINDERS_TO_MOVE_PERIOD"));
|
||||
break;
|
||||
default:
|
||||
@ -1446,7 +1446,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
evaluateGBDeviceEvent(configReadEvent);
|
||||
}
|
||||
|
||||
public void onReadConfigurationDone(DaFitSetting setting, Object value, byte[] data)
|
||||
public void onReadConfigurationDone(MoyoungSetting setting, Object value, byte[] data)
|
||||
{
|
||||
Log.i("CONFIG", setting.name + " = " + value);
|
||||
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress()));
|
||||
@ -1454,20 +1454,20 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
SharedPreferences.Editor prefsEditor = prefs.getPreferences().edit();
|
||||
switch (setting.name) {
|
||||
case "TIME_SYSTEM":
|
||||
DaFitEnumTimeSystem timeSystem = (DaFitEnumTimeSystem) value;
|
||||
if (timeSystem == DaFitEnumTimeSystem.TIME_SYSTEM_24)
|
||||
MoyoungEnumTimeSystem timeSystem = (MoyoungEnumTimeSystem) value;
|
||||
if (timeSystem == MoyoungEnumTimeSystem.TIME_SYSTEM_24)
|
||||
changedProperties.put(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, getContext().getString(R.string.p_timeformat_24h));
|
||||
else if (timeSystem == DaFitEnumTimeSystem.TIME_SYSTEM_12)
|
||||
else if (timeSystem == MoyoungEnumTimeSystem.TIME_SYSTEM_12)
|
||||
changedProperties.put(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, getContext().getString(R.string.p_timeformat_am_pm));
|
||||
else
|
||||
throw new IllegalArgumentException("Invalid value");
|
||||
break;
|
||||
|
||||
case "METRIC_SYSTEM":
|
||||
DaFitEnumMetricSystem metricSystem = (DaFitEnumMetricSystem) value;
|
||||
if (metricSystem == DaFitEnumMetricSystem.METRIC_SYSTEM)
|
||||
MoyoungEnumMetricSystem metricSystem = (MoyoungEnumMetricSystem) value;
|
||||
if (metricSystem == MoyoungEnumMetricSystem.METRIC_SYSTEM)
|
||||
changedProperties.put(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_metric));
|
||||
else if (metricSystem == DaFitEnumMetricSystem.IMPERIAL_SYSTEM)
|
||||
else if (metricSystem == MoyoungEnumMetricSystem.IMPERIAL_SYSTEM)
|
||||
changedProperties.put(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_imperial));
|
||||
else
|
||||
throw new IllegalArgumentException("Invalid value");
|
||||
@ -1475,26 +1475,26 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
case "DISPLAY_WATCH_FACE":
|
||||
byte watchFace = (Byte) value;
|
||||
changedProperties.put(DaFitConstants.PREF_WATCH_FACE, String.valueOf(watchFace));
|
||||
changedProperties.put(MoyoungConstants.PREF_WATCH_FACE, String.valueOf(watchFace));
|
||||
break;
|
||||
|
||||
case "DEVICE_LANGUAGE":
|
||||
DaFitEnumLanguage language = (DaFitEnumLanguage) value;
|
||||
changedProperties.put(DaFitConstants.PREF_LANGUAGE, String.valueOf(language.value()));
|
||||
DaFitEnumLanguage[] supportedLanguages = ((DaFitSettingLanguage) setting).decodeSupportedValues(data);
|
||||
MoyoungEnumLanguage language = (MoyoungEnumLanguage) value;
|
||||
changedProperties.put(MoyoungConstants.PREF_LANGUAGE, String.valueOf(language.value()));
|
||||
MoyoungEnumLanguage[] supportedLanguages = ((MoyoungSettingLanguage) setting).decodeSupportedValues(data);
|
||||
Set<String> supportedLanguagesList = new HashSet<>();
|
||||
for(DaFitEnumLanguage supportedLanguage : supportedLanguages)
|
||||
for(MoyoungEnumLanguage supportedLanguage : supportedLanguages)
|
||||
supportedLanguagesList.add(String.valueOf(supportedLanguage.value()));
|
||||
prefsEditor.putStringSet(DaFitConstants.PREF_LANGUAGE_SUPPORT, supportedLanguagesList);
|
||||
prefsEditor.putStringSet(MoyoungConstants.PREF_LANGUAGE_SUPPORT, supportedLanguagesList);
|
||||
break;
|
||||
|
||||
case "DEVICE_VERSION":
|
||||
DaFitEnumDeviceVersion deviceVersion = (DaFitEnumDeviceVersion) value;
|
||||
changedProperties.put(DaFitConstants.PREF_DEVICE_VERSION, String.valueOf(deviceVersion.value()));
|
||||
MoyoungEnumDeviceVersion deviceVersion = (MoyoungEnumDeviceVersion) value;
|
||||
changedProperties.put(MoyoungConstants.PREF_DEVICE_VERSION, String.valueOf(deviceVersion.value()));
|
||||
break;
|
||||
|
||||
case "DO_NOT_DISTURB_TIME":
|
||||
DaFitSettingTimeRange.TimeRange doNotDisturb = (DaFitSettingTimeRange.TimeRange) value;
|
||||
MoyoungSettingTimeRange.TimeRange doNotDisturb = (MoyoungSettingTimeRange.TimeRange) value;
|
||||
if (doNotDisturb.start_h == 0 && doNotDisturb.start_m == 0 &&
|
||||
doNotDisturb.end_h == 0 && doNotDisturb.end_m == 0)
|
||||
changedProperties.put(MiBandConst.PREF_DO_NOT_DISTURB, MiBandConst.PREF_DO_NOT_DISTURB_OFF);
|
||||
@ -1512,7 +1512,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
case "QUICK_VIEW_TIME":
|
||||
boolean quickViewEnabled2 = !prefs.getString(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, getContext().getString(R.string.p_off)).equals(getContext().getString(R.string.p_off));
|
||||
DaFitSettingTimeRange.TimeRange quickViewTime = (DaFitSettingTimeRange.TimeRange) value;
|
||||
MoyoungSettingTimeRange.TimeRange quickViewTime = (MoyoungSettingTimeRange.TimeRange) value;
|
||||
if (quickViewEnabled2)
|
||||
{
|
||||
if (quickViewTime.start_h == 0 && quickViewTime.start_m == 0 &&
|
||||
@ -1527,15 +1527,15 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
case "SEDENTARY_REMINDER":
|
||||
boolean sedentaryReminderEnabled = (Boolean) value;
|
||||
changedProperties.put(DaFitConstants.PREF_SEDENTARY_REMINDER, sedentaryReminderEnabled ? "on": "off");
|
||||
changedProperties.put(MoyoungConstants.PREF_SEDENTARY_REMINDER, sedentaryReminderEnabled ? "on": "off");
|
||||
break;
|
||||
|
||||
case "REMINDERS_TO_MOVE_PERIOD":
|
||||
DaFitSettingRemindersToMove.RemindersToMove remindersToMove = (DaFitSettingRemindersToMove.RemindersToMove) value;
|
||||
changedProperties.put(DaFitConstants.PREF_SEDENTARY_REMINDER_PERIOD, String.valueOf(remindersToMove.period));
|
||||
changedProperties.put(DaFitConstants.PREF_SEDENTARY_REMINDER_STEPS, String.valueOf(remindersToMove.steps));
|
||||
changedProperties.put(DaFitConstants.PREF_SEDENTARY_REMINDER_START, String.valueOf(remindersToMove.start_h));
|
||||
changedProperties.put(DaFitConstants.PREF_SEDENTARY_REMINDER_END, String.valueOf(remindersToMove.end_h));
|
||||
MoyoungSettingRemindersToMove.RemindersToMove remindersToMove = (MoyoungSettingRemindersToMove.RemindersToMove) value;
|
||||
changedProperties.put(MoyoungConstants.PREF_SEDENTARY_REMINDER_PERIOD, String.valueOf(remindersToMove.period));
|
||||
changedProperties.put(MoyoungConstants.PREF_SEDENTARY_REMINDER_STEPS, String.valueOf(remindersToMove.steps));
|
||||
changedProperties.put(MoyoungConstants.PREF_SEDENTARY_REMINDER_START, String.valueOf(remindersToMove.start_h));
|
||||
changedProperties.put(MoyoungConstants.PREF_SEDENTARY_REMINDER_END, String.valueOf(remindersToMove.end_h));
|
||||
break;
|
||||
}
|
||||
for (Map.Entry<String, String> property : changedProperties.entrySet())
|
||||
@ -1564,7 +1564,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("onSendWeather");
|
||||
|
||||
DaFitWeatherToday weatherToday = new DaFitWeatherToday(weatherSpec);
|
||||
MoyoungWeatherToday weatherToday = new MoyoungWeatherToday(weatherSpec);
|
||||
ByteBuffer packetWeatherToday = ByteBuffer.allocate(weatherToday.pm25 != null ? 21 : 19);
|
||||
packetWeatherToday.put(weatherToday.pm25 != null ? (byte)1 : (byte)0);
|
||||
packetWeatherToday.put(weatherToday.conditionId);
|
||||
@ -1573,21 +1573,21 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
packetWeatherToday.putShort(weatherToday.pm25);
|
||||
packetWeatherToday.put(weatherToday.lunar_or_festival.getBytes("unicodebigunmarked"));
|
||||
packetWeatherToday.put(weatherToday.city.getBytes("unicodebigunmarked"));
|
||||
sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SET_WEATHER_TODAY, packetWeatherToday.array()));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SET_WEATHER_TODAY, packetWeatherToday.array()));
|
||||
|
||||
ByteBuffer packetWeatherForecast = ByteBuffer.allocate(7 * 3);
|
||||
for(int i = 0; i < 7; i++)
|
||||
{
|
||||
DaFitWeatherForecast forecast;
|
||||
MoyoungWeatherForecast forecast;
|
||||
if (weatherSpec.forecasts.size() > i)
|
||||
forecast = new DaFitWeatherForecast(weatherSpec.forecasts.get(i));
|
||||
forecast = new MoyoungWeatherForecast(weatherSpec.forecasts.get(i));
|
||||
else
|
||||
forecast = new DaFitWeatherForecast(DaFitConstants.WEATHER_HAZE, (byte)-100, (byte)-100); // I don't think there is a way to send less (my watch shows only tomorrow anyway...)
|
||||
forecast = new MoyoungWeatherForecast(MoyoungConstants.WEATHER_HAZE, (byte)-100, (byte)-100); // I don't think there is a way to send less (my watch shows only tomorrow anyway...)
|
||||
packetWeatherForecast.put(forecast.conditionId);
|
||||
packetWeatherForecast.put(forecast.minTemp);
|
||||
packetWeatherForecast.put(forecast.maxTemp);
|
||||
}
|
||||
sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SET_WEATHER_FUTURE, packetWeatherForecast.array()));
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SET_WEATHER_FUTURE, packetWeatherForecast.array()));
|
||||
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
@ -14,9 +14,9 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung;
|
||||
|
||||
public class DaFitPacket {
|
||||
public class MoyoungPacket {
|
||||
protected byte[] packet;
|
||||
protected int position = 0;
|
||||
}
|
@ -14,9 +14,8 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung;
|
||||
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -33,8 +32,8 @@ import nodomain.freeyourgadget.gadgetbridge.Logging;
|
||||
* <pre>
|
||||
* {@code
|
||||
* if(packetIn.putFragment(fragment)) {
|
||||
* Pair<Byte, byte[]> packet = DaFitPacketIn.parsePacket(packetIn.getPacket());
|
||||
* packetIn = new DaFitPacketIn();
|
||||
* Pair<Byte, byte[]> packet = MoyoungPacketIn.parsePacket(packetIn.getPacket());
|
||||
* packetIn = new MoyoungPacketIn();
|
||||
* if (packet != null) {
|
||||
* byte packetType = packet.first;
|
||||
* byte[] payload = packet.second;
|
||||
@ -43,10 +42,10 @@ import nodomain.freeyourgadget.gadgetbridge.Logging;
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public class DaFitPacketIn extends DaFitPacket {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DaFitPacketIn.class);
|
||||
public class MoyoungPacketIn extends MoyoungPacket {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MoyoungPacketIn.class);
|
||||
|
||||
public DaFitPacketIn()
|
||||
public MoyoungPacketIn()
|
||||
{
|
||||
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@ -24,15 +24,15 @@ import androidx.annotation.NonNull;
|
||||
* Usage:
|
||||
* <pre>
|
||||
* {@code
|
||||
* DaFitPacketOut packetOut = new DaFitPacketOut(DaFitPacketOut.buildPacket(type, payload));
|
||||
* MoyoungPacketOut packetOut = new MoyoungPacketOut(MoyoungPacketOut.buildPacket(type, payload));
|
||||
* byte[] fragment = new byte[MTU];
|
||||
* while(packetOut.getFragment(fragment))
|
||||
* send(fragment);
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public class DaFitPacketOut extends DaFitPacket {
|
||||
public DaFitPacketOut(byte[] packet)
|
||||
public class MoyoungPacketOut extends MoyoungPacket {
|
||||
public MoyoungPacketOut(byte[] packet)
|
||||
{
|
||||
this.packet = packet;
|
||||
}
|
||||
@ -64,7 +64,7 @@ public class DaFitPacketOut extends DaFitPacket {
|
||||
byte[] packet = new byte[payload.length + 5];
|
||||
packet[0] = (byte)0xFE;
|
||||
packet[1] = (byte)0xEA;
|
||||
if (DaFitDeviceSupport.MTU == 20)
|
||||
if (MoyoungDeviceSupport.MTU == 20)
|
||||
{
|
||||
packet[2] = 16;
|
||||
packet[3] = (byte)(packet.length & 0xFF);
|
@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
@ -27,31 +27,31 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSetting;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSetting;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
|
||||
public class QuerySettingsOperation extends AbstractBTLEOperation<DaFitDeviceSupport> {
|
||||
public class QuerySettingsOperation extends AbstractBTLEOperation<MoyoungDeviceSupport> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(QuerySettingsOperation.class);
|
||||
|
||||
private final DaFitSetting[] settingsToQuery;
|
||||
private final MoyoungSetting[] settingsToQuery;
|
||||
private boolean[] received;
|
||||
|
||||
private DaFitPacketIn packetIn = new DaFitPacketIn();
|
||||
private MoyoungPacketIn packetIn = new MoyoungPacketIn();
|
||||
|
||||
public QuerySettingsOperation(DaFitDeviceSupport support, DaFitSetting[] settingsToQuery) {
|
||||
public QuerySettingsOperation(MoyoungDeviceSupport support, MoyoungSetting[] settingsToQuery) {
|
||||
super(support);
|
||||
this.settingsToQuery = settingsToQuery;
|
||||
}
|
||||
|
||||
public QuerySettingsOperation(DaFitDeviceSupport support) {
|
||||
public QuerySettingsOperation(MoyoungDeviceSupport support) {
|
||||
super(support);
|
||||
DaFitDeviceCoordinator coordinator = (DaFitDeviceCoordinator) DeviceHelper.getInstance().getCoordinator(getDevice());
|
||||
MoyoungDeviceCoordinator coordinator = (MoyoungDeviceCoordinator) DeviceHelper.getInstance().getCoordinator(getDevice());
|
||||
this.settingsToQuery = coordinator.getSupportedSettings();
|
||||
}
|
||||
|
||||
@ -65,12 +65,12 @@ public class QuerySettingsOperation extends AbstractBTLEOperation<DaFitDeviceSup
|
||||
protected void doPerform() throws IOException {
|
||||
received = new boolean[settingsToQuery.length];
|
||||
TransactionBuilder builder = performInitialized("QuerySettingsOperation");
|
||||
for (DaFitSetting setting : settingsToQuery)
|
||||
for (MoyoungSetting setting : settingsToQuery)
|
||||
{
|
||||
if (setting.cmdQuery == -1)
|
||||
continue;
|
||||
|
||||
getSupport().sendPacket(builder, DaFitPacketOut.buildPacket(setting.cmdQuery, new byte[0]));
|
||||
getSupport().sendPacket(builder, MoyoungPacketOut.buildPacket(setting.cmdQuery, new byte[0]));
|
||||
}
|
||||
builder.queue(getQueue());
|
||||
}
|
||||
@ -84,11 +84,11 @@ public class QuerySettingsOperation extends AbstractBTLEOperation<DaFitDeviceSup
|
||||
else
|
||||
{
|
||||
UUID charUuid = characteristic.getUuid();
|
||||
if (charUuid.equals(DaFitConstants.UUID_CHARACTERISTIC_DATA_IN))
|
||||
if (charUuid.equals(MoyoungConstants.UUID_CHARACTERISTIC_DATA_IN))
|
||||
{
|
||||
if (packetIn.putFragment(characteristic.getValue())) {
|
||||
Pair<Byte, byte[]> packet = DaFitPacketIn.parsePacket(packetIn.getPacket());
|
||||
packetIn = new DaFitPacketIn();
|
||||
Pair<Byte, byte[]> packet = MoyoungPacketIn.parsePacket(packetIn.getPacket());
|
||||
packetIn = new MoyoungPacketIn();
|
||||
if (packet != null) {
|
||||
byte packetType = packet.first;
|
||||
byte[] payload = packet.second;
|
||||
@ -108,7 +108,7 @@ public class QuerySettingsOperation extends AbstractBTLEOperation<DaFitDeviceSup
|
||||
boolean receivedEverything = true;
|
||||
for(int i = 0; i < settingsToQuery.length; i++)
|
||||
{
|
||||
DaFitSetting setting = settingsToQuery[i];
|
||||
MoyoungSetting setting = settingsToQuery[i];
|
||||
if (setting.cmdQuery == -1)
|
||||
continue;
|
||||
if (setting.cmdQuery == packetType)
|
@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit;
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
@ -37,10 +37,10 @@ import nodomain.freeyourgadget.gadgetbridge.Logging;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaFitActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.MoyoungActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.User;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation;
|
||||
@ -48,7 +48,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class TrainingFinishedDataOperation extends AbstractBTLEOperation<DaFitDeviceSupport> {
|
||||
public class TrainingFinishedDataOperation extends AbstractBTLEOperation<MoyoungDeviceSupport> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FetchDataOperation.class);
|
||||
|
||||
@ -56,9 +56,9 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<DaFitDe
|
||||
private final long firstPacketTimeInMillis;
|
||||
ByteArrayOutputStream data = new ByteArrayOutputStream();
|
||||
|
||||
private DaFitPacketIn packetIn = new DaFitPacketIn();
|
||||
private MoyoungPacketIn packetIn = new MoyoungPacketIn();
|
||||
|
||||
public TrainingFinishedDataOperation(DaFitDeviceSupport support, byte[] firstPacketData) {
|
||||
public TrainingFinishedDataOperation(MoyoungDeviceSupport support, byte[] firstPacketData) {
|
||||
super(support);
|
||||
this.firstPacketData = firstPacketData;
|
||||
this.firstPacketTimeInMillis = Calendar.getInstance().getTimeInMillis();
|
||||
@ -85,11 +85,11 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<DaFitDe
|
||||
else
|
||||
{
|
||||
UUID charUuid = characteristic.getUuid();
|
||||
if (charUuid.equals(DaFitConstants.UUID_CHARACTERISTIC_DATA_IN))
|
||||
if (charUuid.equals(MoyoungConstants.UUID_CHARACTERISTIC_DATA_IN))
|
||||
{
|
||||
if (packetIn.putFragment(characteristic.getValue())) {
|
||||
Pair<Byte, byte[]> packet = DaFitPacketIn.parsePacket(packetIn.getPacket());
|
||||
packetIn = new DaFitPacketIn();
|
||||
Pair<Byte, byte[]> packet = MoyoungPacketIn.parsePacket(packetIn.getPacket());
|
||||
packetIn = new MoyoungPacketIn();
|
||||
if (packet != null) {
|
||||
byte packetType = packet.first;
|
||||
byte[] payload = packet.second;
|
||||
@ -106,11 +106,11 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<DaFitDe
|
||||
}
|
||||
|
||||
private boolean handlePacket(byte packetType, byte[] payload) {
|
||||
if (packetType == DaFitConstants.CMD_QUERY_LAST_DYNAMIC_RATE) {
|
||||
if (packetType == MoyoungConstants.CMD_QUERY_LAST_DYNAMIC_RATE) {
|
||||
handleTrainingHealthRatePacket(payload, false);
|
||||
return true;
|
||||
}
|
||||
if (packetType == DaFitConstants.CMD_QUERY_MOVEMENT_HEART_RATE) {
|
||||
if (packetType == MoyoungConstants.CMD_QUERY_MOVEMENT_HEART_RATE) {
|
||||
handleTrainingSummaryDataPacket(payload);
|
||||
return true;
|
||||
}
|
||||
@ -121,14 +121,14 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<DaFitDe
|
||||
private void handleTrainingHealthRatePacket(byte[] payload, boolean isFirst) {
|
||||
Log.i("TRAINING DATA", "data: " + Logging.formatBytes(payload));
|
||||
byte sequenceType = payload[0];
|
||||
if (isFirst != (sequenceType == DaFitConstants.ARG_TRANSMISSION_FIRST))
|
||||
if (isFirst != (sequenceType == MoyoungConstants.ARG_TRANSMISSION_FIRST))
|
||||
throw new IllegalArgumentException("Expected packet to be " + (isFirst ? "first" : "continued") + " but got packet of type " + sequenceType);
|
||||
if (sequenceType == DaFitConstants.ARG_TRANSMISSION_LAST && payload.length > 1)
|
||||
if (sequenceType == MoyoungConstants.ARG_TRANSMISSION_LAST && payload.length > 1)
|
||||
throw new IllegalArgumentException("Last packet shouldn't have any data");
|
||||
|
||||
data.write(payload, 1, payload.length - 1);
|
||||
|
||||
if (sequenceType != DaFitConstants.ARG_TRANSMISSION_LAST)
|
||||
if (sequenceType != MoyoungConstants.ARG_TRANSMISSION_LAST)
|
||||
queryMoreData();
|
||||
else
|
||||
processAllData();
|
||||
@ -137,7 +137,7 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<DaFitDe
|
||||
private void queryMoreData() {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("TrainingFinishedDataOperation");
|
||||
getSupport().sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_QUERY_LAST_DYNAMIC_RATE, new byte[0]));
|
||||
getSupport().sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_QUERY_LAST_DYNAMIC_RATE, new byte[0]));
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@ -154,7 +154,7 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<DaFitDe
|
||||
dataBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
Calendar dateRecorded = Calendar.getInstance();
|
||||
dateRecorded.setTime(DaFitConstants.WatchTimeToLocalTime(dataBuffer.getInt()));
|
||||
dateRecorded.setTime(MoyoungConstants.WatchTimeToLocalTime(dataBuffer.getInt()));
|
||||
|
||||
// NOTE: The first sample always matches dateRecorded (which is aligned to the minute)
|
||||
// The last sample is saved at the moment the recording is stopped (and this code starts executing)
|
||||
@ -163,7 +163,7 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<DaFitDe
|
||||
User user = DBHelper.getUser(dbHandler.getDaoSession());
|
||||
Device device = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession());
|
||||
|
||||
DaFitSampleProvider provider = new DaFitSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
MoyoungSampleProvider provider = new MoyoungSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
|
||||
Log.i("START DATE", dateRecorded.getTime().toString());
|
||||
while (dataBuffer.hasRemaining())
|
||||
@ -174,14 +174,14 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<DaFitDe
|
||||
|
||||
Log.i("MEASUREMENT", "at " + dateRecorded.getTime().toString() + " was " + measurement);
|
||||
|
||||
DaFitActivitySample sample = new DaFitActivitySample();
|
||||
MoyoungActivitySample sample = new MoyoungActivitySample();
|
||||
sample.setDevice(device);
|
||||
sample.setUser(user);
|
||||
sample.setProvider(provider);
|
||||
sample.setTimestamp((int)(dateRecorded.getTimeInMillis() / 1000));
|
||||
|
||||
sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED); // Training type will be taken later from CMD_QUERY_MOVEMENT_HEART_RATE (it's not present in the main data packet)
|
||||
sample.setDataSource(DaFitSampleProvider.SOURCE_TRAINING_HEARTRATE);
|
||||
sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED); // Training type will be taken later from CMD_QUERY_MOVEMENT_HEART_RATE (it's not present in the main data packet)
|
||||
sample.setDataSource(MoyoungSampleProvider.SOURCE_TRAINING_HEARTRATE);
|
||||
|
||||
sample.setBatteryLevel(ActivitySample.NOT_MEASURED);
|
||||
sample.setSteps(ActivitySample.NOT_MEASURED);
|
||||
@ -206,7 +206,7 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<DaFitDe
|
||||
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("TrainingFinishedDataOperation fetch training type");
|
||||
getSupport().sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_QUERY_MOVEMENT_HEART_RATE, new byte[] { }));
|
||||
getSupport().sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_QUERY_MOVEMENT_HEART_RATE, new byte[] { }));
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
@ -2634,24 +2634,24 @@
|
||||
<item>ru_RU</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_dafit_watch_face">
|
||||
<string-array name="pref_moyoung_watch_face">
|
||||
<item>Watch face 1</item>
|
||||
<item>Watch face 2</item>
|
||||
<item>Watch face 3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_dafit_watch_face_values">
|
||||
<string-array name="pref_moyoung_watch_face_values">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_dafit_device_version">
|
||||
<string-array name="pref_moyoung_device_version">
|
||||
<item>Chinese edition</item>
|
||||
<item>International edition</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_dafit_device_version_values">
|
||||
<string-array name="pref_moyoung_device_version_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
|
@ -1821,7 +1821,6 @@
|
||||
<string name="devicetype_mijia_lywsd03">Mijia Temperature and Humidity Sensor 2</string>
|
||||
<string name="devicetype_mijia_xmwsdj04">Mijia Temperature and Humidity Sensor 2 (E-ink)</string>
|
||||
<string name="devicetype_mijia_mho_c303">Mijia MHO-C303</string>
|
||||
<string name="devicetype_dafit">Da Fit</string>
|
||||
<string name="devicetype_makibes_hr3">Makibes HR3</string>
|
||||
<string name="devicetype_banglejs">Bangle.js</string>
|
||||
<string name="devicetype_tlw64">TLW64</string>
|
||||
|
@ -2,9 +2,9 @@
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:entries="@array/pref_dafit_device_version"
|
||||
android:entryValues="@array/pref_dafit_device_version_values"
|
||||
android:key="dafit_device_version"
|
||||
android:entries="@array/pref_moyoung_device_version"
|
||||
android:entryValues="@array/pref_moyoung_device_version_values"
|
||||
android:key="moyoung_device_version"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_device_version" />
|
||||
</androidx.preference.PreferenceScreen>
|
@ -3,7 +3,7 @@
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_language"
|
||||
android:defaultValue="0"
|
||||
android:key="dafit_language"
|
||||
android:key="moyoung_language"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_title_language" />
|
||||
</androidx.preference.PreferenceScreen>
|
@ -3,9 +3,9 @@
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_widgets"
|
||||
android:defaultValue="1"
|
||||
android:entries="@array/pref_dafit_watch_face"
|
||||
android:entryValues="@array/pref_dafit_watch_face_values"
|
||||
android:key="dafit_watch_face"
|
||||
android:entries="@array/pref_moyoung_watch_face"
|
||||
android:entryValues="@array/pref_moyoung_watch_face_values"
|
||||
android:key="moyoung_watch_face"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_watch_face" />
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user