You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+26-24Lines changed: 26 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,15 @@ The service has two characteristics:
90
90
* version (``0x0100``) - Simple unsigned 32-bit integer version number. May be 1 or 2.
91
91
* raw transfer (``0x0200``) - Bidirectional link with a custom protocol. The client does WRITE_NO_RESPONSE to the characteristic and then server replies via NOTIFY. (This is similar to the Nordic UART Service but on a single characteristic rather than two.) The commands over the transfer characteristic are idempotent and stateless. A disconnect during a command will reset the state.
92
92
93
+
Time resolution
94
+
---------------
95
+
96
+
Time resolution varies based filesystem type. FATFS can only get down to the 2 second bound after 1980. Littlefs can do 64-bit nanoseconds after January 1st, 1970.
97
+
98
+
To account for this, the protocol has time in 64-bit nanoseconds after January 1st, 1970. However, the server will respond with a potentially truncated version that is the value stored.
99
+
100
+
Also note that devices serving the file transfer protocol may not have it's own clock so do not rely on time ordering. Any internal writes may set the time incorrectly. So, we only recommend using the value as a cache key.
101
+
93
102
Commands
94
103
---------
95
104
@@ -150,7 +159,7 @@ The header is four fixed entries and a variable length path:
150
159
* Path length: 16-bit number encoding the encoded length of the path string.
151
160
* Offset: 32-bit number encoding the starting offset to write.
152
161
* Total size: 32-bit number encoding the total length of the file contents.
153
-
* Current time: 64-bit number encoding nanoseconds since January 1st, 1970. Used as the file modification time. Not all system will s
162
+
* Current time: 64-bit number encoding nanoseconds since January 1st, 1970. Used as the file modification time. Not all system will support the full resolution. Use the truncated time response value for caching.
154
163
* Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.)
155
164
156
165
The server will repeatedly respond until the total length has been transferred with:
@@ -159,6 +168,7 @@ The server will repeatedly respond until the total length has been transferred w
159
168
* 2 Bytes reserved for padding.
160
169
* Offset: 32-bit number encoding the starting offset to write. (Should match the offset from the previous 0x20 or 0x22 message)
161
170
* Free space: 32-bit number encoding the amount of data the client can send.
171
+
* Truncated time: 64-bit number encoding nanoseconds since January 1st, 1970 as stored by the file system. The resolution may be less that the protocol. It is sent back for use in caching on the host side.
162
172
163
173
The client will repeatedly respond until the total length has been transferred with:
164
174
* Command: Single byte. Always ``0x22``.
@@ -170,16 +180,7 @@ The client will repeatedly respond until the total length has been transferred w
170
180
171
181
The transaction is complete after the server has received all data and replied with a status with 0 free space and offset set to the content length.
172
182
173
-
**NOTE**: Current time was added in version 2. The rest of the packets remained the same.
174
-
175
-
Time resolution
176
-
~~~~~~~~~~~~~~~
177
-
178
-
Time resolution varies based filesystem type. FATFS can only get down to the 2 second bound after 1980. Littlefs can do 64-bit nanoseconds after Jan 1, 1970.
179
-
180
-
What do you want to do?
181
-
* We could either return the stored time when doing a write.
182
-
* We could add file system info command that has the smallest resolution in units of 64-bit nanoseconds. This command could to total filesystem size and free space as well.
183
+
**NOTE**: Current time was added in version 3. The rest of the packets remained the same.
183
184
184
185
185
186
``0x30`` - Delete a file or directory
@@ -210,11 +211,14 @@ The header is two fixed entries and a variable length path:
210
211
* Command: Single byte. Always ``0x40``.
211
212
* 1 Byte reserved for padding.
212
213
* Path length: 16-bit number encoding the encoded length of the path string.
214
+
* Current time: 64-bit number encoding nanoseconds since January 1st, 1970. Used as the file modification time. Not all system will support the full resolution. Use the truncated time response value for caching.
213
215
* Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.)
214
216
215
217
The server will reply with:
216
218
* Command: Single byte. Always ``0x41``.
217
219
* Status: Single byte. ``0x01`` if the directory(s) were created or ``0x02`` if any parent of the path is an existing file.
220
+
* 2 Bytes reserved for padding.
221
+
* Truncated time: 64-bit number encoding nanoseconds since January 1st, 1970 as stored by the file system. The resolution may be less that the protocol. It is sent back for use in caching on the host side.
218
222
219
223
``0x50`` - List a directory
220
224
+++++++++++++++++++++++++++
@@ -252,39 +256,37 @@ Moves a file or directory at a given path to a different path. Can be used to
252
256
rename as well. The two paths are sent separately so that they are not limited
253
257
by internal packet buffer sizes differently from other commands.
254
258
255
-
**TODO** Maybe we do pack two paths in one packet. That will limit path length
256
-
but prevent any secondary storage internally.
257
-
258
259
The header is two fixed entries and a variable length path:
259
260
260
261
* Command: Single byte. Always ``0x60``.
261
262
* 1 Byte reserved for padding.
262
263
* Old Path length: 16-bit number encoding the encoded length of the path string.
263
-
* Old Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.)
264
-
265
-
The server will reply with:
266
-
* Command: Single byte. Always ``0x61``.
267
-
* Status: Single byte. ``0x01`` on success or ``0x02`` if the old path is too long for internal buffers.
268
-
269
-
* Command: Single byte. Always ``0x62``.
270
-
* 1 Byte reserved for padding.
271
264
* New Path length: 16-bit number encoding the encoded length of the path string.
265
+
* Old Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.)
272
266
* New Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.)
273
267
274
268
The server will reply with:
275
-
* Command: Single byte. Always ``0x63``.
269
+
* Command: Single byte. Always ``0x61``.
276
270
* Status: Single byte. ``0x01`` on success or ``0x02`` on error.
277
271
272
+
**NOTE**: This is added in version 4.
273
+
278
274
Versions
279
275
=========
280
276
281
277
Version 2
282
278
---------
279
+
* Changes delete to delete contents of non-empty directories automatically.
283
280
281
+
Version 3
282
+
---------
284
283
* Adds modification time.
285
284
* Adds current time to file write command.
285
+
* Adds current time to make directory command.
286
286
* Adds modification time to directory listing entries.
287
-
* Changes delete to delete non-empty directories automatically.
0 commit comments