Skip to content

Commit

Permalink
Fixed ESP32 PSRAM compile guards and memory allocation error when PSR…
Browse files Browse the repository at this point in the history
…AM was enabled but not detected.
  • Loading branch information
mobizt committed Feb 21, 2022
1 parent 8ba6d5f commit 351a19d
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 89 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Mail Client Arduino Library v2.0.3
# Mail Client Arduino Library v2.0.4


[![Join the chat at https://gitter.im/mobizt/ESP_Mail_Client](https://badges.gitter.im/mobizt/ESP_Mail_Client.svg)](https://gitter.im/mobizt/ESP_Mail_Client?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Expand Down Expand Up @@ -164,7 +164,7 @@ The flash (upload) result shows in the command prompt window will look similar t
If the custom built WiFiNINA firmware was installed, the debug message will show the library version with WiFiNINA firmware version which followed by built number (+21120).

```
> C: ESP Mail Client v2.0.3, Fw v1.4.8+21120
> C: ESP Mail Client v2.0.4, Fw v1.4.8+21120
```

## Library Instalation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,9 @@ ESP_Mail_Session session;
/* Setup the configuration for searching or fetching operation and its result */
IMAP_Config config;

void setup()
void connectWiFi()
{

Serial.begin(115200);

#if defined(ARDUINO_ARCH_SAMD)
while (!Serial)
;
Serial.println();
Serial.println("**** Custom built WiFiNINA firmware need to be installed.****\nTo install firmware, read the instruction here, https://github.com/mobizt/ESP-Mail-Client#install-custom-built-wifinina-firmware");

#endif

Serial.println();
WiFi.disconnect();

Serial.print("Connecting to AP");

Expand All @@ -108,13 +97,31 @@ void setup()
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println();
}

/** Enable the debug via Serial port
void setup()
{

Serial.begin(115200);

#if defined(ARDUINO_ARCH_SAMD)
while (!Serial)
;
Serial.println();
Serial.println("**** Custom built WiFiNINA firmware need to be installed.****\nTo install firmware, read the instruction here, https://github.com/mobizt/ESP-Mail-Client#install-custom-built-wifinina-firmware");

#endif

Serial.println();

connectWiFi();

/** Enable the debug via Serial port
* none debug or 0
* basic debug or 1
*
*
* Debug port can be changed via ESP_MAIL_DEFAULT_DEBUG_PORT in ESP_Mail_FS.h
*/
*/
imap.debug(1);

/* Set the callback function to get the reading results */
Expand All @@ -140,10 +147,10 @@ void setup()
session.time.gmt_offset = 3;
session.time.day_light_offset = 0;

/** Assign custom internet connection handler function
* in case of lost internet connection.
/** Assign internet connection handler function
* in case of lost internet connection for re-listening the mailbox.
*/
//session.network_connection_handler = connectWiFi;
session.network_connection_handler = connectWiFi;

/* Connect to server with the session and config */
if (!imap.connect(&session, &config))
Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "ESP Mail Client",
"version": "2.0.3",
"version": "2.0.4",
"keywords": "communication, email, imap, smtp, esp32, esp8266, samd, arduino",
"description": "E-Mail Client Arduino Library to send, read and get incoming E-mail notification for ESP32, ESP8266 and SAMD21 devices. The library also supported other Arduino Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.",
"description": "Arduino Mail Client Library to send, read and get incoming mail notification for ESP32, ESP8266 and SAMD21 devices. The library also supported other Arduino Devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.",
"repository": {
"type": "git",
"url": "https://github.com/mobizt/ESP-Mail-Client.git"
Expand Down
6 changes: 3 additions & 3 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name=ESP Mail Client

version=2.0.3
version=2.0.4

author=Mobizt

maintainer=Mobizt <suwatchai@outlook.com>

sentence=E-Mail Client Arduino Library to send E-mail, read and get incoming E-mail notification for ESP32, ESP8266 and SAMD21 devices.
sentence=Arduino Mail Client Library to send, read and get incoming mail notification for ESP32, ESP8266 and SAMD21 devices.

paragraph=The library also supported other Arduino Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.
paragraph=The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.

category=Communication

Expand Down
27 changes: 22 additions & 5 deletions src/ESP_Mail_Client.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/**
* Mail Client Arduino Library for Espressif's ESP32 and ESP8266 and SAMD21 with u-blox NINA-W102 WiFi/Bluetooth module
*
* Version: 2.0.3
* Released: February 12, 2022
* Version: 2.0.4
* Released: February 21, 2022
*
* Updates:
* - Update custom client features.
* - Fixed flash string issue.
* - Fixed blob and nonCopyContent message sending issue.
* - Fixed ESP32 PSRAM compile guards.
* - Fixed memory allocation error when PSRAM was enabled but not detected.
* - Update examples.
* - Update string class.
*
*
* This library allows Espressif's ESP32, ESP8266 and SAMD devices to send and read Email through the SMTP and IMAP servers.
Expand Down Expand Up @@ -1605,6 +1606,14 @@ bool ESP_Mail_Client::imapAuth(IMAPSession *imap)
s += imap->client.fwVersion();
esp_mail_debug(s.c_str());

#if defined(BOARD_HAS_PSRAM) && defined(MB_STRING_USE_PSRAM)
if (ESP.getPsramSize() == 0)
{
s = esp_mail_str_353;
esp_mail_debug(s.c_str());
}
#endif

debugInfoP(esp_mail_str_225);
s = esp_mail_str_261;
s += esp_mail_str_211;
Expand Down Expand Up @@ -5643,6 +5652,14 @@ bool ESP_Mail_Client::smtpAuth(SMTPSession *smtp)
s += smtp->client.fwVersion();
esp_mail_debug(s.c_str());

#if defined(BOARD_HAS_PSRAM) && defined(MB_STRING_USE_PSRAM)
if (ESP.getPsramSize() == 0)
{
s = esp_mail_str_353;
esp_mail_debug(s.c_str());
}
#endif

debugInfoP(esp_mail_str_236);
s = esp_mail_str_261;
s += esp_mail_str_211;
Expand Down
13 changes: 7 additions & 6 deletions src/ESP_Mail_Client.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#ifndef ESP_Mail_Client_H
#define ESP_Mail_Client_H

#define ESP_MAIL_VERSION "2.0.3"
#define ESP_MAIL_VERSION "2.0.4"

/**
* Mail Client Arduino Library for Espressif's ESP32 and ESP8266 and SAMD21 with u-blox NINA-W102 WiFi/Bluetooth module
*
* Version: 2.0.3
* Released: February 12, 2022
* Version: 2.0.4
* Released: February 21, 2022
*
* Updates:
* - Update custom client features.
* - Fixed flash string issue.
* - Fixed blob and nonCopyContent message sending issue.
* - Fixed ESP32 PSRAM compile guards.
* - Fixed memory allocation error when PSRAM was enabled but not detected.
* - Update examples.
* - Update string class.
*
*
* This library allows Espressif's ESP32, ESP8266 and SAMD devices to send and read Email through the SMTP and IMAP servers.
Expand Down
3 changes: 3 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,7 @@ static const char esp_mail_str_345[] PROGMEM = "connection refused";
static const char esp_mail_str_346[] PROGMEM = "Client is not yet initialized";
static const char esp_mail_str_347[] PROGMEM = "/header.json";
static const char esp_mail_str_352[] PROGMEM = "Custom Client is not yet enabled";
static const char esp_mail_str_353[] PROGMEM = "! W: PSRAM was enabled but not detected.";
#endif

#if defined(MBFS_FLASH_FS) || defined(MBFS_SD_FS)
Expand All @@ -1819,6 +1820,8 @@ static const char esp_mail_str_350[] PROGMEM = "File is still opened.";
static const char esp_mail_str_351[] PROGMEM = "File not found.";
#endif



#if defined(ENABLE_SMTP) || defined(ENABLE_IMAP)

static const unsigned char b64_index_table[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
Expand Down
2 changes: 1 addition & 1 deletion src/extras/ESPTimeHelper/ESPTimeHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <Arduino.h>
#include "./ESP_Mail_FS.h"

#if defined(ESP_Mail_USE_PSRAM)
#if defined(ESP_MAIL_USE_PSRAM)
#define MB_STRING_USE_PSRAM
#endif

Expand Down
Loading

0 comments on commit 351a19d

Please sign in to comment.