Merge pull request #695 from cyberman54/development

Development
This commit is contained in:
Verkehrsrot 2020-12-27 00:41:47 +01:00 committed by GitHub
commit 6b67fedfb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 4 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);
}

View File

@ -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

View File

@ -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(&ETH.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