2023-02-19 12:59:40 +00:00
|
|
|
package main
|
2023-02-19 13:13:02 +00:00
|
|
|
import (
|
|
|
|
"io/fs"
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ErrFileNotExists = errors.New("file does not exist")
|
|
|
|
ErrFileReadOnly = errors.New("file is read only")
|
|
|
|
ErrFileWriteOnly = errors.New("file is write only")
|
|
|
|
ErrInvalidOffset = errors.New("invalid file offset")
|
|
|
|
ErrOffsetChanged = errors.New("offset has already been changed")
|
|
|
|
ErrReadOpen = errors.New("only one file can be opened for reading at a time")
|
|
|
|
ErrWriteOpen = errors.New("only one file can be opened for writing at a time")
|
|
|
|
ErrNoRemoveRoot = errors.New("refusing to remove root directory")
|
|
|
|
)
|
2023-02-19 12:59:40 +00:00
|
|
|
|
|
|
|
type Device struct {
|
2023-02-19 13:13:02 +00:00
|
|
|
}
|
|
|
|
type FS struct {
|
|
|
|
}
|
2023-02-19 12:59:40 +00:00
|
|
|
|
2023-02-19 13:13:02 +00:00
|
|
|
|
|
|
|
type File struct {
|
|
|
|
fs *FS
|
|
|
|
path string
|
|
|
|
offset uint32
|
|
|
|
offsetCh chan uint32
|
|
|
|
length uint32
|
|
|
|
amtLeft uint32
|
|
|
|
amtTferd uint32
|
|
|
|
isReadOnly bool
|
|
|
|
isWriteOnly bool
|
|
|
|
offsetChanged bool
|
2023-02-19 12:59:40 +00:00
|
|
|
}
|
|
|
|
|
2023-02-19 13:13:02 +00:00
|
|
|
|
|
|
|
|
2023-02-19 12:59:40 +00:00
|
|
|
func (i *Device) HeartRate() (uint8, error) {
|
|
|
|
return 10, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *Device) BatteryLevel() (uint8, error) {
|
|
|
|
return 95, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *Device) StepCount() (uint32, error) {
|
|
|
|
return 27000, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type MotionValues struct {
|
|
|
|
X int16
|
|
|
|
Y int16
|
|
|
|
Z int16
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *Device) Motion() (MotionValues, error) {
|
|
|
|
return MotionValues{-12, +64, -19}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *Device) Address() string {
|
|
|
|
return "FA:E4:00:00:00:00"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *Device) Version() (string, error) {
|
|
|
|
return "1.11.0", nil
|
|
|
|
}
|
2023-02-19 13:13:02 +00:00
|
|
|
|
|
|
|
func (blefs *FS) ReadDir(path string) ([]fs.DirEntry, error) {
|
|
|
|
var out []fs.DirEntry
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (blefs *FS) Mkdir(path string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (blefs *FS) Stat(path string) (fs.FileInfo, error) {
|
|
|
|
return nil, ErrFileNotExists
|
|
|
|
}
|
|
|
|
|
|
|
|
func (blefs *FS) Rename(old, new string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (blefs *FS) Remove(path string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (blefs *FS) Open(path string) (*File, error) {
|
|
|
|
return &File{}, nil
|
|
|
|
}
|
|
|
|
func (blefs *FS) Create(path string, size uint32) (*File, error) {
|
|
|
|
return &File{}, nil
|
|
|
|
}
|
|
|
|
func (fl *File) Read(b []byte) (n int, err error) {
|
|
|
|
return 0, ErrFileWriteOnly
|
|
|
|
}
|
|
|
|
func (fl *File) Write(b []byte) (n int, err error) {
|
|
|
|
return 0, ErrFileWriteOnly
|
|
|
|
}
|
|
|
|
func (fl *File) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
// func (fl *File) Stat() (fs.FileInfo, error) {
|
|
|
|
// }
|