Skip to content

Commit dfb0b4c

Browse files
committed
Fix README
1 parent 95608f7 commit dfb0b4c

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

README.rst

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ To install in a virtual environment in your current project:
7171
Usage Examples
7272
==============
7373

74-
See `examples/ble_file_transfer_simpletest.py` for a client example. A stub server implementation is in `examples/ble_file_transfer_stub_server.py`.
74+
See `examples/ble_file_transfer_simpletest.py <examples/ble_file_transfer_simpletest.py>`_ for a client example. A stub server implementation is in `examples/ble_file_transfer_stub_server.py <examples/ble_file_transfer_stub_server.py>`_.
7575

7676
Protocol
7777
=========
@@ -81,45 +81,45 @@ The file transfer protocol is meant to be simple and easy to implement. It uses
8181
GATT Service
8282
--------------
8383

84-
The UUID of the service is `0xfebb`, Adafruit's 16-bit service UUID.
84+
The UUID of the service is ``0xfebb``, Adafruit's 16-bit service UUID.
8585

86-
The base UUID used in characteristics is `ADAFxxxx-4669-6C65-5472-616E73666572`. The 16-bit numbers below are substituted into the `xxxx` portion.
86+
The base UUID used in characteristics is ``ADAFxxxx-4669-6C65-5472-616E73666572``. The 16-bit numbers below are substituted into the ``xxxx`` portion.
8787

8888
The service has two characteristics:
8989

90-
* version (`0x0100`) - Simple unsigned 32-bit integer version number. Always 1.
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.
90+
* version (``0x0100``) - Simple unsigned 32-bit integer version number. Always 1.
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.
9292

9393
Commands
9494
---------
9595

9696
Commands always start with a fixed header. The first entry is always the command number itself encoded in a single byte. The number of subsequent entries in the header will vary by command. The entire header must be sent as a unit so set the characteristic with the full header packet. You can combine multiple commands into a single write as long as the complete header is in the packet.
9797

98-
Paths use `/` as a separator and full paths must start with `/`. Directory paths
99-
must end with `/` when provided as a full path.
98+
Paths use ``/`` as a separator and full paths must start with ``/``. Directory paths
99+
must end with ``/`` when provided as a full path.
100100

101101
All numbers are unsigned.
102102

103103
All values are aligned with respect to the start of the packet.
104104

105-
Status bytes are `0x01` for OK and `0x02` for error. Other values for error may be used for specific commands.
105+
Status bytes are ``0x01`` for OK and ``0x02`` for error. Other values for error may be used for specific commands.
106106

107-
`0x10` - Read a file
108-
++++++++++++++++++++
107+
``0x10`` - Read a file
108+
++++++++++++++++++++++
109109

110110
Given a full path, returns the full contents of the file.
111111

112112
The header is four fixed entries and a variable length path:
113113

114-
* Command: Single byte. Always `0x10`.
114+
* Command: Single byte. Always ``0x10``.
115115
* 1 Byte reserved for padding.
116116
* Path length: 16-bit number encoding the encoded length of the path string.
117117
* Chunk offset: 32-bit number encoding the offset into the file to start the first chunk.
118118
* Chunk size: 32-bit number encoding the amount of data that the client can handle in the first reply.
119119
* Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.)
120120

121121
The server will respond with:
122-
* Command: Single byte. Always `0x11`.
122+
* Command: Single byte. Always ``0x11``.
123123
* Status: Single byte.
124124
* 2 Bytes reserved for padding.
125125
* Chunk offset: 32-bit number encoding the offset into the file of this chunk.
@@ -128,40 +128,40 @@ The server will respond with:
128128
* Chunk-length contents of the file starting from the current position.
129129

130130
If the chunk length is smaller than the total length, then the client will request more data by sending:
131-
* Command: Single byte. Always `0x12`.
131+
* Command: Single byte. Always ``0x12``.
132132
* Status: Single byte. Always OK for now.
133133
* 2 Bytes reserved for padding.
134134
* Chunk offset: 32-bit number encoding the offset into the file to start the next chunk.
135135
* Chunk size: 32-bit number encoding the number of bytes to read. May be different than the original size. Does not need to be limited by the total size.
136136

137137
The transaction is complete after the server has replied with all data. (No acknowledgement needed from the client.)
138138

139-
`0x20` - Write a file
140-
+++++++++++++++++++++
139+
``0x20`` - Write a file
140+
+++++++++++++++++++++++
141141

142142
Writes the content to the given full path. If the file exists, it will be overwritten. Content may be written as received so an interrupted transfer may lead to a truncated file.
143143

144144
Offset larger than the existing file size will introduce zeros into the gap.
145145

146146
The header is four fixed entries and a variable length path:
147147

148-
* Command: Single byte. Always `0x20`.
148+
* Command: Single byte. Always ``0x20``.
149149
* 1 Byte reserved for padding.
150150
* Path length: 16-bit number encoding the encoded length of the path string.
151151
* Offset: 32-bit number encoding the starting offset to write.
152152
* Total size: 32-bit number encoding the total length of the file contents.
153153
* Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.)
154154

155155
The server will repeatedly respond until the total length has been transferred with:
156-
* Command: Single byte. Always `0x21`.
157-
* Status: Single byte. `0x01` if OK. `0x02` if any parent directory is missing or a file.
156+
* Command: Single byte. Always ``0x21``.
157+
* Status: Single byte. ``0x01`` if OK. ``0x02`` if any parent directory is missing or a file.
158158
* 2 Bytes reserved for padding.
159159
* Offset: 32-bit number encoding the starting offset to write. (Should match the offset from the previous 0x20 or 0x22 message)
160160
* Free space: 32-bit number encoding the amount of data the client can send.
161161

162162
The client will repeatedly respond until the total length has been transferred with:
163-
* Command: Single byte. Always `0x22`.
164-
* Status: Single byte. Always `0x01` for OK.
163+
* Command: Single byte. Always ``0x22``.
164+
* Status: Single byte. Always ``0x01`` for OK.
165165
* 2 Bytes reserved for padding.
166166
* Offset: 32-bit number encoding the offset to write.
167167
* Data size: 32-bit number encoding the amount of data the client is sending.
@@ -170,61 +170,63 @@ The client will repeatedly respond until the total length has been transferred w
170170
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.
171171

172172

173-
`0x30` - Delete a file or directory
174-
+++++++++++++++++++++++++++++++++++
173+
``0x30`` - Delete a file or directory
174+
+++++++++++++++++++++++++++++++++++++
175175

176176
Deletes the file or directory at the given full path. Directories must be empty to be deleted.
177177

178178
The header is two fixed entries and a variable length path:
179179

180-
* Command: Single byte. Always `0x30`.
180+
* Command: Single byte. Always ``0x30``.
181181
* 1 Byte reserved for padding.
182182
* Path length: 16-bit number encoding the encoded length of the path string.
183183
* Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.)
184184

185185
The server will reply with:
186-
* Command: Single byte. Always `0x31`.
187-
* Status: Single byte. `0x01` if the file or directory was deleted or `0x02` if the path is a non-empty directory or non-existent.
186+
* Command: Single byte. Always ``0x31``.
187+
* Status: Single byte. ``0x01`` if the file or directory was deleted or ``0x02`` if the path is a non-empty directory or non-existent.
188188

189-
`0x40` - Make a directory
190-
+++++++++++++++++++++++++
189+
``0x40`` - Make a directory
190+
+++++++++++++++++++++++++++
191191

192192
Creates a new directory at the given full path. If a parent directory does not exist, then it will also be created. If any name conflicts with an existing file, an error will be returned.
193193

194194
The header is two fixed entries and a variable length path:
195195

196-
* Command: Single byte. Always `0x40`.
196+
* Command: Single byte. Always ``0x40``.
197197
* 1 Byte reserved for padding.
198198
* Path length: 16-bit number encoding the encoded length of the path string.
199199
* Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.)
200200

201201
The server will reply with:
202-
* Command: Single byte. Always `0x41`.
203-
* Status: Single byte. `0x01` if the directory(s) were created or `0x02` if any parent of the path is an existing file.
202+
* Command: Single byte. Always ``0x41``.
203+
* Status: Single byte. ``0x01`` if the directory(s) were created or ``0x02`` if any parent of the path is an existing file.
204204

205-
`0x50` - List a directory
206-
+++++++++++++++++++++++++
205+
``0x50`` - List a directory
206+
+++++++++++++++++++++++++++
207207

208208
Lists all of the contents in a directory given a full path. Returned paths are *relative* to the given path to reduce duplication.
209209

210210
The header is two fixed entries and a variable length path:
211211

212-
* Command: Single byte. Always `0x50`.
212+
* Command: Single byte. Always ``0x50``.
213213
* 1 Byte reserved for padding.
214214
* Path length: 16-bit number encoding the encoded length of the path string.
215215
* Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.)
216216

217217
The server will reply with n+1 entries for a directory with n files:
218-
* Command: Single byte. Always `0x51`.
219-
* Status: Single byte. `0x01` if the directory exists or `0x02` if it doesn't.
218+
* Command: Single byte. Always ``0x51``.
219+
* Status: Single byte. ``0x01`` if the directory exists or ``0x02`` if it doesn't.
220220
* Path length: 16-bit number encoding the encoded length of the path string.
221221
* Entry number: 32-bit number encoding the entry number.
222222
* Total entries: 32-bit number encoding the total number of entries.
223223
* Flags: 32-bit number encoding data about the entries.
224+
224225
- Bit 0: Set when the entry is a directory
225226
- Bits 1-7: Reserved
227+
226228
* File size: 32-bit number encoding the size of the file. Ignore for directories. Value may change.
227-
* Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.) These paths are relative so they won't contain `/` at all.
229+
* Path: UTF-8 encoded string that is *not* null terminated. (We send the length instead.) These paths are relative so they won't contain ``/`` at all.
228230

229231
The transaction is complete when the final entry is sent from the server. It will have entry number == total entries and zeros for flags, file size and path length.
230232

0 commit comments

Comments
 (0)