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

Committer:
andrewboyson
Date:
2019-02-22
Revision:
125:8c84daac38ab
Parent:
96:43eb7a110f1a
Child:
127:fcdfbfad8770

File content as of revision 125:8c84daac38ab:

#include "tcpbuf.h"

void HttpAddChar  (char c)                                                      {        TcpBufAddChar(c);                                 }
void HttpFillChar (char c, int length)                                          {        TcpBufFillChar(c, length);                        }
int  HttpAddText  (const char* text)                                            { return TcpBufAddText(text);                              }
int  HttpAddV     (char *fmt, va_list argptr)                                   { return TcpBufAddV(fmt, argptr);                          }
int  HttpAddF     (char *fmt, ...)
{
    va_list argptr;
    va_start(argptr, fmt);
    int size = TcpBufAddV(fmt, argptr);
    va_end(argptr);
    return size;
}
void HttpAddData  (const char* data, int length)                                {        TcpBufAddData(data, length);                      }
void HttpAddStream(void (*startFunction)(void), int (*enumerateFunction)(void)) {        TcpBufAddStream(startFunction, enumerateFunction);}
void HttpAddNibbleAsHex(int nibble)
{
    nibble &= 0x0F;
    char c;
    if      (nibble < 0x0A) c = nibble + '0';
    else if (nibble < 0x10) c = nibble - 0xA + 'A';
    else                    c = '0';
    HttpAddChar(c);
}
void HttpAddInt12AsHex(int value)
{   
    HttpAddNibbleAsHex(value >> 8);
    HttpAddNibbleAsHex(value >> 4);
    HttpAddNibbleAsHex(value >> 0);
}
void HttpAddInt16AsHex(int value)
{   
    HttpAddNibbleAsHex(value >> 12);
    HttpAddNibbleAsHex(value >>  8);
    HttpAddNibbleAsHex(value >>  4);
    HttpAddNibbleAsHex(value >>  0);
}