Browse Source

Integrate SIM808 nicely

v_master
Volodymyr Shymanskyy 7 years ago
parent
commit
144a9c371e
7 changed files with 37 additions and 24 deletions
  1. +16
    -2
      TinyGsmClient.h
  2. +0
    -2
      TinyGsmClientA6.h
  3. +0
    -2
      TinyGsmClientESP8266.h
  4. +0
    -2
      TinyGsmClientM590.h
  5. +9
    -12
      TinyGsmClientSIM800.h
  6. +2
    -2
      TinyGsmClientSIM808.h
  7. +10
    -2
      examples/AllFunctions/AllFunctions.ino

+ 16
- 2
TinyGsmClient.h View File

@ -11,14 +11,28 @@
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_SIM900)
#include <TinyGsmClientSIM800.h>
#elif defined(TINY_GSM_MODEM_SIM808)
#include <TinyGsmClientSIM808.h>
typedef TinyGsmSim800 TinyGsm;
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)
#include <TinyGsmClientA6.h>
typedef TinyGsm::GsmClient TinyGsmClient;
#elif defined(TINY_GSM_MODEM_M590)
#include <TinyGsmClientM590.h>
typedef TinyGsm::GsmClient TinyGsmClient;
#elif defined(TINY_GSM_MODEM_ESP8266)
#include <TinyGsmClientESP8266.h>
typedef TinyGsm::GsmClient TinyGsmClient;
#else
#error "Please define GSM modem model"
#endif


+ 0
- 2
TinyGsmClientA6.h View File

@ -714,6 +714,4 @@ private:
GsmClient* sockets[TINY_GSM_MUX_COUNT];
};
typedef TinyGsm::GsmClient TinyGsmClient;
#endif

+ 0
- 2
TinyGsmClientESP8266.h View File

@ -396,6 +396,4 @@ private:
GsmClient* sockets[TINY_GSM_MUX_COUNT];
};
typedef TinyGsm::GsmClient TinyGsmClient;
#endif

+ 0
- 2
TinyGsmClientM590.h View File

@ -702,6 +702,4 @@ private:
GsmClient* sockets[TINY_GSM_MUX_COUNT];
};
typedef TinyGsm::GsmClient TinyGsmClient;
#endif

+ 9
- 12
TinyGsmClientSIM800.h View File

@ -40,24 +40,24 @@ enum RegStatus {
};
class TinyGsm
class TinyGsmSim800
{
public:
class GsmClient : public Client
{
friend class TinyGsm;
friend class TinyGsmSim800;
typedef TinyGsmFifo<uint8_t, TINY_GSM_RX_BUFFER> RxFifo;
public:
GsmClient() {}
GsmClient(TinyGsm& modem, uint8_t mux = 1) {
GsmClient(TinyGsmSim800& modem, uint8_t mux = 1) {
init(&modem, mux);
}
bool init(TinyGsm* modem, uint8_t mux = 1) {
bool init(TinyGsmSim800* modem, uint8_t mux = 1) {
this->at = modem;
this->mux = mux;
sock_available = 0;
@ -171,7 +171,7 @@ public:
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
private:
TinyGsm* at;
TinyGsmSim800* at;
uint8_t mux;
uint16_t sock_available;
uint32_t prev_check;
@ -185,7 +185,7 @@ class GsmClientSecure : public GsmClient
public:
GsmClientSecure() {}
GsmClientSecure(TinyGsm& modem, uint8_t mux = 1)
GsmClientSecure(TinyGsmSim800& modem, uint8_t mux = 1)
: GsmClient(modem, mux)
{}
@ -200,7 +200,7 @@ public:
public:
TinyGsm(Stream& stream)
TinyGsmSim800(Stream& stream)
: stream(stream)
{
memset(sockets, 0, sizeof(sockets));
@ -672,7 +672,7 @@ public:
return res;
}
private:
protected:
bool modemConnect(const char* host, uint16_t port, uint8_t mux, bool ssl = false) {
sendAT(GF("+CIPSSL="), ssl);
@ -904,12 +904,9 @@ finish:
return waitResponse(1000, r1, r2, r3, r4, r5);
}
private:
protected:
Stream& stream;
GsmClient* sockets[TINY_GSM_MUX_COUNT];
};
typedef TinyGsm::GsmClient TinyGsmClient;
typedef TinyGsm::GsmClientSecure TinyGsmClientSecure;
#endif

+ 2
- 2
TinyGsmClientSIM808.h View File

@ -11,13 +11,13 @@
#include <TinyGsmClientSIM800.h>
class TinyGsmSim808: public TinyGsm
class TinyGsmSim808: public TinyGsmSim800
{
public:
TinyGsmSim808(Stream& stream)
: TinyGsm(stream)
: TinyGsmSim800(stream)
{}
/*


+ 10
- 2
examples/AllFunctions/AllFunctions.ino View File

@ -11,6 +11,7 @@
// Select your modem:
#define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7
@ -125,7 +126,14 @@ void loop() {
String ussd_phone_num = modem.sendUSSD("*161#");
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);
DBG("SMS:", res ? "OK" : "fail");
@ -134,7 +142,7 @@ void loop() {
DBG("UTF16 SMS:", res ? "OK" : "fail");
#endif
#ifdef CALL_TARGET
#if defined(CALL_TARGET)
DBG("Calling:", CALL_TARGET);
// This is NOT supported on M590


Loading…
Cancel
Save