11// SPDX-License-Identifier: MIT
2- // Copyright (c) 2021-2022 The Pybricks Authors
2+ // Copyright (c) 2021-2023 The Pybricks Authors
33
44/**
5- * @addtogroup ProtocolPybricks pbio/protocol: Pybricks Communication Protocol
5+ * @addtogroup ProtocolPybricks pbio/protocol: Pybricks Communication Profile
66 *
77 * Additional details about the Pybricks Profile can be found at
88 * <https://github.com/pybricks/technical-info/blob/master/pybricks-ble-profile.md>.
2424#define PBIO_PROTOCOL_VERSION_MAJOR 1
2525
2626/** The minor version number for the protocol. */
27- #define PBIO_PROTOCOL_VERSION_MINOR 2
27+ #define PBIO_PROTOCOL_VERSION_MINOR 3
2828
2929/** The patch version number for the protocol. */
3030#define PBIO_PROTOCOL_VERSION_PATCH 0
@@ -48,7 +48,7 @@ typedef enum {
4848 /**
4949 * Requests that the user program should be stopped.
5050 *
51- * @since Protocol v1.0.0
51+ * @since Pybricks Profile v1.0.0
5252 */
5353 PBIO_PYBRICKS_COMMAND_STOP_USER_PROGRAM = 0 ,
5454
@@ -58,7 +58,7 @@ typedef enum {
5858 * Errors:
5959 * - ::PBIO_PYBRICKS_ERROR_BUSY if another program is already running.
6060 *
61- * @since Protocol v1.2.0
61+ * @since Pybricks Profile v1.2.0
6262 */
6363 PBIO_PYBRICKS_COMMAND_START_USER_PROGRAM = 1 ,
6464
@@ -68,7 +68,7 @@ typedef enum {
6868 * Errors:
6969 * - ::PBIO_PYBRICKS_ERROR_BUSY if another program is already running.
7070 *
71- * @since Protocol v1.2.0
71+ * @since Pybricks Profile v1.2.0
7272 */
7373 PBIO_PYBRICKS_COMMAND_START_REPL = 2 ,
7474
@@ -81,7 +81,7 @@ typedef enum {
8181 * Errors:
8282 * - ::PBIO_PYBRICKS_ERROR_BUSY if the user program is running.
8383 *
84- * @since Protocol v1.2.0
84+ * @since Pybricks Profile v1.2.0
8585 */
8686 PBIO_PYBRICKS_COMMAND_WRITE_USER_PROGRAM_META = 3 ,
8787
@@ -96,7 +96,7 @@ typedef enum {
9696 * - ::PBIO_PYBRICKS_ERROR_BUSY if the user program is running and the
9797 * data would write over the user program area of the user RAM.
9898 *
99- * @since Protocol v1.2.0
99+ * @since Pybricks Profile v1.2.0
100100 */
101101 PBIO_PYBRICKS_COMMAND_WRITE_USER_RAM = 4 ,
102102
@@ -106,8 +106,22 @@ typedef enum {
106106 * If this command was successful, the hub will reboot immediately, which
107107 * means the GATT write request will fail because Bluetooth became
108108 * disconnected.
109+ *
110+ * @since Pybricks Profile v1.2.0
109111 */
110112 PBIO_PYBRICKS_COMMAND_REBOOT_TO_UPDATE_MODE = 5 ,
113+
114+ /**
115+ * Requests to write to stdin on the hub.
116+ *
117+ * It is up to the firmware to determine what to with the received data.
118+ *
119+ * Parameters:
120+ * - payload: The data to write (0 to 512 bytes).
121+ *
122+ * @since Pybricks Profile v1.3.0
123+ */
124+ PBIO_PYBRICKS_COMMAND_WRITE_STDIN = 6 ,
111125} pbio_pybricks_command_t ;
112126
113127/**
@@ -128,13 +142,13 @@ typedef enum {
128142 /**
129143 * An invalid command was requested.
130144 *
131- * @since Protocol v1.2.0
145+ * @since Pybricks Profile v1.2.0
132146 */
133147 PBIO_PYBRICKS_ERROR_INVALID_COMMAND = 0x80 ,
134148 /**
135149 * The command cannot be completed now because the required resources are busy.
136150 *
137- * @since Protocol v1.2.0
151+ * @since Pybricks Profile v1.2.0
138152 */
139153 PBIO_PYBRICKS_ERROR_BUSY = 0x81 ,
140154} pbio_pybricks_error_t ;
@@ -148,14 +162,23 @@ pbio_pybricks_error_t pbio_pybricks_error_from_pbio_error(pbio_error_t error);
148162 */
149163typedef enum {
150164 /**
151- * Status report.
165+ * Status report event .
152166 *
153167 * The payload is a 32-bit little-endian unsigned integer containing
154168 * ::pbio_pybricks_status_t flags.
155169 *
156- * @since Protocol v1.0.0
170+ * @since Pybricks Profile v1.0.0
157171 */
158172 PBIO_PYBRICKS_EVENT_STATUS_REPORT = 0 ,
173+
174+ /**
175+ * Data written to stdout event.
176+ *
177+ * The payload is a variable number of bytes that was written to stdout.
178+ *
179+ * @since Pybricks Profile v1.3.0
180+ */
181+ PBIO_PYBRICKS_EVENT_WRITE_STDOUT = 1 ,
159182} pbio_pybricks_event_t ;
160183
161184/**
@@ -167,55 +190,55 @@ typedef enum {
167190 /**
168191 * Battery voltage is low.
169192 *
170- * @since Protocol v1.0.0
193+ * @since Pybricks Profile v1.0.0
171194 */
172195 PBIO_PYBRICKS_STATUS_BATTERY_LOW_VOLTAGE_WARNING = 0 ,
173196 /**
174197 * Battery voltage is critically low.
175198 *
176- * @since Protocol v1.0.0
199+ * @since Pybricks Profile v1.0.0
177200 */
178201 PBIO_PYBRICKS_STATUS_BATTERY_LOW_VOLTAGE_SHUTDOWN = 1 ,
179202 /**
180203 * Battery current is too high.
181204 *
182- * @since Protocol v1.0.0
205+ * @since Pybricks Profile v1.0.0
183206 */
184207 PBIO_PYBRICKS_STATUS_BATTERY_HIGH_CURRENT = 2 ,
185208 /**
186209 * Bluetooth Low Energy is advertising/discoverable.
187210 *
188- * @since Protocol v1.0.0
211+ * @since Pybricks Profile v1.0.0
189212 */
190213 PBIO_PYBRICKS_STATUS_BLE_ADVERTISING = 3 ,
191214 /**
192215 * Bluetooth Low Energy has low signal.
193216 *
194- * @since Protocol v1.0.0
217+ * @since Pybricks Profile v1.0.0
195218 */
196219 PBIO_PYBRICKS_STATUS_BLE_LOW_SIGNAL = 4 ,
197220 /**
198221 * Power button is currently pressed.
199222 *
200- * @since Protocol v1.0.0
223+ * @since Pybricks Profile v1.0.0
201224 */
202225 PBIO_PYBRICKS_STATUS_POWER_BUTTON_PRESSED = 5 ,
203226 /**
204227 * User program is currently running.
205228 *
206- * @since Protocol v1.0.0
229+ * @since Pybricks Profile v1.0.0
207230 */
208231 PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING = 6 ,
209232 /**
210233 * Hub will shut down.
211234 *
212- * @since Protocol v1.1.0
235+ * @since Pybricks Profile v1.1.0
213236 */
214237 PBIO_PYBRICKS_STATUS_SHUTDOWN = 7 ,
215238 /**
216239 * Hub shutdown has been requested. System processes may now stop.
217240 *
218- * @since Protocol v1.2.0
241+ * @since Pybricks Profile v1.2.0
219242 */
220243 PBIO_PYBRICKS_STATUS_SHUTDOWN_REQUEST = 8 ,
221244 /** Total number of indications. */
@@ -274,9 +297,6 @@ extern const uint8_t pbio_nus_service_uuid[];
274297extern const uint8_t pbio_nus_rx_char_uuid [];
275298extern const uint8_t pbio_nus_tx_char_uuid [];
276299
277- // Downloaded programs are received in chunks up to this size.
278- #define PBIO_PYBRICKS_PROTOCOL_DOWNLOAD_CHUNK_SIZE (100)
279-
280300#endif // _PBIO_PROTOCOL_H_
281301
282302/** @} */
0 commit comments