httpClient.h
1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Custom http client implementation based on httpServer
*
*/
#ifndef HTTP_CLIENT_H
#define HTTP_CLIENT_H
#include "libwismart.h"
#include "lwip/opt.h"
#include "lwip/tcp.h"
#include "lwip/udp.h"
#include "lwip/sys.h"
#include "lwip/api.h"
#include "ch.h"
#include "globals.h"
#define DEFAULT_REMOTE_IP "147.83.2.135" // www.upc.edu
#define DEFAULT_REMOTE_PORT 80
#define ENDL "\r\n"
#define CONTENT_TYPE_HEADER "Content-Type: application/json; charset=UTF-8"
#define DBG_HTTP(fmt,...) printf("%c[1;35mhttpClient.c:%c[1;00m "fmt,0x1B,0x1B, ##__VA_ARGS__)
//#define DBG_HTTP(fmt,...) printf("")
typedef enum reqMethod
{
post,
get,
put,
del //delete may be a special word.
}reqMethod;
typedef struct httpHeaders
{
enum reqMethod method;
char* uri;
int uri_size;
char* host;
int host_size;
}httpHeaders;
int httpRequest(struct httpHeaders head, char* content, int content_size);
const char* reqMethod2text(enum reqMethod method);
char* int2string(int num);
int numberofdigits(int number);
int response2int(char* chars);
#endif