From 89a6f30add6dcbb245b5d37ab1bb5ed7ac575193 Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Fri, 15 Mar 2024 10:48:15 +0100 Subject: [PATCH 1/2] Fix CI: - Add workflow_dispatch - Fix test which was breaking CI - Update CI plugins - Only run CI with esp32dev and esp32s3box (only for Lily boards) - Declared library to only be compatible with esp32 --- .../workflows/build_examples_platformio.yaml | 20 ++++++++++---- .gitignore | 1 - library.json | 6 +++-- library.properties | 2 +- platformio.ini | 26 +++++++++++++++++++ src/TinyGsmClient.h | 1 + src/TinyGsmClientA7670.h | 2 +- src/TinyGsmClientSIM7600.h | 2 +- tools/test_build/test_build.ino | 5 ++-- 9 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 platformio.ini diff --git a/.github/workflows/build_examples_platformio.yaml b/.github/workflows/build_examples_platformio.yaml index b23069b0..6a67c175 100644 --- a/.github/workflows/build_examples_platformio.yaml +++ b/.github/workflows/build_examples_platformio.yaml @@ -1,7 +1,11 @@ name: Build Examples with PlatformIO # Triggers the workflow on push or pull request events -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: build: @@ -34,14 +38,20 @@ jobs: TINY_GSM_MODEM_SIM7000, TINY_GSM_MODEM_SIM7000SSL, TINY_GSM_MODEM_SIM7070, + TINY_GSM_MODEM_A7670, TINY_GSM_MODEM_UBLOX, TINY_GSM_MODEM_SARAR4, TINY_GSM_MODEM_XBEE, TINY_GSM_MODEM_SEQUANS_MONARCH, + # added in this fork + TINY_GSM_MODEM_A7608, + TINY_GSM_MODEM_A7670, + TINY_GSM_MODEM_SIM7020, + TINY_GSM_MODEM_SIM7672 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set variables run: | @@ -54,7 +64,7 @@ jobs: fi - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' @@ -65,7 +75,7 @@ jobs: pip install --upgrade platformio - name: Restore or Cache Platforms and Libraries - uses: actions/cache@v3.3.1 + uses: actions/cache@v4 id: cache_pio with: path: ~/.platformio @@ -87,5 +97,5 @@ jobs: echo "${{ env.LIBRARY_INSTALL_SOURCE }}" pio lib --global install ${{ env.LIBRARY_INSTALL_SOURCE }} sed -i 's/\/\/ #define TINY_GSM_MODEM_SIM800/#define TINY_GSM_MODEM_SIM800/g' ${{ matrix.example }}/* - platformio ci --project-option='build_flags=-D ${{ env.TINYGSM_MODEM_TO_USE }}' --project-option='framework=arduino' --board=uno --board=leonardo --board=yun --board=megaatmega2560 --board=genuino101 --board=mkr1000USB --board=zero --board=teensy31 --board=bluepill_f103c8 --board=uno_pic32 --board=esp01 --board=nodemcuv2 --board=esp32dev + platformio ci --project-option='build_flags=-D ${{ env.TINYGSM_MODEM_TO_USE }}' --project-option='framework=arduino' --board=esp32dev --board=esp32s3box pio lib --global uninstall TinyGSM diff --git a/.gitignore b/.gitignore index 2b40655e..de5d0b2f 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,6 @@ .pio/* .clang_complete .gcc-flags.json -platformio.ini extra_envs.ini lib/readme.txt include/readme.txt diff --git a/library.json b/library.json index a4d18275..7113c5d9 100644 --- a/library.json +++ b/library.json @@ -26,7 +26,9 @@ "examples/*" ] }, - "frameworks": ["arduino", "energia", "wiringpi"], - "platforms": "*", + "frameworks": "arduino", + "platforms": [ + "espressif32" + ], "headers": "TinyGsmClient.h" } diff --git a/library.properties b/library.properties index 5df85809..9a93f05f 100644 --- a/library.properties +++ b/library.properties @@ -6,5 +6,5 @@ sentence=A small Arduino library for GPRS modules, that just works. paragraph=Includes examples for Blynk, MQTT, File Download, and Web Client. Supports many GSM, LTE, and WiFi modules with AT command interfaces. category=Communication url=https://github.com/vshymanskyy/TinyGSM -architectures=* +architectures=esp32 includes=TinyGsmClient.h diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 00000000..c7954e7a --- /dev/null +++ b/platformio.ini @@ -0,0 +1,26 @@ + +[platformio] +lib_dir = . +src_dir = tools/test_build + +[env] +framework = arduino +upload_protocol = esptool +monitor_speed = 115200 +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_SIM7600 + ; -D TINY_GSM_MODEM_A7608 + ; -D TINY_GSM_MODEM_A7670 + ; -D TINY_GSM_MODEM_SIM7672 + +[env:esp32dev] +platform = espressif32 +board = esp32dev + +[env:esp32s3box] +platform = espressif32 +board = esp32s3box diff --git a/src/TinyGsmClient.h b/src/TinyGsmClient.h index 230a34ed..818791c8 100644 --- a/src/TinyGsmClient.h +++ b/src/TinyGsmClient.h @@ -35,6 +35,7 @@ typedef TinyGsmSim7000::GsmClientSim7000 TinyGsmClient; #include "TinyGsmClientSIM7020.h" typedef TinyGsmSim7020 TinyGsm; typedef TinyGsmSim7020::GsmClientSim7020 TinyGsmClient; +typedef TinyGsmSim7020::GsmClientSecureSim7020 TinyGsmClientSecure; #elif defined(TINY_GSM_MODEM_SIM7000SSL) #include "TinyGsmClientSIM7000SSL.h" diff --git a/src/TinyGsmClientA7670.h b/src/TinyGsmClientA7670.h index 823703a7..0ed1a059 100644 --- a/src/TinyGsmClientA7670.h +++ b/src/TinyGsmClientA7670.h @@ -508,7 +508,7 @@ class TinyGsmA7670 : public TinyGsmModem, waitResponse(); } sendAT(GF("+CGNSSPWR=1")); - if (waitResponse(10000UL,"+CGNSSPWR: READY!") != 1) { return false; } + if (waitResponse(10000UL, GF("+CGNSSPWR: READY!")) != 1) { return false; } return true; } diff --git a/src/TinyGsmClientSIM7600.h b/src/TinyGsmClientSIM7600.h index d21bd9c9..71bdc785 100644 --- a/src/TinyGsmClientSIM7600.h +++ b/src/TinyGsmClientSIM7600.h @@ -488,7 +488,7 @@ class TinyGsmSim7600 : public TinyGsmModem, } sendAT(GF("+CGPS=0")); if (waitResponse() != 1) { return false; } - return waitResponse(30000UL,"+CGPS: 0") == 1; + return waitResponse(30000UL,GF("+CGPS: 0")) == 1; } bool isEnableGPSImpl(){ diff --git a/tools/test_build/test_build.ino b/tools/test_build/test_build.ino index 957c1ce5..15ba0cdb 100644 --- a/tools/test_build/test_build.ino +++ b/tools/test_build/test_build.ino @@ -181,8 +181,9 @@ void loop() { int hour = 0; int minute = 0; int second = 0; - modem.getGPS(&latitude, &longitude); - modem.getGPS(&latitude, &longitude, &speed, &alt, &vsat, &usat, &acc, &year, + uint8_t status = 0; + modem.getGPS(&status, &latitude, &longitude); + modem.getGPS(&status, &latitude, &longitude, &speed, &alt, &vsat, &usat, &acc, &year, &month, &day, &hour, &minute, &second); modem.disableGPS(); #endif From 6e05aefd58b7ae38b6afa93182b0d70628831aa5 Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Sun, 17 Mar 2024 17:43:16 +0100 Subject: [PATCH 2/2] Rewrote https_post_file --- platformio.ini | 4 ++-- src/TinyGsmHttpsA76xx.h | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) 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; }