diff --git a/platformio.ini b/platformio.ini index c7954e7a..52456ffc 100644 --- a/platformio.ini +++ b/platformio.ini @@ -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] diff --git a/src/TinyGsmHttpsA76xx.h b/src/TinyGsmHttpsA76xx.h index 3f44c8ba..a10ea3b9 100644 --- a/src/TinyGsmHttpsA76xx.h +++ b/src/TinyGsmHttpsA76xx.h @@ -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=[,[,[,]]] - 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); if (thisModem().waitResponse(120000UL) != 1) { return -1; }