An open API service indexing awesome lists of open source software.

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.

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`.
```html

A simple Web Server

COMP3215



LED ON
LED OFF

```
![Web Page](webpage.png)

### 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.