mirror of
https://github.com/KevinMidboe/TinyGSM.git
synced 2025-10-29 18:00:18 +00:00
Better support for Cellular XBEE3 modules
Also some minor documentation and naming changes for consistency.
This commit is contained in:
@@ -39,15 +39,28 @@ enum RegStatus {
|
||||
REG_UNKNOWN = 4,
|
||||
};
|
||||
|
||||
enum DateTime {
|
||||
enum TinyGSMDateTimeFormat {
|
||||
DATE_FULL = 0,
|
||||
DATE_TIME = 1,
|
||||
DATE_DATE = 2
|
||||
};
|
||||
|
||||
//============================================================================//
|
||||
//============================================================================//
|
||||
// Declaration of the TinyGsmSim800 Class
|
||||
//============================================================================//
|
||||
//============================================================================//
|
||||
|
||||
class TinyGsmSim800
|
||||
{
|
||||
|
||||
//============================================================================//
|
||||
//============================================================================//
|
||||
// The Sim800 Internal Client Class
|
||||
//============================================================================//
|
||||
//============================================================================//
|
||||
|
||||
|
||||
public:
|
||||
|
||||
class GsmClient : public Client
|
||||
@@ -179,14 +192,21 @@ public:
|
||||
|
||||
private:
|
||||
TinyGsmSim800* at;
|
||||
uint8_t mux;
|
||||
uint16_t sock_available;
|
||||
uint32_t prev_check;
|
||||
bool sock_connected;
|
||||
bool got_data;
|
||||
RxFifo rx;
|
||||
uint8_t mux;
|
||||
uint16_t sock_available;
|
||||
uint32_t prev_check;
|
||||
bool sock_connected;
|
||||
bool got_data;
|
||||
RxFifo rx;
|
||||
};
|
||||
|
||||
//============================================================================//
|
||||
//============================================================================//
|
||||
// The SIM800 Secure Client
|
||||
//============================================================================//
|
||||
//============================================================================//
|
||||
|
||||
|
||||
class GsmClientSecure : public GsmClient
|
||||
{
|
||||
public:
|
||||
@@ -206,9 +226,19 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
//============================================================================//
|
||||
//============================================================================//
|
||||
// The SIM800 Modem Functions
|
||||
//============================================================================//
|
||||
//============================================================================//
|
||||
|
||||
public:
|
||||
|
||||
#ifdef GSM_DEFAULT_STREAM
|
||||
TinyGsmSim800(Stream& stream = GSM_DEFAULT_STREAM)
|
||||
#else
|
||||
TinyGsmSim800(Stream& stream)
|
||||
#endif
|
||||
: stream(stream)
|
||||
{
|
||||
memset(sockets, 0, sizeof(sockets));
|
||||
@@ -244,8 +274,8 @@ public:
|
||||
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||
sendAT(GF(""));
|
||||
if (waitResponse(200) == 1) {
|
||||
delay(100);
|
||||
return true;
|
||||
delay(100);
|
||||
return true;
|
||||
}
|
||||
delay(100);
|
||||
}
|
||||
@@ -396,10 +426,10 @@ public:
|
||||
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
|
||||
waitResponse();
|
||||
switch (status) {
|
||||
case 2:
|
||||
case 3: return SIM_LOCKED;
|
||||
case 1: return SIM_READY;
|
||||
default: return SIM_ERROR;
|
||||
case 2:
|
||||
case 3: return SIM_LOCKED;
|
||||
case 1: return SIM_READY;
|
||||
default: return SIM_ERROR;
|
||||
}
|
||||
}
|
||||
return SIM_ERROR;
|
||||
@@ -456,6 +486,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* WiFi functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* GPRS functions
|
||||
*/
|
||||
@@ -734,12 +768,12 @@ public:
|
||||
/*
|
||||
* Time functions
|
||||
*/
|
||||
String getGSMDateTime(DateTime format) {
|
||||
String getGSMDateTime(TinyGSMDateTimeFormat format) {
|
||||
sendAT(GF("+CCLK?"));
|
||||
if (waitResponse(2000L, GF(GSM_NL "+CCLK: \"")) != 1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
String res;
|
||||
|
||||
switch(format) {
|
||||
@@ -892,9 +926,13 @@ public:
|
||||
streamWrite(tail...);
|
||||
}
|
||||
|
||||
bool streamSkipUntil(char c) { //TODO: timeout
|
||||
while (true) {
|
||||
while (!stream.available()) { TINY_GSM_YIELD(); }
|
||||
bool streamSkipUntil(char c) {
|
||||
const unsigned long timeout = 1000L;
|
||||
unsigned long startMillis = millis();
|
||||
while (millis() - startMillis < timeout) {
|
||||
while (millis() - startMillis < timeout && !stream.available()) {
|
||||
TINY_GSM_YIELD();
|
||||
}
|
||||
if (stream.read() == c)
|
||||
return true;
|
||||
}
|
||||
@@ -975,6 +1013,7 @@ finish:
|
||||
}
|
||||
data = "";
|
||||
}
|
||||
//DBG('<', index, '>');
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user