forked from Elara6331/itd
Used generator instead of function in ITProperty
This commit is contained in:
parent
4333b83ca2
commit
083da5b3f0
21
fuse.go
21
fuse.go
@ -47,7 +47,7 @@ func (i Device) VersionBytes() ([]byte, error) {
|
|||||||
type ITProperty struct {
|
type ITProperty struct {
|
||||||
name string
|
name string
|
||||||
Ino uint64
|
Ino uint64
|
||||||
f func() ([]byte, error)
|
gen func(context.Context) (<-chan uint8, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -393,13 +393,13 @@ func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle,
|
|||||||
|
|
||||||
for _, value := range properties {
|
for _, value := range properties {
|
||||||
if value.Ino == f.Ino {
|
if value.Ino == f.Ino {
|
||||||
ans, err := value.f()
|
ans, err := value.gen(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, syscall.EROFS
|
return nil, 0, syscall.EROFS
|
||||||
}
|
}
|
||||||
|
|
||||||
fh = &bytesFileReadHandle{
|
fh = &sensorFileReadHandle{
|
||||||
content: ans,
|
ch: ans,
|
||||||
}
|
}
|
||||||
return fh, fuse.FOPEN_DIRECT_IO, 0
|
return fh, fuse.FOPEN_DIRECT_IO, 0
|
||||||
}
|
}
|
||||||
@ -551,12 +551,13 @@ func startFuse(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
|
|
||||||
mydev := Device{dev : dev};
|
mydev := Device{dev : dev};
|
||||||
|
|
||||||
properties[0].f = mydev.HeartRateBytes;
|
properties[0].gen = mydev.dev.WatchHeartRate;
|
||||||
properties[1].f = mydev.BatteryLevelBytes;
|
// properties[0].f = mydev.HeartRateBytes;
|
||||||
properties[2].f = mydev.MotionBytes;
|
// properties[1].f = mydev.BatteryLevelBytes;
|
||||||
properties[3].f = mydev.StepCountBytes;
|
// properties[2].f = mydev.MotionBytes;
|
||||||
properties[4].f = mydev.VersionBytes;
|
// properties[3].f = mydev.StepCountBytes;
|
||||||
properties[5].f = mydev.AddressBytes;
|
// properties[4].f = mydev.VersionBytes;
|
||||||
|
// properties[5].f = mydev.AddressBytes;
|
||||||
|
|
||||||
myfs, err = dev.FS()
|
myfs, err = dev.FS()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user