Skip to content

modified picow access point example to use lwip http server #701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pico_w/wifi/access_point/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ target_include_directories(picow_access_point_background PRIVATE
${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
${CMAKE_CURRENT_LIST_DIR}/dhcpserver
${CMAKE_CURRENT_LIST_DIR}/dnsserver
${PICO_LWIP_CONTRIB_PATH}/apps/httpd
)

target_link_libraries(picow_access_point_background
pico_cyw43_arch_lwip_threadsafe_background
pico_stdlib
pico_lwip_http
ap_content
pico_status_led
)
# You can change the address below to change the address of the access point
pico_configure_ip4_address(picow_access_point_background PRIVATE
Expand All @@ -31,13 +35,22 @@ target_include_directories(picow_access_point_poll PRIVATE
${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
${CMAKE_CURRENT_LIST_DIR}/dhcpserver
${CMAKE_CURRENT_LIST_DIR}/dnsserver
${PICO_LWIP_CONTRIB_PATH}/apps/httpd
)
target_link_libraries(picow_access_point_poll
pico_cyw43_arch_lwip_poll
pico_stdlib
pico_lwip_http
ap_content
pico_status_led
)
# You can change the address below to change the address of the access point
pico_configure_ip4_address(picow_access_point_poll PRIVATE
CYW43_DEFAULT_IP_AP_ADDRESS 192.168.4.1
)
pico_add_extra_outputs(picow_access_point_poll)

pico_add_library(ap_content NOFLAG)
pico_set_lwip_httpd_content(ap_content INTERFACE
${CMAKE_CURRENT_LIST_DIR}/content/index.shtml
)
13 changes: 13 additions & 0 deletions pico_w/wifi/access_point/content/index.shtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head>
<title>Pico Access Point</title>
</head>
<body>
<h1>Hello from Pico.</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this ought to say "Hello from Pico W" ? 😉

<p>Led is <!--#led--></p>
<p></p>
<form action="/switch.cgi" method="get">
<button name="switch" value="switch">Turn led <!--#not_led--></button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, rather than having the switch_cgi_handler simply reading the LED's current state, and then inverting it, I wonder if it might be more idiomatic to do e.g.:

<button name="switch" value="<!--#not_led-->">Turn led <!--#not_led--></button>

and then have the switch_cgi_handler read the value of the switch parameter? (which I guess would also serve as a useful example of how to deal with GET query-parameters 🙂 )

</form>
</body>
</html>
10 changes: 10 additions & 0 deletions pico_w/wifi/access_point/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@
// This example uses a common include to avoid repetition
#include "lwipopts_examples_common.h"

// Enable some httpd features
#define LWIP_HTTPD_CGI 1
#define LWIP_HTTPD_SSI 1
#define LWIP_HTTPD_SSI_MULTIPART 1
#define LWIP_HTTPD_SUPPORT_POST 0
#define LWIP_HTTPD_SSI_INCLUDE_TAG 0

// Generated file containing html data
#define HTTPD_FSDATA_FILE "pico_fsdata.inc"

#endif
Loading