4 years, 2 months ago.

I want to implement a webserver

Currently, I am using NUCLEO-F401RE board and X-NUCLEO-IDW01M1 shield. And, I want to implement a webserver. How can I start this?

1 Answer

4 years, 2 months ago.

The IDW01M1 example program uses the NetworkSocketAPI library which provides a TCPServer class. Use that to set up a server on your board, then implement HTTP protocol on top of the server.

To parse incoming HTTP requests, check the http_parser folder of mbed-http.

Accepted Answer

Please explain more detail.

I already try it. But, X_NUCLEO_IDW01M1v2 library doesn't support.

int SpwfSAInterface::socket_listen(void* handle, int backlog) {
  return NSAPI_ERROR_UNSUPPORTED;
}

int SpwfSAInterface::socket_accept(void* handle, void* server) {    
  return NSAPI_ERROR_UNSUPPORTED;
}

Like this.

Thanks for your reply.

posted by JungHo Kim 28 Jul 2017

Ah, that's unfortunate. Then you're stuck using the AT command set to deal with this. AT+S.SOCKD looks like what you want. You could change the driver too, but that would be more work (f.e. esp8266 version).

posted by Jan Jongboom 28 Jul 2017

Thanks a lot.

I was disable to embedded web server through "AT+S.HTTPD=0".

And, enable to socket server through "AT+S.SOCKD=80"

But, there was no method to receive from client.

In Tx, I use "AT+S.", and "at+s.".

I want to receive data from client.

posted by JungHo Kim 03 Aug 2017

How it works on ESP8266 is that you get a CONNECT message when someone opens TCP Socket to your server. Unlike a normal command you don't have to do an AT command first, you'll just get the data whenever it's available. If you run SerialPassthrough on your board, start the webserver and connect to the webserver, what do you see? Any messages related to connection?

If you do get those messages, then you can a RxIrq hook on the serial to receive them when they come in.

posted by Jan Jongboom 03 Aug 2017

Thank you for advice.

Here is what I want to make.

1. Run an WiFi-AP on Raspberry Pi 3 (OK)

2. Connect to Raspberry AP and run a web server on MBED with NUCLEO-F401RE + X-NUCLEO-IDW01M1 (OK)

3. Connect to Raspberry AP with my iPhone and connect via safari web browser to my web server. (OK)

4. Receive these HTTP-GET command and route URL and execute properly action. Like GPIO handling. (Fail)

You mean, I will do some kind of hacking.

posted by JungHo Kim 04 Aug 2017

If you inspect the data coming over the serial going from IDW01M1 -> F401RE you should see a `CONNECT` (or something similar) come in, and then the raw payload of the request. The raw payload can be parsed with mbed-http, but if you don't see the payload come in then I can't help you, as I don't have this board...

posted by Jan Jongboom 04 Aug 2017

Thank you very much !!! I can solve this problem.

I got all data from wifi module after run a socket server. After run a socket server, I never use a provided library's API. I'm making my own functions and only use these.

It is a kind of hooking, you said.

posted by JungHo Kim 07 Aug 2017