2. Inherited from infinitime.Device to extend
This commit is contained in:
parent
ec39e649c5
commit
ffe9d43cf8
43
fuse.go
43
fuse.go
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user