botletics / SIM7000-LTE-Shield

Botletics SIM7000 LTE CAT-M1/NB-IoT Shield for Arduino
https://www.botletics.com/products/sim7000-shield
GNU General Public License v3.0
477 stars 215 forks source link

Library not compiling correctly on ESP32 with Express-IDF and Arduino #110

Open leofabri opened 5 years ago

leofabri commented 5 years ago

Hi @botletics, I'm facing compilation issues with your library when I try to compile it for my ESP32 when using express-if and Arduino as a module. I get the following errors:

CXX build/arduino/libraries/SIM7000-LTE-Shield//Adafruit_FONA.o
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp: In member function 'boolean Adafruit_FONA::getGPS(float*, float*, float*, float*, float*, uint16_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t*, float*)':
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:1054:11: warning: variable 'tok' set but not used [-Wunused-but-set-variable]
     char *tok;
           ^
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp: In member function 'boolean Adafruit_FONA::postData(const char*, const char*, const char*, const char*, uint32_t)':
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:1696:23: error: comparison with string literal results in unspecified behaviour [-Werror=address]
   if (request_type == "GET") {
                       ^
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:1700:28: error: comparison with string literal results in unspecified behaviour [-Werror=address]
   else if (request_type == "POST" && bodylen > 0 ) { // POST with content body
                            ^
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:1727:28: error: comparison with string literal results in unspecified behaviour [-Werror=address]
   else if (request_type == "POST" && bodylen == 0) { // POST with query parameters
                            ^
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:1731:28: error: comparison with string literal results in unspecified behaviour [-Werror=address]
   else if (request_type == "HEAD") {
                            ^
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp: In member function 'boolean Adafruit_FONA::postData(const char*, uint16_t, const char*, const char*, const char*)':
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:1763:13: error: suggest parentheses around comparison in operand of '|' [-Werror=parentheses]
   if (_type == SIM7500A | _type == SIM7500E) {
             ^
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:1797:13: error: suggest parentheses around comparison in operand of '|' [-Werror=parentheses]
   if (_type == SIM7500A | _type == SIM7500E) {
             ^
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:1828:13: error: suggest parentheses around comparison in operand of '|' [-Werror=parentheses]
   if (_type == SIM7500A | _type == SIM7500E) {
             ^
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp: In member function 'boolean Adafruit_FONA::FTP_PUT(const char*, const char*, char*, size_t)':
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:2117:20: warning: comparison is always false due to limited range of data type [-Wtype-limits]
       if (remBytes >= 300000) {
                    ^
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp: In member function 'boolean Adafruit_FONA::MQTTunsubscribe(const char*)':
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:2386:1: error: no return statement in function returning non-void [-Werror=return-type]
 }
 ^
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp: In member function 'boolean Adafruit_FONA::MQTTreceive(const char*, const char*, int)':
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:2390:1: error: no return statement in function returning non-void [-Werror=return-type]
 }
 ^
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp: In member function 'boolean Adafruit_FONA::MQTTdisconnect()':
/esp/test/components/arduino/libraries/SIM7000-LTE-Shield/Adafruit_FONA.cpp:2394:1: error: no return statement in function returning non-void [-Werror=return-type]
 }
 ^
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-frame-address'
cc1plus: some warnings being treated as errors
make[1]: *** [/esp/esp-idf/make/component_wrapper.mk:290: libraries/SIM7000-LTE-Shield//Adafruit_FONA.o] Error 1
make: *** [/esp/esp-idf/make/project.mk:582: component-arduino-build] Error 2

It seems like the compiler is having issues with the way the comparisons are done (maybe the compiler is expecting strcmp?), but I don't understand why that is happening. I didn't test it with the bare Arduino IDE but I suppose that it works just fine. Thank you in advance for your support

leofabri commented 5 years ago

Hello, I tried to apply some changes to Adafruit_FONA.cpp to make it runnable (see pull between requests) and now it seems to compile just fine on my ESP32. Unfortunately, when I try to connect to the SIM7600/SIM7000G modules I experience the following problem:

Initializing connections....(May take several seconds)
Configuring to 9600 baud
Attempting to open comm with ATs
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- OK
        ---> AT
        <--- 
        ---> AT
        <--- OK
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
Timeout: No response to AT... last ditch attempt.
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> AT
        <--- 
        ---> ATE0
        <--- 
        ---> ATE0
        <--- 
Couldn't find FONA

Something else was written here. Though I decided to clean my help request a little bit after playing around with the library for several hours without any result.

The only thing I can say about this is that if you upload the code using just the Arduino IDE without esp-idf everything works as it should. The sim module gets detected almost immediately and nothing bad seems to happen. However when you use esp-idf nothing works. The result is the one above. I cannot get the sim module connected because it's not seen by the board.

Please help. Thank you.

botletics commented 4 years ago

Sorry, I've never really used ESP-IDF with Arduino. Are you using it so that you can include the IDF commands inside Arduino IDE? Are you saying that simply installing ESP-IDF makes the code not compile in Arduino IDE, without even adding any IDF commands inside?