Hello ,
I use 'gatts_server_service_table' example as base in my project, I want to make uuid's and characteristic with 16-bit UUID. I tried many solutions I found on this forum, but always UUID is 128-bit (many cases 16-bit inside base_uuid - {0xFB,0x34...})
How i can make 16-bit uuid service?
Thanks, SO
PL
How to create 16-bit UUID's ?
How to create 16-bit UUID's ?
Last edited by rzodkiew on Fri Nov 12, 2021 11:33 am, edited 1 time in total.
Re: How to create 16-bit UUID's ?
many ways to rome
outside of ESP-IDF a few examples
not a complete list, there are many more
online:
https://www.uuidgenerator.net/
github:
https://github.com/typester/esp32-uuid
python 2 and 3
the generation is standard.
uuid1 use time and mac of the pc example, uuid4 use random number
If you want a 16-bit UUID, you have to use a base-uuid, which is fix
more about 16 bit UUIDs example here
for history attached and also here more info
did you look for this one?
or more this, (I don't think so, a completely different topic, but you can combine it with uuid1/uuid4) github: short UUID
edit: add links, attached file
outside of ESP-IDF a few examples
not a complete list, there are many more
online:
https://www.uuidgenerator.net/
github:
https://github.com/typester/esp32-uuid
python 2 and 3
Code: Select all
import uuid
uuid.uuid4()
UUID('xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')
uuid1 use time and mac of the pc example, uuid4 use random number
If you want a 16-bit UUID, you have to use a base-uuid, which is fix
more about 16 bit UUIDs example here
for history attached and also here more info
did you look for this one?
or more this, (I don't think so, a completely different topic, but you can combine it with uuid1/uuid4) github: short UUID
edit: add links, attached file
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Re: How to create 16-bit UUID's ?
Hello,
This is how I solved it using the esp_fill_random(guid.raw, 16) function.
This is how I solved it using the esp_fill_random(guid.raw, 16) function.
Code: Select all
/*
* Guid.h
*
* Created on: 9 Sep 2020
* Author: Bas
*/
#ifndef COMPONENTS_CPP_LIB_MISC_GUID_H_
#define COMPONENTS_CPP_LIB_MISC_GUID_H_
#include <stdint.h>
#include <esp_system.h>
class Guid
{
public:
uint8_t raw[16];
Guid()
{
memset(raw, 0, 16);
}
Guid(uint8_t *data)
{
memcpy(raw, data, 16);
}
bool IsEmpty()
{
bool zero = true;
for(int i=0; i<sizeof(raw); i++)
zero &= raw[i] == 0;
return zero;
}
uint32_t ToArray(uint8_t *data)
{
if(data != NULL)
{
memcpy(data, raw, 16);
}
return 16;
}
static Guid NewGuid()
{
Guid guid;
esp_fill_random(guid.raw, 16);
return guid;
}
std::string ToString()
{
char buff[64];
sprintf(buff, "%x%x%x%x-%x%x-%x%x-%x%x-%x%x%x%x%x%x", raw[0], raw[1], raw[2], raw[3], raw[4], raw[5], raw[6], raw[7], raw[8], raw[9], raw[10], raw[11], raw[12], raw[13], raw[14], raw[15]);
return buff;
}
};
inline bool operator==(Guid const &lhs, Guid const &rhs) { return memcmp(lhs.raw, rhs.raw, sizeof(lhs.raw)) == 0; }
#endif /* COMPONENTS_CPP_LIB_MISC_GUID_H_ */
Re: How to create 16-bit UUID's ?
I found explanation: https://stackoverflow.com/questions/10243769
Who is online
Users browsing this forum: No registered users and 104 guests