Skip to content

Feature request on NimBLEUUID #17

@Jeroen88

Description

@Jeroen88

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions