@@ -81,6 +81,8 @@ static void sendAndEchoToSerial(WiFiClientSecure& client, const char *line) {
81
81
ParseClient::ParseClient () {
82
82
memset (applicationId, 0 , sizeof (applicationId));
83
83
memset (clientKey, 0 , sizeof (clientKey));
84
+ memset (serverURL, 0 , sizeof (serverURL));
85
+ memset (hostFingerprint, 0 , sizeof (hostFingerprint));
84
86
memset (installationId, 0 , sizeof (installationId));
85
87
memset (sessionToken, 0 , sizeof (sessionToken));
86
88
memset (lastPushTime, 0 , sizeof (lastPushTime));
@@ -110,6 +112,29 @@ void ParseClient::begin(const char *applicationId, const char *clientKey) {
110
112
restoreKeys ();
111
113
}
112
114
115
+ void ParseClient::setServerURL (const char *serverURL) {
116
+ Serial.print (" setting serverURL(" );
117
+ Serial.print (serverURL ? serverURL : " NULL" );
118
+ Serial.println (" )" );
119
+ if (serverURL) {
120
+ strncpy (this ->serverURL , serverURL, sizeof (this ->serverURL ));
121
+ }
122
+ }
123
+
124
+ void ParseClient::setHostFingerprint (const char *hostFingerprint) {
125
+ Serial.print (" setting hostFingerprint(" );
126
+ Serial.print (hostFingerprint ? hostFingerprint : " NULL" );
127
+ Serial.println (" )" );
128
+ if (hostFingerprint) {
129
+ strncpy (this ->hostFingerprint , hostFingerprint, sizeof (this ->hostFingerprint ));
130
+ }
131
+ }
132
+
133
+ void ParseClient::setClientInsecure () {
134
+ Serial.println (" setting connection client insecure" );
135
+ client.setInsecure ();
136
+ }
137
+
113
138
void ParseClient::setInstallationId (const char *installationId) {
114
139
if (installationId) {
115
140
if (strcmp (this ->installationId , installationId))
@@ -201,8 +226,10 @@ ParseResponse ParseClient::sendRequest(const String& httpVerb, const String& htt
201
226
202
227
int retry = 3 ;
203
228
bool connected;
229
+
230
+ client.setFingerprint (hostFingerprint);
204
231
205
- while (!(connected = client.connect (PARSE_API , SSL_PORT)) && retry--) {
232
+ while (!(connected = client.connect (serverURL , SSL_PORT)) && retry--) {
206
233
Serial.printf (" connecting...%d\n " , retry);
207
234
yield ();
208
235
}
@@ -220,7 +247,7 @@ ParseResponse ParseClient::sendRequest(const String& httpVerb, const String& htt
220
247
snprintf (buff, sizeof (buff) - 1 , " %s %s HTTP/1.1\r\n " , httpVerb.c_str (), httpPath.c_str ());
221
248
}
222
249
sendAndEchoToSerial (client, buff);
223
- snprintf (buff, sizeof (buff) - 1 , " Host: %s\r\n " , PARSE_API );
250
+ snprintf (buff, sizeof (buff) - 1 , " Host: %s\r\n " , serverURL );
224
251
sendAndEchoToSerial (client, buff);
225
252
snprintf (buff, sizeof (buff) - 1 , " X-Parse-Client-Version: %s\r\n " , CLIENT_VERSION);
226
253
sendAndEchoToSerial (client, buff);
0 commit comments