Added FUSE support #55

Merged
Elara6331 merged 65 commits from yannickulrich/itd:fuse into master 2023-03-25 22:23:52 +00:00
1 changed files with 31 additions and 32 deletions
Showing only changes of commit 2440cb954c - Show all commits

63
fuse.go
View File

@ -90,14 +90,7 @@ type ITNode struct {
path string
}
var properties = []ITProperty {
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 properties = make([]ITProperty, 6)
var myfs *blefs.FS = 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")).
Send()
properties[0].gen = func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchHeartRate(ctx)
return converterU8(ctx, ans), err
}
properties[1].gen = func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchBatteryLevel(ctx)
return converterU8(ctx, ans), err
}
properties[2].gen = func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchMotion(ctx)
return converterMotionValues(ctx, ans), err
}
properties[3].gen = func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchStepCount(ctx)
return converterU32(ctx, ans), err
}
properties[4].gen = func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.Version()
return converter1String(ctx, ans), err
}
properties[5].gen = func(ctx context.Context) (<-chan []byte, error) {
ans := dev.Address()
return converter1String(ctx, ans), nil
}
properties[0] = ITProperty{"heartrate", 2,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchHeartRate(ctx)
return converterU8(ctx, ans), err
}}
properties[1] = ITProperty{"battery", 3,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchBatteryLevel(ctx)
return converterU8(ctx, ans), err
}}
properties[2] = ITProperty{"motion", 4,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchMotion(ctx)
return converterMotionValues(ctx, ans), err
}}
properties[3] = ITProperty{"stepcount", 5,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.WatchStepCount(ctx)
return converterU32(ctx, ans), err
}}
properties[4] = ITProperty{"version", 6,
func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.Version()
return converter1String(ctx, ans), err
}}
properties[5] = ITProperty{"address", 7,
func(ctx context.Context) (<-chan []byte, error) {
ans := dev.Address()
return converter1String(ctx, ans), nil
}}
myfs, err = dev.FS()
if err != nil {