Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
5bbf24bf
Commit
5bbf24bf
authored
Oct 20, 2016
by
Deomid Ryabkov
Committed by
Cesanta Bot
Oct 20, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix line endings in console messages
PUBLISHED_FROM=b7cf888512e535fcb81371d797bf8a72440baeaa
parent
ace1dc53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
main.c
examples/NXP_K64/main.c
+12
-12
No files found.
examples/NXP_K64/main.c
View file @
5bbf24bf
...
...
@@ -47,13 +47,13 @@ void gpio_init() {
void
ev_handler
(
struct
mg_connection
*
nc
,
int
ev
,
void
*
ev_data
)
{
if
(
ev
==
MG_EV_POLL
)
return
;
/* printf("ev %d\n", ev); */
/* printf("ev %d\
r\
n", ev); */
switch
(
ev
)
{
case
MG_EV_ACCEPT
:
{
char
addr
[
32
];
mg_sock_addr_to_str
(
&
nc
->
sa
,
addr
,
sizeof
(
addr
),
MG_SOCK_STRINGIFY_IP
|
MG_SOCK_STRINGIFY_PORT
);
printf
(
"%p: Connection from %s
\n
"
,
nc
,
addr
);
printf
(
"%p: Connection from %s
\
r\
n
"
,
nc
,
addr
);
break
;
}
case
MG_EV_HTTP_REQUEST
:
{
...
...
@@ -61,7 +61,7 @@ void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
char
addr
[
32
];
mg_sock_addr_to_str
(
&
nc
->
sa
,
addr
,
sizeof
(
addr
),
MG_SOCK_STRINGIFY_IP
|
MG_SOCK_STRINGIFY_PORT
);
printf
(
"%p: %.*s %.*s
\n
"
,
nc
,
(
int
)
hm
->
method
.
len
,
hm
->
method
.
p
,
printf
(
"%p: %.*s %.*s
\
r\
n
"
,
nc
,
(
int
)
hm
->
method
.
len
,
hm
->
method
.
p
,
(
int
)
hm
->
uri
.
len
,
hm
->
uri
.
p
);
mg_send_response_line
(
nc
,
200
,
"Content-Type: text/html
\r\n
"
...
...
@@ -75,7 +75,7 @@ void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
break
;
}
case
MG_EV_CLOSE
:
{
printf
(
"%p: Connection closed
\n
"
,
nc
);
printf
(
"%p: Connection closed
\
r\
n
"
,
nc
);
break
;
}
}
...
...
@@ -100,27 +100,27 @@ int main(void) {
lwip_init
();
gpio_init
();
LED_RED_ON
();
printf
(
"Waiting for link...
\n
"
);
printf
(
"Waiting for link...
\
r\
n
"
);
#if USE_DHCP
netif_add
(
&
eth0
,
NULL
,
NULL
,
NULL
,
NULL
,
ethernetif_init
,
ethernet_input
);
printf
(
"Waiting for DHCP...
\n
"
);
printf
(
"Waiting for DHCP...
\
r\
n
"
);
LED_GREEN_ON
();
dhcp_start
(
&
eth0
);
u8_t
os
=
0xff
,
ds
;
do
{
ds
=
eth0
.
dhcp
->
state
;
if
(
ds
!=
os
)
{
printf
(
" DHCP state: %d
\n
"
,
ds
);
printf
(
" DHCP state: %d
\
r\
n
"
,
ds
);
os
=
ds
;
}
sys_check_timeouts
();
}
while
(
ds
!=
DHCP_BOUND
);
printf
(
"DHCP bound.
\n
"
);
printf
(
"DHCP bound.
\
r\
n
"
);
#else
ip_addr_t
ip
,
nm
,
gw
;
if
(
!
ipaddr_aton
(
STATIC_IP
,
&
ip
)
||
!
ipaddr_aton
(
STATIC_NM
,
&
nm
)
||
!
ipaddr_aton
(
STATIC_GW
,
&
gw
))
{
printf
(
"Invalid static IP configuration.
\n
"
);
printf
(
"Invalid static IP configuration.
\
r\
n
"
);
return
1
;
}
else
{
netif_add
(
&
eth0
,
&
ip
,
&
nm
,
&
gw
,
NULL
,
ethernetif_init
,
ethernet_input
);
...
...
@@ -128,7 +128,7 @@ int main(void) {
}
#endif
netif_set_default
(
&
eth0
);
printf
(
"Setting up HTTP server...
\n
"
);
printf
(
"Setting up HTTP server...
\
r\
n
"
);
struct
mg_mgr
mgr
;
mg_mgr_init
(
&
mgr
,
NULL
);
...
...
@@ -138,13 +138,13 @@ int main(void) {
opts
.
error_string
=
&
err
;
struct
mg_connection
*
nc
=
mg_bind_opt
(
&
mgr
,
"80"
,
ev_handler
,
opts
);
if
(
nc
==
NULL
)
{
printf
(
"Failed to create listener: %s
\n
"
,
err
);
printf
(
"Failed to create listener: %s
\
r\
n
"
,
err
);
LED_RED_ON
();
LED_GREEN_OFF
();
return
1
;
}
mg_set_protocol_http_websocket
(
nc
);
printf
(
"Server address: http://%s/
\n
"
,
ipaddr_ntoa
(
&
eth0
.
ip_addr
));
printf
(
"Server address: http://%s/
\
r\
n
"
,
ipaddr_ntoa
(
&
eth0
.
ip_addr
));
LED_RED_OFF
();
LED_GREEN_ON
();
...
...
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