Paperd.Ink Library 0.0.5
Library for interacting with Paperd.Ink devices.
Loading...
Searching...
No Matches
crypto_parser.cpp
Go to the documentation of this file.
1#include "crypto.h"
2#include "crypto_parser.h"
3
5static CRYPTO_STATE key_state;
6
10
12{
13 key_state = NOT_FOUND;
14}
15
17{
18 if (key.equals("usd"))
19 key_state = FOUND_PRICE;
20 else if (key.equals("usd_24h_change"))
21 key_state = FOUND_CHANGE;
22}
23
24void CryptoJsonListener::value(String value)
25{
26 if (key_state == FOUND_PRICE) {
28 //price[CRYPTO_MAX_CHANGE_LENGTH_STR] = '\0';
29 Serial.printf("Price: %s\r\n", Paperdink_Crypto.price);
30 key_state = NOT_FOUND;
31 } else if (key_state == FOUND_CHANGE) {
33 //change[CRYPTO_MAX_CHANGE_LENGTH_STR] = '\0';
34 Serial.printf("Change: %s\r\n", Paperdink_Crypto.change);
35 key_state = NOT_FOUND;
36 }
37}
38
42
46
50
54
virtual void startObject()
virtual void startDocument()
virtual void key(String key)
virtual void endDocument()
virtual void startArray()
virtual void endObject()
virtual void endArray()
virtual void value(String value)
virtual void whitespace(char c)
char change[CRYPTO_MAX_CHANGE_LENGTH_STR]
Definition crypto.h:23
char price[CRYPTO_MAX_PRICE_LENGTH_STR]
Definition crypto.h:22
PaperdinkUICryptoClass Paperdink_Crypto
Definition crypto.cpp:124
#define CRYPTO_MAX_PRICE_LENGTH
Definition crypto.h:9
#define CRYPTO_MAX_CHANGE_LENGTH
Definition crypto.h:13
CRYPTO_STATE
@ FOUND_CHANGE
@ FOUND_PRICE
@ NOT_FOUND