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/http/httpsend.c@96:43eb7a110f1a, 2018-12-29 (annotated)
- Committer:
- andrewboyson
- Date:
- Sat Dec 29 19:03:50 2018 +0000
- Revision:
- 96:43eb7a110f1a
- Parent:
- 61:aad055f1b0d1
- Child:
- 127:fcdfbfad8770
Added ability to add hex nibbles to HTTP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 54:84ef2b29cf7e | 1 | #include "tcpbuf.h" |
andrewboyson | 54:84ef2b29cf7e | 2 | |
andrewboyson | 54:84ef2b29cf7e | 3 | void HttpAddChar (char c) { TcpBufAddChar(c); } |
andrewboyson | 54:84ef2b29cf7e | 4 | void HttpFillChar (char c, int length) { TcpBufFillChar(c, length); } |
andrewboyson | 54:84ef2b29cf7e | 5 | int HttpAddText (const char* text) { return TcpBufAddText(text); } |
andrewboyson | 54:84ef2b29cf7e | 6 | int HttpAddV (char *fmt, va_list argptr) { return TcpBufAddV(fmt, argptr); } |
andrewboyson | 54:84ef2b29cf7e | 7 | int HttpAddF (char *fmt, ...) |
andrewboyson | 54:84ef2b29cf7e | 8 | { |
andrewboyson | 54:84ef2b29cf7e | 9 | va_list argptr; |
andrewboyson | 54:84ef2b29cf7e | 10 | va_start(argptr, fmt); |
andrewboyson | 54:84ef2b29cf7e | 11 | int size = TcpBufAddV(fmt, argptr); |
andrewboyson | 54:84ef2b29cf7e | 12 | va_end(argptr); |
andrewboyson | 54:84ef2b29cf7e | 13 | return size; |
andrewboyson | 54:84ef2b29cf7e | 14 | } |
andrewboyson | 54:84ef2b29cf7e | 15 | void HttpAddData (const char* data, int length) { TcpBufAddData(data, length); } |
andrewboyson | 54:84ef2b29cf7e | 16 | void HttpAddStream(void (*startFunction)(void), int (*enumerateFunction)(void)) { TcpBufAddStream(startFunction, enumerateFunction);} |
andrewboyson | 96:43eb7a110f1a | 17 | void HttpAddNibbleAsHex(int nibble) |
andrewboyson | 96:43eb7a110f1a | 18 | { |
andrewboyson | 96:43eb7a110f1a | 19 | nibble &= 0x0F; |
andrewboyson | 96:43eb7a110f1a | 20 | char c; |
andrewboyson | 96:43eb7a110f1a | 21 | if (nibble < 0x0A) c = nibble + '0'; |
andrewboyson | 96:43eb7a110f1a | 22 | else if (nibble < 0x10) c = nibble - 0xA + 'A'; |
andrewboyson | 96:43eb7a110f1a | 23 | else c = '0'; |
andrewboyson | 96:43eb7a110f1a | 24 | HttpAddChar(c); |
andrewboyson | 96:43eb7a110f1a | 25 | } |
andrewboyson | 96:43eb7a110f1a | 26 | void HttpAddInt12AsHex(int value) |
andrewboyson | 96:43eb7a110f1a | 27 | { |
andrewboyson | 96:43eb7a110f1a | 28 | HttpAddNibbleAsHex(value >> 8); |
andrewboyson | 96:43eb7a110f1a | 29 | HttpAddNibbleAsHex(value >> 4); |
andrewboyson | 96:43eb7a110f1a | 30 | HttpAddNibbleAsHex(value >> 0); |
andrewboyson | 96:43eb7a110f1a | 31 | } |
andrewboyson | 96:43eb7a110f1a | 32 | void HttpAddInt16AsHex(int value) |
andrewboyson | 96:43eb7a110f1a | 33 | { |
andrewboyson | 96:43eb7a110f1a | 34 | HttpAddNibbleAsHex(value >> 12); |
andrewboyson | 96:43eb7a110f1a | 35 | HttpAddNibbleAsHex(value >> 8); |
andrewboyson | 96:43eb7a110f1a | 36 | HttpAddNibbleAsHex(value >> 4); |
andrewboyson | 96:43eb7a110f1a | 37 | HttpAddNibbleAsHex(value >> 0); |
andrewboyson | 96:43eb7a110f1a | 38 | } |