Skip to content

Commit a55ed5d

Browse files
committed
retitled web page and modified cgi hangler
1 parent d316952 commit a55ed5d

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

pico_w/wifi/access_point/content/index.shtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<title>Pico Access Point</title>
44
</head>
55
<body>
6-
<h1>Hello from Pico.</h1>
6+
<h1>Hello from Pico W</h1>
77
<p>Led is <!--#led--></p>
88
<p></p>
99
<form action="/switch.cgi" method="get">
10-
<button name="switch" value="switch">Turn led <!--#not_led--></button>
10+
<button name="switch" value="<!--#not_led-->">Turn led <!--#not_led--></button>
1111
</form>
1212
</body>
1313
</html>

pico_w/wifi/access_point/picow_access_point.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@
2424
static absolute_time_t wifi_connected_time;
2525
bool led_state;
2626
bool complete;
27+
bool desired_state;
2728

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

31-
// Get led state
32-
led_state = status_led_get_state();
33-
printf("LED state: %d\n", led_state);
34-
35-
// Now flip the state
36-
status_led_set_state(!led_state);
32+
// Get desired LED state from GET request and set LED
33+
desired_state = !strcmp("ON", pcValue[0]);
34+
status_led_set_state(desired_state);
3735

3836
// Update led state
3937
led_state = status_led_get_state();

0 commit comments

Comments
 (0)