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:
Wed May 08 12:15:13 2019 +0000
Revision:
142:a8c0890a58d1
Parent:
131:774f7f367031
Child:
144:6bd5c54efc7d
Updated the lpc1768 module

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 61:aad055f1b0d1 1 #include <stdbool.h>
andrewboyson 61:aad055f1b0d1 2
andrewboyson 54:84ef2b29cf7e 3 #include "http.h"
andrewboyson 54:84ef2b29cf7e 4 #include "tcpbuf.h"
andrewboyson 54:84ef2b29cf7e 5 #include "action.h"
andrewboyson 54:84ef2b29cf7e 6 #include "net.h"
andrewboyson 54:84ef2b29cf7e 7 #include "log.h"
andrewboyson 75:603b10404183 8 #include "led.h"
andrewboyson 142:a8c0890a58d1 9 #include "restart.h"
andrewboyson 54:84ef2b29cf7e 10
andrewboyson 54:84ef2b29cf7e 11 bool HttpTrace = false;
andrewboyson 54:84ef2b29cf7e 12
andrewboyson 126:62edacc9f14d 13 //Plumb into these from your html server
andrewboyson 131:774f7f367031 14 void (*HttpRequestFunction)(int size, char* pRequestStream, uint32_t positionInRequestStream, int* pToDo, bool* pPostComplete, uint32_t* pDelayUntil);
andrewboyson 126:62edacc9f14d 15 void (*HttpReplyFunction )(int todo);
andrewboyson 54:84ef2b29cf7e 16
andrewboyson 131:774f7f367031 17 void HttpHandleRequest(int size, char* pRequestStream, uint32_t positionInRequestStream, int* pToDo, bool* pPostComplete, uint32_t* pDelayUntil)
andrewboyson 54:84ef2b29cf7e 18 {
andrewboyson 142:a8c0890a58d1 19 int lastRestartPoint = RestartPoint;
andrewboyson 142:a8c0890a58d1 20 RestartPoint = FAULT_POINT_HttpHandleRequest;
andrewboyson 98:b977424ec7f7 21
andrewboyson 54:84ef2b29cf7e 22 if (HttpTrace)
andrewboyson 54:84ef2b29cf7e 23 {
andrewboyson 79:f50e02fb5c94 24 LogF("HTTP <<< %d (%u)\r\n", size, positionInRequestStream);
andrewboyson 54:84ef2b29cf7e 25 }
andrewboyson 126:62edacc9f14d 26
andrewboyson 131:774f7f367031 27 HttpRequestFunction(size, pRequestStream, positionInRequestStream, pToDo, pPostComplete, pDelayUntil);
andrewboyson 126:62edacc9f14d 28
andrewboyson 142:a8c0890a58d1 29 RestartPoint = lastRestartPoint;
andrewboyson 71:736a5747ade1 30 }
andrewboyson 79:f50e02fb5c94 31 void HttpSendReply(int* pSize, char* pReplyStream, uint32_t positionInReplyStream, uint16_t mss, int todo)
andrewboyson 71:736a5747ade1 32 {
andrewboyson 54:84ef2b29cf7e 33 TcpBufStart(positionInReplyStream, mss, pReplyStream);
andrewboyson 71:736a5747ade1 34 HttpReplyFunction(todo);
andrewboyson 54:84ef2b29cf7e 35 *pSize = TcpBufLength();
andrewboyson 55:e64b8b47a2b6 36
andrewboyson 55:e64b8b47a2b6 37 if (HttpTrace)
andrewboyson 55:e64b8b47a2b6 38 {
andrewboyson 55:e64b8b47a2b6 39 LogF("HTTP >>> %d (%d)\r\n", *pSize, positionInReplyStream);
andrewboyson 55:e64b8b47a2b6 40 }
andrewboyson 71:736a5747ade1 41 }