Added FUSE support #55

Merged
Elara6331 merged 65 commits from yannickulrich/itd:fuse into master 2023-03-25 22:23:52 +00:00
Showing only changes of commit c5a6e0d298 - Show all commits

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) {
yannickulrich marked this conversation as resolved Outdated

These variables should go above BuildRootNode because it's using them and it would be more readable that way. Also, Go doesn't require semicolons, you can remove those.

These variables should go above `BuildRootNode` because it's using them and it would be more readable that way. Also, Go doesn't require semicolons, you can remove those.

Done in 673383f

Done in 673383f
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