Merged two properties lists

This commit is contained in:
Yannick Ulrich 2023-02-26 19:10:47 +00:00
parent 08c8d7e8de
commit 2440cb954c

39
fuse.go
View File

@ -90,14 +90,7 @@ type ITNode struct {
path string path string
} }
var properties = []ITProperty { var properties = make([]ITProperty, 6)
ITProperty{"heartrate", 2, nil},
ITProperty{"battery", 3, nil},
ITProperty{"motion", 4, nil},
ITProperty{"stepcount", 5, nil},
ITProperty{"version", 6, nil},
ITProperty{"address", 7, nil},
}
var myfs *blefs.FS = nil; var myfs *blefs.FS = nil;
var inodemap map[string]uint64 = nil; var inodemap map[string]uint64 = nil;
@ -581,30 +574,36 @@ func startFuse(ctx context.Context, dev *infinitime.Device) error {
Str("target", k.String("fuse.mountpoint")). Str("target", k.String("fuse.mountpoint")).
Send() Send()
properties[0].gen = func(ctx context.Context) (<-chan []byte, error) { properties[0] = ITProperty{"heartrate", 2,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchHeartRate(ctx) ans, err := dev.WatchHeartRate(ctx)
return converterU8(ctx, ans), err return converterU8(ctx, ans), err
} }}
properties[1].gen = func(ctx context.Context) (<-chan []byte, error) { properties[1] = ITProperty{"battery", 3,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchBatteryLevel(ctx) ans, err := dev.WatchBatteryLevel(ctx)
return converterU8(ctx, ans), err return converterU8(ctx, ans), err
} }}
properties[2].gen = func(ctx context.Context) (<-chan []byte, error) { properties[2] = ITProperty{"motion", 4,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchMotion(ctx) ans, err := dev.WatchMotion(ctx)
return converterMotionValues(ctx, ans), err return converterMotionValues(ctx, ans), err
} }}
properties[3].gen = func(ctx context.Context) (<-chan []byte, error) { properties[3] = ITProperty{"stepcount", 5,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchStepCount(ctx) ans, err := dev.WatchStepCount(ctx)
return converterU32(ctx, ans), err return converterU32(ctx, ans), err
} }}
properties[4].gen = func(ctx context.Context) (<-chan []byte, error) { properties[4] = ITProperty{"version", 6,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.Version() ans, err := dev.Version()
return converter1String(ctx, ans), err return converter1String(ctx, ans), err
} }}
properties[5].gen = func(ctx context.Context) (<-chan []byte, error) { properties[5] = ITProperty{"address", 7,
func(ctx context.Context) (<-chan []byte, error) {
ans := dev.Address() ans := dev.Address()
return converter1String(ctx, ans), nil return converter1String(ctx, ans), nil
} }}
myfs, err = dev.FS() myfs, err = dev.FS()
if err != nil { if err != nil {