Add doc comments to api package

This commit is contained in:
2021-10-22 21:01:18 -07:00
parent 80a5867d6b
commit d7057e3f9c
4 changed files with 37 additions and 0 deletions
+14
View File
@@ -6,6 +6,7 @@ import (
"go.arsenm.dev/itd/internal/types"
)
// Address gets the bluetooth address of the connected device
func (c *Client) Address() (string, error) {
res, err := c.request(types.Request{
Type: types.ReqTypeBtAddress,
@@ -17,6 +18,7 @@ func (c *Client) Address() (string, error) {
return res.Value.(string), nil
}
// Version gets the firmware version of the connected device
func (c *Client) Version() (string, error) {
res, err := c.request(types.Request{
Type: types.ReqTypeFwVersion,
@@ -28,6 +30,7 @@ func (c *Client) Version() (string, error) {
return res.Value.(string), nil
}
// BatteryLevel gets the battery level of the connected device
func (c *Client) BatteryLevel() (uint8, error) {
res, err := c.request(types.Request{
Type: types.ReqTypeBattLevel,
@@ -39,6 +42,8 @@ func (c *Client) BatteryLevel() (uint8, error) {
return uint8(res.Value.(float64)), nil
}
// WatchBatteryLevel returns a channel which will contain
// new battery level values as they update
func (c *Client) WatchBatteryLevel() (<-chan uint8, error) {
c.battLevelCh = make(chan uint8, 2)
err := c.requestNoRes(types.Request{
@@ -50,6 +55,7 @@ func (c *Client) WatchBatteryLevel() (<-chan uint8, error) {
return c.battLevelCh, nil
}
// HeartRate gets the heart rate from the connected device
func (c *Client) HeartRate() (uint8, error) {
res, err := c.request(types.Request{
Type: types.ReqTypeHeartRate,
@@ -61,6 +67,8 @@ func (c *Client) HeartRate() (uint8, error) {
return uint8(res.Value.(float64)), nil
}
// WatchHeartRate returns a channel which will contain
// new heart rate values as they update
func (c *Client) WatchHeartRate() (<-chan uint8, error) {
c.heartRateCh = make(chan uint8, 2)
err := c.requestNoRes(types.Request{
@@ -72,6 +80,7 @@ func (c *Client) WatchHeartRate() (<-chan uint8, error) {
return c.heartRateCh, nil
}
// StepCount gets the step count from the connected device
func (c *Client) StepCount() (uint32, error) {
res, err := c.request(types.Request{
Type: types.ReqTypeStepCount,
@@ -83,6 +92,8 @@ func (c *Client) StepCount() (uint32, error) {
return uint32(res.Value.(float64)), nil
}
// WatchStepCount returns a channel which will contain
// new step count values as they update
func (c *Client) WatchStepCount() (<-chan uint32, error) {
c.stepCountCh = make(chan uint32, 2)
err := c.requestNoRes(types.Request{
@@ -94,6 +105,7 @@ func (c *Client) WatchStepCount() (<-chan uint32, error) {
return c.stepCountCh, nil
}
// Motion gets the motion values from the connected device
func (c *Client) Motion() (infinitime.MotionValues, error) {
out := infinitime.MotionValues{}
res, err := c.request(types.Request{
@@ -109,6 +121,8 @@ func (c *Client) Motion() (infinitime.MotionValues, error) {
return out, nil
}
// WatchMotion returns a channel which will contain
// new motion values as they update
func (c *Client) WatchMotion() (<-chan infinitime.MotionValues, error) {
c.motionCh = make(chan infinitime.MotionValues, 2)
err := c.requestNoRes(types.Request{