itd/api/get.go

42 lines
1.0 KiB
Go
Raw Permalink Normal View History

2022-04-23 00:12:30 +00:00
package api
import (
2022-05-01 22:22:28 +00:00
"context"
2023-04-21 02:54:58 +00:00
"go.elara.ws/itd/internal/rpc"
2022-04-23 00:12:30 +00:00
)
2023-01-03 06:30:17 +00:00
func (c *Client) HeartRate(ctx context.Context) (uint8, error) {
res, err := c.client.HeartRate(ctx, &rpc.Empty{})
return uint8(res.Value), err
2022-04-23 00:12:30 +00:00
}
2023-01-03 06:30:17 +00:00
func (c *Client) BatteryLevel(ctx context.Context) (uint8, error) {
res, err := c.client.BatteryLevel(ctx, &rpc.Empty{})
return uint8(res.Value), err
2022-04-23 00:12:30 +00:00
}
2023-01-03 06:30:17 +00:00
type MotionValues struct {
X, Y, Z int16
}
func (c *Client) Motion(ctx context.Context) (MotionValues, error) {
res, err := c.client.Motion(ctx, &rpc.Empty{})
return MotionValues{int16(res.X), int16(res.Y), int16(res.Z)}, err
2022-04-23 00:12:30 +00:00
}
2022-05-01 22:22:28 +00:00
func (c *Client) StepCount(ctx context.Context) (out uint32, err error) {
2023-01-03 06:30:17 +00:00
res, err := c.client.StepCount(ctx, &rpc.Empty{})
return res.Value, err
2022-04-23 00:12:30 +00:00
}
2022-05-01 22:22:28 +00:00
func (c *Client) Version(ctx context.Context) (out string, err error) {
2023-01-03 06:30:17 +00:00
res, err := c.client.Version(ctx, &rpc.Empty{})
return res.Value, err
2022-04-23 00:12:30 +00:00
}
2022-05-01 22:22:28 +00:00
func (c *Client) Address(ctx context.Context) (out string, err error) {
2023-01-03 06:30:17 +00:00
res, err := c.client.Address(ctx, &rpc.Empty{})
return res.Value, err
2022-04-23 00:12:30 +00:00
}