-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from Company-of-Things/21-esp32-http-support
21 esp32 http support
- Loading branch information
Showing
8 changed files
with
167 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
static const char* buypass_cert = | ||
"-----BEGIN CERTIFICATE-----\n" | ||
"MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" | ||
"MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" | ||
"Q2xhc3MgMiBSb290IENBMB4XDTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1ow\n" | ||
"TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw\n" | ||
"HgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB\n" | ||
"BQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1g1Lr\n" |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Lo\n" | ||
"+fsicdl9sz1Gv7SEr5AcD48Saq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7\n" | ||
"KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYdDnkM/crqJIByw5c/8nerQyIKx+u2\n" | ||
"DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWDLfJ6v9r9jv6ly0Us\n" | ||
"H8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0oyLQ\n" | ||
"I+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK7\n" | ||
"5t98biGCwWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h\n" | ||
"3PFaTWwyI0PurKju7koSCTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPz\n" | ||
"Y11aWOIv4x3kqdbQCtCev9eBCfHJxyYNrJgWVqA=\n" | ||
"-----END CERTIFICATE-----\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include "deploii_handler.h" | ||
|
||
DeploiiHandlerWiFiHTTP::DeploiiHandlerWiFiHTTP(bool debug) | ||
#if defined(ESP32) | ||
: _http(), _debug(debug) | ||
#elif defined(ARDUINO) | ||
: _debug(debug) | ||
#else | ||
: _debug(debug) | ||
#endif | ||
{ | ||
} | ||
|
||
DeploiiHandlerWiFiHTTP::~DeploiiHandlerWiFiHTTP() { | ||
#if defined(ESP32) | ||
#elif defined(ARDUINO) | ||
#else | ||
#endif | ||
} | ||
|
||
void DeploiiHandlerWiFiHTTP::connect( | ||
char* boardID, | ||
char* ssid, | ||
const char* pwd, | ||
const char* host, | ||
const int port, | ||
const char* url, | ||
bool ssl) { | ||
connectWiFi(ssid, pwd); | ||
#if defined(ESP32) | ||
if (ssl) | ||
_http.begin(host, port, url, buypass_cert); | ||
else | ||
_http.begin(host, port, url); | ||
|
||
_http.addHeader("Authorization", boardID, false, false); | ||
#elif defined(ARDUINO) | ||
#else | ||
#endif | ||
} | ||
|
||
void DeploiiHandlerWiFiHTTP::loop() { | ||
} | ||
|
||
void DeploiiHandlerWiFiHTTP::send(const uint8_t* data, size_t size) { | ||
#if defined(ESP32) | ||
_http.POST((uint8_t*)data, size); | ||
#elif defined(ARDUINO) | ||
#else | ||
#endif | ||
} | ||
|
||
#if defined(ESP32) | ||
|
||
void DeploiiHandlerWiFiHTTP::connectWiFi(char* ssid, const char* pwd) { | ||
if (_debug) Serial.println("Connecting to WiFi"); | ||
WiFi.mode(WIFI_STA); | ||
WiFi.begin(ssid, pwd); | ||
while (WiFi.status() != WL_CONNECTED) { | ||
delay(DEPLOII_WIFI_RECONNECT_TIME); | ||
if (_debug) { | ||
Serial.println("Connecting to WiFi"); | ||
} | ||
} | ||
if (_debug) { | ||
Serial.println("WiFi connected"); | ||
Serial.println(WiFi.localIP()); | ||
} | ||
if (_debug) Serial.println(WiFi.localIP()); | ||
} | ||
#elif defined(ARDUINO) | ||
|
||
void DeploiiHandlerWiFiHTTP::connectWiFi(char* ssid, const char* pwd) { | ||
while (WiFi.begin(ssid, pwd) != WL_CONNECTED) delay(DEPLOII_WIFI_RECONNECT_TIME); | ||
} | ||
#else | ||
void DeploiiHandlerWiFiHTTP::connectWiFi(char* ssid, const char* pwd) {} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters