Skip to content

Commit

Permalink
Add support Arduino UNO R4 WiFi (Renesas).
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Aug 8, 2023
1 parent ceffc25 commit fa6c01f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/ESP_Mail_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,8 @@ void ESP_Mail_Client::splitToken(const char *str, MB_VECTOR<MB_String> &tk, cons
MB_String tmp;
while (pp != NULL)
{
strsep(&end, delim);
// See RFC2047.h
ESP_MAIL_STRSEP(&end, delim);
if (strlen(pp) > 0)
{
tmp = pp;
Expand Down
6 changes: 4 additions & 2 deletions src/ESP_Mail_IMAP.h
Original file line number Diff line number Diff line change
Expand Up @@ -3658,7 +3658,8 @@ void ESP_Mail_Client::parseFoldersResponse(IMAPSession *imap, char *buf, bool li

while (pp != NULL)
{
strsep(&end, " ");
// See RFC2047.h
ESP_MAIL_STRSEP(&end, " ");
count++;

if (count >= tkPos && strlen(pp) > 0)
Expand Down Expand Up @@ -3923,7 +3924,8 @@ bool ESP_Mail_Client::getFlags(IMAPSession *imap, char *buf, esp_mail_imap_respo

while (pp != NULL)
{
strsep(&end, " ");
// See RFC2047.h
ESP_MAIL_STRSEP(&end, " ");
count++;
if (count >= tkPos && strlen(pp) > 0)
{
Expand Down
8 changes: 8 additions & 0 deletions src/extras/Networks_Provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "SDK_Version_Common.h"

#define ESP_MAIL_STRSEP strsep

#if defined(ESP32) || defined(ESP8266) || defined(ARDUINO_RASPBERRY_PI_PICO_W) || __has_include(<WiFiNINA.h>) ||__has_include(<WiFi101.h>) || __has_include(<WiFiS3.h>)

#if !defined(ESP_MAIL_DISABLE_ONBOARD_WIFI)
Expand All @@ -28,6 +30,12 @@
#include <WiFiS3.h>
#endif

#if __has_include(<WiFiS3.h>)
#undef ESP_MAIL_STRSEP
#define ESP_MAIL_STRSEP strsepImpl
#define ESP_MAIL_USE_STRSEP_IMPL
#endif

#if !defined(ARDUINO_RASPBERRY_PI_PICO_W) && !defined(MB_ARDUINO_ARCH_SAMD) && !__has_include(<WiFiS3.h>)
#define ESP_MAIL_HAS_WIFI_DISCONNECT
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/extras/RFC2047.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ void RFC2047_Decoder::rfc2047DecodeWord(char *d, const char *s, size_t dlen)

while (pp != NULL)
{

strsep(&end, "?");
// See RFC2047.h
ESP_MAIL_STRSEP(&end, "?");
count++;
switch (count)
{
Expand Down Expand Up @@ -153,7 +153,7 @@ void RFC2047_Decoder::rfc2047DecodeWord(char *d, const char *s, size_t dlen)
}
break;
}

pp = end;
}

Expand Down
33 changes: 18 additions & 15 deletions src/extras/RFC2047.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <Arduino.h>
#include "ESP_Mail_FS.h"
#include "MB_FS.h"
#include "Networks_Provider.h"

#if defined(ESP32)
#if defined(BOARD_HAS_PSRAM) && defined(ESP_Mail_USE_PSRAM)
Expand All @@ -20,9 +21,9 @@

#define strfcpy(A, B, C) strncpy(A, B, C), *(A + (C)-1) = 0



static char *__attribute__((used)) strsep(char **stringp, const char *delim)
#if defined(ESP_MAIL_USE_STRSEP_IMPL)
// This is strsep implementation because strdup may not available in some platform.
static char *__attribute__((used)) strsepImpl(char **stringp, const char *delim)
{
char *rv = *stringp;
if (rv)
Expand All @@ -36,14 +37,16 @@ static char *__attribute__((used)) strsep(char **stringp, const char *delim)
return rv;
}

#endif

enum
{
ENCOTHER,
ENC7BIT,
ENC8BIT,
ENCQUOTEDPRINTABLE,
ENCBASE64,
ENCBINARY
ENCOTHER,
ENC7BIT,
ENC8BIT,
ENCQUOTEDPRINTABLE,
ENCBASE64,
ENCBINARY
};

__attribute__((used)) static const char *Charset = "utf-8";
Expand Down Expand Up @@ -78,14 +81,14 @@ class RFC2047_Decoder
{

public:
RFC2047_Decoder();
~RFC2047_Decoder();
void decode(MB_FS *mbfs, char *d, const char *s, size_t dlen);
RFC2047_Decoder();
~RFC2047_Decoder();
void decode(MB_FS *mbfs, char *d, const char *s, size_t dlen);

private:
void rfc2047DecodeWord(char *d, const char *s, size_t dlen);
char *safe_strdup(const char *s);
MB_FS *mbfs = nullptr;
void rfc2047DecodeWord(char *d, const char *s, size_t dlen);
char *safe_strdup(const char *s);
MB_FS *mbfs = nullptr;
};

#endif // RFC2047_H

0 comments on commit fa6c01f

Please sign in to comment.