1#include "main-header.h"
8int adr_isvalid(
long a) {
20long adr_create_new_node_id() {
29 if (strlen(buf) != 17) {
30 printf(
"Invalid mac: \"%s\" (%i length)\r\n", buf, (
int)strlen(buf));
31 for (i = 0; i < 17; i++) {
37 mculib_mcu_get_unique_id(&ln, &buf);
44 for (i = 0; i < ln; i++) {
46 c = c + db[i] + rseed;
48 printf(
" == %i\r\n", c);
49 res = (c & 0xFF00) >> 8;
50 res = res | (c & 0xFF);
54 for (i = 0; i < 6; i++) {
55 z = z ^ (db[i] + rseed);
58 res = res + mculib_get_seconds_since_boot() + get_systickctr();
61 if (adr_isvalid(res)) {
67void node_to_str(
long l,
char *buf) {
71void pretty_node_to_str(
long l,
char *buf) {
76 if (l == 0x00000001) {
78 }
else if (l == 0xFFFFFFFF) {
86 memcpy(buf, t, strlen(t));
90void print_node_id(
long l) {
93 node_to_str(l, (
char *)&buf);
95 IPLOG(
"[%D] NODE-ID: %s\r\n", mculib_get_seconds_since_boot(), (
char *)&buf);
long get_my_node_id()
get the id of my node
int esp_get_mac(char *buf, int bufsize)
get the esp8266 mac address.