itd/api/watch.go

72 lines
1.1 KiB
Go
Raw Normal View History

2022-04-23 00:12:30 +00:00
package api
import (
2022-05-01 22:22:28 +00:00
"context"
2022-04-23 00:12:30 +00:00
"go.arsenm.dev/infinitime"
)
2022-05-01 22:22:28 +00:00
func (c *Client) WatchHeartRate(ctx context.Context) (<-chan uint8, error) {
outCh := make(chan uint8, 2)
err := c.client.Call(
2022-05-01 22:22:28 +00:00
ctx,
"ITD",
2022-04-23 00:12:30 +00:00
"WatchHeartRate",
nil,
outCh,
2022-04-23 00:12:30 +00:00
)
if err != nil {
2022-05-01 22:22:28 +00:00
return nil, err
2022-04-23 00:12:30 +00:00
}
2022-05-01 22:22:28 +00:00
return outCh, nil
2022-04-23 00:12:30 +00:00
}
2022-05-01 22:22:28 +00:00
func (c *Client) WatchBatteryLevel(ctx context.Context) (<-chan uint8, error) {
outCh := make(chan uint8, 2)
err := c.client.Call(
2022-05-01 22:22:28 +00:00
ctx,
"ITD",
2022-04-23 00:12:30 +00:00
"WatchBatteryLevel",
nil,
outCh,
2022-04-23 00:12:30 +00:00
)
if err != nil {
2022-05-01 22:22:28 +00:00
return nil, err
2022-04-23 00:12:30 +00:00
}
2022-05-01 22:22:28 +00:00
return outCh, nil
2022-04-23 00:12:30 +00:00
}
2022-05-01 22:22:28 +00:00
func (c *Client) WatchStepCount(ctx context.Context) (<-chan uint32, error) {
outCh := make(chan uint32, 2)
err := c.client.Call(
2022-05-01 22:22:28 +00:00
ctx,
"ITD",
2022-04-23 00:12:30 +00:00
"WatchStepCount",
nil,
outCh,
2022-04-23 00:12:30 +00:00
)
if err != nil {
2022-05-01 22:22:28 +00:00
return nil, err
2022-04-23 00:12:30 +00:00
}
2022-05-01 22:22:28 +00:00
return outCh, nil
2022-04-23 00:12:30 +00:00
}
2022-05-01 22:22:28 +00:00
func (c *Client) WatchMotion(ctx context.Context) (<-chan infinitime.MotionValues, error) {
outCh := make(chan infinitime.MotionValues, 2)
err := c.client.Call(
2022-05-01 22:22:28 +00:00
ctx,
"ITD",
2022-04-23 00:12:30 +00:00
"WatchMotion",
nil,
outCh,
2022-04-23 00:12:30 +00:00
)
if err != nil {
2022-05-01 22:22:28 +00:00
return nil, err
2022-04-23 00:12:30 +00:00
}
2022-05-01 22:22:28 +00:00
return outCh, nil
2022-04-23 00:12:30 +00:00
}