vshymanskyy / TinyGSM

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

Empty stream after call waitResponse() #776

Open Dexter0007 opened 4 months ago

Dexter0007 commented 4 months ago

Hi, I'm trying to get USSD code response from modem but method sendUSSDImpl not working (always return empty string).

I'm using ESP32 WROOM32 using HW Serial2 and NEOWAY M590 REVISION 01.30c

This code not working:

 String sendUSSDImpl(const String& code) {
     sendAT(GF("+CSCS=\"GSM\""));
     waitResponse();
     sendAT(GF("+CUSD=1,\""), code, GF("\",15"));

     int8_t state = waitResponse(10000L);

     String str = String(stream.available());

     return "Received:" + str + ", state:" + String(state);

 }

Return always: Received:0, state:1

This code working good:

String sendUSSDImpl(const String& code) {
    sendAT(GF("+CSCS=\"GSM\""));
    waitResponse();
    sendAT(GF("+CUSD=1,\""), code, GF("\",15"));

    delay(10000);

    int8_t state = 0; 

    String str = String(stream.available());

    return "Received:" + str + ", state:" + String(state);

}

Return always: Received:86, state:0

I can't read data by stream.readString(); if waitResponse() is before.