aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authormarcoveeneman <marco-veeneman@hotmail.com>2018-03-15 08:02:32 +0100
committermarcoveeneman <marco-veeneman@hotmail.com>2018-03-15 08:02:32 +0100
commit7a9ddb8ada6195cf7f869502b9cc197766027ad2 (patch)
tree99db2ccdba598f11d15ff56e461510e96b8cd112 /demos
parent2f799372b1b74a0b29039ee3dc853881ad05414e (diff)
downloadChibiOS-Contrib-7a9ddb8ada6195cf7f869502b9cc197766027ad2.tar.gz
ChibiOS-Contrib-7a9ddb8ada6195cf7f869502b9cc197766027ad2.tar.bz2
ChibiOS-Contrib-7a9ddb8ada6195cf7f869502b9cc197766027ad2.zip
Removed custom web server and use LwIP httpd in demo
Diffstat (limited to 'demos')
-rw-r--r--demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/Makefile3
-rw-r--r--demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/main.c7
-rw-r--r--demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/web/web.c120
-rw-r--r--demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/web/web.h51
4 files changed, 4 insertions, 177 deletions
diff --git a/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/Makefile b/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/Makefile
index 0d30f91..4584bdf 100644
--- a/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/Makefile
+++ b/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/Makefile
@@ -111,8 +111,7 @@ LDSCRIPT= $(STARTUPLD)/TM4C129xNC.ld
# setting.
CSRC = $(ALLCSRC) \
$(CHIBIOS)/os/various/evtimer.c \
- main.c \
- web/web.c \
+ main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
diff --git a/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/main.c b/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/main.c
index ac9c3f4..0f88419 100644
--- a/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/main.c
+++ b/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/main.c
@@ -17,7 +17,7 @@
#include "ch.h"
#include "hal.h"
#include "lwipthread.h"
-#include "web/web.h"
+#include "lwip/apps/httpd.h"
/*
* Application entry point.
@@ -43,10 +43,9 @@ int main(void)
sdStart(&SD1, NULL);
/*
- * Creates the HTTP thread (it changes priority internally).
+ * Creates the LwIP HTTP server.
*/
- chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1,
- http_server, NULL);
+ httpd_init();
while (1) {
osalThreadSleepMilliseconds(500);
diff --git a/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/web/web.c b/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/web/web.c
deleted file mode 100644
index 8d0d281..0000000
--- a/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/web/web.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-/*
- * This file is a modified version of the lwIP web server demo. The original
- * author is unknown because the file didn't contain any license information.
- */
-
-/**
- * @file web.c
- * @brief HTTP server wrapper thread code.
- * @addtogroup WEB_THREAD
- * @{
- */
-
-#include "ch.h"
-
-#include "lwip/opt.h"
-#include "lwip/arch.h"
-#include "lwip/api.h"
-
-#include "web.h"
-
-#if LWIP_NETCONN
-
-static const char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n";
-static const char http_index_html[] = "<html><head><title>Congrats!</title></head><body><h1>Welcome to our lwIP HTTP server!</h1><p>This is a small test page.</body></html>";
-
-static void http_server_serve(struct netconn *conn) {
- struct netbuf *inbuf;
- char *buf;
- u16_t buflen;
- err_t err;
-
- /* Read the data from the port, blocking if nothing yet there.
- We assume the request (the part we care about) is in one netbuf */
- err = netconn_recv(conn, &inbuf);
-
- if (err == ERR_OK) {
- netbuf_data(inbuf, (void **)&buf, &buflen);
-
- /* Is this an HTTP GET command? (only check the first 5 chars, since
- there are other formats for GET, and we're keeping it very simple )*/
- if (buflen>=5 &&
- buf[0]=='G' &&
- buf[1]=='E' &&
- buf[2]=='T' &&
- buf[3]==' ' &&
- buf[4]=='/' ) {
-
- /* Send the HTML header
- * subtract 1 from the size, since we dont send the \0 in the string
- * NETCONN_NOCOPY: our data is const static, so no need to copy it
- */
- netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY);
-
- /* Send our HTML page */
- netconn_write(conn, http_index_html, sizeof(http_index_html)-1, NETCONN_NOCOPY);
- }
- }
- /* Close the connection (server closes in HTTP) */
- netconn_close(conn);
-
- /* Delete the buffer (netconn_recv gives us ownership,
- so we have to make sure to deallocate the buffer) */
- netbuf_delete(inbuf);
-}
-
-/**
- * Stack area for the http thread.
- */
-THD_WORKING_AREA(wa_http_server, WEB_THREAD_STACK_SIZE);
-
-/**
- * HTTP server thread.
- */
-THD_FUNCTION(http_server, p) {
- struct netconn *conn, *newconn;
- err_t err;
-
- (void)p;
-
- /* Create a new TCP connection handle */
- conn = netconn_new(NETCONN_TCP);
- LWIP_ERROR("http_server: invalid conn", (conn != NULL), return;);
-
- /* Bind to port 80 (HTTP) with default IP address */
- netconn_bind(conn, NULL, WEB_THREAD_PORT);
-
- /* Put the connection into LISTEN state */
- netconn_listen(conn);
-
- /* Goes to the final priority after initialization.*/
- chThdSetPriority(WEB_THREAD_PRIORITY);
-
- while(1) {
- err = netconn_accept(conn, &newconn);
- if (err != ERR_OK)
- continue;
- http_server_serve(newconn);
- netconn_delete(newconn);
- }
-}
-
-#endif /* LWIP_NETCONN */
-
-/** @} */
diff --git a/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/web/web.h b/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/web/web.h
deleted file mode 100644
index 106dc26..0000000
--- a/demos/TIVA/RT-TM4C1294-LAUNCHPAD-LWIP/web/web.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-/**
- * @file web.h
- * @brief HTTP server wrapper thread macros and structures.
- * @addtogroup WEB_THREAD
- * @{
- */
-
-#ifndef _WEB_H_
-#define _WEB_H_
-
-#ifndef WEB_THREAD_STACK_SIZE
-#define WEB_THREAD_STACK_SIZE 1024
-#endif
-
-#ifndef WEB_THREAD_PORT
-#define WEB_THREAD_PORT 80
-#endif
-
-#ifndef WEB_THREAD_PRIORITY
-#define WEB_THREAD_PRIORITY (LOWPRIO + 2)
-#endif
-
-extern THD_WORKING_AREA(wa_http_server, WEB_THREAD_STACK_SIZE);
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- THD_FUNCTION(http_server, p);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _WEB_H_ */
-
-/** @} */