Skip to content

Commit eba4842

Browse files
committed
Add mgos_bt_uuid128_from_bytes()
1 parent db7ac49 commit eba4842

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

include/mgos_bt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ const char *mgos_bt_uuid_to_str(const struct mgos_bt_uuid *uuid, char *out);
7171
bool mgos_bt_uuid_from_str(const struct mg_str str, struct mgos_bt_uuid *uuid);
7272
int mgos_bt_uuid_cmp(const struct mgos_bt_uuid *a,
7373
const struct mgos_bt_uuid *b);
74+
void mgos_bt_uuid128_from_bytes(const uint8_t *bytes, bool reverse,
75+
struct mgos_bt_uuid *uuid);
7476

7577
void mgos_event_trigger_schedule(int ev, const void *ev_data, size_t data_len);
7678

src/mgos_bt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ bool mgos_bt_uuid_from_str(const struct mg_str str, struct mgos_bt_uuid *uuid) {
111111
return result;
112112
}
113113

114+
void mgos_bt_uuid128_from_bytes(const uint8_t *bytes, bool reverse,
115+
struct mgos_bt_uuid *uuid) {
116+
uuid->len = 16;
117+
for (int i = 0; i < 16; i++) {
118+
uuid->uuid.uuid128[i] = bytes[reverse ? 15 - i : i];
119+
}
120+
}
121+
114122
int mgos_bt_uuid_cmp(const struct mgos_bt_uuid *a,
115123
const struct mgos_bt_uuid *b) {
116124
int result = 0;

0 commit comments

Comments
 (0)