Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
8982d370
Commit
8982d370
authored
Sep 16, 2015
by
Robert Foss
Browse files
Removed #define for forcing storage on flash
parent
3d5c54ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/modules/enduser_setup.c
View file @
8982d370
...
@@ -28,18 +28,17 @@
...
@@ -28,18 +28,17 @@
* |dns_body|
* |dns_body|
* |ip - 32 bits|
* |ip - 32 bits|
*
*
* DNS Header Part | FLAGS | | Q COUNT | | A CNT | |AUTH CNT| | ADD CNT| */
* 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
};
static
const
char
dns_header
[]
=
{
0x80
,
0x00
,
0x00
,
0x01
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
};
/* DNS Query Part | Q TYPE | | Q CLASS| */
/* DNS Query Part | Q TYPE | | Q CLASS| */
static
const
char
ROM_CONST_ATTR
dns_body
[]
=
{
0x00
,
0x01
,
0x00
,
0x01
,
static
const
char
dns_body
[]
=
{
0x00
,
0x01
,
0x00
,
0x01
,
/* DNS Answer Part |LBL OFFS| | TYPE | | CLASS | | TTL | | RD LEN | */
/* DNS Answer Part |LBL OFFS| | TYPE | | CLASS | | TTL | | RD LEN | */
0xC0
,
0x0C
,
0x00
,
0x01
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x78
,
0x00
,
0x04
};
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
http_html_filename
[]
=
"index.html"
;
static
const
char
ROM_CONST_ATTR
http_header_200
[]
=
"HTTP/1.1 200 OK
\r\n
Content-Type: text/html
\r\n\r\n
"
;
static
const
char
http_header_200
[]
=
"HTTP/1.1 200 OK
\r\n
Content-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
http_header_404
[]
=
"HTTP/1.1 404 Not Found
\r\n
"
;
static
const
char
http_html_backup
[]
=
"<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content='width=380'><title>Connect gadget to you WiFi</title><style media=screen type=text/css>*{margin:0;padding:0}html{height:100%;background:linear-gradient(rgba(196,102,0,.2),rgba(155,89,182,.2)),url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAAA8AgMAAACm+SSwAAAADFBMVEVBR1FFS1VHTlg8Q0zU/YXIAAADVElEQVQ4yy1TTYvTUBQ9GTKiYNoodsCF4MK6U4TZChOhiguFWHyBFzqlLl4hoeNvEBeCrlrhBVKq1EUKLTP+hvi1GyguXqBdiZCBzGqg20K8L3hDQnK55+OeJNguHx6UujYl3dL5ALn4JOIUluAqeAWciyGaSdvngOWzNT+G0UyGUOxVOAdqkjXDCbBiUyjZ5QzYEbGadYAi6kHxth+kthXNVNCDofwhGv1D4QGGiM9iAjbCHgr2iUUpDJbs+VPQ4xAr2fX7KXbkOJMdok965Ksb+6lrjdkem8AshIuHm9Nyu19uTunYlOXDTQqi8VgeH0kBXH2xq/ouiMZPzuMukymutrBmulUTovC6HqNFW2ZOiqlpSXZOTvSUeUPxChjxol8BLbRy4gJuhV7OR4LRVBs3WQ9VVAU7SXgK2HeUrOj7bC8YsUgr3lEV/TXB7hK90EBnxaeg1Ov15bY80M736ekCGesGAaGvG0Ct4WRkVQVHIgIM9xJgvSFfPay8Q6GNv7VpR7xUnkvhnMQCJDYkYOtNLihV70tCU1Sk+BQrpoP+HLHUrJkuta40C6LP5GvBv+Hqo10ATxxFrTPvNdPr7XwgQud6RvQN/sXjBGzqbU27wcj9cgsyvSTrpyXV8gKpXeNJU3aFl7MOdldzV4+HfO19jBa5f2IjWwx1OLHIvFHkqbBj20ro1g7nDfY1DpScvDRUNARgjMMVO0zoMjKxJ6uWCPP+YRAWbGoaN8kXYHmLjB9FXLGOazfFVCvOgqzfnicNPrHtPKlex2ye824gMza0cTZ2sS2Xm7Qst/UfFw8O6vVtmUKxZy9xFgzMys5cJ5fxZw4y37Ufk1Dsfb8MqOjYxE3ZMWxiDcO0PYUaD2ys+8OW1pbB7/e3sfZeGVCL0Q2aMjjPdm2sxADuejZxHJAd8dO9DSUdA0V8/NggRRanDkBrANn8yHlEQOn/MmwoQfQF7xgmKDnv520bS/pgylP67vf3y2V5sCwfoCEMkZClgOfJAFX9eXefR2RpnmRs4CDVPceaRfoFzCkJVJX27vWZnoqyvmtXU3+dW1EIXIu8Qg5Qta4Zlv7drUCoWe8/8MXzaEwux7ESE9h6qnHj3mIO0/D9RvzfxPmjWiQ1vbeSk4rrHwhAre35EEVaAAAAAElFTkSuQmCC)}body{font-family:arial,verdana}div{position:absolute;margin:auto;top:0;right:0;bottom:0;left:0;width:320px;height:274px}form{width:320px;text-align:center;position:relative}form fieldset{background:#fff;border:0 none;border-radius:5px;box-shadow:0 0 15px 1px rgba(0,0,0,.4);padding:20px 30px;box-sizing:border-box}form input{padding:15px;border:1px solid #ccc;border-radius:3px;margin-bottom:10px;width:100%;box-sizing:border-box;font-family:montserrat;color:#2C3E50;font-size:13px}form .action-button{width:100px;background:#27AE60;font-weight:700;color:#fff;border:0 none;border-radius:3px;cursor:pointer;padding:10px 5px;margin:10px 5px}#msform .action-button:focus,form .action-button:hover{box-shadow:0 0 0 2px #fff,0 0 0 3px #27AE60}.fs-title{font-size:15px;text-transform:uppercase;color:#2C3E50;margin-bottom:10px}.fs-subtitle{font-weight:400;font-size:13px;color:#666;margin-bottom:20px}</style><body><div><form><fieldset><h2 class=fs-title>WiFi Login</h2><h3 class=fs-subtitle>Connect gadget to your WiFi</h3><input autocorrect=off autocapitalize=none name=wifi_ssid placeholder='WiFi Name'> <input type=password name=wifi_password placeholder='Password'1> <input type=submit name=save class='submit action-button' value='Save'></fieldset></form></div>"
;
static
const
char
ROM_CONST_ATTR
http_html_backup
[]
=
"<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content='width=380'><title>Connect gadget to you WiFi</title><style media=screen type=text/css>*{margin:0;padding:0}html{height:100%;background:linear-gradient(rgba(196,102,0,.2),rgba(155,89,182,.2)),url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAAA8AgMAAACm+SSwAAAADFBMVEVBR1FFS1VHTlg8Q0zU/YXIAAADVElEQVQ4yy1TTYvTUBQ9GTKiYNoodsCF4MK6U4TZChOhiguFWHyBFzqlLl4hoeNvEBeCrlrhBVKq1EUKLTP+hvi1GyguXqBdiZCBzGqg20K8L3hDQnK55+OeJNguHx6UujYl3dL5ALn4JOIUluAqeAWciyGaSdvngOWzNT+G0UyGUOxVOAdqkjXDCbBiUyjZ5QzYEbGadYAi6kHxth+kthXNVNCDofwhGv1D4QGGiM9iAjbCHgr2iUUpDJbs+VPQ4xAr2fX7KXbkOJMdok965Ksb+6lrjdkem8AshIuHm9Nyu19uTunYlOXDTQqi8VgeH0kBXH2xq/ouiMZPzuMukymutrBmulUTovC6HqNFW2ZOiqlpSXZOTvSUeUPxChjxol8BLbRy4gJuhV7OR4LRVBs3WQ9VVAU7SXgK2HeUrOj7bC8YsUgr3lEV/TXB7hK90EBnxaeg1Ov15bY80M736ekCGesGAaGvG0Ct4WRkVQVHIgIM9xJgvSFfPay8Q6GNv7VpR7xUnkvhnMQCJDYkYOtNLihV70tCU1Sk+BQrpoP+HLHUrJkuta40C6LP5GvBv+Hqo10ATxxFrTPvNdPr7XwgQud6RvQN/sXjBGzqbU27wcj9cgsyvSTrpyXV8gKpXeNJU3aFl7MOdldzV4+HfO19jBa5f2IjWwx1OLHIvFHkqbBj20ro1g7nDfY1DpScvDRUNARgjMMVO0zoMjKxJ6uWCPP+YRAWbGoaN8kXYHmLjB9FXLGOazfFVCvOgqzfnicNPrHtPKlex2ye824gMza0cTZ2sS2Xm7Qst/UfFw8O6vVtmUKxZy9xFgzMys5cJ5fxZw4y37Ufk1Dsfb8MqOjYxE3ZMWxiDcO0PYUaD2ys+8OW1pbB7/e3sfZeGVCL0Q2aMjjPdm2sxADuejZxHJAd8dO9DSUdA0V8/NggRRanDkBrANn8yHlEQOn/MmwoQfQF7xgmKDnv520bS/pgylP67vf3y2V5sCwfoCEMkZClgOfJAFX9eXefR2RpnmRs4CDVPceaRfoFzCkJVJX27vWZnoqyvmtXU3+dW1EIXIu8Qg5Qta4Zlv7drUCoWe8/8MXzaEwux7ESE9h6qnHj3mIO0/D9RvzfxPmjWiQ1vbeSk4rrHwhAre35EEVaAAAAAElFTkSuQmCC)}body{font-family:arial,verdana}div{position:absolute;margin:auto;top:0;right:0;bottom:0;left:0;width:320px;height:274px}form{width:320px;text-align:center;position:relative}form fieldset{background:#fff;border:0 none;border-radius:5px;box-shadow:0 0 15px 1px rgba(0,0,0,.4);padding:20px 30px;box-sizing:border-box}form input{padding:15px;border:1px solid #ccc;border-radius:3px;margin-bottom:10px;width:100%;box-sizing:border-box;font-family:montserrat;color:#2C3E50;font-size:13px}form .action-button{width:100px;background:#27AE60;font-weight:700;color:#fff;border:0 none;border-radius:3px;cursor:pointer;padding:10px 5px;margin:10px 5px}#msform .action-button:focus,form .action-button:hover{box-shadow:0 0 0 2px #fff,0 0 0 3px #27AE60}.fs-title{font-size:15px;text-transform:uppercase;color:#2C3E50;margin-bottom:10px}.fs-subtitle{font-weight:400;font-size:13px;color:#666;margin-bottom:20px}</style><body><div><form><fieldset><h2 class=fs-title>WiFi Login</h2><h3 class=fs-subtitle>Connect gadget to your WiFi</h3><input autocorrect=off autocapitalize=none name=wifi_ssid placeholder='WiFi Name'> <input type=password name=wifi_password placeholder='Password'1> <input type=submit name=save class='submit action-button' value='Save'></fieldset></form></div>"
;
static
struct
espconn
*
espconn_dns_udp
;
static
struct
espconn
*
espconn_dns_udp
;
static
struct
espconn
*
espconn_http_tcp
;
static
struct
espconn
*
espconn_http_tcp
;
...
@@ -93,12 +92,12 @@ static void enduser_setup_check_station(void)
...
@@ -93,12 +92,12 @@ static void enduser_setup_check_station(void)
{
{
has_ip
|=
((
char
*
)
&
ip
)[
i
];
has_ip
|=
((
char
*
)
&
ip
)[
i
];
}
}
if
(
has_ip
==
0
)
if
(
has_ip
==
0
)
{
{
return
;
return
;
}
}
struct
station_config
cnf
;
struct
station_config
cnf
;
wifi_station_get_config
(
&
cnf
);
wifi_station_get_config
(
&
cnf
);
...
@@ -368,18 +367,18 @@ static int enduser_setup_http_serve_header(struct espconn *http_client, char *he
...
@@ -368,18 +367,18 @@ static int enduser_setup_http_serve_header(struct espconn *http_client, char *he
/**
/**
* Serve HTML
* Serve HTML
*
*
* @return - return 0 iff html was served successfully
* @return - return 0 iff html was served successfully
*/
*/
static
int
enduser_setup_http_serve_html
(
struct
espconn
*
http_client
)
static
int
enduser_setup_http_serve_html
(
struct
espconn
*
http_client
)
{
{
PRINT_FUNC
(
"enduser_setup_http_serve_html
\n
"
);
PRINT_FUNC
(
"enduser_setup_http_serve_html
\n
"
);
if
(
http_payload
.
data
==
NULL
)
if
(
http_payload
.
data
==
NULL
)
{
{
enduser_setup_http_load_payload
();
enduser_setup_http_load_payload
();
}
}
int8_t
err
=
espconn_sent
(
http_client
,
http_payload
.
data
,
http_payload
.
len
);
int8_t
err
=
espconn_sent
(
http_client
,
http_payload
.
data
,
http_payload
.
len
);
if
(
err
==
ESPCONN_MEM
)
if
(
err
==
ESPCONN_MEM
)
{
{
...
@@ -394,9 +393,9 @@ static int enduser_setup_http_serve_html(struct espconn *http_client)
...
@@ -394,9 +393,9 @@ static int enduser_setup_http_serve_html(struct espconn *http_client)
else
if
(
err
!=
0
)
else
if
(
err
!=
0
)
{
{
NODE_DEBUG
(
"enduser_setup_http_serve_html failed. espconn_send failed
\n
"
);
NODE_DEBUG
(
"enduser_setup_http_serve_html failed. espconn_send failed
\n
"
);
return
1
;
return
1
;
}
}
return
0
;
return
0
;
}
}
...
@@ -424,7 +423,7 @@ static void enduser_setup_http_recvcb(void *arg, char *data, unsigned short data
...
@@ -424,7 +423,7 @@ static void enduser_setup_http_recvcb(void *arg, char *data, unsigned short data
enduser_setup_http_disconnect
(
http_client
);
enduser_setup_http_disconnect
(
http_client
);
return
;
return
;
}
}
int
retval
=
enduser_setup_http_handle_credentials
(
data
,
data_len
);
int
retval
=
enduser_setup_http_handle_credentials
(
data
,
data_len
);
if
(
retval
==
0
)
if
(
retval
==
0
)
{
{
...
@@ -437,13 +436,13 @@ static void enduser_setup_http_recvcb(void *arg, char *data, unsigned short data
...
@@ -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
"
);
NODE_DEBUG
(
"enduser_setup_http_recvcb failed. Failed to handle wifi credentials.
\n
"
);
return
;
return
;
}
}
if
(
retval
!=
1
)
if
(
retval
!=
1
)
{
{
NODE_DEBUG
(
"enduser_setup_http_recvcb failed. Unknown error code #%u.
\n
"
,
retval
);
NODE_DEBUG
(
"enduser_setup_http_recvcb failed. Unknown error code #%u.
\n
"
,
retval
);
return
;
return
;
}
}
/* Reject requests that probably aren't relevant to free up resources. */
/* Reject requests that probably aren't relevant to free up resources. */
if
(
c_strncmp
(
data
,
"GET / "
,
6
)
!=
0
)
if
(
c_strncmp
(
data
,
"GET / "
,
6
)
!=
0
)
{
{
...
@@ -452,7 +451,7 @@ static void enduser_setup_http_recvcb(void *arg, char *data, unsigned short data
...
@@ -452,7 +451,7 @@ static void enduser_setup_http_recvcb(void *arg, char *data, unsigned short data
enduser_setup_http_disconnect
(
http_client
);
enduser_setup_http_disconnect
(
http_client
);
return
;
return
;
}
}
retval
=
enduser_setup_http_serve_html
(
http_client
);
retval
=
enduser_setup_http_serve_html
(
http_client
);
if
(
retval
!=
0
)
if
(
retval
!=
0
)
{
{
...
@@ -470,7 +469,7 @@ static void enduser_setup_http_connectcb(void *arg)
...
@@ -470,7 +469,7 @@ static void enduser_setup_http_connectcb(void *arg)
int8_t
err
=
0
;
int8_t
err
=
0
;
err
|=
espconn_regist_recvcb
(
callback_espconn
,
enduser_setup_http_recvcb
);
err
|=
espconn_regist_recvcb
(
callback_espconn
,
enduser_setup_http_recvcb
);
if
(
err
!=
0
)
if
(
err
!=
0
)
{
{
NODE_DEBUG
(
"enduser_setup_http_connectcb failed. Callback registration failed.
\n
"
);
NODE_DEBUG
(
"enduser_setup_http_connectcb failed. Callback registration failed.
\n
"
);
...
@@ -535,21 +534,21 @@ static void enduser_setup_http_start(void)
...
@@ -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
"
);
NODE_DEBUG
(
"enduser_setup_http_start failed. Can't find connection from espconn argument
\n
"
);
enduser_setup_http_free
();
enduser_setup_http_free
();
return
;
return
;
}
}
else
if
(
err
!=
0
)
else
if
(
err
!=
0
)
{
{
NODE_DEBUG
(
"enduser_setup_http_start failed. ERRROR #%u
\n
"
,
err
);
NODE_DEBUG
(
"enduser_setup_http_start failed. ERRROR #%u
\n
"
,
err
);
enduser_setup_http_free
();
enduser_setup_http_free
();
return
;
return
;
}
}
err
=
espconn_regist_time
(
espconn_http_tcp
,
2
,
0
);
err
=
espconn_regist_time
(
espconn_http_tcp
,
2
,
0
);
if
(
err
==
ESPCONN_ARG
)
if
(
err
==
ESPCONN_ARG
)
{
{
NODE_DEBUG
(
"enduser_setup_http_start failed. Unable to set TCP timeout.
\n
"
);
NODE_DEBUG
(
"enduser_setup_http_start failed. Unable to set TCP timeout.
\n
"
);
enduser_setup_http_free
();
enduser_setup_http_free
();
return
;
return
;
}
}
err
=
enduser_setup_http_load_payload
();
err
=
enduser_setup_http_load_payload
();
...
@@ -561,7 +560,7 @@ static void enduser_setup_http_start(void)
...
@@ -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
"
);
NODE_DEBUG
(
"enduser_setup_http_start failed. Unable to allocate memory for HTTP payload.
\n
"
);
enduser_setup_http_free
();
enduser_setup_http_free
();
return
;
return
;
}
}
}
}
...
@@ -751,7 +750,7 @@ static void enduser_setup_dns_start(void)
...
@@ -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
);
NODE_DEBUG
(
"enduser_setup_dns_start failed. Couldn't create connection, ERROR #%d.
\n
"
,
err
);
enduser_setup_dns_free
();
enduser_setup_dns_free
();
return
;
return
;
}
}
}
}
...
@@ -786,7 +785,7 @@ static int enduser_setup_start(lua_State* L)
...
@@ -786,7 +785,7 @@ static int enduser_setup_start(lua_State* L)
enduser_setup_ap_start
();
enduser_setup_ap_start
();
enduser_setup_dns_start
();
enduser_setup_dns_start
();
enduser_setup_http_start
();
enduser_setup_http_start
();
return
0
;
return
0
;
}
}
...
...
include/c_types.h
View file @
8982d370
...
@@ -86,7 +86,6 @@ typedef enum {
...
@@ -86,7 +86,6 @@ typedef enum {
#define TEXT_SECTION_ATTR __attribute__((section(".text")))
#define TEXT_SECTION_ATTR __attribute__((section(".text")))
#define RAM_CONST_ATTR __attribute__((section(".rodata")))
#define RAM_CONST_ATTR __attribute__((section(".rodata")))
#define ROM_CONST_ATTR __attribute__((section("irom0.rodata")))
#ifndef __cplusplus
#ifndef __cplusplus
typedef
unsigned
char
bool
;
typedef
unsigned
char
bool
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment