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 ffe9d43cf8 - Show all commits

43
fuse.go
View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"go.arsenm.dev/infinitime"
"go.arsenm.dev/logger/log" "go.arsenm.dev/logger/log"
"os" "os"
"context" "context"
@ -10,28 +11,32 @@ import (
"strconv" "strconv"
) )
func (i *Device) HeartRateBytes() ([]byte, error) { type Device struct {
v, err := i.HeartRate() dev *infinitime.Device
}
func (i Device) HeartRateBytes() ([]byte, error) {
v, err := i.dev.HeartRate()
return []byte(strconv.Itoa(int(v)) + "\n"), err return []byte(strconv.Itoa(int(v)) + "\n"), err
} }
func (i *Device) BatteryLevelBytes() ([]byte, error) { func (i Device) BatteryLevelBytes() ([]byte, error) {
v, err := i.BatteryLevel() v, err := i.dev.BatteryLevel()
return []byte(strconv.Itoa(int(v)) + "\n"), err return []byte(strconv.Itoa(int(v)) + "\n"), err
} }
func (i *Device) StepCountBytes() ([]byte, error) { func (i Device) StepCountBytes() ([]byte, error) {
v, err := i.StepCount() v, err := i.dev.StepCount()
return []byte(strconv.Itoa(int(v)) + "\n"), err return []byte(strconv.Itoa(int(v)) + "\n"), err
} }
func (i *Device) MotionBytes() ([]byte, error) { func (i Device) MotionBytes() ([]byte, error) {
v, err := i.Motion() v, err := i.dev.Motion()
return []byte(strconv.Itoa(int(v.X)) + " " + strconv.Itoa(int(v.Y)) + " " + strconv.Itoa(int(v.Z)) + "\n"), err return []byte(strconv.Itoa(int(v.X)) + " " + strconv.Itoa(int(v.Y)) + " " + strconv.Itoa(int(v.Z)) + "\n"), err
} }
func (i *Device) AddressBytes() ([]byte, error) { func (i Device) AddressBytes() ([]byte, error) {
v := i.Address() v := i.dev.Address()
return []byte(v + "\n"), nil return []byte(v + "\n"), nil
} }
func (i *Device) VersionBytes() ([]byte, error) { func (i Device) VersionBytes() ([]byte, error) {
v, err := i.Version() v, err := i.dev.Version()
return []byte(v + "\n"), err return []byte(v + "\n"), err
} }
@ -507,12 +512,14 @@ func startFuse(ctx context.Context, dev *infinitime.Device) error {
Str("target", mntDir). Str("target", mntDir).
Send() Send()
properties[0].f = dev.HeartRateBytes; mydev := Device{dev : dev};
properties[1].f = dev.BatteryLevelBytes;
properties[2].f = dev.MotionBytes; properties[0].f = mydev.HeartRateBytes;
properties[3].f = dev.StepCountBytes; properties[1].f = mydev.BatteryLevelBytes;
properties[4].f = dev.VersionBytes; properties[2].f = mydev.MotionBytes;
properties[5].f = dev.AddressBytes; properties[3].f = mydev.StepCountBytes;
properties[4].f = mydev.VersionBytes;
properties[5].f = mydev.AddressBytes;
myfs = &FS{}; myfs = &FS{};
inodemap = make(map[string]uint64) inodemap = make(map[string]uint64)