blefs

package
v0.0.0-...-d41922d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FSStatusOk    = 0x01
	FSStatusError = 0x02
)
View Source
const (
	FSCmdReadFile  = 0x10
	FSCmdDataReq   = 0x12
	FSCmdWriteFile = 0x20
	FSCmdTransfer  = 0x22
	FSCmdDelete    = 0x30
	FSCmdMkdir     = 0x40
	FSCmdListDir   = 0x50
	FSCmdMove      = 0x60
)

Filesystem command

View Source
const (
	FSResponseReadFile  = 0x11
	FSResponseWriteFile = 0x21
	FSResponseDelete    = 0x31
	FSResponseMkdir     = 0x41
	FSResponseListDir   = 0x51
	FSResponseMove      = 0x61
)

Filesystem response

Variables

View Source
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")
)
View Source
var (
	ErrFSUnexpectedResponse = errors.New("unexpected response returned by filesystem")
	ErrFSResponseTimeout    = errors.New("timed out waiting for response")
	ErrFSError              = errors.New("error reported by filesystem")
)

Functions

This section is empty.

Types

type DirEntry

type DirEntry struct {
	// contains filtered or unexported fields
}

DirEntry represents an entry from a directory listing

func (DirEntry) Info

func (de DirEntry) Info() (fs.FileInfo, error)

Info returns the FileInfo for the file or subdirectory described by the entry.

func (DirEntry) IsDir

func (de DirEntry) IsDir() bool

IsDir reports whether the entry describes a directory.

func (DirEntry) Name

func (de DirEntry) Name() string

Name returns the name of the file described by the entry

func (DirEntry) String

func (de DirEntry) String() string

func (DirEntry) Type

func (de DirEntry) Type() fs.FileMode

Type returns the type bits for the entry.

type FS

type FS struct {
	// contains filtered or unexported fields
}

FS implements the fs.FS interface for the Adafruit BLE FS protocol

func New

func New(transfer *gatt.GattCharacteristic1) (*FS, error)

New creates a new fs given the transfer characteristic

func (*FS) Close

func (blefs *FS) Close() error

func (*FS) Create

func (blefs *FS) Create(path string, size uint32) (*File, error)

Create makes a new file on the BLE file system and returns it.

func (*FS) GoFS

func (blefs *FS) GoFS() fs.FS

func (*FS) Mkdir

func (blefs *FS) Mkdir(path string) error

Mkdir creates a directory at the given path

func (*FS) MkdirAll

func (blefs *FS) MkdirAll(path string) error

func (*FS) Open

func (blefs *FS) Open(path string) (*File, error)

Open opens a file and returns it as an fs.File to satisfy the fs.FS interface

func (*FS) ReadDir

func (blefs *FS) ReadDir(path string) ([]fs.DirEntry, error)

ReadDir returns a list of directory entries from the given path

func (*FS) Remove

func (blefs *FS) Remove(path string) error

Remove removes a file or directory

func (*FS) RemoveAll

func (blefs *FS) RemoveAll(path string) error

func (*FS) Rename

func (blefs *FS) Rename(old, new string) error

Rename moves or renames a file or directory

func (*FS) Stat

func (blefs *FS) Stat(path string) (fs.FileInfo, error)

Stat does a ReadDir() and finds the current file in the output

type FSError

type FSError struct {
	Code int8
}

FSError represents an error returned by BLE FS

func (FSError) Error

func (err FSError) Error() string

Error returns the string associated with the error code

type File

type File struct {
	// contains filtered or unexported fields
}

File represents a file on the BLE filesystem

func (*File) Close

func (fl *File) Close() error

Close must be called before opening another file

func (*File) Progress

func (file *File) Progress() <-chan uint32

Progress returns a channel that receives the amount of bytes sent as they are sent

func (*File) Read

func (fl *File) Read(b []byte) (n int, err error)

Read reads data from a file into b

func (*File) Seek

func (fl *File) Seek(offset int64, whence int) (int64, error)

Seek changes the offset of the file being read/written. This can only be done once in between reads/writes.

func (*File) Size

func (file *File) Size() uint32

Size returns the total size of the opened file

func (*File) Stat

func (fl *File) Stat() (fs.FileInfo, error)

Stat does a ReadDir() and finds the current file in the output

func (*File) Write

func (fl *File) Write(b []byte) (n int, err error)

Write writes data from b into a file on the BLE filesysyem

func (*File) WriteString

func (fl *File) WriteString(s string) (n int, err error)

WriteString converts the string to []byte and calls Write()

type FileInfo

type FileInfo struct {
	// contains filtered or unexported fields
}

FileInfo implements fs.FileInfo

func (FileInfo) IsDir

func (fi FileInfo) IsDir() bool

IsDir returns whether the file is a directory

func (FileInfo) ModTime

func (fi FileInfo) ModTime() time.Time

ModTime returns the modification time of the file As of now, this is unimplemented in InfiniTime, and will always return 0.

func (FileInfo) Mode

func (fi FileInfo) Mode() fs.FileMode

Mode returns the mode of the file

func (FileInfo) Name

func (fi FileInfo) Name() string

Name returns the base name of the file

func (FileInfo) Size

func (fi FileInfo) Size() int64

Size returns the total size of the file

func (FileInfo) Sys

func (fi FileInfo) Sys() interface{}

Sys is unimplemented and returns nil

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL