Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add https support, use WiFiClientSecure instead of WiFiClient #5

Merged
merged 1 commit into from
Oct 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions linka-firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ PMS pms(pmsSerial, false); // Use the software serial port for the PMS
PMS::DATA g_data;

// Start HTTP client
WiFiClient client;
WiFiClientSecure client;
HTTPClient http;

// WifiManager
Expand All @@ -105,7 +105,7 @@ WiFiConnectParam latitude_param("latitude", "Latitude", "", 13);
WiFiConnectParam longitude_param("longitude", "Longitude", "", 13);
WiFiConnectParam sensor_param("sensor", "Sensor model", "PMS7003", 8);
WiFiConnectParam description_param("description", "Description", "", 21);
WiFiConnectParam api_url_param("api_url", "URL for the backend", "http://rald-dev.greenbeep.com/api/v1/measurements", 71);
WiFiConnectParam api_url_param("api_url", "URL for the backend", "https://rald-dev.greenbeep.com/api/v1/measurements", 71);

// vars to store parameters
char api_key[33] = "";
Expand Down Expand Up @@ -329,6 +329,8 @@ void reportToHttp()
recorded);
Serial.println(measurements);

client.setInsecure();

if (http.begin(client, api_url)) {

// Add headers
Expand Down