Skip to content

Commit 4651d67

Browse files
committed
Update Signer class and fixed NTP time synching issue.
1 parent cb85962 commit 4651d67

File tree

7 files changed

+22
-21
lines changed

7 files changed

+22
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Arduino Google Sheet Client Library for ESP8266 and ESP32
22

33

4-
Arduino Google Sheet Client Library for ESP8266 and ESP32 v1.0.1.
4+
Arduino Google Sheet Client Library for ESP8266 and ESP32 v1.0.2.
55

66
This library allows devices to authenticate and communicate with Google Sheet APIs using the Service Account.
77

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ESP-Google-Sheet-Client",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"keywords": "communication, REST, esp32, esp8266, arduino",
55
"description": "Arduino Google Sheet REST client library for ESP8266 and ESP32. This library allows devices to communicate with Google Sheet API to read, edit and delete the spreadsheets",
66
"repository": {

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name=ESP-Google-Sheet-Client
22

3-
version=1.0.1
3+
version=1.0.2
44

55
author=Mobizt
66

src/lib/ESPSigner/ESPSigner.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.2
2+
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.4
33
*
44
* This library used RS256 for signing algorithm.
55
*
@@ -238,11 +238,15 @@ bool ESP_Signer::handleToken()
238238
config->signer.tokens.status = esp_signer_token_status_uninitialized;
239239
}
240240

241-
config->signer.tokens.status = esp_signer_token_status_on_initialize;
242-
config->signer.tokens.error.code = 0;
243-
config->signer.tokens.error.message.clear();
244-
config->_int.esp_signer_last_jwt_generation_error_cb_millis = 0;
245-
sendTokenStatusCB();
241+
if (config->signer.tokens.status != esp_signer_token_status_on_initialize)
242+
{
243+
244+
config->signer.tokens.status = esp_signer_token_status_on_initialize;
245+
config->signer.tokens.error.code = 0;
246+
config->signer.tokens.error.message.clear();
247+
config->_int.esp_signer_last_jwt_generation_error_cb_millis = 0;
248+
sendTokenStatusCB();
249+
}
246250

247251
_token_processing_task_enable = true;
248252
tokenProcessingTask();
@@ -1219,7 +1223,6 @@ void ESP_Signer::checkToken()
12191223
config->signer.tokens.error.code = 0;
12201224
config->signer.tokens.error.message.clear();
12211225
config->_int.esp_signer_last_jwt_generation_error_cb_millis = 0;
1222-
config->signer.tokens.status = esp_signer_token_status_uninitialized;
12231226
_token_processing_task_end_request = false;
12241227
_token_processing_task_enable = false;
12251228
}

src/lib/ESPSigner/ESPSigner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.2
2+
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.4
33
*
44
* This library used RS256 for signing algorithm.
55
*

src/lib/ESPSigner/SignerConst.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ struct esp_signer_cfg_int_t
223223
unsigned long esp_signer_last_jwt_begin_step_millis = 0;
224224
uint16_t esp_signer_reconnect_tmo = WIFI_RECONNECT_TIMEOUT;
225225
bool esp_signer_clock_rdy = false;
226+
bool esp_signer_clock_init = false;
226227
float esp_signer_gmt_offset = 0;
227228
const char *esp_signer_caCert = nullptr;
228229
bool esp_signer_processing = false;

src/lib/ESPSigner/SignerUtils.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Util class, SignerUtils.h version 1.0.3
2+
* Util class, SignerUtils.h version 1.0.4
33
*
44
*
55
* Created April 18, 2022
@@ -1267,18 +1267,15 @@ class SignerUtils
12671267

12681268
if (!config->_int.esp_signer_clock_rdy || gmtOffset != config->_int.esp_signer_gmt_offset)
12691269
{
1270+
if (gmtOffset != config->_int.esp_signer_gmt_offset)
1271+
config->_int.esp_signer_clock_init = false;
12701272

1271-
configTime(gmtOffset * 3600, 0, "pool.ntp.org", "time.nist.gov");
1273+
if (!config->_int.esp_signer_clock_init)
1274+
configTime(gmtOffset * 3600, 0, "pool.ntp.org", "time.nist.gov");
1275+
1276+
config->_int.esp_signer_clock_init = true;
12721277

12731278
now = time(nullptr);
1274-
unsigned long timeout = millis();
1275-
while (now < default_ts)
1276-
{
1277-
now = time(nullptr);
1278-
if (now > default_ts || millis() - timeout > ntpTimeout)
1279-
break;
1280-
delay(10);
1281-
}
12821279
}
12831280

12841281
config->_int.esp_signer_clock_rdy = now > default_ts;

0 commit comments

Comments
 (0)