-
Notifications
You must be signed in to change notification settings - Fork 37
/
Exosite.h
136 lines (107 loc) · 4.52 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//*****************************************************************************
//
// exosite.h - Prototypes for the Exosite Cloud API
//
// Copyright (c) 2012-2017 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.3"
// 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.io";
int serverPort = 80;
char rxdata[200];
char aliasList[50];
char* varPtr;
char* varPtr2;
boolean ret;
int stringPos;
boolean DataRx;
boolean RxLoop;
char c;
unsigned long longPollTimeoutRequest;
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
#ifdef SL_DRIVER_VERSION
void setDomain(const char *domain, int port=443);
#else /*CC3200*/
void setDomain(const char *domain, int port=80);
#endif /*CC3200*/
boolean writeRead(const char* writeString,const char* readString, char** returnString);
boolean writeRead(const String &writeString, const String &readString, String &returnString);
boolean read(const char* readString, char** returnString);
boolean read(const String &readString, String &returnString);
boolean longPoll(const int timeoutRequest, const char* readString, char** returnString, const char* currentTimestamp);
boolean longPoll(const int timeoutRequest, const String &readString, String &returnString, const String = "");
boolean write(const char* writeString);
boolean write(const String &writeString);
boolean provision(const char* vendorString, const char* modelString, const char* snString);
boolean listAvailableContent(const char* vendorString, const char* modelString, char** returnString);
boolean listAvailableContent(const String &vendorString, const String &modelString, String &returnString);
boolean getContentInfo(const char* vendorString, const char* modelString, const char* idString, char** returnString);
boolean getContentInfo(const String &vendorString, const String &modelString, const String &idString, String &returnString);
boolean downloadContent(const char* vendorString, const char* modelString, const char* idString, char** returnString, const char* byteRange);
boolean downloadContent(const String &vendorString, const String &modelString, const String &idString, String &returnString, const String = "");
boolean saveNVCIK();
boolean fetchNVCIK();
unsigned long timestamp();
};
#endif