feature: Sleep as android support #3687

Merged
joserebelo merged 1 commit from nitanmarcel/Gadgetbridge:sleep_as_android into master 2024-04-20 10:59:02 +00:00
Contributor

Rework of #3188 which seems to not be updated for a long time.

Going to a different approach, instead of implementing support for just a specific device it focuses on general support.

The first commit brings a receiver for sleep as android intents that then trigger the method onSleepForAndroidAction on device support classes.

TODO:

  • Implement an option to set a device as the default provider for Sleep As Android.

  • Implement sending data to Sleep As Android from a device to use as example. Probably a ZeppOS device which I own.

    • Partially implemented
  • Move configuration to preferences screen

  • Features toggles

  • Alarms and alarm slot selector

  • Pause/Resume tracking from watch

Rework of #3188 which seems to not be updated for a long time. Going to a different approach, instead of implementing support for just a specific device it focuses on general support. The first commit brings a receiver for sleep as android intents that then trigger the method `onSleepForAndroidAction` on device support classes. TODO: - [x] Implement an option to set a device as the default provider for Sleep As Android. - [x] Implement sending data to Sleep As Android from a device to use as example. Probably a ZeppOS device which I own. - Partially implemented - [x] Move configuration to preferences screen - [x] Features toggles - [x] Alarms and alarm slot selector - [ ] ~~Pause/Resume tracking from watch~~
nitanmarcel added 1 commit 2024-04-06 11:19:32 +00:00
nitanmarcel force-pushed sleep_as_android from 7fcf1f5fd4 to a4cecc0c93 2024-04-06 11:21:32 +00:00 Compare
nitanmarcel added 1 commit 2024-04-06 13:58:17 +00:00
Author
Contributor

Option to set unset a device as the default provider for Sleep For Android

Option to set unset a device as the default provider for Sleep For Android
nitanmarcel added 1 commit 2024-04-06 16:07:34 +00:00
nitanmarcel added 1 commit 2024-04-06 16:21:40 +00:00
Member

I feel like selecting the default device for sleep as android might fit better in a "Sleep for Android" preferences screen (maybe there are other settings we want, for example enabling the feature).

You can see an example of how we list all available devices in the dashboard preferences.

I feel like selecting the default device for sleep as android might fit better in a "Sleep for Android" preferences screen (maybe there are other settings we want, for example enabling the feature). You can see an example of how we list all available devices in the dashboard preferences.
nitanmarcel added 1 commit 2024-04-06 17:13:54 +00:00
Author
Contributor

I feel like selecting the default device for sleep as android might fit better in a "Sleep for Android" preferences screen (maybe there are other settings we want, for example enabling the feature).

You can see an example of how we list all available devices in the dashboard preferences.

I'm actually thinking of adding controls on what data to be sent to sleep as android, so I guess that will be a good place to move the configuration.

I tough of this as more of a device specific control since it's not something that every device can support, for example earbuds.

I'll move it to it's own settings if you would like, and handle the provider device, default alarm slot (todo) there. Plus the data controls.

> I feel like selecting the default device for sleep as android might fit better in a "Sleep for Android" preferences screen (maybe there are other settings we want, for example enabling the feature). > > You can see an example of how we list all available devices in the dashboard preferences. I'm actually thinking of adding controls on what data to be sent to sleep as android, so I guess that will be a good place to move the configuration. I tough of this as more of a device specific control since it's not something that every device can support, for example earbuds. I'll move it to it's own settings if you would like, and handle the provider device, default alarm slot (todo) there. Plus the data controls.
Member

I'd suggest a supportsSleepAsAndroid on the coordinators, so they can declare whether they implement support or not. I haven't checked what's needed, but maybe even we can declare what specific capabilities are supported (accelerometer, SPO2, etc)

I'd suggest a supportsSleepAsAndroid on the coordinators, so they can declare whether they implement support or not. I haven't checked what's needed, but maybe even we can declare what specific capabilities are supported (accelerometer, SPO2, etc)
Author
Contributor

I'd suggest a supportsSleepAsAndroid on the coordinators, so they can declare whether they implement support or not. I haven't checked what's needed, but maybe even we can declare what specific capabilities are supported (accelerometer, SPO2, etc)

I do have that, that's how I'm checking whatever to show the provider option or not. Or to which coordinator to send the intents.

Yeah we could have a getSupportedSleepAsAndroidFeatures (maybe something shorter) on coordinators to return an array or something with some constants.

> I'd suggest a supportsSleepAsAndroid on the coordinators, so they can declare whether they implement support or not. I haven't checked what's needed, but maybe even we can declare what specific capabilities are supported (accelerometer, SPO2, etc) I do have that, that's how I'm checking whatever to show the provider option or not. Or to which coordinator to send the intents. Yeah we could have a getSupportedSleepAsAndroidFeatures (maybe something shorter) on coordinators to return an array or something with some constants.
Author
Contributor

I'd suggest a supportsSleepAsAndroid on the coordinators, so they can declare whether they implement support or not. I haven't checked what's needed, but maybe even we can declare what specific capabilities are supported (accelerometer, SPO2, etc)

Something like this?

> I'd suggest a supportsSleepAsAndroid on the coordinators, so they can declare whether they implement support or not. I haven't checked what's needed, but maybe even we can declare what specific capabilities are supported (accelerometer, SPO2, etc) Something like this?
nitanmarcel added 1 commit 2024-04-06 21:08:08 +00:00
Author
Contributor

I'd suggest a supportsSleepAsAndroid on the coordinators, so they can declare whether they implement support or not. I haven't checked what's needed, but maybe even we can declare what specific capabilities are supported (accelerometer, SPO2, etc)

Done.

Now there are toggle for what data to send. The deactivated switches mean that the current selected device does not support that specific data.

EDIT: I've merged RR interval and SDDN into the heart rate feature since they require the same sensors

> I'd suggest a supportsSleepAsAndroid on the coordinators, so they can declare whether they implement support or not. I haven't checked what's needed, but maybe even we can declare what specific capabilities are supported (accelerometer, SPO2, etc) Done. Now there are toggle for what data to send. The deactivated switches mean that the current selected device does not support that specific data. EDIT: I've merged RR interval and SDDN into the heart rate feature since they require the same sensors
nitanmarcel added 1 commit 2024-04-07 04:25:25 +00:00
nitanmarcel added 1 commit 2024-04-07 07:02:56 +00:00
nitanmarcel force-pushed sleep_as_android from ed27c74f8e to ad262e2ceb 2024-04-07 07:03:50 +00:00 Compare
nitanmarcel added 1 commit 2024-04-07 08:22:03 +00:00
nitanmarcel added 1 commit 2024-04-07 08:24:46 +00:00
nitanmarcel changed title from WIP: feature: Sleep as android support to feature: Sleep as android support 2024-04-07 08:27:25 +00:00
Author
Contributor

@joserebelo

I think this is ready for a review as it is. It sends enough data to make Sleep As Android reliable.

@joserebelo I think this is ready for a review as it is. It sends enough data to make Sleep As Android reliable.
nitanmarcel changed title from feature: Sleep as android support to WIP: feature: Sleep as android support 2024-04-07 08:51:39 +00:00
nitanmarcel added 1 commit 2024-04-07 09:04:24 +00:00
Member

Without looking at the code, is it also possible to provide analyzed sleep data back to Gadgetbridge for charting and archiving?

Without looking at the code, is it also possible to provide analyzed sleep data back to Gadgetbridge for charting and archiving?
nitanmarcel added 1 commit 2024-04-07 10:32:38 +00:00
Author
Contributor

Without looking at the code, is it also possible to provide analyzed sleep data back to Gadgetbridge for charting and archiving?

Based on this yes.

https://docs.sleep.urbandroid.org/devs/content_provider_api.html#sleep-data-content-provider

> Without looking at the code, is it also possible to provide analyzed sleep data back to Gadgetbridge for charting and archiving? Based on this yes. https://docs.sleep.urbandroid.org/devs/content_provider_api.html#sleep-data-content-provider
nitanmarcel added 1 commit 2024-04-07 11:10:12 +00:00
nitanmarcel added 1 commit 2024-04-07 11:36:07 +00:00
Author
Contributor

I used it to track my sleep last night. So far it works pretty good.

The missing heart rate numbers seem to be a bug with Sleep As Android. If I zoom on a timestamp I can see the the numbers flashing.

EDIT: Nope. it was totally my fault I guess xD

I used it to track my sleep last night. So far it works pretty good. The missing heart rate numbers seem to be a bug with Sleep As Android. If I zoom on a timestamp I can see the the numbers flashing. EDIT: Nope. it was totally my fault I guess xD
nitanmarcel added 1 commit 2024-04-08 10:37:46 +00:00
nitanmarcel force-pushed sleep_as_android from a8c877a350 to 8a20e5e088 2024-04-08 17:56:26 +00:00 Compare
Author
Contributor

@joserebelo what does -1 means in real time HR bpm? That the data is broken or that there's no data sent from the watch?

EDIT: that looks maybe like a bug? I've tested with Notify app and the HR is constantly sent correctly compares with Gadgetbridge

@joserebelo what does -1 means in real time HR bpm? That the data is broken or that there's no data sent from the watch? EDIT: that looks maybe like a bug? I've tested with Notify app and the HR is constantly sent correctly compares with Gadgetbridge
nitanmarcel added 1 commit 2024-04-09 06:39:50 +00:00
Author
Contributor

@joserebelo what does -1 means in real time HR bpm? That the data is broken or that there's no data sent from the watch?

EDIT: that looks maybe like a bug? I've tested with Notify app and the HR is constantly sent correctly compares with Gadgetbridge

I've opened an issue since it sometimes works and sometimes it doesn't.

#3695

> @joserebelo what does -1 means in real time HR bpm? That the data is broken or that there's no data sent from the watch? > > > EDIT: that looks maybe like a bug? I've tested with Notify app and the HR is constantly sent correctly compares with Gadgetbridge I've opened an issue since it sometimes works and sometimes it doesn't. https://codeberg.org/Freeyourgadget/Gadgetbridge/issues/3695
nitanmarcel force-pushed sleep_as_android from 7817974997 to 68540f64a1 2024-04-09 15:49:22 +00:00 Compare
nitanmarcel added 1 commit 2024-04-09 18:18:16 +00:00
nitanmarcel added 1 commit 2024-04-09 19:00:17 +00:00
nitanmarcel added 3 commits 2024-04-10 09:37:15 +00:00
Author
Contributor

Does anyone has any idea how to handle sending tracking actions to sleep as android?

I was thinking notifications that have buttons for increasing the pause time and resuming the tracking but I don't think my mi band 7 supports multiple buttons. Or I just can't figure out how to use them

Does anyone has any idea how to handle sending tracking actions to sleep as android? I was thinking notifications that have buttons for increasing the pause time and resuming the tracking but I don't think my mi band 7 supports multiple buttons. Or I just can't figure out how to use them
nitanmarcel added 1 commit 2024-04-10 16:13:57 +00:00
Member

@nitanmarcel maybe we could hijack the canned responses as buttons?

@nitanmarcel maybe we could hijack the canned responses as buttons?
Author
Contributor

@nitanmarcel maybe we could hijack the canned responses as buttons?

I suppose we could.

I've took a look at Notify and it seems that it doesn't handle this at all on the watch. Doesn't seem to handle pausing and un pausing the tracking at all

> @nitanmarcel maybe we could hijack the canned responses as buttons? I suppose we could. I've took a look at Notify and it seems that it doesn't handle this at all on the watch. Doesn't seem to handle pausing and un pausing the tracking at all
Author
Contributor

Anyway I wish to remove the WIP today if everything goes fine. Hopefully, I'm currently analyzing the data I have with someone from Sleep As Android support since I've had some issues a couple of days ago and I want to make sure the tracking is on point

Anyway I wish to remove the WIP today if everything goes fine. Hopefully, I'm currently analyzing the data I have with someone from Sleep As Android support since I've had some issues a couple of days ago and I want to make sure the tracking is on point
nitanmarcel force-pushed sleep_as_android from bc6c44e892 to d42080111d 2024-04-11 10:15:47 +00:00 Compare
nitanmarcel changed title from WIP: feature: Sleep as android support to feature: Sleep as android support 2024-04-11 10:16:00 +00:00
Author
Contributor

The PR is pretty much done and now it's ready for a review.

There is a small issue with the movement received from my watch with some unusual wild movement but I'm not 100% sure it's caused by my watch, the code or how badly I'm sleeping. Except that everything looks good so far.

My graph:

image

Average graph:

image

The PR is pretty much done and now it's ready for a review. There is a small issue with the movement received from my watch with some unusual wild movement but I'm not 100% sure it's caused by my watch, the code or how badly I'm sleeping. Except that everything looks good so far. My graph: ![image](/attachments/dd96c793-afc0-4d32-8c3a-08eaf62a69c9) Average graph: ![image](/attachments/d556bf8f-f7c0-4071-8d32-89c216075aa1)
nitanmarcel changed title from feature: Sleep as android support to WIP: feature: Sleep as android support 2024-04-12 04:13:37 +00:00
Author
Contributor

Nah I don't like how this ended so far, I need more time to figure out what's wrong with the movement data.

Nah I don't like how this ended so far, I need more time to figure out what's wrong with the movement data.
nitanmarcel force-pushed sleep_as_android from d42080111d to c3b6e983ce 2024-04-17 10:20:48 +00:00 Compare
nitanmarcel changed title from WIP: feature: Sleep as android support to feature: Sleep as android support 2024-04-17 10:21:38 +00:00
Author
Contributor

Ready for review

image

Ready for review ![image](/attachments/b0b3da4b-9575-4df7-8a1d-b732864f465c)
joserebelo requested changes 2024-04-17 21:47:19 +00:00
joserebelo left a comment
Member

This is very cool - great effort!

Just a couple of comments here and there, but my main concern would really be to remove the sender from the coordinator, as I believe it should live in the support class, unlike the supported features.

This is very cool - great effort! Just a couple of comments here and there, but my main concern would really be to remove the sender from the coordinator, as I believe it should live in the support class, unlike the supported features.
@ -0,0 +42,4 @@
if (!defaultDeviceAddr.isEmpty()) {
GBDevice device = GBApplication.app().getDeviceManager().getDeviceByAddress(defaultDeviceAddr);
if (device != null) {
int maxAlarmSlots = device.getDeviceCoordinator().getAlarmSlotCount(device);
Member

There may be a weird interaction here with the alarms reserved for calendar events on some devices.

You should probably subtract int reservedSlots = prefs.getInt(DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR, 0);

There may be a weird interaction here with the alarms reserved for calendar events on some devices. You should probably subtract `int reservedSlots = prefs.getInt(DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR, 0);`
nitanmarcel marked this conversation as resolved
@ -0,0 +204,4 @@
*/
public void confirmConnected() {
if (!isDeviceDefault()) return;
LOG.debug("Confirming connected");
Member

Shouldn't we actually confirmed that we're connected here? Maybe device.isInitialized?

Shouldn't we actually confirmed that we're connected here? Maybe `device.isInitialized`?
Author
Contributor

Yeah. I've implemented the check in isDeviceDefault() method.

The confirmConnected one just sends an intent to sleep as android when it requests it.

Yeah. I've implemented the check in isDeviceDefault() method. The confirmConnected one just sends an intent to sleep as android when it requests it.
nitanmarcel marked this conversation as resolved
@ -84,6 +86,8 @@ public abstract class ZeppOsCoordinator extends HuamiCoordinator {
return Collections.emptyMap();
}
private final SleepAsAndroidSender sleepAsAndroidSender = new SleepAsAndroidSender(new ArrayList<>(List.of(SleepAsAndroidFeature.ACCELEROMETER, SleepAsAndroidFeature.HEART_RATE, SleepAsAndroidFeature.NOTIFICATIONS, SleepAsAndroidFeature.ALARMS)));
Member

Coordinators are supposed to be stateless, and this sender is stateful by design (i needs to know the device).

I would refactor this into a function to get the supported features:

public Set<SleepAsAndroidFeature> getSleepAsAndroidFeatures() {
    // by default, return Collections.emptySet()
    return new HashSet<>(
        SleepAsAndroidFeature.ACCELEROMETER,
        // ...
    ));

And I would add the device as a parameter on the SleepAsAndroidSender. This would allow us to instantiate it directly in the support class, and make it clear that there should be an instance of the sender for each device.

What do you think?

Coordinators are supposed to be stateless, and this sender is stateful by design (i needs to know the device). I would refactor this into a function to get the supported features: ```java public Set<SleepAsAndroidFeature> getSleepAsAndroidFeatures() { // by default, return Collections.emptySet() return new HashSet<>( SleepAsAndroidFeature.ACCELEROMETER, // ... )); ``` And I would add the device as a parameter on the SleepAsAndroidSender. This would allow us to instantiate it directly in the support class, and make it clear that there should be an instance of the sender for each device. What do you think?
Member

An EnumSet would be more efficient even.

An EnumSet would be more efficient even.
Author
Contributor

I've used EnumSet also I moved SleepAsAndroid to Support

I've used EnumSet also I moved SleepAsAndroid to Support
nitanmarcel marked this conversation as resolved
@ -480,3 +493,2 @@
developer.add(R.xml.devicesettings_wifi_hotspot);
}
if (supportsFtpServer(device)) {
if (supportsWifiHotspot(device)) {
Member

Any reason to move the wifi hotspot? I think it makes sense to keep separate from ftp server.

Any reason to move the wifi hotspot? I think it makes sense to keep separate from ftp server.
nitanmarcel marked this conversation as resolved
@ -0,0 +15,4 @@
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Member

I think we should just ignore the action here if sleep as android is disabled in preferences.

I think we should just ignore the action here if sleep as android is disabled in preferences.
nitanmarcel marked this conversation as resolved
@ -870,0 +972,4 @@
}
private void setSleepAsAndroidAlarm(int hour, int minute, boolean enabled) {
Alarm alarm = new Alarm() {
Member

Instead of this class, you can use AlarmUtils.createSingleShot

Instead of this class, you can use `AlarmUtils.createSingleShot`
Author
Contributor

Is there a way to trigger an alarm without setting one?

I used createSignleShot instead of manually creating the Alarm object

Is there a way to trigger an alarm without setting one? I used createSignleShot instead of manually creating the Alarm object
Member

I don't think all devices support it, setting an alarm is probably the most supported way

I don't think all devices support it, setting an alarm is probably the most supported way
Author
Contributor

I don't think all devices support it, setting an alarm is probably the most supported way

Yeah I've noticed in AlarmClockReceiver that it sends a notification of type GENERIC_ALARM_CLOCK but it acts as an notification for my device.

> I don't think all devices support it, setting an alarm is probably the most supported way Yeah I've noticed in AlarmClockReceiver that it sends a notification of type GENERIC_ALARM_CLOCK but it acts as an notification for my device.
Author
Contributor

Alarms will be a little weird. At least on mi band 7 due to limitations.

On device that supports it, should be better to use START_ALARM and STOP_ALARM to give more control over alarms.

Currently Mi Band 7 will know when an alarm was set but not when was disabled.

Alarms will be a little weird. At least on mi band 7 due to limitations. On device that supports it, should be better to use START_ALARM and STOP_ALARM to give more control over alarms. Currently Mi Band 7 will know when an alarm was set but not when was disabled.
Member

I don't understand the problem - do you need to know on the phone when the alarm was stopped, or to notify the band from the phone that it should stop?

I don't understand the problem - do you need to know on the phone when the alarm was stopped, or to notify the band from the phone that it should stop?
@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
Member

This file is not needed, right?

This file is not needed, right?
nitanmarcel marked this conversation as resolved
@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
Member

This file is not needed, right?

This file is not needed, right?
nitanmarcel marked this conversation as resolved
@ -2792,2 +2792,4 @@
<string name="pref_speak_notifications_aloud_title">Speak Notifications Aloud</string>
<string name="pref_header_calls_and_notifications">Calls and notifications</string>
<string name="sleepasandroid_settings">Sleep As Android</string>
<string name="pref_sleepasandroid_enable_title">Enable</string>
Member

Can you re-use function_enabled?

Can you re-use `function_enabled`?
nitanmarcel marked this conversation as resolved
@ -0,0 +6,4 @@
android:title="@string/pref_header_general"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="true"
Member

I think this should be disabled by default, as it can leak data without the user being aware otherwise.

I think this should be disabled by default, as it can leak data without the user being aware otherwise.
nitanmarcel marked this conversation as resolved
@ -0,0 +7,4 @@
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_key_sleepasandroid_enable"
Member

Actually, I don't see this preference being used anywhere 🤔 did I miss it?

Actually, I don't see this preference being used anywhere 🤔 did I miss it?
nitanmarcel marked this conversation as resolved
nitanmarcel added 9 commits 2024-04-18 11:06:41 +00:00
nitanmarcel added 1 commit 2024-04-18 13:29:00 +00:00
Some checks are pending
ci/woodpecker/pr/can_master_build Pipeline is pending approval
ci/woodpecker/pr/run_lint Pipeline is pending approval
ci/woodpecker/pr/run_tests Pipeline is pending approval
5e67ae9346
sleepasandroid: Add note on alarms in zeppos implementation
joserebelo reviewed 2024-04-18 19:37:58 +00:00
@ -589,0 +594,4 @@
@Override
public Set<SleepAsAndroidFeature> getSleepAsAndroidFeatures() {
return null;
Member

nulls are evil, I'd prefer return Collections.emptySet();

nulls are evil, I'd prefer `return Collections.emptySet();`
nitanmarcel marked this conversation as resolved
nitanmarcel added 1 commit 2024-04-18 19:43:51 +00:00
Some checks are pending
ci/woodpecker/pr/can_master_build Pipeline is pending approval
ci/woodpecker/pr/run_lint Pipeline is pending approval
ci/woodpecker/pr/run_tests Pipeline is pending approval
9a7c6c79e4
sleepasandroid: replace null return with empty set in getSleepAsAndroidFeatures method
Signed-off-by: Marcel Alexandru Nitan <nitan.marcel@protonmail.com>
joserebelo reviewed 2024-04-18 19:44:26 +00:00
@ -0,0 +16,4 @@
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (GBApplication.getPrefs().getBoolean("pref_key_sleepasandroid_enable", true)) {
Member

The default should be false here.

The default should be false here.
nitanmarcel marked this conversation as resolved
nitanmarcel added 1 commit 2024-04-18 19:49:12 +00:00
Some checks are pending
ci/woodpecker/pr/can_master_build Pipeline is pending approval
ci/woodpecker/pr/run_lint Pipeline is pending approval
ci/woodpecker/pr/run_tests Pipeline is pending approval
f350566d4b
sleepasandroid: set pref_key_sleepasandroid_enable to false as default value
Signed-off-by: Marcel Alexandru Nitan <nitan.marcel@protonmail.com>
nitanmarcel force-pushed sleep_as_android from f350566d4b to 00e45f2737 2024-04-18 20:40:18 +00:00 Compare
joserebelo reviewed 2024-04-19 17:26:08 +00:00
@ -0,0 +108,4 @@
int maxAlarmSlots = device.getDeviceCoordinator().getAlarmSlotCount(device);
if (maxAlarmSlots > 0) {
List<String> alarmSlots = new ArrayList<>();
int reservedAlarmSlot = GBApplication.getPrefs().getInt(DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR, 0);
Member

This preference is the number of slots reserved, not the slot index.

for (int i = reservedAlarmSlot; i < maxAlarmSlots; i++) {

This preference is the number of slots reserved, not the slot index. `for (int i = reservedAlarmSlot; i < maxAlarmSlots; i++) {`
Author
Contributor

I hope I got it correctly now.

I hope I got it correctly now.
nitanmarcel marked this conversation as resolved
joserebelo reviewed 2024-04-19 17:29:10 +00:00
@ -0,0 +77,4 @@
* @return
*/
public boolean isFeatureEnabled(SleepAsAndroidFeature feature) {
boolean enabled = true;
Member

I think we should return false right away here if pref_key_sleepasandroid_enable is false - this disables all features / every function here.

I think we should return false right away here if `pref_key_sleepasandroid_enable` is false - this disables all features / every function here.
nitanmarcel marked this conversation as resolved
joserebelo reviewed 2024-04-19 17:31:54 +00:00
joserebelo left a comment
Member

Apologies - 2 last comments and I believe this should be good to go.

Apologies - 2 last comments and I believe this should be good to go.
Member

@nitanmarcel What do you think are the minimum requirements for a device to support sleep as android? For instance my device reports only minutely heart rate and steps, but not real-time and no raw movement sensor data. I'd like to know whether it would be worth the effort to try to add support for it.

@nitanmarcel What do you think are the minimum requirements for a device to support sleep as android? For instance my device reports only minutely heart rate and steps, but not real-time and no raw movement sensor data. I'd like to know whether it would be worth the effort to try to add support for it.
Author
Contributor

@nitanmarcel What do you think are the minimum requirements for a device to support sleep as android? For instance my device reports only minutely heart rate and steps, but not real-time and no raw movement sensor data. I'd like to know whether it would be worth the effort to try to add support for it.

Raw sensors are a must for Sleep as Android, you can get away without the other ones.

Doesn't support or it's not implemented yet in Gadgetbridge?

> @nitanmarcel What do you think are the minimum requirements for a device to support sleep as android? For instance my device reports only minutely heart rate and steps, but not real-time and no raw movement sensor data. I'd like to know whether it would be worth the effort to try to add support for it. Raw sensors are a must for Sleep as Android, you can get away without the other ones. Doesn't support or it's not implemented yet in Gadgetbridge?
Member

Two other things:

  1. Would you mind squashing the commits before merge (or that I squash the commits when merging)?
  2. From https://docs.sleep.urbandroid.org/devs/wearable_api.html, we need to ask Sleep as Android to whitelist the Gadgetbridge package - we need to whitelist the mainline, bangle, and all nighties. Will you take care of this once merged (or did you already?)
Two other things: 1. Would you mind squashing the commits before merge (or that I squash the commits when merging)? 2. From https://docs.sleep.urbandroid.org/devs/wearable_api.html, we need to ask Sleep as Android to whitelist the Gadgetbridge package - we need to whitelist the mainline, bangle, and all nighties. Will you take care of this once merged (or did you already?)
Author
Contributor

Two other things:

  1. Would you mind squashing the commits before merge (or that I squash the commits when merging)?
  2. From https://docs.sleep.urbandroid.org/devs/wearable_api.html, we need to ask Sleep as Android to whitelist the Gadgetbridge package - we need to whitelist the mainline, bangle, and all nighties.

Yeah, I did that with the other commits.

  1. We should wait for release, or ask them to add the nightly if you want. For now Gadgetbridge works if you use the DYI wearable and use the gadgetbridge package name. No idea if this works with the nightly one because of the whitelist thing.
> Two other things: > > 1. Would you mind squashing the commits before merge (or that I squash the commits when merging)? > 2. From https://docs.sleep.urbandroid.org/devs/wearable_api.html, we need to ask Sleep as Android to whitelist the Gadgetbridge package - we need to whitelist the mainline, bangle, and all nighties. Yeah, I did that with the other commits. 2. We should wait for release, or ask them to add the nightly if you want. For now Gadgetbridge works if you use the DYI wearable and use the gadgetbridge package name. No idea if this works with the nightly one because of the whitelist thing.
Author
Contributor

The non nightly package might have worked because Gadgetbridge is used by pebble so I assume it's whitelisted now that I look at it

The non nightly package might have worked because Gadgetbridge is used by pebble so I assume it's whitelisted now that I look at it
Author
Contributor

@nitanmarcel What do you think are the minimum requirements for a device to support sleep as android? For instance my device reports only minutely heart rate and steps, but not real-time and no raw movement sensor data. I'd like to know whether it would be worth the effort to try to add support for it.

Actually you might be able to get away without realtime raw sensors. I don't think Sleep as Android will detect deep sleep and such but for tracking the HR might work.

> @nitanmarcel What do you think are the minimum requirements for a device to support sleep as android? For instance my device reports only minutely heart rate and steps, but not real-time and no raw movement sensor data. I'd like to know whether it would be worth the effort to try to add support for it. Actually you might be able to get away without realtime raw sensors. I don't think Sleep as Android will detect deep sleep and such but for tracking the HR might work.
nitanmarcel force-pushed sleep_as_android from 00e45f2737 to 2190c82ed7 2024-04-20 09:17:00 +00:00 Compare
joserebelo merged commit 2190c82ed7 into master 2024-04-20 10:59:02 +00:00
Member

Gave this a quick smoke test, seems to work fine (at least data seems to flow :))

I have also added a small page to the website in 8e6faaa7ca, feel free to add any more info if you want.

Thanks!

Gave this a quick smoke test, seems to work fine (at least data seems to flow :)) I have also added a small page to the website in https://codeberg.org/Freeyourgadget/website/commit/8e6faaa7ca30925563a73a06ff99d360d85fae2a, feel free to add any more info if you want. Thanks!
First-time contributor

Nice that the implementation of Sleep as Android is available.

Does this only work with Zepp devices?

Nice that the implementation of Sleep as Android is available. Does this only work with Zepp devices?
Member

@skdubg yup, this implementation only covers Zepp OS, although it shouldn't be too hard to add support to other devices that can provide the same data.

@skdubg yup, this implementation only covers Zepp OS, although it shouldn't be too hard to add support to other devices that can provide the same data.
First-time contributor

maybe there is someone who can do this for Xiaomi protobuf devices 🙂

maybe there is someone who can do this for Xiaomi protobuf devices 🙂
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Freeyourgadget/Gadgetbridge#3687
No description provided.