introduce global var device clientId
This commit is contained in:
parent
bad60592c3
commit
5777df2c48
@ -127,6 +127,7 @@ extern std::array<uint64_t, 0xff>::iterator it;
|
|||||||
extern std::array<uint64_t, 0xff> beacons;
|
extern std::array<uint64_t, 0xff> beacons;
|
||||||
|
|
||||||
extern configData_t cfg; // current device configuration
|
extern configData_t cfg; // current device configuration
|
||||||
|
extern char clientId[20]; // unique clientID
|
||||||
extern char lmic_event_msg[LMIC_EVENTMSG_LEN]; // display buffer
|
extern char lmic_event_msg[LMIC_EVENTMSG_LEN]; // display buffer
|
||||||
extern uint8_t volatile channel; // wifi channel rotation counter
|
extern uint8_t volatile channel; // wifi channel rotation counter
|
||||||
extern uint8_t volatile rf_load; // RF traffic indicator
|
extern uint8_t volatile rf_load; // RF traffic indicator
|
||||||
|
@ -76,14 +76,6 @@ void IRAM_ATTR watchdog() { xTaskResumeFromISR(RestartHandle); }
|
|||||||
|
|
||||||
void start_boot_menu(void) {
|
void start_boot_menu(void) {
|
||||||
|
|
||||||
uint8_t mac[6];
|
|
||||||
char clientId[20];
|
|
||||||
|
|
||||||
// hash 6 byte MAC to 4 byte hash
|
|
||||||
esp_eth_get_mac(mac);
|
|
||||||
const uint32_t hashedmac = myhash((const char *)mac, 6);
|
|
||||||
snprintf(clientId, 20, "paxcounter_%08x", hashedmac);
|
|
||||||
|
|
||||||
const char *host = clientId;
|
const char *host = clientId;
|
||||||
const char *ssid = WIFI_SSID;
|
const char *ssid = WIFI_SSID;
|
||||||
const char *password = WIFI_PASS;
|
const char *password = WIFI_PASS;
|
||||||
|
@ -91,6 +91,7 @@ configData_t cfg; // struct holds current device configuration
|
|||||||
char lmic_event_msg[LMIC_EVENTMSG_LEN]; // display buffer for LMIC event message
|
char lmic_event_msg[LMIC_EVENTMSG_LEN]; // display buffer for LMIC event message
|
||||||
uint8_t batt_level = 0; // display value
|
uint8_t batt_level = 0; // display value
|
||||||
uint8_t volatile rf_load = 0; // RF traffic indicator
|
uint8_t volatile rf_load = 0; // RF traffic indicator
|
||||||
|
char clientId[20] = {0}; // unique ClientID
|
||||||
|
|
||||||
hw_timer_t *ppsIRQ = NULL, *displayIRQ = NULL, *matrixDisplayIRQ = NULL;
|
hw_timer_t *ppsIRQ = NULL, *displayIRQ = NULL, *matrixDisplayIRQ = NULL;
|
||||||
|
|
||||||
@ -137,6 +138,14 @@ void setup() {
|
|||||||
// load device configuration from NVRAM and set runmode
|
// load device configuration from NVRAM and set runmode
|
||||||
do_after_reset();
|
do_after_reset();
|
||||||
|
|
||||||
|
// hash 6 byte device MAC to 4 byte clientID
|
||||||
|
uint8_t mac[6];
|
||||||
|
esp_eth_get_mac(mac);
|
||||||
|
const uint32_t hashedmac = myhash((const char *)mac, 6);
|
||||||
|
snprintf(clientId, 20, "paxcounter_%08x", hashedmac);
|
||||||
|
ESP_LOGI(TAG, "Starting %s v%s (runmode=%d / restarts=%d)", clientId,
|
||||||
|
PROGVERSION, RTC_runmode, RTC_restarts);
|
||||||
|
|
||||||
// print chip information on startup if in verbose mode after coldstart
|
// print chip information on startup if in verbose mode after coldstart
|
||||||
#if (VERBOSE)
|
#if (VERBOSE)
|
||||||
|
|
||||||
|
@ -42,14 +42,8 @@ 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;
|
|
||||||
uint8_t mac[6];
|
|
||||||
char clientId[20];
|
|
||||||
|
|
||||||
// hash 6 byte MAC to 4 byte hash
|
IPAddress mqtt_server_ip;
|
||||||
esp_eth_get_mac(mac);
|
|
||||||
const uint32_t hashedmac = myhash((const char *)mac, 6);
|
|
||||||
snprintf(clientId, 20, "paxcounter_%08x", hashedmac);
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "MQTT name is %s", MQTT_CLIENTNAME);
|
ESP_LOGI(TAG, "MQTT name is %s", MQTT_CLIENTNAME);
|
||||||
|
|
||||||
|
@ -42,13 +42,6 @@ inline String getHeaderValue(String header, String headerName) {
|
|||||||
|
|
||||||
void start_ota_update() {
|
void start_ota_update() {
|
||||||
|
|
||||||
uint8_t mac[6];
|
|
||||||
char clientId[20];
|
|
||||||
|
|
||||||
// hash 6 byte MAC to 4 byte hash
|
|
||||||
esp_eth_get_mac(mac);
|
|
||||||
const uint32_t hashedmac = myhash((const char *)mac, 6);
|
|
||||||
snprintf(clientId, 20, "paxcounter_%08x", hashedmac);
|
|
||||||
const char *host = clientId;
|
const char *host = clientId;
|
||||||
|
|
||||||
switch_LED(LED_ON);
|
switch_LED(LED_ON);
|
||||||
|
@ -88,9 +88,6 @@ void do_after_reset(void) {
|
|||||||
RTC_restarts++;
|
RTC_restarts++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Starting Software v%s (runmode=%d / restarts=%d)", PROGVERSION,
|
|
||||||
RTC_runmode, RTC_restarts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void enter_deepsleep(const uint64_t wakeup_sec, gpio_num_t wakeup_gpio) {
|
void enter_deepsleep(const uint64_t wakeup_sec, gpio_num_t wakeup_gpio) {
|
||||||
|
Loading…
Reference in New Issue
Block a user