Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A76xx: Rewrote https_post_file #6

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ monitor_filters = esp32_exception_decoder, log2file
build_flags =
-Wall -Wextra -Wunused -Wmisleading-indentation -Wduplicated-cond -Wlogical-op -Wnull-dereference
; -D TINY_GSM_MODEM_SIM7000
-D TINY_GSM_MODEM_SIM7020
; -D TINY_GSM_MODEM_SIM7020
; -D TINY_GSM_MODEM_SIM7600
; -D TINY_GSM_MODEM_A7608
; -D TINY_GSM_MODEM_A7670
-D TINY_GSM_MODEM_A7670
; -D TINY_GSM_MODEM_SIM7672

[env:esp32dev]
Expand Down
14 changes: 6 additions & 8 deletions src/TinyGsmHttpsA76xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,19 @@ class TinyGsmHttpsA76xx
/**
* @brief POSTFile
* @note Send file to server
* @param *filepath:File path and file name, full path required
* @param *filepath:File path and file name, full path required. C:/file for local storage and D:/file for SD card
* @param method: 0 = GET 1 = POST 2 = HEAD 3 = DELETE
* @param sendFileAsBody: 0 = Send file as HTTP header and body , 1 = Send file as Body
* @retval httpCode, -1 = failed
*/
int https_post_file(const char *filepath, uint8_t method = 1, bool sendFileAsBody = 1)
{
// A76XX Series_AT Command Manual_V1.09, Page 363
// AT+HTTPPOSTFILE=<filename>[,<path>[,<method>[,<send_header>]]]
uint8_t path = 1;
if (!filepath)return -1;
if (&filepath[3] == NULL)return -1;
if (filepath[0] == 'd' || filepath[0] == 'D') {
path = 2;
}
thisModem().sendAT("+HTTPPOSTFILE=\"", &filepath[3], "\",", path, ',', method, ',', sendFileAsBody);
// filename: full path required. C:/file for local storage and D:/file for SD card
if (!filepath || strlen(filepath) < 4) return -1; // no file
uint8_t path = filepath[0] == 'd' || filepath[0] == 'D' ? 2 : 1; // storage (2 for SD or 1 for local)
thisModem().sendAT("+HTTPPOSTFILE=\"", filepath[3], "\",", path, ',', method, ',', sendFileAsBody);
lewisxhe marked this conversation as resolved.
Show resolved Hide resolved
if (thisModem().waitResponse(120000UL) != 1) {
return -1;
}
Expand Down