Implement BLE filesystem (experimental and will change in the future)
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/muka/go-bluetooth/bluez/profile/adapter"
|
||||
"github.com/muka/go-bluetooth/bluez/profile/device"
|
||||
"github.com/muka/go-bluetooth/bluez/profile/gatt"
|
||||
"go.arsenm.dev/infinitime/blefs"
|
||||
)
|
||||
|
||||
const BTName = "InfiniTime"
|
||||
@@ -24,6 +25,8 @@ const (
|
||||
CurrentTimeChar = "00002a2b-0000-1000-8000-00805f9b34fb"
|
||||
BatteryLvlChar = "00002a19-0000-1000-8000-00805f9b34fb"
|
||||
HeartRateChar = "00002a37-0000-1000-8000-00805f9b34fb"
|
||||
FSTransferChar = "adaf0200-4669-6c65-5472-616e73666572"
|
||||
FSVersionChar = "adaf0100-4669-6c65-5472-616e73666572"
|
||||
)
|
||||
|
||||
type Device struct {
|
||||
@@ -37,6 +40,8 @@ type Device struct {
|
||||
currentTimeChar *gatt.GattCharacteristic1
|
||||
battLevelChar *gatt.GattCharacteristic1
|
||||
heartRateChar *gatt.GattCharacteristic1
|
||||
fsVersionChar *gatt.GattCharacteristic1
|
||||
fsTransferChar *gatt.GattCharacteristic1
|
||||
onReconnect func()
|
||||
Music MusicCtrl
|
||||
DFU DFU
|
||||
@@ -311,6 +316,10 @@ func (i *Device) resolveChars() error {
|
||||
i.DFU.ctrlPointChar = char
|
||||
case DFUPacketChar:
|
||||
i.DFU.packetChar = char
|
||||
case FSTransferChar:
|
||||
i.fsTransferChar = char
|
||||
case FSVersionChar:
|
||||
i.fsVersionChar = char
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -642,3 +651,8 @@ func (i *Device) NotifyCall(from string) (<-chan uint8, error) {
|
||||
}()
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// FS creates and returns a new filesystem from the device
|
||||
func (i *Device) FS() (*blefs.FS, error) {
|
||||
return blefs.New(i.fsTransferChar)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user