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

Sim7600 SSL support v.0.12.0 #808

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

floBik
Copy link

@floBik floBik commented Sep 9, 2024

Co-authored-by: @Matt-Stedman

The following PR is an evolution of PR #767 and should resolve issue #786 . A few things have been done:

  • Bump to v0.12.0 of TinyGSM
  • Refactoring of certificate handling
  • updated readme
  • some bug fixes

Feel free to test this and give some feedback if something should be changed.

@apanagar
Copy link

First off, thanks for this work. This PR looks like exactly what I was looking for. I'm currently trying to run this code on the sim7600 but it seems like the String class in framework-arduino-sam doesn't have an isEmpty method: https://github.com/arduino/ArduinoCore-sam/blob/master/cores/arduino/WString.h

Currently getting the following error trace:

Processing due (platform: atmelsam; board: due; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/due.html
PLATFORM: Atmel SAM (8.3.0) > Arduino Due (Programming Port)
HARDWARE: AT91SAM3X8E 84MHz, 96KB RAM, 512KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink, stlink)
PACKAGES: 
 - framework-arduino-sam @ 1.6.12 
 - framework-cmsis @ 1.40500.0 (4.5.0) 
 - framework-cmsis-atmel @ 1.2.2 
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- StreamDebugger @ 1.0.1
|-- TinyGSM @ 0.12.0
Building in release mode
Compiling .pio/build/due/src/main.cpp.o
Compiling .pio/build/due/FrameworkArduinoVariant/variant.cpp.o
Compiling .pio/build/due/FrameworkArduino/IPAddress.cpp.o
Compiling .pio/build/due/FrameworkArduino/Print.cpp.o
Compiling .pio/build/due/FrameworkArduino/Reset.cpp.o
Compiling .pio/build/due/FrameworkArduino/RingBuffer.cpp.o
Compiling .pio/build/due/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/due/FrameworkArduino/UARTClass.cpp.o
Compiling .pio/build/due/FrameworkArduino/USARTClass.cpp.o
Compiling .pio/build/due/FrameworkArduino/USB/CDC.cpp.o
In file included from lib/TinyGSM/src/TinyGsmClient.h:55:0,
                 from src/main.cpp:100:
lib/TinyGSM/src/TinyGsmClientSIM7600.h: In member function 'virtual int TinyGsmSim7600::GsmClientSecureSim7600::connect(const char*, uint16_t, int)':
lib/TinyGSM/src/TinyGsmClientSIM7600.h:362:51: error: 'class String' has no member named 'isEmpty'
       if (certValidation && at->certificates[mux].isEmpty()) {return -1;}
                                                   ^~~~~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h: In member function 'virtual void TinyGsmSim7600::GsmClientSecureSim7600::stop(uint32_t)':
lib/TinyGSM/src/TinyGsmClientSIM7600.h:372:30: error: 'class String' has no member named 'isEmpty'
       if (!certificates[mux].isEmpty()) {
                              ^~~~~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h:376:36: error: 'class String' has no member named 'isEmpty'
       if (!clientCertificates[mux].isEmpty()) {
                                    ^~~~~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h:380:35: error: 'class String' has no member named 'isEmpty'
       if (!clientPrivateKeys[mux].isEmpty()) {
                                   ^~~~~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h: In member function 'bool TinyGsmSim7600::modemConnect(const char*, uint16_t, uint8_t, SSLVersion, int)':
lib/TinyGSM/src/TinyGsmClientSIM7600.h:913:30: error: 'class String' has no member named 'isEmpty'
       if (!certificates[mux].isEmpty()) {
                              ^~~~~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h:919:36: error: 'class String' has no member named 'isEmpty'
       if (!clientCertificates[mux].isEmpty()) {
                                    ^~~~~~~
In file included from lib/TinyGSM/src/TinyGsmClient.h:55:0,
                 from src/main.cpp:100:
lib/TinyGSM/src/TinyGsmClientSIM7600.h:924:35: error: 'class String' has no member named 'isEmpty'
       if (!clientPrivateKeys[mux].isEmpty()) {
                                   ^~~~~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h:929:30: error: 'class String' has no member named 'isEmpty'
       if (!certificates[mux].isEmpty() &&!clientCertificates[mux].isEmpty() && !clientPrivateKeys[mux].isEmpty()) {
                              ^~~~~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h:929:67: error: 'class String' has no member named 'isEmpty'
       if (!certificates[mux].isEmpty() &&!clientCertificates[mux].isEmpty() && !clientPrivateKeys[mux].isEmpty()) {
                                                                   ^~~~~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h:929:104: error: 'class String' has no member named 'isEmpty'
       if (!certificates[mux].isEmpty() &&!clientCertificates[mux].isEmpty() && !clientPrivateKeys[mux].isEmpty()) {
                                                                                                        ^~~~~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h:931:36: error: 'class String' has no member named 'isEmpty'
       } else if (certificates[mux].isEmpty() && !clientCertificates[mux].isEmpty() && !clientPrivateKeys[mux].isEmpty()) {
                                    ^~~~~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h:931:74: error: 'class String' has no member named 'isEmpty'
       } else if (certificates[mux].isEmpty() && !clientCertificates[mux].isEmpty() && !clientPrivateKeys[mux].isEmpty()) {
                                                                          ^~~~~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h:931:111: error: 'class String' has no member named 'isEmpty'
       } else if (certificates[mux].isEmpty() && !clientCertificates[mux].isEmpty() && !clientPrivateKeys[mux].isEmpty()) {
                                                                                                               ^~~~~~~
src/main.cpp: In function 'void loop()':
src/main.cpp:239:15: error: no matching function for call to 'TinyGsmSim7600::GsmClientSecureSim7600::stop()'
   client.stop();
               ^
In file included from lib/TinyGSM/src/TinyGsmClient.h:55:0,
                 from src/main.cpp:100:
lib/TinyGSM/src/TinyGsmClientSIM7600.h:368:11: note: candidate: virtual void TinyGsmSim7600::GsmClientSecureSim7600::stop(uint32_t)
      void stop(uint32_t maxWaitMs) override {
           ^~~~
lib/TinyGSM/src/TinyGsmClientSIM7600.h:368:11: note:   candidate expects 1 argument, 0 provided
*** [.pio/build/due/src/main.cpp.o] Error 1
===================================================================== [FAILED] Took 1.04 seconds =====================================================================

https://registry.platformio.org/tools/platformio/framework-arduino-sam
Using the Arduino Due specifically because the sim7600 tx/rx are 3.3v and the Due natively supports 3.3v.

Thanks again

@arduino12
Copy link

@floBik
It looks like Arduino String doesn't support the isEmpty() method-
(I am using the Also the Arduino Core STM32 if it matters..)

So I replaced all str.isEmpty() calls with !str.length() in TinyGsmClientSIM7600.h..
It compiles but doesn't work.. TINY_GSM_DEBUG didn't help..

I use the SIM7600E modem, and these commands seems to fail in the modem.gprsConnect():

AT+CCHCLOSE=0 -> ERROR
AT+CIPCLOSE=0 -> +CIPCLOSE: 0,4 ERROR
AT+CCHSEND=0,32 -> ERROR
AT+CCHSEND=0,17 -> ERROR
AT+CCHSEND=0,21 -> ERROR
AT+CCHSEND=0,2 -> ERROR
AT+CCHRECV? -> +CCHRECV: LEN,0,0 OK
AT+CCHCLOSE=0 -> ERROR
AT+CIPCLOSE=0 -> +CIPCLOSE: 0,4 ERROR

But the modem.gprsConnect() returns 0..

Any help will be much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants