itd/api/watch.go

82 lines
1.2 KiB
Go
Raw Normal View History

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