Skip to content

Commit

Permalink
Merge pull request #26 from AlexIII/master
Browse files Browse the repository at this point in the history
crtp
  • Loading branch information
SRGDamia1 authored Jan 31, 2020
2 parents 4ad29b5 + 58b7a5a commit 7d6aba2
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 235 deletions.
11 changes: 9 additions & 2 deletions examples/AllFunctions/AllFunctions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,15 @@ void loop() {
DBG("SMS:", res ? "OK" : "fail");

// This is only supported on SIMxxx series
res = modem.sendSMS_UTF16(SMS_TARGET, u"Привіііт!", 9);
DBG("UTF16 SMS:", res ? "OK" : "fail");
res = modem.sendSMS_UTF8_begin(SMS_TARGET);
if(res) {
auto stream = modem.sendSMS_UTF8_stream();
stream.print(F("Привіііт! Print number: "));
stream.print(595);
res = modem.sendSMS_UTF8_end();
}
DBG("UTF8 SMS:", res ? "OK" : "fail");

#endif

#if TINY_GSM_TEST_CALL && defined(CALL_TARGET)
Expand Down
2 changes: 0 additions & 2 deletions src/TinyGsmClientA6.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ TINY_GSM_CLIENT_PEEK_FLUSH_CONNECTED()
memset(sockets, 0, sizeof(sockets));
}

virtual ~TinyGsmA6() {}

/*
* Basic functions
*/
Expand Down
30 changes: 1 addition & 29 deletions src/TinyGsmClientBG96.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ enum RegStatus {
};


class TinyGsmBG96
class TinyGsmBG96: public TinyGsmUTFSMS<TinyGsmBG96>
{

public:
Expand Down Expand Up @@ -146,7 +146,6 @@ TINY_GSM_CLIENT_PEEK_FLUSH_CONNECTED()
{
memset(sockets, 0, sizeof(sockets));
}
virtual ~TinyGsmBG96() {}

/*
* Basic functions
Expand Down Expand Up @@ -416,33 +415,6 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return waitResponse(60000L) == 1;
}

bool sendSMS_UTF16(const String& number, const void* text, size_t len) {
sendAT(GF("+CMGF=1"));
waitResponse();
sendAT(GF("+CSCS=\"HEX\""));
waitResponse();
sendAT(GF("+CSMP=17,167,0,8"));
waitResponse();

sendAT(GF("+CMGS=\""), number, GF("\""));
if (waitResponse(GF(">")) != 1) {
return false;
}

uint16_t* t = (uint16_t*)text;
for (size_t i=0; i<len; i++) {
uint8_t c = t[i] >> 8;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
c = t[i] & 0xFF;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
}
stream.write((char)0x1A);
stream.flush();
return waitResponse(60000L) == 1;
}


/*
* Location functions
Expand Down
2 changes: 0 additions & 2 deletions src/TinyGsmClientESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ class GsmClientSecure : public GsmClient
memset(sockets, 0, sizeof(sockets));
}

virtual ~TinyGsmESP8266() {}

/*
* Basic functions
*/
Expand Down
2 changes: 0 additions & 2 deletions src/TinyGsmClientM590.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ TINY_GSM_CLIENT_PEEK_FLUSH_CONNECTED()
memset(sockets, 0, sizeof(sockets));
}

virtual ~TinyGsmM590() {}

/*
* Basic functions
*/
Expand Down
31 changes: 1 addition & 30 deletions src/TinyGsmClientM95.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ enum RegStatus {
};


class TinyGsmM95
class TinyGsmM95: public TinyGsmUTFSMS<TinyGsmM95>
{

public:
Expand Down Expand Up @@ -143,8 +143,6 @@ TINY_GSM_CLIENT_PEEK_FLUSH_CONNECTED()
memset(sockets, 0, sizeof(sockets));
}

virtual ~TinyGsmM95() {}

/*
* Basic functions
*/
Expand Down Expand Up @@ -479,33 +477,6 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
return waitResponse(60000L) == 1;
}

bool sendSMS_UTF16(const String& number, const void* text, size_t len) {
sendAT(GF("+CMGF=1"));
waitResponse();
sendAT(GF("+CSCS=\"HEX\""));
waitResponse();
sendAT(GF("+CSMP=17,167,0,8"));
waitResponse();

sendAT(GF("+CMGS=\""), number, GF("\""));
if (waitResponse(GF(">")) != 1) {
return false;
}

uint16_t* t = (uint16_t*)text;
for (size_t i=0; i<len; i++) {
uint8_t c = t[i] >> 8;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
c = t[i] & 0xFF;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
}
stream.write((char)0x1A);
stream.flush();
return waitResponse(60000L) == 1;
}

/** Delete all SMS */
bool deleteAllSMS() {
sendAT(GF("+QMGDA=6"));
Expand Down
31 changes: 1 addition & 30 deletions src/TinyGsmClientMC60.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enum RegStatus {
};


class TinyGsmMC60
class TinyGsmMC60: public TinyGsmUTFSMS<TinyGsmMC60>
{

public:
Expand Down Expand Up @@ -147,8 +147,6 @@ TINY_GSM_CLIENT_PEEK_FLUSH_CONNECTED()
memset(sockets, 0, sizeof(sockets));
}

virtual ~TinyGsmMC60() {}

/*
* Basic functions
*/
Expand Down Expand Up @@ -460,33 +458,6 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
return waitResponse(60000L) == 1;
}

bool sendSMS_UTF16(const String& number, const void* text, size_t len) {
sendAT(GF("+CMGF=1"));
waitResponse();
sendAT(GF("+CSCS=\"HEX\""));
waitResponse();
sendAT(GF("+CSMP=17,167,0,8"));
waitResponse();

sendAT(GF("+CMGS=\""), number, GF("\""));
if (waitResponse(GF(">")) != 1) {
return false;
}

uint16_t* t = (uint16_t*)text;
for (size_t i=0; i<len; i++) {
uint8_t c = t[i] >> 8;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
c = t[i] & 0xFF;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
}
stream.write((char)0x1A);
stream.flush();
return waitResponse(60000L) == 1;
}

/** Delete all SMS */
bool deleteAllSMS() {
sendAT(GF("+QMGDA=6"));
Expand Down
34 changes: 1 addition & 33 deletions src/TinyGsmClientSIM5360.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum TinyGSMDateTimeFormat {
DATE_DATE = 2
};

class TinyGsmSim5360
class TinyGsmSim5360: public TinyGsmUTFSMS<TinyGsmSim5360>
{

public:
Expand Down Expand Up @@ -130,8 +130,6 @@ TINY_GSM_CLIENT_PEEK_FLUSH_CONNECTED()
memset(sockets, 0, sizeof(sockets));
}

virtual ~TinyGsmSim5360(){}

/*
* Basic functions
*/
Expand Down Expand Up @@ -522,36 +520,6 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return waitResponse(60000L) == 1;
}

bool sendSMS_UTF16(const String& number, const void* text, size_t len) {
// Select message format (1=text)
sendAT(GF("+CMGF=1"));
waitResponse();
// Select TE character set
sendAT(GF("+CSCS=\"HEX\""));
waitResponse();
// Set text mode parameters
sendAT(GF("+CSMP=17,167,0,8"));
waitResponse();
// Send the message
sendAT(GF("+CMGS=\""), number, GF("\""));
if (waitResponse(GF(">")) != 1) {
return false;
}

uint16_t* t = (uint16_t*)text;
for (size_t i=0; i<len; i++) {
uint8_t c = t[i] >> 8;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
c = t[i] & 0xFF;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
}
stream.write((char)0x1A);
stream.flush();
return waitResponse(60000L) == 1;
}


/*
* Location functions
Expand Down
31 changes: 1 addition & 30 deletions src/TinyGsmClientSIM7000.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum TinyGSMDateTimeFormat {
DATE_DATE = 2
};

class TinyGsmSim7000
class TinyGsmSim7000: public TinyGsmUTFSMS<TinyGsmSim7000>
{

public:
Expand Down Expand Up @@ -154,8 +154,6 @@ class GsmClientSecure : public GsmClient
memset(sockets, 0, sizeof(sockets));
}

virtual ~TinyGsmSim7000() {}

/*
* Basic functions
*/
Expand Down Expand Up @@ -564,33 +562,6 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return waitResponse(60000L) == 1;
}

bool sendSMS_UTF16(const String& number, const void* text, size_t len) {
sendAT(GF("+CMGF=1"));
waitResponse();
sendAT(GF("+CSCS=\"HEX\""));
waitResponse();
sendAT(GF("+CSMP=17,167,0,8"));
waitResponse();

sendAT(GF("+CMGS=\""), number, GF("\""));
if (waitResponse(GF(">")) != 1) {
return false;
}

uint16_t* t = (uint16_t*)text;
for (size_t i=0; i<len; i++) {
uint8_t c = t[i] >> 8;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
c = t[i] & 0xFF;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
}
stream.write((char)0x1A);
stream.flush();
return waitResponse(60000L) == 1;
}


/*
* Location functions
Expand Down
34 changes: 1 addition & 33 deletions src/TinyGsmClientSIM7600.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum TinyGSMDateTimeFormat {
DATE_DATE = 2
};

class TinyGsmSim7600
class TinyGsmSim7600: public TinyGsmUTFSMS<TinyGsmSim7600>
{

public:
Expand Down Expand Up @@ -130,8 +130,6 @@ TINY_GSM_CLIENT_PEEK_FLUSH_CONNECTED()
memset(sockets, 0, sizeof(sockets));
}

virtual ~TinyGsmSim7600(){}

/*
* Basic functions
*/
Expand Down Expand Up @@ -498,36 +496,6 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return waitResponse(60000L) == 1;
}

bool sendSMS_UTF16(const String& number, const void* text, size_t len) {
// Select message format (1=text)
sendAT(GF("+CMGF=1"));
waitResponse();
// Select TE character set
sendAT(GF("+CSCS=\"HEX\""));
waitResponse();
// Set text mode parameters
sendAT(GF("+CSMP=17,167,0,8"));
waitResponse();
// Send the message
sendAT(GF("+CMGS=\""), number, GF("\""));
if (waitResponse(GF(">")) != 1) {
return false;
}

uint16_t* t = (uint16_t*)text;
for (size_t i=0; i<len; i++) {
uint8_t c = t[i] >> 8;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
c = t[i] & 0xFF;
if (c < 0x10) { stream.print('0'); }
stream.print(c, HEX);
}
stream.write((char)0x1A);
stream.flush();
return waitResponse(60000L) == 1;
}


/*
* Location functions
Expand Down
Loading

0 comments on commit 7d6aba2

Please sign in to comment.