Fix custom hostname (#2)

- Changed HOSTNAME to constant macro definition so it is properly evaluated via #ifdef directive.

- Increased max. hostname length to 24 characters.
This commit is contained in:
hem@hdk 2020-09-23 13:10:11 +02:00 committed by GitHub
parent 4e1dbdd2b0
commit 0c10ef4ba9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -30,7 +30,7 @@ char serialInputHelper[RECV_LINE_SIZE];
int lastCPM = 0, currentCPM = 0;
float lastuSv = 0, currentuSv = 0;
char hostname[16];
char hostname[24];
void setup() {
delay(3000);
@ -55,9 +55,9 @@ void setup() {
#ifdef HOSTNAME
hostname = HOSTNAME;
strncpy(hostname, HOSTNAME, sizeof(hostname));
#else
snprintf(hostname, 24, "GEIGERCTR-%X", chipid);
snprintf(hostname, sizeof(hostname), "GEIGERCTR-%X", chipid);
#endif
#ifdef USE_HA_AUTODISCOVERY

View file

@ -15,7 +15,7 @@
#define BAUD_GEIGERCOUNTER 9600
//const char* HOSTNAME = "ESP-GeigerCounter"; //Optional
//#define HOSTNAME "ESP-GeigerCounter" //Optional
const char* OTA_PASSWORD = "foobar";