From 721fadfd148f41015d3c6cc0c15187109159b6e5 Mon Sep 17 00:00:00 2001 From: Robert Foss Date: Sun, 27 Sep 2015 14:02:25 -0400 Subject: [PATCH] Changed SSID to be suffixed by MAC. --- app/modules/enduser_setup.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/modules/enduser_setup.c b/app/modules/enduser_setup.c index 1d0823a8..d5019890 100644 --- a/app/modules/enduser_setup.c +++ b/app/modules/enduser_setup.c @@ -43,6 +43,8 @@ #include "espconn.h" #include "flash_fs.h" +#define ENDUSER_SETUP_AP_SSID "SetupGadget" + #define MIN(x, y) (((x) < (y)) ? (x) : (y)) #define ENDUSER_SETUP_ERR_FATAL (1 << 0) @@ -635,9 +637,23 @@ static void enduser_setup_ap_start(void) ENDUSER_SETUP_DEBUG(state->lua_L, "enduser_setup_ap_start"); struct softap_config cnf; - char ssid[] = "SetupGadget"; - c_memcpy(&(cnf.ssid), ssid, c_strlen(ssid)); - cnf.ssid_len = c_strlen(ssid); + c_memset(&(cnf), 0, sizeof(struct softap_config)); + + char ssid[] = ENDUSER_SETUP_AP_SSID; + int ssid_name_len = c_strlen(ENDUSER_SETUP_AP_SSID); + c_memcpy(&(cnf.ssid), ssid, ssid_name_len); + + uint8_t mac[6]; + wifi_get_macaddr(SOFTAP_IF, mac); + cnf.ssid[ssid_name_len] = '_'; + cnf.ssid[ssid_name_len + 1] = (char) (65 + (0x0F & mac[3])); + cnf.ssid[ssid_name_len + 2] = (char) (65 + ((0xF0 & mac[3]) >> 4)); + cnf.ssid[ssid_name_len + 3] = (char) (65 + (0x0F & mac[4])); + cnf.ssid[ssid_name_len + 4] = (char) (65 + ((0xF0 & mac[4]) >> 4)); + cnf.ssid[ssid_name_len + 5] = (char) (65 + (0x0F & mac[5])); + cnf.ssid[ssid_name_len + 6] = (char) (65 + ((0xF0 & mac[5]) >> 4)); + + cnf.ssid_len = c_strlen(ssid) + 7; cnf.channel = 1; cnf.authmode = AUTH_OPEN; cnf.ssid_hidden = 0;