From 0b8d844a4c94fdcfbdd313314c6399e890aad585 Mon Sep 17 00:00:00 2001 From: KidMaxwell Date: Sun, 11 May 2025 21:28:51 +0200 Subject: [PATCH] fix SIM7020 --- src/SimpleNBClientSIM7020.h | 9 +++++---- src/SimpleNBCommon.h | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/SimpleNBClientSIM7020.h b/src/SimpleNBClientSIM7020.h index c333284..e1be643 100644 --- a/src/SimpleNBClientSIM7020.h +++ b/src/SimpleNBClientSIM7020.h @@ -191,7 +191,7 @@ class SimpleNBSim7020 // : Optional. Although the documenation say can passing-in a , but actual // implementation dos not allowed (you get an ERROR). sendAT(GF("+CSOC=1,1,1")); - if (waitResponse(60000L) != 1) { return false; } + if (waitResponse(10000L) != 1) { return false; } int16_t cid = streamGetIntBefore('\n'); waitResponse(); if (cid < SIMPLE_NB_MUX_COUNT) @@ -200,8 +200,8 @@ class SimpleNBSim7020 } bool deactivateDataNetwork() { - sendAT(GF("+CSOC=0")); - if (waitResponse(60000L) != 1) { return false; } + sendAT(GF("+CSOCL=0")); + if (waitResponse(10000L) != 1) { return false; } return true; } @@ -299,6 +299,7 @@ class SimpleNBSim7020 // when not using SSL, the TCP application toolkit is more stable sendAT(GF("+CIPSTART="), GF("\"TCP"), GF("\",\""), host, GF("\","), port); int8_t rsp = 0; + waitResponse(timeout_ms, GF("OK" ACK_NL)); rsp = waitResponse(timeout_ms, GF("CONNECT OK" ACK_NL), GF("CONNECT FAIL" ACK_NL), GF("ALREADY CONNECT" ACK_NL), GF("ERROR" ACK_NL), @@ -365,7 +366,7 @@ class SimpleNBSim7020 size_t modemGetAvailable(uint8_t mux) { if (!sockets[mux]) return 0; - sendAT(GF("+CIPRXGET=4"), mux); + sendAT(GF("+CIPRXGET=4")); size_t result = 0; if (waitResponse(GF("+CIPRXGET:")) == 1) { streamSkipUntil(','); // Skip mode 4 diff --git a/src/SimpleNBCommon.h b/src/SimpleNBCommon.h index ae4d588..9322a8f 100644 --- a/src/SimpleNBCommon.h +++ b/src/SimpleNBCommon.h @@ -117,17 +117,18 @@ uint32_t SimpleNBAutoBaud(T& SerialAT, uint32_t minimum = 9600, } template -bool SimpleNBBegin(T& SerialAT, uint32_t rate) { +bool SimpleNBBegin(T& SerialAT, uint32_t rate, uint32_t RX_pin, uint32_t TX_pin) { DBG("Communicate at baud rate", rate, "..."); - SerialAT.begin(rate); - delay(10); + SerialAT.begin(rate,SERIAL_8N1,RX_pin,TX_pin); + delay(500); for (int j = 0; j < 10; j++) { SerialAT.print("AT\r\n"); String input = SerialAT.readString(); + Serial.println(input); if (input.indexOf("OK") >= 0) { return true; } - delay(10); + delay(100); } DBG("No response from modem, check your hardware connection"); return false;