Skip to content

Commit

Permalink
Update Signer class and fixed NTP time synching issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Apr 18, 2022
1 parent cb85962 commit 4651d67
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Arduino Google Sheet Client Library for ESP8266 and ESP32


Arduino Google Sheet Client Library for ESP8266 and ESP32 v1.0.1.
Arduino Google Sheet Client Library for ESP8266 and ESP32 v1.0.2.

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

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ESP-Google-Sheet-Client",
"version": "1.0.1",
"version": "1.0.2",
"keywords": "communication, REST, esp32, esp8266, arduino",
"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",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=ESP-Google-Sheet-Client

version=1.0.1
version=1.0.2

author=Mobizt

Expand Down
17 changes: 10 additions & 7 deletions src/lib/ESPSigner/ESPSigner.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.2
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.4
*
* This library used RS256 for signing algorithm.
*
Expand Down Expand Up @@ -238,11 +238,15 @@ bool ESP_Signer::handleToken()
config->signer.tokens.status = esp_signer_token_status_uninitialized;
}

config->signer.tokens.status = esp_signer_token_status_on_initialize;
config->signer.tokens.error.code = 0;
config->signer.tokens.error.message.clear();
config->_int.esp_signer_last_jwt_generation_error_cb_millis = 0;
sendTokenStatusCB();
if (config->signer.tokens.status != esp_signer_token_status_on_initialize)
{

config->signer.tokens.status = esp_signer_token_status_on_initialize;
config->signer.tokens.error.code = 0;
config->signer.tokens.error.message.clear();
config->_int.esp_signer_last_jwt_generation_error_cb_millis = 0;
sendTokenStatusCB();
}

_token_processing_task_enable = true;
tokenProcessingTask();
Expand Down Expand Up @@ -1219,7 +1223,6 @@ void ESP_Signer::checkToken()
config->signer.tokens.error.code = 0;
config->signer.tokens.error.message.clear();
config->_int.esp_signer_last_jwt_generation_error_cb_millis = 0;
config->signer.tokens.status = esp_signer_token_status_uninitialized;
_token_processing_task_end_request = false;
_token_processing_task_enable = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ESPSigner/ESPSigner.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.2
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.4
*
* This library used RS256 for signing algorithm.
*
Expand Down
1 change: 1 addition & 0 deletions src/lib/ESPSigner/SignerConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ struct esp_signer_cfg_int_t
unsigned long esp_signer_last_jwt_begin_step_millis = 0;
uint16_t esp_signer_reconnect_tmo = WIFI_RECONNECT_TIMEOUT;
bool esp_signer_clock_rdy = false;
bool esp_signer_clock_init = false;
float esp_signer_gmt_offset = 0;
const char *esp_signer_caCert = nullptr;
bool esp_signer_processing = false;
Expand Down
17 changes: 7 additions & 10 deletions src/lib/ESPSigner/SignerUtils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Util class, SignerUtils.h version 1.0.3
* Util class, SignerUtils.h version 1.0.4
*
*
* Created April 18, 2022
Expand Down Expand Up @@ -1267,18 +1267,15 @@ class SignerUtils

if (!config->_int.esp_signer_clock_rdy || gmtOffset != config->_int.esp_signer_gmt_offset)
{
if (gmtOffset != config->_int.esp_signer_gmt_offset)
config->_int.esp_signer_clock_init = false;

configTime(gmtOffset * 3600, 0, "pool.ntp.org", "time.nist.gov");
if (!config->_int.esp_signer_clock_init)
configTime(gmtOffset * 3600, 0, "pool.ntp.org", "time.nist.gov");

config->_int.esp_signer_clock_init = true;

now = time(nullptr);
unsigned long timeout = millis();
while (now < default_ts)
{
now = time(nullptr);
if (now > default_ts || millis() - timeout > ntpTimeout)
break;
delay(10);
}
}

config->_int.esp_signer_clock_rdy = now > default_ts;
Expand Down

0 comments on commit 4651d67

Please sign in to comment.