mkpine.github.io-pine

BLE FS


The BLE FS protocol in InfiniTime is mostly Adafruit’s BLE file transfer protocol, as described in adafruit/Adafruit_CircuitPython_BLE_File_Transfer. There are some deviations, such as the status codes. These will be described later in the document.


UUIDs

There are two relevant UUIDs in this protocol: the version characteristic, and the raw transfer characteristic.

Version

UUID: adaf0100-4669-6c65-5472-616e73666572

The version characteristic returns the version of the protocol to which the sender adheres. It returns a single unsigned 32-bit integer. The latest version at the time of writing this is 4.

Transfer

UUID: adaf0200-4669-6c65-5472-616e73666572

The transfer characteristic is responsible for all the data transfer between the client and the watch. It supports write and notify. Writing a packet on the characteristic results in a response via notify.


Usage

The separator for paths is /, and absolute paths must start with /.

All of the following commands and responses are transferred via the transfer characteristic

Read file

To begin reading a file, a header must first be sent. The header packet should be formatted like so:

To continue reading the file after this initial packet, the following packet should be sent until all the data has been received. No close command is required after the data has been received.

Both of these commands receive the following response:

Write file

To begin writing to a file, a header must first be sent. The header packet should be formatted like so:

To continue reading the file after this initial packet, the following packet should be sent until all the data has been sent and a response had been received with 0 free space. No close command is required after the data has been received.

Both of these commands receive the following response:

Delete file

The response to this packet will be as follows:

Make directory

The response to this packet will be as follows:

List directory

Paths returned by this command are relative to the path given in the request

The response to this packet will be as follows. Responses will be sent until the final entry, which will have entry number == total entries

Move file or directory

The response to this packet will be as follows:


Deviations

This section describes the differences between Adafruit’s spec and InfiniTime’s implementation.

Status codes

The status codes returned by InfiniTime are a signed 8-bit integer, rather than an unsigned one as described in the spec.

InfiniTime uses LittleFS error codes rather than the ones described in the spec. Those codes can be found in lfs.h.