repair convert mac to mqtt clientname
This commit is contained in:
parent
73263c3d04
commit
70150fa606
@ -42,12 +42,12 @@ esp_err_t mqtt_init(void) {
|
|||||||
int mqtt_connect(const char *my_host, const uint16_t my_port) {
|
int mqtt_connect(const char *my_host, const uint16_t my_port) {
|
||||||
IPAddress mqtt_server_ip;
|
IPAddress mqtt_server_ip;
|
||||||
uint8_t mac[6];
|
uint8_t mac[6];
|
||||||
char clientId[16];
|
char clientId[20];
|
||||||
|
|
||||||
// hash 6 digit MAC to 4 digits
|
// hash 6 byte MAC to 4 byte hash
|
||||||
esp_eth_get_mac(mac);
|
esp_eth_get_mac(mac);
|
||||||
const uint16_t hashedmac = hash((const char *)mac, 4);
|
const uint32_t hashedmac = hash((const char *)mac, 6);
|
||||||
snprintf(clientId, 16, "paxcounter_%04x", hashedmac);
|
snprintf(clientId, 20, "paxcounter_%08x", hashedmac);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "MQTT name is %s", MQTT_CLIENTNAME);
|
ESP_LOGI(TAG, "MQTT name is %s", MQTT_CLIENTNAME);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user