vshymanskyy / TinyGSM

A small Arduino library for GSM modules, that just works
GNU Lesser General Public License v3.0
1.97k stars 725 forks source link

Can't connect/register to network on SIM7600 #807

Open CcKefa opened 2 months ago

CcKefa commented 2 months ago

[ x] I have read the Troubleshooting section of the ReadMe

What type of issues is this?

[ ] Request to support a new module

[ ] Bug or problem compiling the library [ ] Bug or issue with library functionality (ie, sending data over TCP/IP) [x ] Question or request for help

What are you working with?

Modem: Main processor board: TinyGSM version: Code: <!--

define TINY_GSM_MODEM_SIM7600

define DUMP_AT_COMMANDS

// Set serial for debug console (to the Serial Monitor, default speed 115200)

define SerialMon Serial

// Set serial for AT commands (to the module) // Use Hardware Serial on Mega, Leonardo, Micro

ifndef __AVR_ATmega328P__

define SerialAT Serial1

// or Software Serial on Uno, Nano

else

include

SoftwareSerial SerialAT(2, 3); // RX, TX

endif

// Increase RX buffer to capture the entire response // Chips without internal buffering (A6/A7, ESP8266, M590) // need enough space in the buffer for the entire response // else data will be lost (and the http library will fail).

if !defined(TINY_GSM_RX_BUFFER)

define TINY_GSM_RX_BUFFER 650

endif

// Define the serial console for debug prints, if needed

define TINY_GSM_DEBUG SerialMon

// Add a reception delay, if needed. // This may be needed for a fast processor at a slow baud rate.

define TINY_GSM_YIELD() { delay(20); }

// Uncomment this if you want to use SSL // #define USE_SSL

// Define how you're planning to connect to the internet. // This is only needed for this example, not in other code.

define TINY_GSM_USE_GPRS true

define TINY_GSM_USE_WIFI false

// set GSM PIN, if any

define GSM_PIN ""

// Your GPRS credentials, if any const char apn[] = "apn"; // changed to "apn" for privacy const char gprsUser[] = ""; const char gprsPass[] = "";

// Your WiFi connection credentials, if applicable const char wifiSSID[] = "YourSSID"; const char wifiPass[] = "YourWiFiPass";

// Server details const char server[] = ""; const char resource[] = "";

include

// Just in case someone defined the wrong thing..

if TINY_GSM_USE_GPRS && not defined TINY_GSM_MODEM_HAS_GPRS

undef TINY_GSM_USE_GPRS

undef TINY_GSM_USE_WIFI

define TINY_GSM_USE_GPRS false

define TINY_GSM_USE_WIFI true

endif

if TINY_GSM_USE_WIFI && not defined TINY_GSM_MODEM_HAS_WIFI

undef TINY_GSM_USE_GPRS

undef TINY_GSM_USE_WIFI

define TINY_GSM_USE_GPRS true

define TINY_GSM_USE_WIFI false

endif

ifdef DUMP_AT_COMMANDS

include

StreamDebugger debugger(SerialAT, SerialMon); TinyGsm modem(debugger);

else

TinyGsm modem(SerialAT);

endif

if defined(TINY_GSM_MODEM_HAS_SSL)

define USE_SSL

endif

ifdef USE_SSL

TinyGsmClientSecure client(modem); const int port = ;

else

TinyGsmClient client(modem); const int port = ;

endif

define RX 17

define TX 16

//#define RI 32 // Not in use

void setup() { // Set console baud rate SerialMon.begin(115200); delay(10);

SerialMon.println("Iniciando seriales"); SerialAT.begin(115200, SERIAL_8N1, RX, TX, false); delay(1000);

// Restart takes quite some time // To skip it, call init() instead of restart() SerialMon.println("Initializing modem..."); modem.restart(); // modem.init(); delay(15000); // modem.factoryDefault(); // Non existent for SIM7600

String modemInfo = modem.getModemInfo(); delay(3000); SerialMon.print("Modem Info: "); SerialMon.println(modemInfo); delay(5000); modem.setPhoneFunctionality(1); modem.setNetworkMode(2);

delay(10000);

esp_sleep_enable_ext0_wakeup(GPIO_NUM_34, HIGH); }

void loop() {

if TINY_GSM_USE_GPRS

// GPRS connection parameters are usually set after network registration SerialMon.print(F("Connecting to ")); SerialMon.print(apn); if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { SerialMon.println(" fail"); delay(10000); return; } SerialMon.println(" success"); delay(2000); } -->

Scenario, steps to reproduce

Trying to connect using the library function gprsConnect(). It loops trying to connect and fails everytime.

Expected result

Module registered and connected to network

Actual result

Module can't connect. NETOPEN returns 1 and loops trying to connect with the same result every time.

Debug and AT command log

Initializing modem... AT

OK AT+CRESET

OK [25361] ### TinyGSM Version: 0.12.0 [25362] ### TinyGSM Compiled Module: TinyGsmClientSIM7600 AT AT AT AT AT AT AT AT AT

RDY

+CPIN: READY AT OK ATE0 ATE0 OK AT+CMEE=2

PB DONE

OK AT+CGMI

SIMCOM INCORPORATED

OK AT+CGMM

SIMCOM_SIM7600SA-MNSE

OK [30635] ### Modem: SIMCOM INCORPORATED SIMCOM_SIM7600SA-MNSE [30635] ### Modem: SIMCOM INCORPORATED SIMCOM_SIM7600SA-MNSE AT+CTZR=0

OK AT+CTZU=1

OK AT+CPIN?

+CPIN: READY

OK Modem reiniciado ATI

Manufacturer: SIMCOM INCORPORATED Model: SIMCOM_SIM7600SA-MNSE Revision: SIM7600M11_A_V2.0 IMEI: 863427044693423 +GCAP: +CGSM

OK Modem Info: Manufacturer: SIMCOM INCORPORATED Model: SIMCOM_SIM7600SA-MNSE Revision: SIM7600M11_A_V2.0 IMEI: 863427044693423 +GCAP: +CGSM AT+CFUN=1

OK AT+CNMP=2

OK Connecting to xxxxx AT+NETCLOSE

+NETCLOSE: 2

ERROR AT+CGDCONT=1,"IP","xxxxx","0.0.0.0",0,0

OK AT+CIPMODE=0

OK AT+CIPSENDMODE=0

OK AT+CIPCCFG=10,0,0,0,1,0,75000

OK AT+CIPTIMEOUT=75000,15000,15000

OK AT+NETOPEN

OK

+NETOPEN: 1 [144027] ### Unhandled: OK

+NETOPEN: 1 fail Connecting to xxxxx AT+NETCLOSE

+NETCLOSE: 2

ERROR AT+CGDCONT=1,"IP","xxxxx","0.0.0.0",0,0

OK AT+CIPMODE=0

OK AT+CIPSENDMODE=0

OK AT+CIPCCFG=10,0,0,0,1,0,75000

OK AT+CIPTIMEOUT=75000,15000,15000

OK AT+NETOPEN

OK

+NETOPEN: 1 [230423] ### Unhandled: OK

+NETOPEN: 1 fail

CcKefa commented 2 months ago

Some additional info: When sending AT+COPS=? It returns a list of operators. Just as it should. When sending AT+COPS? Returns +COPS: 2. When sending AT+CPSI? Returns +CPSI: NO SERVICE,Online With the register AT commands I get: +CEREG: 0,4 +CGREG: 0,0 +CREG: 0,0