forked from exosite-garage/arduino_exosite_library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExosite.h
117 lines (92 loc) · 3.24 KB
/
Exosite.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//*****************************************************************************
//
// exosite.h - Prototypes for the Exosite Cloud API
//
// Copyright (c) 2012 Exosite LLC. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Exosite LLC nor the names of its contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
//*****************************************************************************
#ifndef Exosite_h
#define Exosite_h
#define ACTIVATOR_VERSION "2.5.0"
// Select a Debug Level:
//#define EXOSITEDEBUG 1
//#define EXOSITEDEBUG 2
//#define EXOSITEDEBUG 3
// Enable or Disable Direct from ROM Sending
// Disabled on ESP because of performance issue and lack of need.
#if defined(ESP8266) or defined(NO_FLASH_NET_STRINGS)
#define G(x) x
#else
#define G(x) F(x)
#endif
// Enable Memory Debugging: (requires MemoryFree library)
//#define EXOSITEDEBUGMEM
#ifndef CIK_EEPROM_ADDRESS
#define CIK_EEPROM_ADDRESS 0 //Takes Addresses 0 - 39 (dec)
#endif
// Do not Edit Past This Point
#include <SPI.h>
#include <Client.h>
#include <EEPROM.h>
#ifdef EXOSITEDEBUGMEM
#include <MemoryFree.h>
#endif
class Exosite
{
private:
class Client* client;
char cik[41];
const char *serverName = "m2.exosite.com";
char rxdata[200];
char aliasList[50];
char* varPtr;
char* varPtr2;
boolean ret;
int stringPos;
boolean DataRx;
boolean RxLoop;
char c;
unsigned long timeout_time;
unsigned long time_now;
unsigned long timeout;
// Helpers
boolean isHex(char *str, int len);
public:
// Constructor
Exosite(Client *_client);
Exosite(const char *_cik, Client *_client);
Exosite(const String _cik, Client *_client);
#if defined(ESP8266)
void begin();
#endif
// Current Methods
void setDomain(const char *domain);
boolean writeRead(const char* writeString,const char* readString, char** returnString);
boolean writeRead(const String &writeString, const String &readString, String &returnString);
boolean provision(const char* vendorString, const char* modelString, const char* snString);
boolean saveNVCIK();
boolean fetchNVCIK();
unsigned long time();
// Depreciated Methods
int sendToCloud(String res, int value);
int readFromCloud(String res ,String* pResult);
};
#endif