A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.

Dependents:   oldheating gps motorhome heating

Committer:
andrewboyson
Date:
Thu Jan 19 23:03:26 2017 +0000
Revision:
1:5f70c361db20
Child:
2:849103b5a16d
TCP and HTTP beginning to work - got 'hello world' message displayed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 1:5f70c361db20 1 #include "mbed.h"
andrewboyson 1:5f70c361db20 2
andrewboyson 1:5f70c361db20 3 void HttpRequest(int position, int len, char *pData)
andrewboyson 1:5f70c361db20 4 {
andrewboyson 1:5f70c361db20 5 }
andrewboyson 1:5f70c361db20 6 int HttpResponse(int position, char *pData)
andrewboyson 1:5f70c361db20 7 {
andrewboyson 1:5f70c361db20 8 char *pHtml = "HTTP/1.1 200 OK\r\n"
andrewboyson 1:5f70c361db20 9 "Content-Type: text/html; charset=UTF-8\r\n"
andrewboyson 1:5f70c361db20 10 "Connection: close\r\n"
andrewboyson 1:5f70c361db20 11 "\r\n"
andrewboyson 1:5f70c361db20 12 "<html>\r\n"
andrewboyson 1:5f70c361db20 13 "<head>\r\n"
andrewboyson 1:5f70c361db20 14 " <title>GPS Clock</title>\r\n"
andrewboyson 1:5f70c361db20 15 "</head>\r\n"
andrewboyson 1:5f70c361db20 16 "<body>\r\n"
andrewboyson 1:5f70c361db20 17 " Hello World, this is the GPS Clock.\r\n"
andrewboyson 1:5f70c361db20 18 "</body>\r\n"
andrewboyson 1:5f70c361db20 19 "</html>\r\n";
andrewboyson 1:5f70c361db20 20 int len = strlen(pHtml) - position;
andrewboyson 1:5f70c361db20 21 if (len <= 0) return 0;
andrewboyson 1:5f70c361db20 22 strcpy(pData, pHtml);
andrewboyson 1:5f70c361db20 23 return strlen(pHtml);
andrewboyson 1:5f70c361db20 24
andrewboyson 1:5f70c361db20 25 }