Integrate SIM808 nicely
This commit is contained in:
@@ -11,14 +11,28 @@
|
|||||||
|
|
||||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_SIM900)
|
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_SIM900)
|
||||||
#include <TinyGsmClientSIM800.h>
|
#include <TinyGsmClientSIM800.h>
|
||||||
#elif defined(TINY_GSM_MODEM_SIM808)
|
typedef TinyGsmSim800 TinyGsm;
|
||||||
#include <TinyGsmClientSIM808.h>
|
typedef TinyGsmSim800::GsmClient TinyGsmClient;
|
||||||
|
typedef TinyGsmSim800::GsmClientSecure TinyGsmClientSecure;
|
||||||
|
|
||||||
|
#elif defined(TINY_GSM_MODEM_SIM808) || defined(TINY_GSM_MODEM_SIM868)
|
||||||
|
#include <TinyGsmClientSIM808.h>
|
||||||
|
typedef TinyGsmSim808 TinyGsm;
|
||||||
|
typedef TinyGsmSim808::GsmClient TinyGsmClient;
|
||||||
|
typedef TinyGsmSim808::GsmClientSecure TinyGsmClientSecure;
|
||||||
|
|
||||||
#elif defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_A7)
|
#elif defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_A7)
|
||||||
#include <TinyGsmClientA6.h>
|
#include <TinyGsmClientA6.h>
|
||||||
|
typedef TinyGsm::GsmClient TinyGsmClient;
|
||||||
|
|
||||||
#elif defined(TINY_GSM_MODEM_M590)
|
#elif defined(TINY_GSM_MODEM_M590)
|
||||||
#include <TinyGsmClientM590.h>
|
#include <TinyGsmClientM590.h>
|
||||||
|
typedef TinyGsm::GsmClient TinyGsmClient;
|
||||||
|
|
||||||
#elif defined(TINY_GSM_MODEM_ESP8266)
|
#elif defined(TINY_GSM_MODEM_ESP8266)
|
||||||
#include <TinyGsmClientESP8266.h>
|
#include <TinyGsmClientESP8266.h>
|
||||||
|
typedef TinyGsm::GsmClient TinyGsmClient;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Please define GSM modem model"
|
#error "Please define GSM modem model"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -714,6 +714,4 @@ private:
|
|||||||
GsmClient* sockets[TINY_GSM_MUX_COUNT];
|
GsmClient* sockets[TINY_GSM_MUX_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef TinyGsm::GsmClient TinyGsmClient;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -396,6 +396,4 @@ private:
|
|||||||
GsmClient* sockets[TINY_GSM_MUX_COUNT];
|
GsmClient* sockets[TINY_GSM_MUX_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef TinyGsm::GsmClient TinyGsmClient;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -702,6 +702,4 @@ private:
|
|||||||
GsmClient* sockets[TINY_GSM_MUX_COUNT];
|
GsmClient* sockets[TINY_GSM_MUX_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef TinyGsm::GsmClient TinyGsmClient;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -40,24 +40,24 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsm
|
class TinyGsmSim800
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class GsmClient : public Client
|
class GsmClient : public Client
|
||||||
{
|
{
|
||||||
friend class TinyGsm;
|
friend class TinyGsmSim800;
|
||||||
typedef TinyGsmFifo<uint8_t, TINY_GSM_RX_BUFFER> RxFifo;
|
typedef TinyGsmFifo<uint8_t, TINY_GSM_RX_BUFFER> RxFifo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GsmClient() {}
|
GsmClient() {}
|
||||||
|
|
||||||
GsmClient(TinyGsm& modem, uint8_t mux = 1) {
|
GsmClient(TinyGsmSim800& modem, uint8_t mux = 1) {
|
||||||
init(&modem, mux);
|
init(&modem, mux);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool init(TinyGsm* modem, uint8_t mux = 1) {
|
bool init(TinyGsmSim800* modem, uint8_t mux = 1) {
|
||||||
this->at = modem;
|
this->at = modem;
|
||||||
this->mux = mux;
|
this->mux = mux;
|
||||||
sock_available = 0;
|
sock_available = 0;
|
||||||
@@ -171,7 +171,7 @@ public:
|
|||||||
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TinyGsm* at;
|
TinyGsmSim800* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
uint16_t sock_available;
|
uint16_t sock_available;
|
||||||
uint32_t prev_check;
|
uint32_t prev_check;
|
||||||
@@ -185,7 +185,7 @@ class GsmClientSecure : public GsmClient
|
|||||||
public:
|
public:
|
||||||
GsmClientSecure() {}
|
GsmClientSecure() {}
|
||||||
|
|
||||||
GsmClientSecure(TinyGsm& modem, uint8_t mux = 1)
|
GsmClientSecure(TinyGsmSim800& modem, uint8_t mux = 1)
|
||||||
: GsmClient(modem, mux)
|
: GsmClient(modem, mux)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsm(Stream& stream)
|
TinyGsmSim800(Stream& stream)
|
||||||
: stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
@@ -672,7 +672,7 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
|
||||||
bool modemConnect(const char* host, uint16_t port, uint8_t mux, bool ssl = false) {
|
bool modemConnect(const char* host, uint16_t port, uint8_t mux, bool ssl = false) {
|
||||||
sendAT(GF("+CIPSSL="), ssl);
|
sendAT(GF("+CIPSSL="), ssl);
|
||||||
@@ -904,12 +904,9 @@ finish:
|
|||||||
return waitResponse(1000, r1, r2, r3, r4, r5);
|
return waitResponse(1000, r1, r2, r3, r4, r5);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
Stream& stream;
|
Stream& stream;
|
||||||
GsmClient* sockets[TINY_GSM_MUX_COUNT];
|
GsmClient* sockets[TINY_GSM_MUX_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef TinyGsm::GsmClient TinyGsmClient;
|
|
||||||
typedef TinyGsm::GsmClientSecure TinyGsmClientSecure;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,13 +11,13 @@
|
|||||||
|
|
||||||
#include <TinyGsmClientSIM800.h>
|
#include <TinyGsmClientSIM800.h>
|
||||||
|
|
||||||
class TinyGsmSim808: public TinyGsm
|
class TinyGsmSim808: public TinyGsmSim800
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsmSim808(Stream& stream)
|
TinyGsmSim808(Stream& stream)
|
||||||
: TinyGsm(stream)
|
: TinyGsmSim800(stream)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
// Select your modem:
|
// Select your modem:
|
||||||
#define TINY_GSM_MODEM_SIM800
|
#define TINY_GSM_MODEM_SIM800
|
||||||
|
// #define TINY_GSM_MODEM_SIM808
|
||||||
// #define TINY_GSM_MODEM_SIM900
|
// #define TINY_GSM_MODEM_SIM900
|
||||||
// #define TINY_GSM_MODEM_A6
|
// #define TINY_GSM_MODEM_A6
|
||||||
// #define TINY_GSM_MODEM_A7
|
// #define TINY_GSM_MODEM_A7
|
||||||
@@ -125,7 +126,14 @@ void loop() {
|
|||||||
String ussd_phone_num = modem.sendUSSD("*161#");
|
String ussd_phone_num = modem.sendUSSD("*161#");
|
||||||
DBG("Phone number (USSD):", ussd_phone_num);
|
DBG("Phone number (USSD):", ussd_phone_num);
|
||||||
|
|
||||||
#ifdef SMS_TARGET
|
#if defined(TINY_GSM_MODEM_SIM808)
|
||||||
|
modem.enableGPS();
|
||||||
|
String gps_raw = modem.getGPSraw();
|
||||||
|
modem.disableGPS();
|
||||||
|
DBG("GPS raw data:", gps_raw);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SMS_TARGET)
|
||||||
res = modem.sendSMS(SMS_TARGET, String("Hello from ") + imei);
|
res = modem.sendSMS(SMS_TARGET, String("Hello from ") + imei);
|
||||||
DBG("SMS:", res ? "OK" : "fail");
|
DBG("SMS:", res ? "OK" : "fail");
|
||||||
|
|
||||||
@@ -134,7 +142,7 @@ void loop() {
|
|||||||
DBG("UTF16 SMS:", res ? "OK" : "fail");
|
DBG("UTF16 SMS:", res ? "OK" : "fail");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CALL_TARGET
|
#if defined(CALL_TARGET)
|
||||||
DBG("Calling:", CALL_TARGET);
|
DBG("Calling:", CALL_TARGET);
|
||||||
|
|
||||||
// This is NOT supported on M590
|
// This is NOT supported on M590
|
||||||
|
|||||||
Reference in New Issue
Block a user