Skip to content

Commit

Permalink
Update printf.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Aug 13, 2023
1 parent 08b4c15 commit a161246
Show file tree
Hide file tree
Showing 65 changed files with 855 additions and 1,041 deletions.
7 changes: 2 additions & 5 deletions examples/IMAP/ACL/ACL.ino
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ void setup()
#if defined(ARDUINO_ARCH_SAMD)
while (!Serial)
;
Serial.println();
Serial.println("**** Custom built WiFiNINA firmware need to be installed.****\n");
Serial.println("To install firmware, read the instruction here, https://github.com/mobizt/ESP-Mail-Client#install-custom-build-wifinina-firmware");
#endif

Serial.println();
Expand Down Expand Up @@ -183,7 +180,7 @@ void setup()

for (size_t i = 0; i < acl_list.size(); i++)
{
ESP_MAIL_PRINTF("Identifier: %s, Rights: ", acl_list[i].identifier.c_str());
MailClient.printf("Identifier: %s, Rights: ", acl_list[i].identifier.c_str());
if (acl_list[i].rights.lookup)
Serial.print("l");
if (acl_list[i].rights.read)
Expand Down Expand Up @@ -290,7 +287,7 @@ void setup()
Serial.println("Delete ACLs success");
}

ESP_MAIL_PRINTF("Free Heap: %d\n", MailClient.getFreeHeap());
MailClient.printf("Free Heap: %d\n", MailClient.getFreeHeap());
}

void loop()
Expand Down
9 changes: 3 additions & 6 deletions examples/IMAP/Append_Message/Append_Message.ino
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ void setup()
#if defined(ARDUINO_ARCH_SAMD)
while (!Serial)
;
Serial.println();
Serial.println("**** Custom built WiFiNINA firmware need to be installed.****\n");
Serial.println("To install firmware, read the instruction here, https://github.com/mobizt/ESP-Mail-Client#install-custom-build-wifinina-firmware");
#endif

Serial.println();
Expand Down Expand Up @@ -227,12 +224,12 @@ void setup()
// If not, one message can append for a APPEND command.
// Outlook.com does not accept flag and date/time arguments in APPEND command
if (!MailClient.appendMessage(&imap, &message[0], false /* if not last message to append */, "\\Flagged" /* flags or empty string for Outlook.com */, "Thu, 16 Jun 2022 12:30:25 -0800 (PST)" /* date/time or empty string for Outlook.com */))
ESP_MAIL_PRINTF("Message appending error, Error Code: %d, Reason: %s", imap.errorCode(), imap.errorReason().c_str());
MailClient.printf("Message appending error, Error Code: %d, Reason: %s", imap.errorCode(), imap.errorReason().c_str());

if (!MailClient.appendMessage(&imap, &message[1], true /* last message to append */))
ESP_MAIL_PRINTF("Message appending error, Error Code: %d, Reason: %s", imap.errorCode(), imap.errorReason().c_str());
MailClient.printf("Message appending error, Error Code: %d, Reason: %s", imap.errorCode(), imap.errorReason().c_str());

ESP_MAIL_PRINTF("Free Heap: %d\n", MailClient.getFreeHeap());
MailClient.printf("Free Heap: %d\n", MailClient.getFreeHeap());

#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ void setup()
#if defined(ARDUINO_ARCH_SAMD)
while (!Serial)
;
Serial.println();
Serial.println("**** Custom built WiFiNINA firmware need to be installed.****\n");
Serial.println("To install firmware, read the instruction here, https://github.com/mobizt/ESP-Mail-Client#install-custom-build-wifinina-firmware");
#endif

Serial.println();
Expand Down Expand Up @@ -190,15 +187,15 @@ void setup()

/* Copy all messages in the list to the folder "test" */
if (imap.copyMessages(&toCopy, F("test")))
ESP_MAIL_PRINTF("\nMessages copied\n");
MailClient.printf("\nMessages copied\n");

/* Delete all messages in the list from the opened folder (move to trash) */
// imap.deleteMessages(&toCopy);

// imap.deleteolder("test");
// imap.deleteolder("test2");

ESP_MAIL_PRINTF("Free Heap: %d\n", MailClient.getFreeHeap());
MailClient.printf("Free Heap: %d\n", MailClient.getFreeHeap());
}

void loop()
Expand All @@ -217,7 +214,7 @@ void printAllMailboxesInfo(IMAPSession &imap)
{
/* Iterate each folder info using the folder info item data */
FolderInfo folderInfo = folders.info(i);
ESP_MAIL_PRINTF("%s%s%s", i == 0 ? "\nAvailable folders: " : ", ", folderInfo.name, i == folders.size() - 1 ? "\n" : "");
MailClient.printf("%s%s%s", i == 0 ? "\nAvailable folders: " : ", ", folderInfo.name, i == folders.size() - 1 ? "\n" : "");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ void setup()
#if defined(ARDUINO_ARCH_SAMD)
while (!Serial)
;
Serial.println();
Serial.println("**** Custom built WiFiNINA firmware need to be installed.****\n");
Serial.println("To install firmware, read the instruction here, https://github.com/mobizt/ESP-Mail-Client#install-custom-build-wifinina-firmware");
#endif

Serial.println();
Expand Down Expand Up @@ -186,13 +183,13 @@ void setup()
String sequence_set2 = String(msg_begin) + ":" + String(msg_last);

if (imap.copyMessages(sequence_set2, false /* if sequence set are message numbers not UIDs */, F("test")))
ESP_MAIL_PRINTF("\nCopying messages using message numbers ranges success\n");
MailClient.printf("\nCopying messages using message numbers ranges success\n");
else
ESP_MAIL_PRINTF("\nError, copying messages using message numbers ranges\n");
MailClient.printf("\nError, copying messages using message numbers ranges\n");

// imap.deleteolder("test");

ESP_MAIL_PRINTF("Free Heap: %d\n", MailClient.getFreeHeap());
MailClient.printf("Free Heap: %d\n", MailClient.getFreeHeap());
}

void loop()
Expand All @@ -211,7 +208,7 @@ void printAllMailboxesInfo(IMAPSession &imap)
{
/* Iterate each folder info using the folder info item data */
FolderInfo folderInfo = folders.info(i);
ESP_MAIL_PRINTF("%s%s%s", i == 0 ? "\nAvailable folders: " : ", ", folderInfo.name, i == folders.size() - 1 ? "\n" : "");
MailClient.printf("%s%s%s", i == 0 ? "\nAvailable folders: " : ", ", folderInfo.name, i == folders.size() - 1 ? "\n" : "");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ void setup()
#if defined(ARDUINO_ARCH_SAMD)
while (!Serial)
;
Serial.println();
Serial.println("**** Custom built WiFiNINA firmware need to be installed.****\n");
Serial.println("To install firmware, read the instruction here, https://github.com/mobizt/ESP-Mail-Client#install-custom-build-wifinina-firmware");
#endif

Serial.println();
Expand Down Expand Up @@ -186,13 +183,13 @@ void setup()
String sequence_set1 = String(uid_begin) + ":" + String(uid_last);

if (imap.copyMessages(sequence_set1, true /* if sequence set are the UIDs */, F("test")))
ESP_MAIL_PRINTF("\nCopying messages using UIDs ranges success\n");
MailClient.printf("\nCopying messages using UIDs ranges success\n");
else
ESP_MAIL_PRINTF("\nError, copying messages using UIDs ranges\n");
MailClient.printf("\nError, copying messages using UIDs ranges\n");

// imap.deleteolder("test");

ESP_MAIL_PRINTF("Free Heap: %d\n", MailClient.getFreeHeap());
MailClient.printf("Free Heap: %d\n", MailClient.getFreeHeap());
}

void loop()
Expand All @@ -211,7 +208,7 @@ void printAllMailboxesInfo(IMAPSession &imap)
{
/* Iterate each folder info using the folder info item data */
FolderInfo folderInfo = folders.info(i);
ESP_MAIL_PRINTF("%s%s%s", i == 0 ? "\nAvailable folders: " : ", ", folderInfo.name, i == folders.size() - 1 ? "\n" : "");
MailClient.printf("%s%s%s", i == 0 ? "\nAvailable folders: " : ", ", folderInfo.name, i == folders.size() - 1 ? "\n" : "");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ void setup()
#if defined(ARDUINO_ARCH_SAMD)
while (!Serial)
;
Serial.println();
Serial.println("**** Custom built WiFiNINA firmware need to be installed.****\n");
Serial.println("To install firmware, read the instruction here, https://github.com/mobizt/ESP-Mail-Client#install-custom-build-wifinina-firmware");
#endif

Serial.println();
Expand Down Expand Up @@ -337,7 +334,7 @@ void customCharacterDecodingCallback(IMAP_Decoding_Info *decoding)
void imapCallback(IMAP_Status status)
{
/* Print the current status */
ESP_MAIL_PRINTF(status.info());
MailClient.printf(status.info());

/* Show the result when reading finished */
if (status.success())
Expand All @@ -364,37 +361,37 @@ void printAllMailboxesInfo(IMAPSession &imap)
{
/* Iterate each folder info using the folder info item data */
FolderInfo folderInfo = folders.info(i);
ESP_MAIL_PRINTF("%s%s%s", i == 0 ? "\nAvailable folders: " : ", ", folderInfo.name, i == folders.size() - 1 ? "\n" : "");
MailClient.printf("%s%s%s", i == 0 ? "\nAvailable folders: " : ", ", folderInfo.name, i == folders.size() - 1 ? "\n" : "");
}
}
}

void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
{
/* Show the mailbox info */
ESP_MAIL_PRINTF("\nInfo of the selected folder\nTotal Messages: %d\n", sFolder.msgCount());
ESP_MAIL_PRINTF("UID Validity: %d\n", sFolder.uidValidity());
ESP_MAIL_PRINTF("Predicted next UID: %d\n", sFolder.nextUID());
MailClient.printf("\nInfo of the selected folder\nTotal Messages: %d\n", sFolder.msgCount());
MailClient.printf("UID Validity: %d\n", sFolder.uidValidity());
MailClient.printf("Predicted next UID: %d\n", sFolder.nextUID());
if (sFolder.unseenIndex() > 0)
ESP_MAIL_PRINTF("First Unseen Message Number: %d\n", sFolder.unseenIndex());
MailClient.printf("First Unseen Message Number: %d\n", sFolder.unseenIndex());
else
ESP_MAIL_PRINTF("Unseen Messages: No\n");
MailClient.printf("Unseen Messages: No\n");

if (sFolder.modSeqSupported())
ESP_MAIL_PRINTF("Highest Modification Sequence: %llu\n", sFolder.highestModSeq());
MailClient.printf("Highest Modification Sequence: %llu\n", sFolder.highestModSeq());
for (size_t i = 0; i < sFolder.flagCount(); i++)
ESP_MAIL_PRINTF("%s%s%s", i == 0 ? "Flags: " : ", ", sFolder.flag(i).c_str(), i == sFolder.flagCount() - 1 ? "\n" : "");
MailClient.printf("%s%s%s", i == 0 ? "Flags: " : ", ", sFolder.flag(i).c_str(), i == sFolder.flagCount() - 1 ? "\n" : "");

if (sFolder.flagCount(true))
{
for (size_t i = 0; i < sFolder.flagCount(true); i++)
ESP_MAIL_PRINTF("%s%s%s", i == 0 ? "Permanent Flags: " : ", ", sFolder.flag(i, true).c_str(), i == sFolder.flagCount(true) - 1 ? "\n" : "");
MailClient.printf("%s%s%s", i == 0 ? "Permanent Flags: " : ", ", sFolder.flag(i, true).c_str(), i == sFolder.flagCount(true) - 1 ? "\n" : "");
}
}

void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
{
ESP_MAIL_PRINTF("Attachment: %d file(s)\n****************************\n", atts.size());
MailClient.printf("Attachment: %d file(s)\n****************************\n", atts.size());
for (size_t j = 0; j < atts.size(); j++)
{
IMAP_Attach_Item att = atts[j];
Expand All @@ -403,7 +400,7 @@ void printAttacements(MB_VECTOR<IMAP_Attach_Item> &atts)
* esp_mail_att_type_attachment or 1
* esp_mail_att_type_inline or 2
*/
ESP_MAIL_PRINTF("%d. Filename: %s, Name: %s, Size: %d, MIME: %s, Type: %s, Description: %s, Creation Date: %s\n", j + 1, att.filename, att.name, att.size, att.mime, att.type == esp_mail_att_type_attachment ? "attachment" : "inline", att.description, att.creationDate);
MailClient.printf("%d. Filename: %s, Name: %s, Size: %d, MIME: %s, Type: %s, Description: %s, Creation Date: %s\n", j + 1, att.filename, att.name, att.size, att.mime, att.type == esp_mail_att_type_attachment ? "attachment" : "inline", att.description, att.creationDate);
}
Serial.println();
}
Expand All @@ -425,68 +422,68 @@ void printMessages(MB_VECTOR<IMAP_MSG_Item> &msgItems, bool headerOnly)
IMAP_MSG_Item msg = msgItems[i];

Serial.println("****************************");
ESP_MAIL_PRINTF("Number: %d\n", msg.msgNo);
ESP_MAIL_PRINTF("UID: %d\n", msg.UID);
MailClient.printf("Number: %d\n", msg.msgNo);
MailClient.printf("UID: %d\n", msg.UID);

// The attachment status in search may be true in case the "multipart/mixed"
// content type header was set with no real attachtment included.
ESP_MAIL_PRINTF("Attachment: %s\n", msg.hasAttachment ? "yes" : "no");
MailClient.printf("Attachment: %s\n", msg.hasAttachment ? "yes" : "no");

ESP_MAIL_PRINTF("Messsage-ID: %s\n", msg.ID);
MailClient.printf("Messsage-ID: %s\n", msg.ID);

if (strlen(msg.flags))
ESP_MAIL_PRINTF("Flags: %s\n", msg.flags);
MailClient.printf("Flags: %s\n", msg.flags);
if (strlen(msg.acceptLang))
ESP_MAIL_PRINTF("Accept Language: %s\n", msg.acceptLang);
MailClient.printf("Accept Language: %s\n", msg.acceptLang);
if (strlen(msg.contentLang))
ESP_MAIL_PRINTF("Content Language: %s\n", msg.contentLang);
MailClient.printf("Content Language: %s\n", msg.contentLang);
if (strlen(msg.from))
ESP_MAIL_PRINTF("From: %s\n", msg.from);
MailClient.printf("From: %s\n", msg.from);
if (strlen(msg.sender))
ESP_MAIL_PRINTF("Sender: %s\n", msg.sender);
MailClient.printf("Sender: %s\n", msg.sender);
if (strlen(msg.to))
ESP_MAIL_PRINTF("To: %s\n", msg.to);
MailClient.printf("To: %s\n", msg.to);
if (strlen(msg.cc))
ESP_MAIL_PRINTF("CC: %s\n", msg.cc);
MailClient.printf("CC: %s\n", msg.cc);
if (strlen(msg.date))
{
ESP_MAIL_PRINTF("Date: %s\n", msg.date);
ESP_MAIL_PRINTF("Timestamp: %d\n", (int)MailClient.Time.getTimestamp(msg.date));
MailClient.printf("Date: %s\n", msg.date);
MailClient.printf("Timestamp: %d\n", (int)MailClient.Time.getTimestamp(msg.date));
}
if (strlen(msg.subject))
ESP_MAIL_PRINTF("Subject: %s\n", msg.subject);
MailClient.printf("Subject: %s\n", msg.subject);
if (strlen(msg.reply_to))
ESP_MAIL_PRINTF("Reply-To: %s\n", msg.reply_to);
MailClient.printf("Reply-To: %s\n", msg.reply_to);
if (strlen(msg.return_path))
ESP_MAIL_PRINTF("Return-Path: %s\n", msg.return_path);
MailClient.printf("Return-Path: %s\n", msg.return_path);
if (strlen(msg.in_reply_to))
ESP_MAIL_PRINTF("In-Reply-To: %s\n", msg.in_reply_to);
MailClient.printf("In-Reply-To: %s\n", msg.in_reply_to);
if (strlen(msg.references))
ESP_MAIL_PRINTF("References: %s\n", msg.references);
MailClient.printf("References: %s\n", msg.references);
if (strlen(msg.comments))
ESP_MAIL_PRINTF("Comments: %s\n", msg.comments);
MailClient.printf("Comments: %s\n", msg.comments);
if (strlen(msg.keywords))
ESP_MAIL_PRINTF("Keywords: %s\n", msg.keywords);
MailClient.printf("Keywords: %s\n", msg.keywords);

/* If the result contains the message info (Fetch mode) */
if (!headerOnly)
{
if (strlen(msg.text.content))
ESP_MAIL_PRINTF("Text Message: %s\n", msg.text.content);
MailClient.printf("Text Message: %s\n", msg.text.content);
if (strlen(msg.text.charSet))
ESP_MAIL_PRINTF("Text Message Charset: %s\n", msg.text.charSet);
MailClient.printf("Text Message Charset: %s\n", msg.text.charSet);
if (strlen(msg.text.transfer_encoding))
ESP_MAIL_PRINTF("Text Message Transfer Encoding: %s\n", msg.text.transfer_encoding);
MailClient.printf("Text Message Transfer Encoding: %s\n", msg.text.transfer_encoding);
if (strlen(msg.html.content))
ESP_MAIL_PRINTF("HTML Message: %s\n", msg.html.content);
MailClient.printf("HTML Message: %s\n", msg.html.content);
if (strlen(msg.html.charSet))
ESP_MAIL_PRINTF("HTML Message Charset: %s\n", msg.html.charSet);
MailClient.printf("HTML Message Charset: %s\n", msg.html.charSet);
if (strlen(msg.html.transfer_encoding))
ESP_MAIL_PRINTF("HTML Message Transfer Encoding: %s\n\n", msg.html.transfer_encoding);
MailClient.printf("HTML Message Transfer Encoding: %s\n\n", msg.html.transfer_encoding);

if (msg.rfc822.size() > 0)
{
ESP_MAIL_PRINTF("\r\nRFC822 Messages: %d message(s)\n****************************\n", msg.rfc822.size());
MailClient.printf("\r\nRFC822 Messages: %d message(s)\n****************************\n", msg.rfc822.size());
printMessages(msg.rfc822, headerOnly);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ void customCommandCallback(IMAP_Response res)
// When you send multiple commands with different tag simultaneously,
// tag will be used as command identifier.

ESP_MAIL_PRINTF("> C: TAG %s\n", res.tag.c_str());
ESP_MAIL_PRINTF("< S: %s\n", res.text.c_str());
MailClient.printf("> C: TAG %s\n", res.tag.c_str());
MailClient.printf("< S: %s\n", res.text.c_str());

if (res.completed)
{
ESP_MAIL_PRINTF("> C: Response finished with status %s\n\n", res.status.c_str());
MailClient.printf("> C: Response finished with status %s\n\n", res.status.c_str());
}
}

Expand All @@ -117,9 +117,6 @@ void setup()
#if defined(ARDUINO_ARCH_SAMD)
while (!Serial)
;
Serial.println();
Serial.println("**** Custom built WiFiNINA firmware need to be installed.****\n");
Serial.println("To install firmware, read the instruction here, https://github.com/mobizt/ESP-Mail-Client#install-custom-build-wifinina-firmware");
#endif

Serial.println();
Expand Down
9 changes: 3 additions & 6 deletions examples/IMAP/Custom_Command/Basic_Auth/Basic_Auth.ino
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ void customCommandCallback(IMAP_Response res)
// When you send multiple commands with different tag simultaneously,
// tag will be used as command identifier.

ESP_MAIL_PRINTF("> C: TAG %s\n", res.tag.c_str());
ESP_MAIL_PRINTF("< S: %s\n", res.text.c_str());
MailClient.printf("> C: TAG %s\n", res.tag.c_str());
MailClient.printf("< S: %s\n", res.text.c_str());

if (res.completed)
{
ESP_MAIL_PRINTF("> C: Response finished with status %s\n\n", res.status.c_str());
MailClient.printf("> C: Response finished with status %s\n\n", res.status.c_str());
}
}

Expand All @@ -117,9 +117,6 @@ void setup()
#if defined(ARDUINO_ARCH_SAMD)
while (!Serial)
;
Serial.println();
Serial.println("**** Custom built WiFiNINA firmware need to be installed.****\n");
Serial.println("To install firmware, read the instruction here, https://github.com/mobizt/ESP-Mail-Client#install-custom-build-wifinina-firmware");
#endif

Serial.println();
Expand Down
Loading

0 comments on commit a161246

Please sign in to comment.