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

Sim7000 SSL CASEND response #706

Open Michaelcombs opened 1 year ago

Michaelcombs commented 1 year ago

In TinyGSMClientSim7000SSL.h, modemSend

After writing data to the stream, the code expects the response:

+CASEND, ,,

as per the Sim7000 documentation. The Sim7000 is actually returning:

OK

see code: https://github.com/vshymanskyy/TinyGSM/blob/3356c1d5c7bbde4a8440021b591453545ffccbde/src/TinyGsmClientSIM7000SSL.h#L433

muddejp commented 1 year ago

I verified this as well. It greatly slows down data transmission waiting for the wrong response. I changed the code to

int16_t modemSend(const void* buff, size_t len, uint8_t mux) {
    // send data on prompt
    sendAT(GF("+CASEND="), mux, ',', (uint16_t)len);
    if (waitResponse(GF(">")) != 1) { return 0; }

    stream.write(reinterpret_cast<const uint8_t*>(buff), len);
    stream.flush();

    // after posting data, module responds with:
    //+CASEND: <cid>,<result>,<sendlen>
    //if (waitResponse(GF(GSM_NL "+CASEND:")) != 1) { return 0; }
    if (waitResponse(GF(GSM_NL "OK")) != 1) { return 0; }
    //streamSkipUntil(',');                            // Skip mux
    //if (streamGetIntBefore(',') != 0) { return 0; }  // If result != success
    return streamGetIntBefore('\n');
  }

And it works great.