Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions pico_w/wifi/access_point/content/index.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<title>Pico Access Point</title>
</head>
<body>
<h1>Hello from Pico.</h1>
<h1>Hello from Pico W</h1>
<p>Led is <!--#led--></p>
<p></p>
<form action="/switch.cgi" method="get">
<button name="switch" value="switch">Turn led <!--#not_led--></button>
<button name="switch" value="<!--#not_led-->">Turn led <!--#not_led--></button>
</form>
</body>
</html>
10 changes: 4 additions & 6 deletions pico_w/wifi/access_point/picow_access_point.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@
static absolute_time_t wifi_connected_time;
bool led_state;
bool complete;
bool desired_state;

static const char *switch_cgi_handler(int iIndex, int iNumParams, char *pcParam[], char *pcValue[]) {
printf("Switch cgi handler called\n");

// Get led state
led_state = status_led_get_state();
printf("LED state: %d\n", led_state);

// Now flip the state
status_led_set_state(!led_state);
// Get desired LED state from GET request and set LED
desired_state = !strcmp("ON", pcValue[0]);
status_led_set_state(desired_state);

// Update led state
led_state = status_led_get_state();
Expand Down