Skip to content

Commit b4c666e

Browse files
bug fixes
1 parent 997a43d commit b4c666e

File tree

3 files changed

+47
-16
lines changed

3 files changed

+47
-16
lines changed

.vscode/c_cpp_properties.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Win32",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"${env:LOCALAPPDATA}/Arduino15/**"
8+
],
9+
"defines": [
10+
"_DEBUG",
11+
"UNICODE",
12+
"_UNICODE"
13+
],
14+
"cStandard": "c17",
15+
"cppStandard": "c++17",
16+
"intelliSenseMode": "windows-msvc-x64"
17+
}
18+
],
19+
"version": 4
20+
}

GoogleDocs.ino

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
#include "HTTPSRedirect.h"
1313
#include "DebugMacros.h"
1414

15-
// Fill ssid and password with your network credentials
16-
const char* ssid = "";
17-
const char* password = "";
18-
19-
const char* host = "script.google.com";
20-
// Replace with your own script id to make server side changes
21-
const char *GScriptId = "AKfycbzYw5G-oxvnwHpAJfDsS0PWNrO0KTBMiCW78lHUcEO6ZnFHvSw";
15+
extern const char* ssid;
16+
extern const char* password;
17+
extern const char* host;
18+
extern const char *GScriptId;
2219

2320
const int httpsPort = 443;
2421

@@ -33,9 +30,10 @@ String url2 = String("/macros/s/") + GScriptId + "/exec?cal";
3330
// Read from Google Spreadsheet
3431
String url3 = String("/macros/s/") + GScriptId + "/exec?read";
3532

36-
String payload_base = "{\"command\": \"appendRow\", \
37-
\"sheet_name\": \"Sheet1\", \
38-
\"values\": ";
33+
String payload_prefix = "{\"command\": \"appendRow\", \
34+
\"sheet_name\": \"Sheet1\", \
35+
\"values\": \"";
36+
String payload_suffix = "\"}";
3937
String payload = "";
4038

4139
HTTPSRedirect* client = nullptr;
@@ -109,9 +107,9 @@ void setup() {
109107
*/
110108

111109
// Send memory data to Google Sheets
112-
payload = payload_base + "\"" + free_heap_before + "," + free_stack_before + "\"}";
110+
payload = payload_prefix + free_heap_before + "," + free_stack_before + payload_suffix;
113111
client->POST(url2, host, payload, false);
114-
payload = payload_base + "\"" + ESP.getFreeHeap() + "," + ESP.getFreeContStack() + "\"}";
112+
payload = payload_prefix + ESP.getFreeHeap() + "," + ESP.getFreeContStack() + payload_suffix;
115113
client->POST(url2, host, payload, false);
116114

117115
// Note: setup() must finish within approx. 1s, or the the watchdog timer
@@ -125,7 +123,7 @@ void setup() {
125123
client->GET(url, host);
126124

127125
// Send memory data to Google Sheets
128-
payload = payload_base + "\"" + ESP.getFreeHeap() + "," + ESP.getFreeContStack() + "\"}";
126+
payload = payload_prefix + ESP.getFreeHeap() + "," + ESP.getFreeContStack() + payload_suffix;
129127
client->POST(url2, host, payload, false);
130128

131129
Serial.println("\nGET: Fetch Google Calendar Data:");
@@ -135,7 +133,7 @@ void setup() {
135133
client->GET(url2, host);
136134

137135
// Send memory data to Google Sheets
138-
payload = payload_base + "\"" + ESP.getFreeHeap() + "," + ESP.getFreeContStack() + "\"}";
136+
payload = payload_prefix + ESP.getFreeHeap() + "," + ESP.getFreeContStack() + payload_suffix;
139137
client->POST(url2, host, payload, false);
140138

141139
Serial.println("\nSeries of GET and POST requests");
@@ -170,7 +168,7 @@ void loop() {
170168
if (client != nullptr){
171169
if (!client->connected()){
172170
client->connect(host, httpsPort);
173-
payload = payload_base + "\"" + free_heap_before + "," + free_stack_before + "\"}";
171+
payload = payload_prefix + free_heap_before + "," + free_stack_before + payload_suffix;
174172
client->POST(url2, host, payload, false);
175173
}
176174
}
@@ -198,7 +196,7 @@ void loop() {
198196
}
199197

200198
Serial.println("POST append memory data to spreadsheet:");
201-
payload = payload_base + "\"" + ESP.getFreeHeap() + "," + ESP.getFreeContStack() + "\"}";
199+
payload = payload_prefix + ESP.getFreeHeap() + "," + ESP.getFreeContStack() + payload_suffix;
202200
if(client->POST(url2, host, payload)){
203201
;
204202
}

config.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// HTTPSRedirect Configuration file
2+
// Fill in your Wifi network credentials
3+
#ifndef HTTPSREDIRECT_CONFIG
4+
#define HTTPSREDIRECT_CONFIG
5+
const char* ssid = "";
6+
const char* password = "";
7+
8+
const char* host = "script.google.com";
9+
// Replace this with your own Google Sheets
10+
// script-id to make server side changes
11+
const char *GScriptId = "AKfycbzYw5G-oxvnwHpAJfDsS0PWNrO0KTBMiCW78lHUcEO6ZnFHvSw";
12+
13+
#endif

0 commit comments

Comments
 (0)