https://github.com/rhthomas/frdm-web-server
COMP3215 Lab 2 – Build a simple web server on the KW41Z which is accessed over USB.
https://github.com/rhthomas/frdm-web-server
arm arm-cortex-m0 keil nxp rtos web-server
Last synced: 2 months ago
JSON representation
COMP3215 Lab 2 – Build a simple web server on the KW41Z which is accessed over USB.
- Host: GitHub
- URL: https://github.com/rhthomas/frdm-web-server
- Owner: rhthomas
- Created: 2017-11-11T12:00:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-26T21:10:33.000Z (over 7 years ago)
- Last Synced: 2025-01-25T16:32:01.205Z (4 months ago)
- Topics: arm, arm-cortex-m0, keil, nxp, rtos, web-server
- Language: C
- Size: 1.44 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# KW41Z USB web server
## mbed Library
A PPP example application and library can be found [here](https://os.mbed.com/users/nixnax/code/PPP-Blinky/).
### HTML
The web page to be loaded by the KW41z is shown below. Pressing the *LED ON* button sends a POST request with `button=1`. Conversely with *LED OFF* the it sets `button=0`.
```htmlA simple Web Server
COMP3215
LED ON
LED OFF
```
### Extracting the button value
In lines 893-894 in the `httpResponse()` function, the value of `button` is extracted using `strstr()`.
```c
...
httpGetLedOff = strstr(dataStart,"button=0");
httpGetLedOn = strstr(dataStart,"button=1");
...
```At the bottom of the response handler the LED state is then handled (lines 943-953).
```c
...
if(httpGetLedOn) {
// put something here to send RF to turn on LED
led1 = 0;
memcpy(n+dataStart,body,sizeof(body));
n = n + sizeof(body)-1; // one less than size
} else if(httpGetLedOff) {
// put something here to send RF to turn off LED
led1 = 1;
memcpy(n+dataStart,body,sizeof(body));
n = n + sizeof(body)-1; // one less than size
}
...
```After setting the state of the LED, the webpage is then reserved to the host.