From 592cb98606125c333200d097c14fdb6410b34d05 Mon Sep 17 00:00:00 2001 From: jmsdevelop <156369581+jmsdevelop@users.noreply.github.com> Date: Sat, 31 May 2025 12:40:44 +0200 Subject: [PATCH] get only IP from response --- src/TinyGsmClientSIM7600.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/TinyGsmClientSIM7600.h b/src/TinyGsmClientSIM7600.h index 0a27f235..834edd8e 100644 --- a/src/TinyGsmClientSIM7600.h +++ b/src/TinyGsmClientSIM7600.h @@ -283,8 +283,20 @@ class TinyGsmSim7600 : public TinyGsmModem, sendAT(GF("+IPADDR")); // Inquire Socket PDP address // sendAT(GF("+CGPADDR=1")); // Show PDP address String res; + int pIni, pEnd; if (waitResponse(10000L, res) != 1) { return ""; } - cleanResponseString(res); + pIni = res.indexOf("+IPADDR: "); + if (pIni >= 0) { + pIni += 9; // Jump 9 chars "+IPADDR: " + pEnd = res.indexOf("OK", pIni); + res = res.substring(pIni, pEnd); + res.replace("\r", ""); + res.replace("\n", ""); + res.replace(" ", ""); + res.trim(); + } else { + cleanResponseString(res); + } res.trim(); return res; }