Skip to content

Commit f570b6e

Browse files
committed
Fix ESP32 SPIFFS open file read issue.
1 parent fe57533 commit f570b6e

15 files changed

+189
-65
lines changed

library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ESP-Google-Sheet-Client",
3-
"version": "1.3.3",
3+
"version": "1.3.4",
44
"keywords": "communication, REST, esp32, esp8266, raspberrypi, arduino",
55
"description": "Arduino Google Sheet REST client library for ESP8266, ESP32 and Raspberry Pi Pico (RP2040). This library allows devices to communicate with Google Sheet API to read, edit and delete the spreadsheets",
66
"repository": {
@@ -12,5 +12,5 @@
1212
"email": "suwatchai@outlook.com"
1313
}],
1414
"frameworks": "arduino",
15-
"platforms": "espressif32, espressif8266, raspberrypi"
15+
"platforms": "espressif32, espressif8266, rp2040"
1616
}

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.3.3
3+
version=1.3.4
44

55
author=Mobizt
66

src/ESP_Google_Sheet_Client.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
2-
* Google Sheet Client, GS_Google_Sheet_Client.cpp v1.3.3
2+
* Google Sheet Client, GS_Google_Sheet_Client.cpp v1.3.4
33
*
44
* This library supports Espressif ESP8266 and ESP32 MCUs
55
*
6-
* Created February 6, 2023
6+
* Created March 5, 2023
77
*
88
* The MIT License (MIT)
99
* Copyright (c) 2022 K. Suwatchai (Mobizt)
@@ -137,7 +137,7 @@ bool GSheetClass::beginRequest(MB_String &req, host_type_t host_type)
137137
if (client && !client->connected())
138138
{
139139

140-
#if defined(ESP8266) || defined(PICO_RP2040)
140+
#if defined(ESP8266) || defined(MB_ARDUINO_PICO)
141141
if (host_type == host_type_sheet)
142142
client->ethDNSWorkAround(&config.spi_ethernet_module, (const char *)FPSTR("sheets.googleapis.com"), 443);
143143
else if (host_type == host_type_drive)
@@ -195,7 +195,7 @@ void GSheetClass::setCert(const char *ca)
195195
{
196196
cert_updated = true;
197197
cert_addr = addr;
198-
#if defined(ESP8266) || defined(PICO_RP2040)
198+
#if defined(ESP8266) || defined(MB_ARDUINO_PICO)
199199
waitClockReady();
200200
#endif
201201
}
@@ -210,7 +210,7 @@ void GSheetClass::setCertFile(const char *filename, esp_google_sheet_file_storag
210210
{
211211
cert_updated = true;
212212

213-
#if defined(ESP8266) || defined(PICO_RP2040)
213+
#if defined(ESP8266) || defined(MB_ARDUINO_PICO)
214214
waitClockReady();
215215
#endif
216216
}
@@ -244,7 +244,7 @@ bool GSheetClass::setSecure()
244244
if (!authMan.reconnect(client))
245245
return false;
246246

247-
#if (defined(ESP8266) || defined(PICO_RP2040))
247+
#if (defined(ESP8266) || defined(MB_ARDUINO_PICO))
248248
if (TimeHelper::getTime(&mb_ts, &mb_ts_offset) > GS_DEFAULT_TS)
249249
{
250250
config.internal.clock_rdy = true;

src/ESP_Google_Sheet_Client.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#ifndef ESP_GOOGLE_SHEET_CLIENT_VERSION
2-
#define ESP_GOOGLE_SHEET_CLIENT_VERSION "1.3.3"
2+
#define ESP_GOOGLE_SHEET_CLIENT_VERSION "1.3.4"
33
#endif
44

55
/**
6-
* Google Sheet Client, ESP_Google_Sheet_Client.h v1.3.3
6+
* Google Sheet Client, ESP_Google_Sheet_Client.h v1.3.4
77
*
88
* This library supports Espressif ESP8266 and ESP32 MCUs
99
*
10-
* Created February 6, 2023
10+
* Created March 5, 2023
1111
*
1212
* The MIT License (MIT)
13-
* Copyright (c) 2022 K. Suwatchai (Mobizt)
13+
* Copyright (c) 2023 K. Suwatchai (Mobizt)
1414
*
1515
*
1616
* Permission is hereby granted, free of charge, to any person returning a copy of
@@ -32,6 +32,7 @@
3232
*/
3333

3434
#include <Arduino.h>
35+
#include "mbfs/MB_MCU.h"
3536

3637
#ifndef ESP_Google_Sheet_Client_H
3738
#define ESP_Google_Sheet_Client_H

src/ESP_Google_Sheet_Client_FS_Config.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define ESP_GOOGLE_SHEET_CLIENT_FS_CONFIG_H_
33

44
#include <Arduino.h>
5+
#include "mbfs/MB_MCU.h"
56

67
/**
78
* To use other flash file systems
@@ -24,7 +25,7 @@
2425
#endif
2526
#if defined(ESP32) || defined(ESP8266)
2627
#define DEFAULT_FLASH_FS SPIFFS
27-
#elif defined(PICO_RP2040)
28+
#elif defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_NANO_RP2040_CONNECT)
2829
#include <LittleFS.h>
2930
#define DEFAULT_FLASH_FS LittleFS
3031
#endif
@@ -42,7 +43,7 @@
4243
#include <SD.h>
4344
#define DEFAULT_SD_FS SD
4445
#define CARD_TYPE_SD 1
45-
#elif defined(PICO_RP2040)
46+
#elif defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_NANO_RP2040_CONNECT)
4647
// Use SDFS (ESP8266SdFat) instead of SD
4748
#include <SDFS.h>
4849
#define DEFAULT_SD_FS SDFS

src/GS_Const.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#define GS_MIN_WIFI_RECONNECT_TIMEOUT 10 * 1000
2626
#define GS_MAX_WIFI_RECONNECT_TIMEOUT 5 * 60 * 1000
2727

28+
#include <Arduino.h>
29+
#include "mbfs/MB_MCU.h"
30+
2831
#if defined(ESP32) && !defined(ESP_ARDUINO_VERSION) /* ESP32 core < v2.0.x */
2932
#include <sys/time.h>
3033
#else
@@ -258,7 +261,7 @@ struct gauth_token_signer_resources_t
258261
size_t signatureSize = 256;
259262
#if defined(ESP32)
260263
uint8_t *hash = nullptr;
261-
#elif defined(ESP8266) || defined(PICO_RP2040)
264+
#elif defined(ESP8266) || defined(MB_ARDUINO_PICO)
262265
char *hash = nullptr;
263266
#endif
264267
unsigned char *signature = nullptr;

src/GS_Helper.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef GS_HELPER_H
22
#define GS_HELPER_H
33

4-
#include "ESP_Google_Sheet_Client_FS_Config.h"
5-
64
#include <Arduino.h>
5+
#include "mbfs/MB_MCU.h"
6+
#include "ESP_Google_Sheet_Client_FS_Config.h"
77
#include <time.h>
88

99
#if !defined(__AVR__)
@@ -14,7 +14,7 @@
1414
#include "GS_Const.h"
1515
#if defined(ESP8266)
1616
#include <Schedule.h>
17-
#elif defined(PICO_RP2040)
17+
#elif defined(MB_ARDUINO_PICO)
1818
#include <WiFi.h>
1919
#include <WiFiNTP.h>
2020
#endif
@@ -69,10 +69,10 @@ namespace TimeHelper
6969
inline time_t getTime(uint32_t *mb_ts, uint32_t *mb_ts_offset)
7070
{
7171
uint32_t &tm = *mb_ts;
72-
#if defined(ENABLE_EXTERNAL_CLIENT) || defined(PICO_RP2040)
72+
#if defined(ENABLE_EXTERNAL_CLIENT) || defined(MB_ARDUINO_PICO)
7373
tm = *mb_ts_offset + millis() / 1000;
7474

75-
#if defined(PICO_RP2040)
75+
#if defined(MB_ARDUINO_PICO)
7676
if (tm < time(nullptr))
7777
tm = time(nullptr);
7878
#endif
@@ -157,9 +157,9 @@ namespace TimeHelper
157157

158158
#else
159159

160-
#if defined(ESP32) || defined(ESP8266) || defined(PICO_RP2040)
160+
#if defined(ESP32) || defined(ESP8266) || defined(MB_ARDUINO_PICO)
161161

162-
#if defined(PICO_RP2040)
162+
#if defined(MB_ARDUINO_PICO)
163163
NTP.begin("pool.ntp.org", "time.nist.gov");
164164
NTP.waitSet();
165165

src/GS_SDHelper.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define GS_SD_HELPER_H_
44

55
#include <Arduino.h>
6+
#include "mbfs/MB_MCU.h"
67
#include "ESP_Google_Sheet_Client.h"
78

89
// If SD Card used for storage, assign SD card type and FS used in src/ESP_Google_Sheet_Client_FS_Config.h and
@@ -18,7 +19,7 @@
1819
#define SPI_CLOCK_IN_MHz 16
1920
#elif defined(ESP8266)
2021
#define SPI_CS_PIN 15
21-
#elif defined(PICO_RP2040)
22+
#elif defined(MB_ARDUINO_PICO)
2223
// Use SPI 1's SS (GPIO 13) port as CS for SPI
2324
#define SPI_CS_PIN PIN_SPI1_SS
2425
#endif
@@ -37,7 +38,7 @@ SPIClass spi;
3738

3839
SDFSConfig sdFSConfig(SPI_CS_PIN, SPI_HALF_SPEED);
3940

40-
#elif defined(PICO_RP2040)
41+
#elif defined(MB_ARDUINO_PICO)
4142

4243
/** Use Pico SPI 1 for SPI
4344
* MISO GPIO 12
@@ -102,7 +103,7 @@ bool SD_Card_Mounting()
102103
return true;
103104
}
104105

105-
#elif defined(PICO_RP2040)
106+
#elif defined(MB_ARDUINO_PICO)
106107

107108
Serial.print("\nMounting SD Card... ");
108109

src/auth/GAuthManager.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
2-
* Google Sheet Client, GAuthManager v1.0.1
2+
* Google Sheet Client, GAuthManager v1.0.2
33
*
44
* This library supports Espressif ESP8266, ESP32 and Raspberry Pi Pico MCUs.
55
*
6-
* Created February 6, 2023
6+
* Created March 5, 2023
77
*
88
* The MIT License (MIT)
99
* Copyright (c) 2022 K. Suwatchai (Mobizt)
@@ -30,6 +30,8 @@
3030
#ifndef GAUTH_MANAGER_CPP
3131
#define GAUTH_MANAGER_CPP
3232

33+
#include <Arduino.h>
34+
#include "mbfs/MB_MCU.h"
3335
#include "GAuthManager.h"
3436

3537
GAuthManager::GAuthManager()
@@ -185,7 +187,7 @@ time_t GAuthManager::getTime()
185187
bool GAuthManager::setTime(time_t ts)
186188
{
187189

188-
#if !defined(ESP_GOOGLE_SHEET_CLIENT_ENABLE_EXTERNAL_CLIENT) && (defined(ESP8266) || defined(ESP32) || defined(PICO_RP2040))
190+
#if !defined(ESP_GOOGLE_SHEET_CLIENT_ENABLE_EXTERNAL_CLIENT) && (defined(ESP8266) || defined(ESP32) || defined(MB_ARDUINO_PICO))
189191

190192
if (TimeHelper::setTimestamp(ts) == 0)
191193
{
@@ -428,7 +430,7 @@ void GAuthManager::tokenProcessingTask()
428430
// flag set for valid time required
429431
bool sslValidTime = false;
430432

431-
#if defined(ESP8266) || defined(PICO_RP2040)
433+
#if defined(ESP8266) || defined(MB_ARDUINO_PICO)
432434
// valid time required for SSL handshake using server certificate in ESP8266
433435
if (config->cert.data != NULL || config->cert.file.length() > 0)
434436
sslValidTime = true;
@@ -872,7 +874,7 @@ bool GAuthManager::createJWT()
872874
MemoryHelper::freeBuffer(mbfs, config->signer.hash);
873875
return false;
874876
}
875-
#elif defined(ESP8266) || defined(PICO_RP2040)
877+
#elif defined(ESP8266) || defined(MB_ARDUINO_PICO)
876878
config->signer.hash = MemoryHelper::createBuffer<char *>(mbfs, config->signer.hashSize);
877879
br_sha256_context mc;
878880
br_sha256_init(&mc);
@@ -973,7 +975,7 @@ bool GAuthManager::createJWT()
973975

974976
if (ret != 0)
975977
return false;
976-
#elif defined(ESP8266) || defined(PICO_RP2040)
978+
#elif defined(ESP8266) || defined(MB_ARDUINO_PICO)
977979
// RSA private key
978980
BearSSL::PrivateKey *pk = nullptr;
979981
Utils::idle();

src/auth/GAuthManager.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
2-
* Google Sheet Client, GAuthManager v1.0.1
2+
* Google Sheet Client, GAuthManager v1.0.2
33
*
44
* This library supports Espressif ESP8266, ESP32 and Raspberry Pi Pico MCUs.
55
*
6-
* Created February 6, 2023
6+
* Created March 5, 2023
77
*
88
* The MIT License (MIT)
99
* Copyright (c) 2022 K. Suwatchai (Mobizt)
@@ -28,7 +28,8 @@
2828
*/
2929
#ifndef GAUTH_MANAGER_H
3030
#define GAUTH_MANAGER_H
31-
31+
#include <Arduino.h>
32+
#include "mbfs/MB_MCU.h"
3233
#include "client/GS_TCP_Client.h"
3334
#include <FS.h>
3435
#include "mbfs/MB_FS.h"
@@ -157,7 +158,7 @@ class GAuthManager
157158
}
158159
#endif
159160

160-
#if defined(PICO_RP2040)
161+
#if defined(MB_ARDUINO_PICO)
161162
#if __has_include(<WiFiMulti.h>)
162163
#define HAS_WIFIMULTI
163164
WiFiMulti *multi = nullptr;

0 commit comments

Comments
 (0)