diff --git a/include/mgos_bt.h b/include/mgos_bt.h index d03592c..480d33a 100644 --- a/include/mgos_bt.h +++ b/include/mgos_bt.h @@ -71,6 +71,8 @@ const char *mgos_bt_uuid_to_str(const struct mgos_bt_uuid *uuid, char *out); bool mgos_bt_uuid_from_str(const struct mg_str str, struct mgos_bt_uuid *uuid); int mgos_bt_uuid_cmp(const struct mgos_bt_uuid *a, const struct mgos_bt_uuid *b); +void mgos_bt_uuid128_from_bytes(const uint8_t *bytes, bool reverse, + struct mgos_bt_uuid *uuid); void mgos_event_trigger_schedule(int ev, const void *ev_data, size_t data_len); diff --git a/src/mgos_bt.c b/src/mgos_bt.c index b9a951c..ab64274 100644 --- a/src/mgos_bt.c +++ b/src/mgos_bt.c @@ -111,6 +111,14 @@ bool mgos_bt_uuid_from_str(const struct mg_str str, struct mgos_bt_uuid *uuid) { return result; } +void mgos_bt_uuid128_from_bytes(const uint8_t *bytes, bool reverse, + struct mgos_bt_uuid *uuid) { + uuid->len = 16; + for (int i = 0; i < 16; i++) { + uuid->uuid.uuid128[i] = bytes[reverse ? 15 - i : i]; + } +} + int mgos_bt_uuid_cmp(const struct mgos_bt_uuid *a, const struct mgos_bt_uuid *b) { int result = 0;