Skip to content

Commit 5f6003e

Browse files
(#198): Added 'const's for the length of the setup SSID prefix
1 parent 406a693 commit 5f6003e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Firmware/GPAD_API/GPAD_API/GPAD_API.ino

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
* -- rlr, Oct. 24, 2022
5151
*/
5252

53+
#include <array>
54+
5355
#include "alarm_api.h"
5456
#include "GPAD_HAL.h"
5557
#include "gpad_utility.h"
@@ -150,13 +152,14 @@ const char *mqtt_broker_name = "public.cloud.shiftr.io";
150152
const char *mqtt_user = "public";
151153
const char *mqtt_password = "public";
152154

155+
const size_t MAC_ADDRESS_STRING_LENGTH = 13;
153156
// MQTT Topics, MAC plus an extention
154157
// A MAC addresss treated as a string has 12 chars.
155158
// The strings "_ALM" and "_ACK" have 4 chars.
156159
// A null character is one other. 12 + 4 + 1 = 17
157160
char subscribe_Alarm_Topic[17];
158161
char publish_Ack_Topic[17];
159-
char macAddressString[13];
162+
char macAddressString[MAC_ADDRESS_STRING_LENGTH];
160163

161164
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
162165
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
@@ -484,12 +487,15 @@ void setup()
484487
Serial.println(publish_Ack_Topic);
485488
Serial.println("XXXXXXX");
486489
#endif
490+
// Setup SSID length is the length of the prefix, 'Krake_', which is 7
491+
// plus the length of the MAC address string, MAC_ADDRESS_STRING_LENGTH
492+
const size_t SETUP_SSID_LENGTH = 7 + MAC_ADDRESS_STRING_LENGTH;
493+
char setupSsid[SETUP_SSID_LENGTH] = "Krake_";
494+
strcat(setupSsid, macAddressString);
487495

488496
// We call this a second time to get the MAC on the screen
489497
// clearLCD();
490498
// req for Wifi Man and OTA
491-
char setupSsid[20] = "Krake_\0";
492-
strcat(setupSsid, macAddressString);
493499

494500
WiFiMan(setupSsid);
495501
initLittleFS();

0 commit comments

Comments
 (0)