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
tcp/tcpbuf.c
- Committer:
- andrewboyson
- Date:
- 2019-08-20
- Revision:
- 155:22f249751106
- Parent:
- 146:0fc66d610fd6
File content as of revision 155:22f249751106:
#include <stdbool.h> #include <stdint.h> static uint32_t currentPositionInMessage; static uint32_t bufferPositionInMessage; static int bufferLength; static uint8_t* pBuffer; static uint8_t* p; void TcpBufStart(uint32_t position, int mss, uint8_t *pData) { currentPositionInMessage = 0; bufferPositionInMessage = position; bufferLength = mss; pBuffer = pData; p = pData; } int TcpBufLength() { return p - pBuffer; } bool TcpBufFilled() { return p - pBuffer >= bufferLength; } void TcpBufAddChar(char c) { //Add character if the current position is within the buffer if (currentPositionInMessage >= bufferPositionInMessage && currentPositionInMessage < bufferPositionInMessage + bufferLength) *p++ = c; currentPositionInMessage++; } uint8_t* TcpBufGetPointerNext(void) { return p; }