Auto Generation of devEUI

I noticed that there isn’t much information on how to dynamically create the devEUI on the Heltec board:

the hard coded devEui:

uint8_t devEui[] = { 0x00, 0x21, 0x24, 0x2A, 0x92, 0xF0, 0xA3, 0x49 };

This is set in the14th line of the script and is needed at start up as a parameter. but this can be changed at setup. As there is no true randomness when randomly generating UUID’s this is my preferred method:

My strategy for getting a unique number was to as follows:
inside of void setup()

Receive the chip ID as a unsigned 32 bit integer with 64 bits of data:

uint64_t chipID=getID();

Then split the Chip ID into two 32 bit guarantee integers:

uint32_t low = chipID % 0xFFFFFFFF;
uint32_t high = (chipID >> 32) % 0xFFFFFFFF;

Then for a extra layer of randomness times the two integers together:

uint32_t CHIP = low*high;

I then split the 32 bit integer into 3 8 bit integers:

uint8_t bytes[3];
bytes[0] = (CHIP >> 0) & 0xFF;
bytes[1] = (CHIP >> 8) & 0xFF;
bytes[2] = (CHIP >> 16) & 0xFF;

I then replace the last 3 bytes of the of uint8_t devEui[] :

devEui[5] = bytes[0];
devEui[6] = bytes[1];
devEui[7] = bytes[2];

You can further the algorithm to include the other 5 bytes but this method means you can have a uniform first 5 bytes when placing the information into the things network.

Hope this Helps!

Jack Bonnell
BNL Consultancy
https://bnlconsultancy.co.uk/

Thank you for your suggestions.

hi,

we have updated Development environment for cubecell.

please git pull

Nice. Thanks for the instruction!! :sunglasses: