Skip to content

Commit

Permalink
Add mgos_bt_uuid128_from_bytes()
Browse files Browse the repository at this point in the history
  • Loading branch information
rojer committed Jul 4, 2021
1 parent db7ac49 commit eba4842
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/mgos_bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 8 additions & 0 deletions src/mgos_bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit eba4842

Please sign in to comment.