commit
6b67fedfb3
@ -4,6 +4,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
uint32_t IRAM_ATTR rokkit(const char *data, int len);
|
||||
uint32_t IRAM_ATTR hash(const char *data, int len);
|
||||
|
||||
#endif
|
@ -17,7 +17,7 @@
|
||||
#define MQTT_KEEPALIVE 10 // keep alive interval in seconds
|
||||
|
||||
#ifndef MQTT_CLIENTNAME
|
||||
#define MQTT_CLIENTNAME clientId.c_str()
|
||||
#define MQTT_CLIENTNAME clientId
|
||||
#endif
|
||||
|
||||
extern TaskHandle_t mqttTask;
|
||||
|
@ -85,3 +85,7 @@ uint32_t IRAM_ATTR rokkit(const char *data, int len) {
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
uint32_t IRAM_ATTR hash(const char *data, int len) {
|
||||
return rokkit(data, len);
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ uint16_t mac_analyze(MacBuffer_t MacBuffer) {
|
||||
snprintf(buff, sizeof(buff), "%08X",
|
||||
*mac + (uint32_t)salt); // convert unsigned 32-bit salted MAC
|
||||
// to 8 digit hex string
|
||||
uint16_t hashedmac = rokkit(&buff[3], 5); // hash MAC 8 digit -> 5 digit
|
||||
uint16_t hashedmac = hash(&buff[3], 5); // hash MAC 8 digit -> 5 digit
|
||||
auto newmac = macs.insert(hashedmac); // add hashed MAC, if new unique
|
||||
bool added =
|
||||
newmac.second ? true : false; // true if hashed MAC is unique in container
|
||||
|
@ -41,7 +41,10 @@ esp_err_t mqtt_init(void) {
|
||||
|
||||
int mqtt_connect(const char *my_host, const uint16_t my_port) {
|
||||
IPAddress mqtt_server_ip;
|
||||
static String clientId = "paxcounter-" + ETH.macAddress();
|
||||
const uint16_t hashed = hash(Ð.macAddress()[0], 4); // hash MAC to 4 digits
|
||||
char clientId[16];
|
||||
snprintf(clientId, 16, "paxcounter_%d", hashed);
|
||||
|
||||
ESP_LOGI(TAG, "MQTT name is %s", MQTT_CLIENTNAME);
|
||||
|
||||
// resolve server host name
|
||||
|
Loading…
Reference in New Issue
Block a user