TinyGsmClientSequansMonarch.h: use data mode
Use data mode instead of text mode to be able to send any content such as raw binary. This will allow us to use TinyGSM with ArduinoBearSSL and ArduinoMqtt. It should be noted that for an unclear reason GSM_NL must be set to '\n' instead of '\r\n' to avoid "CME ERROR: operation not supported" in this mode with the Monarch GMS01Q. Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
This commit is contained in:
@@ -467,8 +467,8 @@ class TinyGsmSequansMonarch
|
|||||||
// <recvDataMode1> = Receive data mode = 0 - data as text (1 for hex)
|
// <recvDataMode1> = Receive data mode = 0 - data as text (1 for hex)
|
||||||
// <keepalive1> = unused = 0
|
// <keepalive1> = unused = 0
|
||||||
// <listenAutoRsp1> = Listen auto-response mode = 0 - deactivated
|
// <listenAutoRsp1> = Listen auto-response mode = 0 - deactivated
|
||||||
// <sendDataMode1> = Send data mode = 0 - data as text (1 for hex)
|
// <sendDataMode1> = Send data mode = 1 - data as hex (0 for text)
|
||||||
sendAT(GF("+SQNSCFGEXT="), mux, GF(",1,0,0,0,0"));
|
sendAT(GF("+SQNSCFGEXT="), mux, GF(",1,0,0,0,1"));
|
||||||
waitResponse(5000L);
|
waitResponse(5000L);
|
||||||
|
|
||||||
// Socket dial
|
// Socket dial
|
||||||
@@ -508,7 +508,13 @@ class TinyGsmSequansMonarch
|
|||||||
|
|
||||||
sendAT(GF("+SQNSSENDEXT="), mux, ',', (uint16_t)len);
|
sendAT(GF("+SQNSSENDEXT="), mux, ',', (uint16_t)len);
|
||||||
waitResponse(10000L, GF(GSM_NL "> "));
|
waitResponse(10000L, GF(GSM_NL "> "));
|
||||||
stream.write(reinterpret_cast<const uint8_t*>(buff), len);
|
// Translate bytes into char to be able to send them as an hex string
|
||||||
|
char char_command[2];
|
||||||
|
for (int i=0; i<len; i++) {
|
||||||
|
memset(&char_command, 0, sizeof(char_command));
|
||||||
|
sprintf(&char_command[0], "%02X", reinterpret_cast<const uint8_t*>(buff)[i]);
|
||||||
|
stream.write(char_command, sizeof(char_command));
|
||||||
|
}
|
||||||
stream.flush();
|
stream.flush();
|
||||||
if (waitResponse() != 1) {
|
if (waitResponse() != 1) {
|
||||||
DBG("### no OK after send");
|
DBG("### no OK after send");
|
||||||
@@ -720,7 +726,8 @@ class TinyGsmSequansMonarch
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
GsmClientSequansMonarch* sockets[TINY_GSM_MUX_COUNT];
|
GsmClientSequansMonarch* sockets[TINY_GSM_MUX_COUNT];
|
||||||
const char* gsmNL = GSM_NL;
|
// GSM_NL (\r\n) is not accepted with SQNSSENDEXT in data mode so use \n
|
||||||
|
const char* gsmNL = "\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SRC_TINYGSMCLIENTSEQUANSMONARCH_H_
|
#endif // SRC_TINYGSMCLIENTSEQUANSMONARCH_H_
|
||||||
|
Reference in New Issue
Block a user