Check possible mux numbers

Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
Sara Damiano
2020-02-18 17:54:04 -05:00
parent da5c7b4233
commit 7b40ee2f33
15 changed files with 120 additions and 68 deletions

View File

@@ -85,7 +85,6 @@ class TinyGsmSequansMonarch
bool init(TinyGsmSequansMonarch* modem, uint8_t mux = 1) {
this->at = modem;
this->mux = mux;
sock_available = 0;
prev_check = 0;
sock_connected = false;
@@ -93,6 +92,11 @@ class TinyGsmSequansMonarch
// adjust for zero indexed socket array vs Sequans' 1 indexed mux numbers
// using modulus will force 6 back to 0
if (mux >= 1 && mux <= TINY_GSM_MUX_COUNT) {
this->mux = mux;
} else {
this->mux = (mux % TINY_GSM_MUX_COUNT) + 1;
}
at->sockets[mux % TINY_GSM_MUX_COUNT] = this;
return true;