@@ -255,6 +255,12 @@ class StatusFlag(IntFlag):
255255 .. availability:: Since Pybricks protocol v1.2.0.
256256 """
257257
258+ BLE_HOST_CONNECTED = 1 << 9
259+ """Bluetooth Low Energy host is connected.
260+
261+ .. availability:: Since Pybricks protocol v1.4.0.
262+ """
263+
258264
259265class HubCapabilityFlag (IntFlag ):
260266 """
@@ -277,14 +283,36 @@ class HubCapabilityFlag(IntFlag):
277283 .. availability:: Since Pybricks protocol v1.2.0.
278284 """
279285
280- USER_PROG_MULTI_FILE_MPY6_1_NATIVE = 2 << 1
286+ USER_PROG_MULTI_FILE_MPY6_1_NATIVE = 1 << 2
281287 """
282288 Hub supports user programs using a multi-file blob with MicroPython MPY (ABI V6.1) files
283289 including native module support.
284290
285291 .. availability:: Since Pybricks protocol v1.3.0.
286292 """
287293
294+ BUILTIN_USER_PROGRAM_PORT_VIEW = 1 << 3
295+ """
296+ Hub has the built-in user program "port view" feature.
297+
298+ .. availability:: Since Pybricks protocol v1.4.0.
299+ """
300+
301+ BUILTIN_USER_PROGRAM_IMU_CALIBRATION = 1 << 4
302+ """
303+ Hub has the built-in user program "IMU calibration" feature.
304+
305+ .. availability:: Since Pybricks protocol v1.4.0.
306+ """
307+
308+ USER_PROG_FORMAT_MULTI_MPY_V6_3_NATIVE = 1 << 5
309+ """
310+ Hub supports user programs using a multi-file blob with MicroPython MPY (ABI V6.3) files
311+ including native module support.
312+
313+ .. availability:: Since Pybricks protocol v1.5.0.
314+ """
315+
288316
289317def unpack_hub_capabilities (data : bytes ) -> Tuple [int , HubCapabilityFlag , int ]:
290318 """
@@ -295,10 +323,32 @@ def unpack_hub_capabilities(data: bytes) -> Tuple[int, HubCapabilityFlag, int]:
295323
296324 Returns:
297325 A tuple of the maximum characteristic write size in bytes, the hub capability
298- flags and the max user program size in bytes.
326+ flags and the max user program size in bytes and the number of slots.
327+ """
328+ if len (data ) == 11 :
329+ # Pybricks protocol v1.5
330+ max_char_size , flags , max_user_prog_size , num_of_slots = unpack ("<HIIB" , data )
331+ else :
332+ # Pybricks protocol v1.2
333+ max_char_size , flags , max_user_prog_size = unpack ("<HII" , data )
334+ num_of_slots = 0
335+
336+ return max_char_size , HubCapabilityFlag (flags ), max_user_prog_size , num_of_slots
337+
338+
339+ def unpack_hub_capabilities_v15 (data : bytes ) -> Tuple [int , HubCapabilityFlag , int , int ]:
340+ """
341+ Unpacks the value read from the hub capabilities characteristic. (Pybricks protocol v1.5)
342+
343+ Args:
344+ data: The raw characteristic value.
345+
346+ Returns:
347+ A tuple of the maximum characteristic write size in bytes, the hub capability
348+ flags and the max user program size in bytes and the number of slots.
299349 """
300- max_char_size , flags , max_user_prog_size = unpack ("<HII " , data )
301- return max_char_size , HubCapabilityFlag (flags ), max_user_prog_size
350+ max_char_size , flags , max_user_prog_size , num_of_slots = unpack ("<HIIB " , data )
351+ return max_char_size , HubCapabilityFlag (flags ), max_user_prog_size , num_of_slots
302352
303353
304354# The Pybricks Protocol version also implies certain other services and
0 commit comments