Added oneshot property to ITProperty

This commit is contained in:
Yannick Ulrich 2023-03-12 12:43:42 +00:00
parent 84c7a33c40
commit c5a6e0d298

View File

@ -15,6 +15,7 @@ import (
type ITProperty struct {
name string
Ino uint64
oneshot bool
gen func(context.Context) (<-chan []byte, error)
}
@ -54,32 +55,37 @@ func BuildRootNode(dev *infinitime.Device) (*ITNode, error) {
var properties = make([]ITProperty, 6)
func BuildProperties(dev *infinitime.Device) {
properties[0] = ITProperty{"heartrate", 2,
properties[0] = ITProperty{"heartrate", 2, true,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchHeartRate(ctx)
return converterU8(ctx, ans), err
}}
properties[1] = ITProperty{"battery", 3,
properties[1] = ITProperty{"battery", 3, true,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchBatteryLevel(ctx)
return converterU8(ctx, ans), err
}}
properties[2] = ITProperty{"motion", 4,
properties[2] = ITProperty{"motion", 4, true,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchMotion(ctx)
return converterMotionValues(ctx, ans), err
}}
properties[3] = ITProperty{"stepcount", 5,
properties[3] = ITProperty{"motion", 5, true,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchMotion(ctx)
return converterMotionValues(ctx, ans), err
}}
properties[4] = ITProperty{"stepcount", 6, true,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchStepCount(ctx)
return converterU32(ctx, ans), err
}}
properties[4] = ITProperty{"version", 6,
properties[5] = ITProperty{"version", 7, true,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.Version()
return converter1String(ctx, ans), err
}}
properties[5] = ITProperty{"address", 7,
properties[6] = ITProperty{"address", 8, true,
func(ctx context.Context) (<-chan []byte, error) {
ans := dev.Address()
return converter1String(ctx, ans), nil