summaryrefslogtreecommitdiff
path: root/extmod/modbluetooth.h
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2019-10-16 20:45:44 +1100
committerJim Mussared <jim.mussared@gmail.com>2019-10-22 13:54:05 +1100
commit56fc3edf989e1216b1a00d8ab75ebefff33a67e8 (patch)
tree81e735b387ad79ec9a88ca1f7b76c397f422bc58 /extmod/modbluetooth.h
parentf1d91908fa427cb419d6fcd5f64f6c581a0cdd0f (diff)
extmod/modbluetooth: Make UUID support the buffer protocol.
Internally change the representation of UUIDs to LE uint8* to simplify this. This allows UUIDs to be easily used in BLE payloads (such as advertising). Ref: #5186
Diffstat (limited to 'extmod/modbluetooth.h')
-rw-r--r--extmod/modbluetooth.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/extmod/modbluetooth.h b/extmod/modbluetooth.h
index f7284a43e..e99641e8f 100644
--- a/extmod/modbluetooth.h
+++ b/extmod/modbluetooth.h
@@ -120,14 +120,14 @@ _IRQ_ALL = const(0xffff)
// Common UUID type.
// Ports are expected to map this to their own internal UUID types.
+// Internally the UUID data is little-endian, but the user should only
+// ever see this if they use the buffer protocol, e.g. in order to
+// construct an advertising payload (which needs to be in LE).
+// Both the constructor and the print function work in BE.
typedef struct {
mp_obj_base_t base;
uint8_t type;
- union {
- uint16_t _16;
- uint32_t _32;
- uint8_t _128[16];
- } uuid;
+ uint8_t data[16];
} mp_obj_bluetooth_uuid_t;
//////////////////////////////////////////////////////////////
@@ -140,8 +140,10 @@ typedef struct {
// Any method returning an int returns errno on failure, otherwise zero.
// Note: All methods dealing with addresses (as 6-byte uint8 pointers) are in big-endian format.
-// (i.e. the same way they would be printed on a device sticker or in a UI).
-// This means that the lower level implementation might need to reorder them (e.g. Nimble works in little-endian)
+// (i.e. the same way they would be printed on a device sticker or in a UI), so the user sees
+// addresses in a way that looks like what they'd expect.
+// This means that the lower level implementation will likely need to reorder them (e.g. Nimble
+// works in little-endian, as does BLE itself).
// Enables the Bluetooth stack.
int mp_bluetooth_init(void);