diff --git a/app/modules/enduser_setup.c b/app/modules/enduser_setup.c index 0ec9df19..3e6b18c1 100644 --- a/app/modules/enduser_setup.c +++ b/app/modules/enduser_setup.c @@ -28,18 +28,17 @@ * |dns_body| * |ip - 32 bits| * - * DNS Header Part | FLAGS | | Q COUNT | | A CNT | |AUTH CNT| | ADD CNT| */ -static const char ROM_CONST_ATTR dns_header[] = { 0x80, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }; -/* DNS Query Part | Q TYPE | | Q CLASS| */ -static const char ROM_CONST_ATTR dns_body[] = { 0x00, 0x01, 0x00, 0x01, -/* DNS Answer Part |LBL OFFS| | TYPE | | CLASS | | TTL | | RD LEN | */ - 0xC0, 0x0C, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, 0x04 }; + * DNS Header Part | FLAGS | | Q COUNT | | A CNT | |AUTH CNT| | ADD CNT| */ +static const char dns_header[] = { 0x80, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }; +/* DNS Query Part | Q TYPE | | Q CLASS| */ +static const char dns_body[] = { 0x00, 0x01, 0x00, 0x01, +/* DNS Answer Part |LBL OFFS| | TYPE | | CLASS | | TTL | | RD LEN | */ + 0xC0, 0x0C, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, 0x04 }; -static const char ROM_CONST_ATTR http_html_filename[] = "index.html"; -static const char ROM_CONST_ATTR http_header_200[] = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"; -static const char ROM_CONST_ATTR http_header_404[] = "HTTP/1.1 404 Not Found\r\n"; - -static const char ROM_CONST_ATTR http_html_backup[] = "Connect gadget to you WiFi

WiFi Login

Connect gadget to your WiFi

"; +static const char http_html_filename[] = "index.html"; +static const char http_header_200[] = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"; +static const char http_header_404[] = "HTTP/1.1 404 Not Found\r\n"; +static const char http_html_backup[] = "Connect gadget to you WiFi

WiFi Login

Connect gadget to your WiFi

"; static struct espconn *espconn_dns_udp; static struct espconn *espconn_http_tcp; @@ -93,12 +92,12 @@ static void enduser_setup_check_station(void) { has_ip |= ((char *) &ip)[i]; } - + if (has_ip == 0) { return; } - + struct station_config cnf; wifi_station_get_config(&cnf); @@ -368,18 +367,18 @@ static int enduser_setup_http_serve_header(struct espconn *http_client, char *he /** * Serve HTML - * + * * @return - return 0 iff html was served successfully */ static int enduser_setup_http_serve_html(struct espconn *http_client) { PRINT_FUNC("enduser_setup_http_serve_html\n"); - + if (http_payload.data == NULL) { enduser_setup_http_load_payload(); } - + int8_t err = espconn_sent(http_client, http_payload.data, http_payload.len); if (err == ESPCONN_MEM) { @@ -394,9 +393,9 @@ static int enduser_setup_http_serve_html(struct espconn *http_client) else if (err != 0) { NODE_DEBUG("enduser_setup_http_serve_html failed. espconn_send failed\n"); - return 1; + return 1; } - + return 0; } @@ -424,7 +423,7 @@ static void enduser_setup_http_recvcb(void *arg, char *data, unsigned short data enduser_setup_http_disconnect(http_client); return; } - + int retval = enduser_setup_http_handle_credentials(data, data_len); if (retval == 0) { @@ -437,13 +436,13 @@ static void enduser_setup_http_recvcb(void *arg, char *data, unsigned short data NODE_DEBUG("enduser_setup_http_recvcb failed. Failed to handle wifi credentials.\n"); return; } - + if (retval != 1) { NODE_DEBUG("enduser_setup_http_recvcb failed. Unknown error code #%u.\n", retval); return; } - + /* Reject requests that probably aren't relevant to free up resources. */ if (c_strncmp(data, "GET / ", 6) != 0) { @@ -452,7 +451,7 @@ static void enduser_setup_http_recvcb(void *arg, char *data, unsigned short data enduser_setup_http_disconnect(http_client); return; } - + retval = enduser_setup_http_serve_html(http_client); if (retval != 0) { @@ -470,7 +469,7 @@ static void enduser_setup_http_connectcb(void *arg) int8_t err = 0; err |= espconn_regist_recvcb(callback_espconn, enduser_setup_http_recvcb); - + if (err != 0) { NODE_DEBUG("enduser_setup_http_connectcb failed. Callback registration failed.\n"); @@ -535,21 +534,21 @@ static void enduser_setup_http_start(void) { NODE_DEBUG("enduser_setup_http_start failed. Can't find connection from espconn argument\n"); enduser_setup_http_free(); - return; + return; } else if (err != 0) { NODE_DEBUG("enduser_setup_http_start failed. ERRROR #%u\n", err); enduser_setup_http_free(); - return; + return; } - + err = espconn_regist_time(espconn_http_tcp, 2, 0); if (err == ESPCONN_ARG) { NODE_DEBUG("enduser_setup_http_start failed. Unable to set TCP timeout.\n"); enduser_setup_http_free(); - return; + return; } err = enduser_setup_http_load_payload(); @@ -561,7 +560,7 @@ static void enduser_setup_http_start(void) { NODE_DEBUG("enduser_setup_http_start failed. Unable to allocate memory for HTTP payload.\n"); enduser_setup_http_free(); - return; + return; } } @@ -751,7 +750,7 @@ static void enduser_setup_dns_start(void) { NODE_DEBUG("enduser_setup_dns_start failed. Couldn't create connection, ERROR #%d.\n", err); enduser_setup_dns_free(); - return; + return; } } @@ -786,7 +785,7 @@ static int enduser_setup_start(lua_State* L) enduser_setup_ap_start(); enduser_setup_dns_start(); enduser_setup_http_start(); - + return 0; } diff --git a/include/c_types.h b/include/c_types.h index ec0ce554..36ef6d12 100644 --- a/include/c_types.h +++ b/include/c_types.h @@ -86,7 +86,6 @@ typedef enum { #define TEXT_SECTION_ATTR __attribute__((section(".text"))) #define RAM_CONST_ATTR __attribute__((section(".rodata"))) -#define ROM_CONST_ATTR __attribute__((section("irom0.rodata"))) #ifndef __cplusplus typedef unsigned char bool;