diff --git a/Makefile b/Makefile index 61ef537..1b7c0ee 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ ESPTOOLOPTS = -ff 40m -fm dio -fs 32m TARGET = app # which modules (subdirectories) of the project to include in compiling -MODULES = driver user easygpio +MODULES = driver user easygpio c_functions EXTRA_INCDIR = include $(BUILD_AREA)/esp-open-sdk/esp-open-lwip/include #EXTRA_INCDIR = include diff --git a/c_functions/missing.c b/c_functions/missing.c new file mode 100644 index 0000000..8688acb --- /dev/null +++ b/c_functions/missing.c @@ -0,0 +1,21 @@ +#include "c_types.h" +#include "mem.h" +#include "ets_sys.h" +#include "osapi.h" +#include "gpio.h" +#include "os_type.h" + +char *_strcat(char *dest, const char *src) +{ + size_t i, j; + for (i = 0; dest[i] != '\0'; i++); + + for (j = 0; src[j] != '\0'; j++) + { + dest[i + j] = src[j]; + } + + dest[i + j] = '\0'; + + return dest; +} diff --git a/firmware/0x00000.bin b/firmware/0x00000.bin index 473c178..2c415a3 100644 Binary files a/firmware/0x00000.bin and b/firmware/0x00000.bin differ diff --git a/firmware/0x10000.bin b/firmware/0x10000.bin index 700a132..e997b15 100644 Binary files a/firmware/0x10000.bin and b/firmware/0x10000.bin differ diff --git a/user/user_config.h b/user/user_config.h index bb5e5e7..11a573b 100644 --- a/user/user_config.h +++ b/user/user_config.h @@ -1,7 +1,7 @@ #ifndef _USER_CONFIG_ #define _USER_CONFIG_ -#define ESPERPASS_VERSION "V0.0.2" +#define ESPERPASS_VERSION "V0.0.3" #define WIFI_SSID "ssid" #define WIFI_PASSWORD "password" diff --git a/user/user_main.c b/user/user_main.c index 32a2053..312ad1a 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -392,7 +392,7 @@ static char INVALID_ARG[] = "Invalid argument\r\n"; void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) { - #define MAX_CMD_TOKENS 9 + #define MAX_CMD_TOKENS 20 char cmd_line[MAX_CON_CMD_SIZE+1]; char response[512]; @@ -810,7 +810,37 @@ console_handle_command(struct espconn *pespconn) // atleast 3 tokens, proceed if (strcmp(tokens[1], "ssid") == 0) { - os_sprintf(config.ssid, "%s", tokens[2]); + // Handle case when ssid has spaces in it + // This means the rest of the ssid has been split over the remainder + // of the tokens[] array and we need to re-concatenate them + // to get the full ssid name. + if (nTokens > 3) + { + char ssid[50] = {}; + int i; + + // The ssid starts at the 3rd token, position 2 in the tokens + // array. Hence i = 2. + for (i = 2; i < nTokens; i++) + { + _strcat(ssid, tokens[i]); + + // Restore the space character between tokens + // that form the ssid. + // Don't add space after the last token. + if (i < nTokens - 1) + { + _strcat(ssid, " "); + } + } + + // Copy the recomposed ssid to the config. + os_sprintf(config.ssid, "%s", ssid); + } + else + { + os_sprintf(config.ssid, "%s", tokens[2]); + } config.auto_connect = 1; os_sprintf(response, "SSID set (auto_connect = 1)\r\n"); @@ -819,7 +849,37 @@ console_handle_command(struct espconn *pespconn) if (strcmp(tokens[1], "password") == 0) { - os_sprintf(config.password, "%s", tokens[2]); + // Handle case when password has spaces in it + // This means the rest of the password has been split over the remainder + // of the tokens[] array and we need to re-concatenate them + // to get the full password. + if (nTokens > 3) + { + char password[50] = {}; + int i; + + // The password starts at the 3rd token, position 2 in the tokens + // array. Hence i = 2. + for (i = 2; i < nTokens; i++) + { + _strcat(password, tokens[i]); + + // Restore the space character between tokens + // that form the password. + // Don't add space after the last token. + if (i < nTokens - 1) + { + _strcat(password, " "); + } + } + + // Copy the recomposed password to the config. + os_sprintf(config.password, "%s", password); + } + else + { + os_sprintf(config.password, "%s", tokens[2]); + } os_sprintf(response, "Password set\r\n"); goto command_handled; @@ -1467,7 +1527,10 @@ user_init() os_printf("\r\n\r\n***ESPerPass not yet configured***\r\n"); os_printf("Hit return to show the CMD> prompt and follow these instructions:\r\n"); os_printf("Note that the console does not support the backspace key.\r\n"); - os_printf("If you make a mistake, hit return and try the command again.\r\n\r\n"); + os_printf("If you make a mistake, hit return and try the command again.\r\n"); + os_printf("Note that the maximum length for the SSID is 31 character,\r\n"); + os_printf("for the password 64 characters. Spaces are allowed.\r\n\r\n"); + os_printf("1. Set your Internet WiFi ssid: set ssid \r\n"); os_printf("2. Set your Internet WiFi password: set password \r\n"); os_printf("3. Save the settings: save\r\n");