-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpSyncTransaction.h
69 lines (54 loc) · 1.37 KB
/
HttpSyncTransaction.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* "Drinks" RFID Terminal
* Buy sodas with your company badge!
*
* Benoit Blanchon 2014 - MIT License
* https://github.com/bblanchon/DrinksRfidTerminal
*/
#ifndef _HTTPSYNCTRANSACTION_H
#define _HTTPSYNCTRANSACTION_H
#include "Catalog.h"
#include "HttpClient.h"
class HttpSyncTransaction
{
public:
HttpSyncTransaction(HttpClient& http)
: http(http)
{
}
bool perform()
{
//return send() && parse() && validate();
bool res = send();
if(res)
Serial.println("Send OK");
else
Serial.println("Send NOK");
res = parse();
if(res)
Serial.println("parse OK");
else
Serial.println("parse NOK");
res = validate();
if(res)
Serial.println("validate OK");
else
Serial.println("validate NOK");
return send() && parse() && validate();
}
void getCatalog(Catalog&);
unsigned long getTime() { return strtoul(time, 0, 10); }
private:
bool send();
bool parse();
bool validate();
HttpClient& http;
static const int buffer_size = 512; //increased for bigger JSON
char buffer[buffer_size];
const char* time;
const char* header;
const char* products[Catalog::MAX_PRODUCT_COUNT + 1];
const char* dbID[Catalog::MAX_PRODUCT_COUNT + 1];
const char* hash;
};
#endif