Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request on NimBLEUUID #17

Closed
Jeroen88 opened this issue Apr 28, 2020 · 3 comments
Closed

Feature request on NimBLEUUID #17

Jeroen88 opened this issue Apr 28, 2020 · 3 comments

Comments

@Jeroen88
Copy link

Jeroen88 commented Apr 28, 2020

Could you please add to NimBLEUUID.h:

    NimBLEUUID(uint32_t first, uint16_t second, uint16_t third, uint64_t fourth);

and to NimBLEUUID.cpp:

NimBLEUUID::NimBLEUUID(uint32_t first, uint16_t second, uint16_t third, uint64_t fourth) {
    m_uuid.u.type        = BLE_UUID_TYPE_128;
    memcpy(m_uuid.u128.value + 12, &first,  4);
    memcpy(m_uuid.u128.value + 10, &second, 2);
    memcpy(m_uuid.u128.value + 8,  &third,  2);
    memcpy(m_uuid.u128.value,      &fourth, 8);
    m_valueSet = true;
}

This does not save any library memory, but is does save sketch memory. In stead of

BLEUUID("ebe0ccb0-7a0a-4b0c-8a1a-6ff2997da3a6")

you can do

BLEUUID(0xebe0ccb0, 0x7a0a, 0x4b0c, 0x8a1a6ff2997da3a6)

thus trading 37 bytes of the string literal for 16 bytes uint literals, saving 21 bytes per UUID literal!

@h2zero
Copy link
Owner

h2zero commented Apr 28, 2020

Looks good to me, could you make a PR for this?

@Jeroen88
Copy link
Author

Maybe I will make PRs later, for now I just copied the library to my library folder and dit not set up git for it. For now it would be easy if you integrate it :)

Jeroen88 pushed a commit to Jeroen88/NimBLE-Arduino that referenced this issue Apr 28, 2020
@Jeroen88
Copy link
Author

Made PR #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants