From a7d815242dbc653ff6327e932990b44d56eeb7fe Mon Sep 17 00:00:00 2001 From: Fabio Pintus Date: Mon, 27 Sep 2021 10:26:29 +0200 Subject: [PATCH] add SMS and socket binary data --- CHANGELOG | 29 + examples/AGNSS_example/AGNSS_example.ino | 53 +- .../Bosch_sensor_example.ino | 3 +- examples/CLIP_example/CLIP_example.ino | 131 + examples/CheckModule/CheckModule.ino | 67 +- examples/FTP_example/FTP_example.ino | 39 +- examples/GNSS_example/GNSS_example.ino | 56 +- .../LWM2M_example_2G/LWM2M_example_2G.ino | 31 +- .../LWM2M_example_4G/LWM2M_example_4G.ino | 32 +- examples/M2M_example/M2M_example.ino | 42 +- examples/ME310_AT_Test/ME310_AT_Test.ino | 135 +- examples/MQTT_example/MQTT_example.ino | 56 +- examples/Ping_example/Ping_example.ino | 36 +- examples/Socket_example/Socket_example.ino | 45 +- .../TransparentBridge/TransparentBridge.ino | 76 +- library.properties | 2 +- src/ATCommandDataParsing.cpp | 20 +- src/ATCommandDataParsing.h | 12 +- src/ME310.cpp | 2115 ++++++++++------- src/ME310.h | 65 +- src/Parser.cpp | 290 ++- src/Parser.h | 47 +- src/PathParsing.cpp | 27 + src/PathParsing.h | 2 +- 24 files changed, 2042 insertions(+), 1369 deletions(-) create mode 100644 CHANGELOG create mode 100644 examples/CLIP_example/CLIP_example.ino diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..b0944d9 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,29 @@ +ME310 0.0.0 - ????.??.?? + +ME310 2.4.0 - 2021.09.27 +* Add SMS management in AT commands +* Add binary mode improvements for sockets data + +ME310 2.3.0 - 2021.08.11 +* Added Calling Line Identification Presentation management (CLIP) + +ME310 2.2.0 - 2021.07.29 + +* URC wait method added +* Added URC management improvements in LwM2M code + +ME310 2.1.0 - 2021.07.26 + +* Added MQTT and LWM2M AT commands coverage with example sketches + +ME310 2.0.0 - 2021.05.06 + +* Added support to more AT commands and the command/online modes + +ME310 1.0.1 - 2021.03.24 + +* Improved namespace naming convention and some AT commands management + +ME310 1.0.0 - 2021.02.04 + +* Initial release \ No newline at end of file diff --git a/examples/AGNSS_example/AGNSS_example.ino b/examples/AGNSS_example/AGNSS_example.ino index 4d3f2c7..4e9166d 100644 --- a/examples/AGNSS_example/AGNSS_example.ino +++ b/examples/AGNSS_example/AGNSS_example.ino @@ -11,7 +11,10 @@ Sample test of the use of AT commands via ME310 library @details - In this example sketch, the use of methods offered by the ME310 library for using AT commands is shown. + In this example sketch, it is shown how to use AGNSS management, using ME310 library.\n + AGNSS is enable, GNSS configuration, GNSS controller power management, GNSS nmea configuration functions are shown.\n + GPS positions are acquired and response is printed. + @version 1.0.0 @@ -31,31 +34,23 @@ /*When NMEA_DEBUG is 0 Unsolicited NMEA is disable*/ #define NMEA_DEBUG 0 -using namespace me310; +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif +using namespace me310; +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ ME310 myME310; ME310::return_t rc; int count = 0; -void turnOnModule (){ - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - while(myME310.attention() == ME310::RETURN_TOUT) - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} - - void setup() { pinMode(ON_OFF, OUTPUT); pinMode(LED_BUILTIN, OUTPUT); @@ -64,7 +59,7 @@ void setup() { Serial.begin(115200); myME310.begin(115200); delay(1000); - turnOnModule(); + myME310.powerOn(ON_OFF); delay(5000); Serial.println("Telit Test AT GNSS command"); Serial.println("ME310 ON"); @@ -98,7 +93,7 @@ void setup() { if (rc == ME310::RETURN_VALID) { - myME310.module_reboot(); //issue command AT#REBOOT + myME310.module_reboot(); //issue command AT#REBOOT Serial.println(myME310.buffer_cstr(1)); } @@ -117,7 +112,7 @@ void setup() { Serial.println(ME310::return_string(rc)); if (rc == ME310::RETURN_VALID) { - myME310.module_reboot(); //issue command AT#REBOOT + myME310.module_reboot(); //issue command AT#REBOOT Serial.println(myME310.buffer_cstr(1)); } delay(5000); @@ -132,12 +127,12 @@ void setup() { Serial.println(ME310::return_string(rc)); if (rc == ME310::RETURN_VALID) { - myME310.module_reboot(); //issue command AT#REBOOT + myME310.module_reboot(); //issue command AT#REBOOT Serial.println(myME310.buffer_cstr(1)); } delay(5000); - - + + ///////////////////////////////////// // Set on/off GNSS controller // AT$GPSP= @@ -176,7 +171,7 @@ void setup() { // Set the real-time clock of the module. // AT+CCLK="05/07/21,12:40:00+00" ///////////////////////////////////// - Serial.println("Set the real-time clock of the module."); + Serial.println("Set the real-time clock of the module."); rc = myME310.clock_management("05/07/21,12:40:00+00"); Serial.println(ME310::return_string(rc)); @@ -196,7 +191,7 @@ void setup() { // Read command returns the requested and the active status for each agnss provider. // $AGNSS: ,, // Request value is 0 to disable or 1 to enable - ///////////////////////////////////// + ///////////////////////////////////// myME310.read_gnss_set_agnss_enable(); Serial.println(myME310.buffer_cstr(1)); } @@ -226,7 +221,7 @@ void loop() { int len = tmp_pos.copy(valid_pos, ((len_pos2-1)-len_pos), len_pos+1); if(len > 2) { - digitalWrite(LED_BUILTIN, HIGH); + digitalWrite(LED_BUILTIN, HIGH); delay(6000); digitalWrite(LED_BUILTIN, LOW); delay(1000); diff --git a/examples/Bosch_sensor_example/Bosch_sensor_example.ino b/examples/Bosch_sensor_example/Bosch_sensor_example.ino index 698ea7d..9a146f7 100644 --- a/examples/Bosch_sensor_example/Bosch_sensor_example.ino +++ b/examples/Bosch_sensor_example/Bosch_sensor_example.ino @@ -30,12 +30,11 @@ #include float x = 0, y = 0, z = 0; -float xACC = 0, yACC = 0, zACC = 0; +float xACC = 0, yACC = 0, zACC = 0; int16_t temperature = 0; uint8_t idDev = 0; void setup() { - Wire.begin(); Serial.begin(115200); delay(1000); diff --git a/examples/CLIP_example/CLIP_example.ino b/examples/CLIP_example/CLIP_example.ino new file mode 100644 index 0000000..fa14ec9 --- /dev/null +++ b/examples/CLIP_example/CLIP_example.ino @@ -0,0 +1,131 @@ +/*Copyright (C) 2020 Telit Communications S.p.A. Italy - All Rights Reserved.*/ +/* See LICENSE file in the project root for full license information. */ + +/** + @file + ME310.cpp + string.h + stdio.h + + @brief + Sample test of the use of AT+CLIP command via ME310 library + + @details + In this example sketch, the use of methods offered by the ME310 library for using AT commands is shown.\n + The Calling line identify is enable and wait_for_unsolicited is call in loop part. The response is printed with buffer_cstr_raw.\n + To use this example is necessary a voice variant firmware and a SIM card that supports voice. + + @version + 1.0.0 + + @note + + @author + Cristina Desogus + + @date + 11/08/2021 + */ + +#include +#include + +#define APN "APN" + +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif + +using namespace me310; +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ +ME310 myME310; +ME310::return_t rc; //Enum of return value methods + +int cID = 1; //PDP Context Identifier +char ipProt[] = "IP"; //Packet Data Protocol type +bool flag; + + +void setup() { + + pinMode(ON_OFF, OUTPUT); + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(ON_OFF, LOW); + + Serial.begin(115200); + myME310.begin(115200); + + delay(2000); + Serial.println("Telit Test AT CLIP command"); + myME310.powerOn(ON_OFF); + Serial.println("ME310 ON"); + delay(2000); + Serial.println("AT Command"); + myME310.report_mobile_equipment_error(2); //issue command AT+CMEE=2 and wait for answer or timeout + rc = myME310.read_enter_pin(); //issue command AT+cpin? in read mode, check that the SIM is inserted and the module is not waiting for the PIN + if(strcmp(myME310.buffer_cstr(2), "OK") == 0) // read response in 2 array position + { + delay(2000); + Serial.println("Define PDP Context"); + rc = myME310.define_pdp_context(cID, ipProt, APN); //issue command AT+CGDCONT=cid,PDP_type,APN + if(rc == ME310::RETURN_VALID) + { + myME310.read_define_pdp_context(); //issue command AT+CGDCONT=? (read mode) + Serial.print("pdp context read :"); + Serial.println(myME310.buffer_cstr(1)); //print second line of modem answer + + Serial.print("gprs network registration status :"); + rc = myME310.read_gprs_network_registration_status(); //issue command AT+CGREG? (read mode) + Serial.println(myME310.buffer_cstr(1)); + if(rc == ME310::RETURN_VALID) + { + while ((strcmp(myME310.buffer_cstr(1), "+CGREG: 0,1") != 0) && (strcmp(myME310.buffer_cstr(1), "+CGREG: 0,5") != 0)) + { + delay(3000); + myME310.read_gprs_network_registration_status(); + Serial.println(myME310.buffer_cstr(1)); + } + } + Serial.println("Activate context"); + myME310.context_activation(cID, 1); //issue command AT#SGACT=cid,state and wait for answer or timeout + + rc = myME310.calling_line_identification_presentation(1); //issue command AT+CLIP=enable and wait for answer or timeout + Serial.println(rc); + if(rc == ME310::RETURN_VALID) + { + Serial.println("Calling Line Identity is enable"); + flag = true; + } + else + { + Serial.println((String)"Error: " + rc + " Error string: " + myME310.buffer_cstr(2)); + flag = false; + } + } + } + else + { + Serial.println((String)"Error: " + rc + " Error string: " + myME310.buffer_cstr(2)); + } +} + +void loop() { + + if(flag) + { + myME310.wait_for_unsolicited(ME310::TOUT_5SEC); + Serial.println(myME310.buffer_cstr_raw()); + delay(1000); + } + else + { + Serial.println("Calling Line Identity is not enable"); + exit(0); + } +} diff --git a/examples/CheckModule/CheckModule.ino b/examples/CheckModule/CheckModule.ino index 04cf14b..e05359e 100644 --- a/examples/CheckModule/CheckModule.ino +++ b/examples/CheckModule/CheckModule.ino @@ -1,3 +1,30 @@ +/*Copyright (C) 2020 Telit Communications S.p.A. Italy - All Rights Reserved.*/ +/* See LICENSE file in the project root for full license information. */ + +/** + @file + ME310.cpp + string.h + stdio.h + + @brief + Sample test of the use of AT commands via ME310 library + + @details + In this example sketch, it is shown how to use a basic AT commands via ME310 library.\n + + @version + 1.0.0 + + @note + + @author + + + @date + 20/10/2020 + */ + #include /* @@ -7,36 +34,23 @@ #define PAD_MODULE_TX UART_TX_PAD_0 #define PAD_MODULE_RX SERCOM_RX_PAD_1 #define PIN_MODULE_RTS 30 - #define PIN_MODULE_CTS 31 + #define PIN_MODULE_CTS 31 + */ - #define ON_OFF 27 - - Uart SerialModule(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the right GPIO to control ON_OFF*/ +#endif - ME310 myME310 (SerialModule); - - */ using namespace me310; - +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ ME310 myME310; -void turnOnModule (){ - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - while(myME310.attention() == ME310::RETURN_TOUT) - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} - void setup() { pinMode(ON_OFF, OUTPUT); pinMode(LED_BUILTIN, OUTPUT); @@ -45,8 +59,7 @@ void setup() { myME310.begin(115200); delay(1000); - - turnOnModule; + myME310.powerOn(ON_OFF); } void loop() { diff --git a/examples/FTP_example/FTP_example.ino b/examples/FTP_example/FTP_example.ino index c27acb4..4a72910 100644 --- a/examples/FTP_example/FTP_example.ino +++ b/examples/FTP_example/FTP_example.ino @@ -11,7 +11,7 @@ Sample test of the use of AT commands via ME310 library @details - In this example sketch, the use of methods offered by the ME310 library for using AT commands is shown. + In this example sketch, it is shown how to use FTP management, using ME310 library.\n @version 1.0.0 @@ -34,29 +34,24 @@ #define FTP_USER "Username" #define FTP_PASS "Password" +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif + using namespace me310; +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ +ME310 myME310; +ME310::return_t rc; //Enum of return value methods int cID = 1; //PDP Context Identifier char ipProt[] = "IP"; //Packet Data Protocol type -ME310 myME310; -ME310::return_t rc; //Enum of return value methods -void turnOnModule (){ - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - while(myME310.attention() == ME310::RETURN_TOUT) - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} void setup() { @@ -69,7 +64,7 @@ void setup() { delay(1000); Serial.println("Telit Test AT FTP command"); - turnOnModule(); + myME310.powerOn(); Serial.println("ME310 ON"); Serial.println("AT Command"); @@ -194,7 +189,7 @@ void loop() { { Serial.println((String)"ERROR: " + myME310.return_string(rc)); } - /*rc = myME310.ftp_close(); - Serial.println("The application has ended..."); */ + rc = myME310.ftp_close(); + Serial.println("The application has ended..."); exit(0); } diff --git a/examples/GNSS_example/GNSS_example.ino b/examples/GNSS_example/GNSS_example.ino index ae3f315..859ec83 100644 --- a/examples/GNSS_example/GNSS_example.ino +++ b/examples/GNSS_example/GNSS_example.ino @@ -11,7 +11,10 @@ Sample test of the use of AT commands via ME310 library @details - In this example sketch, the use of methods offered by the ME310 library for using AT commands is shown. + In this example sketch, it is shown how to use GNSS management using ME310 library.\n + GNSS configuration, GNSS controller power management, GNSS nmea configuration functions are shown.\n + GPS positions are acquired and response is printed. + @version 1.0.0 @@ -21,7 +24,7 @@ @author Cristina Desogus - @date + @date 02/07/2021 */ @@ -31,30 +34,23 @@ /*When NMEA_DEBUG is 0 Unsolicited NMEA is disable*/ #define NMEA_DEBUG 0 -using namespace me310; +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif +using namespace me310; +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ ME310 myME310; +ME310::return_t rc; //Enum of return value methods -ME310::return_t rc; int count = 0; -void turnOnModule (){ - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - while(myME310.attention() == ME310::RETURN_TOUT) - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} - void setup() { pinMode(ON_OFF, OUTPUT); pinMode(LED_BUILTIN, OUTPUT); @@ -63,10 +59,10 @@ void setup() { Serial.begin(115200); myME310.begin(115200); delay(1000); - turnOnModule(); + myME310.powerOn(); delay(5000); - Serial.println("Telit Test AT GNSS command"); - Serial.println("ME310 ON"); + Serial.println("Telit Test AT GNSS command"); + Serial.println("ME310 ON"); Serial.println("AT Command"); ME310::return_t rc = myME310.attention(); // issue command and wait for answer or timeout Serial.println(myME310.buffer_cstr(0)); // print first line of modem answer @@ -87,10 +83,10 @@ void setup() { // 0 : priority GNSS // 1 : priority WWAN ///////////////////////////////////// - rc = myME310.gnss_configuration(0,0); + rc = myME310.gnss_configuration(0,0); if (rc == ME310::RETURN_VALID) { - myME310.module_reboot(); //issue command AT#REBOOT + myME310.module_reboot(); //issue command AT#REBOOT Serial.println(myME310.buffer_cstr(1)); } @@ -107,7 +103,7 @@ void setup() { rc = myME310.gnss_configuration(2,1); if (rc == ME310::RETURN_VALID) { - myME310.module_reboot(); //issue command AT#REBOOT + myME310.module_reboot(); //issue command AT#REBOOT Serial.println(myME310.buffer_cstr(1)); } delay(5000); @@ -121,7 +117,7 @@ void setup() { rc = myME310.gnss_configuration(3,0); if (rc == ME310::RETURN_VALID) { - myME310.module_reboot(); //issue command AT#REBOOT + myME310.module_reboot(); //issue command AT#REBOOT Serial.println(myME310.buffer_cstr(1)); } delay(5000); @@ -190,7 +186,7 @@ void loop() { digitalWrite(LED_BUILTIN, LOW); delay(1000); } - } + } } } delay(5000); @@ -221,6 +217,4 @@ void loop() { exit(0); } count++; - } - diff --git a/examples/LWM2M_example/LWM2M_example_2G/LWM2M_example_2G.ino b/examples/LWM2M_example/LWM2M_example_2G/LWM2M_example_2G.ino index e0e4ef1..21c4b99 100644 --- a/examples/LWM2M_example/LWM2M_example_2G/LWM2M_example_2G.ino +++ b/examples/LWM2M_example/LWM2M_example_2G/LWM2M_example_2G.ino @@ -43,27 +43,18 @@ bool isr = false; bool radius = false; const char *resp; - +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ ME310 myME310; -void turnOnModule () { - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - //issue command AT and wait for answer or timeout - while (myME310.attention() == ME310::RETURN_TOUT) - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} - void setup() { char pin[] = "XXXX"; @@ -83,7 +74,7 @@ void setup() { delay(10000); Serial.println("Telit Test AT LWM2M accelerometer"); - turnOnModule(); + myME310.powerOn(); Serial.println("ME310 ON"); //issue command AT+CMEE=2 and wait for answer or timeout diff --git a/examples/LWM2M_example/LWM2M_example_4G/LWM2M_example_4G.ino b/examples/LWM2M_example/LWM2M_example_4G/LWM2M_example_4G.ino index ee22bbb..66a5027 100644 --- a/examples/LWM2M_example/LWM2M_example_4G/LWM2M_example_4G.ino +++ b/examples/LWM2M_example/LWM2M_example_4G/LWM2M_example_4G.ino @@ -43,27 +43,19 @@ bool isr = false; bool radius = false; const char *resp; - +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif + +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ ME310 myME310; -void turnOnModule () { - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - //issue command AT and wait for answer or timeout - while (myME310.attention() == ME310::RETURN_TOUT) - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} - void setup() { char pin[] = "XXXX"; @@ -83,7 +75,7 @@ void setup() { delay(10000); Serial.println("Telit Test AT LWM2M accelerometer"); - turnOnModule(); + myME310.powerOn(); Serial.println("ME310 ON"); //issue command AT+CMEE=2 and wait for answer or timeout diff --git a/examples/M2M_example/M2M_example.ino b/examples/M2M_example/M2M_example.ino index ecf14f3..6cec910 100644 --- a/examples/M2M_example/M2M_example.ino +++ b/examples/M2M_example/M2M_example.ino @@ -11,7 +11,9 @@ Sample test of the use of AT commands via ME310 library @details - In this example sketch, the use of methods offered by the ME310 library for using AT commands is shown. + In this example sketch, it is shown to use M2M management, using ME310 library.\n + Check directory, create a new directory, add file in directory, get list of directory, delete files and directory functions are shown.\n + @version 1.0.0 @@ -28,30 +30,24 @@ #include #include -using namespace me310; +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif +using namespace me310; +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ ME310 myME310; -ME310::return_t rc; //Enum of return value methods +ME310::return_t rc; //Enum of return value methods + char dir[] = "/mod/dir1"; char dataStr[] = "Some data to write\nAnother row"; -void turnOnModule (){ - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - while(myME310.attention() == ME310::RETURN_TOUT) - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} - void setup() { pinMode(ON_OFF, OUTPUT); @@ -63,7 +59,7 @@ void setup() { delay(1000); Serial.println("Telit Test AT M2M command"); - turnOnModule(); + myME310.powerOn(); Serial.println("ME310 is ON"); Serial.println("AT Command"); @@ -139,12 +135,12 @@ void loop() { Serial.println("List directory content after delete dir: "); myME310.m2m_list(); Serial.println(myME310.buffer_cstr_raw()); - } + } else { Serial.println(myME310.return_string(rc)); } - } + } } Serial.println("The application has ended..."); exit(0); diff --git a/examples/ME310_AT_Test/ME310_AT_Test.ino b/examples/ME310_AT_Test/ME310_AT_Test.ino index 72c2560..e5a8095 100644 --- a/examples/ME310_AT_Test/ME310_AT_Test.ino +++ b/examples/ME310_AT_Test/ME310_AT_Test.ino @@ -28,45 +28,23 @@ #include -/* - //sercom2 - #define PIN_MODULE_RX 29 - #define PIN_MODULE_TX 28 - #define PAD_MODULE_TX UART_TX_PAD_0 - #define PAD_MODULE_RX SERCOM_RX_PAD_1 - #define PIN_MODULE_RTS 30 - #define PIN_MODULE_CTS 31 - - #define ON_OFF 27 - - Uart SerialModule(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); - - ME310 myME310 (SerialModule); - - */ +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif using namespace me310; - -ME310 myME310; +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ +ME310 myME310; +ME310::return_t rc; //Enum of return value methods void print_buffer(ME310 &aME310, const char *term = "OK"); -void turnOnModule (){ - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - while(myME310.attention() == ME310::RETURN_TOUT) - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} void setup() { pinMode(ON_OFF, OUTPUT); @@ -79,7 +57,7 @@ void setup() { Serial.println("SERCOMM Telit Test AT"); - turnOnModule(); + myME310.powerOn(); Serial.println("ME310 ON"); @@ -90,15 +68,14 @@ void setup() { Serial.print(ME310::return_string(rc)); // print return value Serial.println(" answer from ME310 MODULE"); if(rc != ME310::RETURN_VALID) // exit on error - return; - + return; Serial.println(); Serial.print("Soft Reset Command : "); rc = myME310.soft_reset (); // issue command and wait for answer or timeout Serial.println(ME310::return_string(rc)); // print return value if(rc != ME310::RETURN_VALID) // exit on error - return; + return; Serial.println(); Serial.println("Display Config Profile : "); @@ -130,7 +107,7 @@ void setup() { else Serial.println("PIN required"); } - else return; + else return; Serial.println(); Serial.print("Print ICCID : "); @@ -146,15 +123,15 @@ void setup() { } } else return; - - Serial.print("Print IMSI : "); + + Serial.print("Print IMSI : "); rc = myME310.imsi(); // no command echo if(rc == ME310::RETURN_VALID) Serial.println(myME310.buffer_cstr(1)); else return; - + Serial.println(); - Serial.println("List Capabilities : "); + Serial.println("List Capabilities : "); rc = myME310.capabilities_list(); if(rc == ME310::RETURN_VALID) // print all rows returned from ME310 except command echo (index = 0) Serial.println(myME310.buffer_cstr(1)); @@ -168,67 +145,67 @@ void setup() { Serial.println(); - Serial.print("Manufacturer Identification : "); + Serial.print("Manufacturer Identification : "); rc = myME310.manufacturer_identification(); - if(rc == ME310::RETURN_VALID) + if(rc == ME310::RETURN_VALID) Serial.println(myME310.buffer_cstr(1)); - else return; + else return; - Serial.print("Model Identification : "); + Serial.print("Model Identification : "); rc = myME310.model_identification(); - if(rc == ME310::RETURN_VALID) + if(rc == ME310::RETURN_VALID) Serial.println(myME310.buffer_cstr(1)); - else return; + else return; - Serial.print("Revision Identification : "); + Serial.print("Revision Identification : "); rc = myME310.revision_identification(); - if(rc == ME310::RETURN_VALID) + if(rc == ME310::RETURN_VALID) Serial.println(myME310.buffer_cstr(1)); - else return; + else return; - Serial.print("Serial Number : "); + Serial.print("Serial Number : "); rc = myME310.serial_number(); - if(rc == ME310::RETURN_VALID) + if(rc == ME310::RETURN_VALID) Serial.println(myME310.buffer_cstr(1)); else return; - Serial.print("Request Manufacturer Ident. : "); + Serial.print("Request Manufacturer Ident. : "); rc = myME310.request_manufacturer_identification(); - if(rc == ME310::RETURN_VALID) + if(rc == ME310::RETURN_VALID) Serial.println(myME310.buffer_cstr(1)); - else return; - - Serial.print("Request Model Ident. : "); + else return; + + Serial.print("Request Model Ident. : "); rc = myME310.request_model_identification(); - if(rc == ME310::RETURN_VALID) + if(rc == ME310::RETURN_VALID) Serial.println(myME310.buffer_cstr(1)); - else return; + else return; - Serial.print("Request Revision Ident. : "); + Serial.print("Request Revision Ident. : "); rc = myME310.request_revision_identification(); - if(rc == ME310::RETURN_VALID) + if(rc == ME310::RETURN_VALID) Serial.println(myME310.buffer_cstr(1)); - else return; + else return; - Serial.print("Product Serial Number : "); + Serial.print("Product Serial Number : "); rc = myME310.request_psn_identification(); - if(rc == ME310::RETURN_VALID) + if(rc == ME310::RETURN_VALID) Serial.println(myME310.buffer_cstr(1)); - else return; - - Serial.print("Product Code : "); + else return; + + Serial.print("Product Code : "); rc = myME310.request_product_code(); - if(rc == ME310::RETURN_VALID) + if(rc == ME310::RETURN_VALID) Serial.println(myME310.buffer_cstr(1)); - else return; - - Serial.println(); - Serial.println("Software Package Version : "); + else return; + + Serial.println(); + Serial.println("Software Package Version : "); rc = myME310.request_software_package_version(); - if(rc == ME310::RETURN_VALID) + if(rc == ME310::RETURN_VALID) print_buffer(myME310); - else return; - + else return; + } void loop() { @@ -254,9 +231,9 @@ void print_buffer(ME310 &aME310, const char *term) if(term) { if(strcmp(tmp,term)) - Serial.println(tmp); // print if not null + Serial.println(tmp); // print if not null else - break; + break; } } else break; // exit loop if null diff --git a/examples/MQTT_example/MQTT_example.ino b/examples/MQTT_example/MQTT_example.ino index a1e3b26..c1eb58c 100644 --- a/examples/MQTT_example/MQTT_example.ino +++ b/examples/MQTT_example/MQTT_example.ino @@ -11,7 +11,10 @@ Sample test of the use of AT commands via ME310 library @details - In this example sketch, the use of methods offered by the ME310 library for using AT commands is shown. + In this example sketch, it is shown how to use MQTT management, using ME310 library.\n + MQTT enable, MQTT configuration, MQTT connect, MQTT topic subscribe, MQTT publish, MQTT read + and MQTT disconnect methods are used and responses are printed.\ + @version 1.0.0 @@ -29,41 +32,34 @@ #include #include -using namespace me310; - - -#define APN "\"web.omnitel.it\"" +#define APN "\"APN\"" #define HOSTNAME "api-dev.devicewise.com" #define PORT 1883 -#define CLIENT_ID "test_m2mb_mqtt_id" -#define CLIENT_USERNAME "test_m2mb_mqtt" -#define CLIENT_PASSWORD "q3XYKetChZRdGuKF" +#define CLIENT_ID "CLIENTID" +#define CLIENT_USERNAME "CLIENTUSERNAME" +#define CLIENT_PASSWORD "PASSWORD" + +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif + +using namespace me310; +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ +ME310 myME310; +ME310::return_t rc; //Enum of return value methods int cID = 1; //PDP Context Identifier char ipProt[]= "IP"; //Packet Data Protocol type -ME310 myME310; -ME310::return_t rc; //Enum of return value methods int count = 0; -void turnOnModule (){ - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - while(myME310.attention() == ME310::RETURN_TOUT) - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} - void setup() { pinMode(ON_OFF, OUTPUT); @@ -75,7 +71,7 @@ void setup() { delay(1000); - turnOnModule(); + myME310.powerOn(); Serial.println("Telit Test AT MQTT command"); Serial.println("ME310 ON"); Serial.println("AT Command"); @@ -163,7 +159,7 @@ void setup() { // // AT#MQPUBS=instance_number, topic, retain, qos, message //////////////////////////////////// - + myME310.mqtt_publish(1, "topic", 1, 0, "message"); //issue command AT#MQPUBS=instance_number, topic, retain, qos, message and wait for answer or timeout Serial.println(myME310.buffer_cstr(1)); @@ -186,7 +182,7 @@ void loop(){ //////////////////////////////////// myME310.read_mqtt_read(); //issue command AT#MQREAD? and wait for answer or timeout Serial.println(myME310.buffer_cstr(1)); - + ///////////////////////////////////// // COMMAND TO READ A MESSAGE // diff --git a/examples/Ping_example/Ping_example.ino b/examples/Ping_example/Ping_example.ino index 791d64b..18cb928 100644 --- a/examples/Ping_example/Ping_example.ino +++ b/examples/Ping_example/Ping_example.ino @@ -29,30 +29,24 @@ #include #include -using namespace me310; - #define APN "apn" -char server[] = "8.8.8.8"; +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif +using namespace me310; +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ ME310 myME310; +ME310::return_t rc; //Enum of return value methods -void turnOnModule (){ - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - while(myME310.attention() == ME310::RETURN_TOUT) - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} +char server[] = "8.8.8.8"; void setup() { @@ -70,7 +64,7 @@ void setup() { delay(1000); Serial.println("Telit Test AT command Ping"); - turnOnModule(); + myME310.powerOn(); Serial.println("ME310 is ON"); myME310.report_mobile_equipment_error(2); //issue command AT+CMEE=2 and wait for answer or timeout @@ -94,7 +88,7 @@ void setup() { Serial.println(myME310.buffer_cstr(1)); } } - Serial.println("Activate context"); + Serial.println("Activate context"); myME310.context_activation(cID, 1); //issue command AT#SGACT=cid,state and wait for answer or timeout } } diff --git a/examples/Socket_example/Socket_example.ino b/examples/Socket_example/Socket_example.ino index a941526..ce74774 100644 --- a/examples/Socket_example/Socket_example.ino +++ b/examples/Socket_example/Socket_example.ino @@ -28,7 +28,22 @@ //#include #define APN "apn" + +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif + using namespace me310; +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ +ME310 myME310; +ME310::return_t rc; //Enum of return value methods + int cID = 1; //PDP Context Identifier int connID = 1; //Socket connection identifier. char ipProt[] = "IP"; //Packet Data Protocol type @@ -36,26 +51,6 @@ char ipProt[] = "IP"; //Packet Data Protocol type char server[] = "modules.telit.com"; //echo server int port = 10510; -ME310 myME310; - -void turnOnModule (){ - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - while(myME310.attention() == ME310::RETURN_TOUT) //issue command AT and wait for answer or timeout - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} - - void setup() { int rc; @@ -68,11 +63,11 @@ void setup() { myME310.begin(115200); delay(3000); - myME310.module_reboot(); // issue command at#reboot + myME310.module_reboot(); // issue command at#reboot delay(10000); Serial.println("Telit Test AT Socket command"); - turnOnModule(); + myME310.powerOn(); Serial.println("ME310 ON"); myME310.report_mobile_equipment_error(2); //issue command AT+CMEE=2 and wait for answer or timeout @@ -99,7 +94,7 @@ void setup() { Serial.println(myME310.buffer_cstr(1)); } } - Serial.println("Activate context"); + Serial.println("Activate context"); myME310.context_activation(cID, 1); //issue command AT#SGACT=cid,state and wait for answer or timeout } } @@ -140,7 +135,7 @@ void loop() { delay(5000); if(r == ME310::RETURN_VALID) { - Serial.print("READ: "); + Serial.print("READ: "); r = myME310.socket_receive_data_command_mode(connID, (int) sizeof(data), 0, ME310::TOUT_10SEC); //issue command AT#SRECV=connID,size and wait for answer or timeout Serial.println(myME310.return_string(r)); if(r == ME310::RETURN_VALID) @@ -159,7 +154,7 @@ void loop() { { Serial.println(myME310.return_string(r)); } - } + } } else { diff --git a/examples/TransparentBridge/TransparentBridge.ino b/examples/TransparentBridge/TransparentBridge.ino index 991b2b3..b4a2959 100644 --- a/examples/TransparentBridge/TransparentBridge.ino +++ b/examples/TransparentBridge/TransparentBridge.ino @@ -1,42 +1,48 @@ -#include +/*Copyright (C) 2020 Telit Communications S.p.A. Italy - All Rights Reserved.*/ +/* See LICENSE file in the project root for full license information. */ + +/** + @file + ME310.cpp + string.h + stdio.h + + @brief + Driver Library for ME310 Telit Modem + + @details + The library contains a single class that implements a C++ interface to all ME310 AT Commands. + It makes it easy to build Arduino applications that use the full power of ME310 module -/* - //sercom2 - #define PIN_MODULE_RX 29 - #define PIN_MODULE_TX 28 - #define PAD_MODULE_TX UART_TX_PAD_0 - #define PAD_MODULE_RX SERCOM_RX_PAD_1 - #define PIN_MODULE_RTS 30 - #define PIN_MODULE_CTS 31 + @version + 1.0.0 + + @note - #define ON_OFF 27 - - Uart SerialModule(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + @author + Cristina Desogus - ME310 myME310 (SerialModule); - + @date + 28/10/2020 */ +#include + +#ifndef ARDUINO_TELIT_SAMD_CHARLIE +#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/ +#endif + using namespace me310; - -ME310 myME310; +/* + * If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n + * Please refer to your board configuration in variant.h file. + * Example: + * Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS); + * ME310 myME310 (Serial1); + */ +ME310 myME310; +ME310::return_t rc; //Enum of return value methods -void turnOnModule (){ - digitalWrite(LED_BUILTIN, HIGH); - delay(200); - digitalWrite(LED_BUILTIN, LOW); - delay(500); - - while(myME310.attention() == ME310::RETURN_TOUT) - { - digitalWrite(ON_OFF, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(6000); - digitalWrite(ON_OFF, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); - } -} void setup() { pinMode(ON_OFF, OUTPUT); @@ -46,12 +52,12 @@ void setup() { Serial.begin(115200); myME310.begin(115200); delay(1000); - + Serial.println("TURN ON ME310"); - turnOnModule(); + myME310.powerOn(); Serial.println("ME310 TURNED ON"); Serial.println("Bridge Communication Enabled"); - + } void loop() { diff --git a/library.properties b/library.properties index b5d0e3f..e306a9b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ME310G1 -version=2.2.1 +version=2.4.0 author=Telit maintainer=Telit sentence=Allows communication with ME310G1 Telit module. diff --git a/src/ATCommandDataParsing.cpp b/src/ATCommandDataParsing.cpp index ac6c6cb..ebb094a 100644 --- a/src/ATCommandDataParsing.cpp +++ b/src/ATCommandDataParsing.cpp @@ -12,8 +12,8 @@ The class implements the data parsing function for AT command which need specific response.\n It is possible obtain data payload - @version - 1.0.0 + @version + 1.1.0 @note Dependencies: @@ -21,7 +21,6 @@ Parser.h @author - @date 02/23/2021 @@ -38,9 +37,9 @@ using namespace telitAT; /*! * \param str string to parse */ -ATCommandDataParsing::ATCommandDataParsing(char* aCommand, char* str, int flag) +ATCommandDataParsing::ATCommandDataParsing(const char* aCommand, const char* str, int flag, uint32_t option) { - _str = str; + _str = (char* )str; char* cmd; cmd = findCommand(aCommand); if(cmd == NULL && flag == -1) @@ -57,7 +56,7 @@ ATCommandDataParsing::ATCommandDataParsing(char* aCommand, char* str, int flag) { if(strcmp(cmd, "AT#SRECV") == 0) { - _parser = new SRECVParser(); + _parser = new SRECVParser(option); } else if(strcmp(cmd, "AT#FTPRECV") == 0) { @@ -71,6 +70,10 @@ ATCommandDataParsing::ATCommandDataParsing(char* aCommand, char* str, int flag) { _parser = new PingParser(); } + else if(strcmp(cmd, "AT+CMGL") == 0) + { + _parser = new SMSListParser(); + } else { _parser = new GenericParser(); @@ -176,7 +179,7 @@ int ATCommandDataParsing::startPositionPayloadOffset() Searches the string of command * \return command string if the format of string is right otherwise return null. */ -char* ATCommandDataParsing::findCommand(char* aCommand) +char* ATCommandDataParsing::findCommand(const char* aCommand) { string tmp_str; tmp_str = aCommand; @@ -201,6 +204,5 @@ char* ATCommandDataParsing::findCommand(char* aCommand) */ ATCommandDataParsing::~ATCommandDataParsing() { - delete _parser; - delete _str; + delete (_parser); } \ No newline at end of file diff --git a/src/ATCommandDataParsing.h b/src/ATCommandDataParsing.h index 4232b7d..07bc3bd 100644 --- a/src/ATCommandDataParsing.h +++ b/src/ATCommandDataParsing.h @@ -11,8 +11,8 @@ The class implements the data parsing function for AT command which need specific response.\n It is possible obtain data payload, receivedBytes - @version - 1.0.0 + @version + 1.2.0 @note Dependencies: @@ -47,7 +47,7 @@ class ATCommandDataParsing { public: - ATCommandDataParsing(char* aCommand, char* str, int flag); + ATCommandDataParsing(const char* aCommand, const char* str, int flag, uint32_t option = 0); uint8_t * extractedPayload(); int receivedBytes(); bool commandResponseResult(); @@ -57,14 +57,14 @@ class ATCommandDataParsing ~ATCommandDataParsing(); private: - - char* findCommand(char* aCommand); + + char* findCommand(const char* aCommand); private: int _exBytes; //!< Expected bytes int _recvBytes; //!< Received bytes - char *_str; //!< Pointer to string + string _str; char _command[64]; //!< Array to command string Parser *_parser; //!< Pointer to class parser }; diff --git a/src/ME310.cpp b/src/ME310.cpp index bdcedb5..f5ccca1 100644 --- a/src/ME310.cpp +++ b/src/ME310.cpp @@ -7,6 +7,7 @@ string.h stdio.h ATCommandDataParsing.h + PathParsing.h @brief Driver Library for ME310 Telit Modem @@ -15,9 +16,9 @@ The library contains a single class that implements a C++ interface to all ME310 AT Commands. It makes it easy to build Arduino applications that use the full power of ME310 module - @version - 2.2.1 - + @version + 2.4.0 + @note @author @@ -25,7 +26,7 @@ @date 28/10/2020 */ - + #include "ME310.h" #include #include @@ -33,36 +34,33 @@ #include #include - using namespace telitAT; using namespace me310; -using namespace std; +using namespace std; const char ME310::CTRZ[1] = {0x1A}; ///< String for Termination Ctrl-z const char *ME310::OK_STRING = "OK"; ///< String for OK modem answer const char *ME310::ERROR_STRING = "ERROR"; ///< String for ERROR modem answer const char *ME310::CONNECT_STRING = "CONNECT"; ///< String for CONNECT modem answer const char *ME310::CME_ERROR_STRING = "+CME ERROR: "; ///< String for +CME ERROR modem answer -const char *ME310::SEQUENCE_STRING = ">>> "; ///< Sequence string -const char *ME310::WAIT_DATA_STRING = "> "; ///< Wait Data string +const char *ME310::SEQUENCE_STRING = ">>> "; ///< Sequence string +const char *ME310::WAIT_DATA_STRING = "> "; ///< Wait Data string const char *ME310::TERMINATION_STRING = ""; ///< Termination character const char *ME310::NO_CARRIER_STRING = "NO CARRIER"; ///< String for NO CARRIER modem answer - //! \brief Class Constructor /*! * \param aSerial Uart object for serial communication - */ + */ ME310::ME310(Uart &aSerial): mSerial(aSerial) {} //! \brief Class Destructor /*! - */ + */ ME310::~ME310() { - delete mpBuffer; - delete _payloadData; + mSerial.end(); } /*! \brief Begin method @@ -70,18 +68,77 @@ ME310::~ME310() */ void ME310::begin(unsigned long baudRate) { + mBaudrate = baudRate; mSerial.begin(baudRate); } +/*! \brief End method +/*! \details +This method calls the end of the Serial. +*/ +void ME310::end() +{ + mSerial.end(); +} + +/*! \brief Power ON module +/*! \details +This method makes the Power ON of the module + * \param onoff_gpio GPIO to control ON/OFF +*/ +void ME310::powerOn(unsigned int onoff_gpio) +{ + bool is_ready = false; + digitalWrite(LED_BUILTIN, HIGH); + delay(200); + digitalWrite(LED_BUILTIN, LOW); + delay(500); + char mybuffer[100]; + while(!is_ready) + { + if(attention() == ME310::RETURN_TOUT) + { + delay(1000); + } + else + { + is_ready = true; + break; + } + mSerial.end(); + digitalWrite(onoff_gpio, HIGH); + digitalWrite(LED_BUILTIN, HIGH); + delay(6000); + digitalWrite(onoff_gpio, LOW); + digitalWrite(LED_BUILTIN, LOW); + delay(1000); + begin(mBaudrate); + for(int i = 0; i < 5; i++) + { + if(attention() == ME310::RETURN_TOUT) + { + delay(1000); + } + else + { + is_ready = true; + break; + } + } + /*Read any remaining bytes from the uart buffer to get rid of any pending response*/ + mSerial.readBytes(mybuffer, 100); + } +} + // Command Line Prefixes ------------------------------------------------------- //! \brief Implements the AT command and waits for OK answer /*! * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::attention(tout_t aTimeout) -{ - return send_wait(F("AT"),OK_STRING,aTimeout); + */ +ME310::return_t ME310::attention(tout_t aTimeout) +{ + return send_wait(F("AT"),OK_STRING,aTimeout); } //! \brief Implements the A/ command and waits for OK answer @@ -89,9 +146,9 @@ ME310::return_t ME310::attention(tout_t aTimeout) The command immediately executes the previously issued command or commands. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::repeat_last_auto(tout_t aTimeout) -{ +{ return send_wait(F("A/"),OK_STRING,aTimeout); } @@ -100,9 +157,9 @@ ME310::return_t ME310::repeat_last_auto(tout_t aTimeout) The command immediately executes the previously issued command or commands. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::repeat_last(tout_t aTimeout) -{ +{ return send_wait(F("AT#/"),OK_STRING,aTimeout); } @@ -113,10 +170,10 @@ This command sets the AT command interface style. * \param value interface value * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::select_interface_style(int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SELINT=%d"), value); return send_wait((char*)mBuffer,OK_STRING,aTimeout); } @@ -127,10 +184,10 @@ Set configuration parameters to default values. * \param value configuration value * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::set_factory_config (int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT&F%d"), value); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -141,10 +198,10 @@ Soft Reset * \param value reset type * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::soft_reset (int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATZ%d"), value); return send_wait((char*)mBuffer,OK_STRING,aTimeout); } @@ -155,10 +212,10 @@ Basic profile on startup. * \param value profile index * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::default_reset_basic_profile_designation (int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT&Y=%d"), value); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -169,10 +226,10 @@ Define which full profile is loaded at startup. * \param value profile index * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::default_reset_full_profile_designation (int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT&P%d"), value); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -183,10 +240,10 @@ Execution command stores on profile the complete configuration of the device * \param value profile identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::store_current_configuration (int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT&W%d"), value); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -197,10 +254,10 @@ The command displays telephone numbers stored in the internal phonebook. * \param value phonebook record number * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::display_internal_phonebook_number (int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT&N%d"), value); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -212,10 +269,10 @@ AT&W and selected with AT&P. * \param value Parameter to select the user profile * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::extended_reset (int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#Z%d"), value); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -225,9 +282,9 @@ ME310::return_t ME310::extended_reset (int value, tout_t aTimeout) The command displays some of the basic modem configuration settings and parameters * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::display_config_profile(tout_t aTimeout) -{ +{ return send_wait(F("AT&V"), OK_STRING, aTimeout); } @@ -237,7 +294,7 @@ Set command allows to select the installation country code according to ITU-T35 * \param value installation country code * \param aTimeout timeout in ms * \return return code - */ + */ /*ME310::return_t ME310::country_installation (int value,ME310::tout_t aTimeout) { snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGI=%d"), value); @@ -249,97 +306,97 @@ Set command allows to select the installation country code according to ITU-T35 This command returns the equipment supported command set list. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::capabilities_list(tout_t aTimeout) -{ +{ return send_wait(F("AT+GCAP"), OK_STRING, aTimeout); } - + //! \brief Implements the AT+GMI command and waits for OK answer /*! \details This command returns the manufacturer identification. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::manufacturer_identification(tout_t aTimeout) -{ +{ return send_wait(F("AT+GMI"), OK_STRING, aTimeout); } - + //! \brief Implements the AT+GMM command and waits for OK answer /*! \details The command returns the model identification. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::model_identification(tout_t aTimeout) -{ +{ return send_wait(F("AT+GMM"), OK_STRING, aTimeout); } - + //! \brief Implements the AT+GMR command and waits for OK answer /*! \details The command returns the software revision identification. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::revision_identification(tout_t aTimeout) -{ +{ return send_wait(F("AT+GMR"), OK_STRING, aTimeout); } - + //! \brief Implements the AT+GSN command and waits for OK answer /*! \details The command reports the device board serial number. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::serial_number(tout_t aTimeout) -{ +{ return send_wait(F("AT+GSN"), OK_STRING, aTimeout); } - + //! \brief Implements the AT+CGMI command and waits for OK answer /*! \details The command returns device manufacturer identification code . * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::request_manufacturer_identification(tout_t aTimeout) -{ +{ return send_wait(F("AT+CGMI"),OK_STRING,aTimeout); } - + //! \brief Implements the AT+CGMM command and waits for OK answer /*! \details This command returns the device model identification. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::request_model_identification(tout_t aTimeout) -{ +{ return send_wait(F("AT+CGMM"),OK_STRING,aTimeout); } - + //! \brief Implements the AT+CGMR command and waits for OK answer /*! \details The command returns device software revision number. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::request_revision_identification(tout_t aTimeout) -{ +{ return send_wait(F("AT+CGMR"),OK_STRING,aTimeout); } - + //! \brief Implements the AT+CGSN command and waits for OK answer /*! \details This command allows to retrieve the product serial number in form of IMEI of the mobile. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::request_psn_identification(tout_t aTimeout) -{ +{ return send_wait(F("AT+CGSN"),OK_STRING,aTimeout); } @@ -348,32 +405,32 @@ ME310::return_t ME310::request_psn_identification(tout_t aTimeout) The command returns device manufacturer identification code. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::request_manufacturer_identification_echo(tout_t aTimeout) -{ +{ return send_wait(F("AT#CGMI"),OK_STRING,aTimeout); } - + //! \brief Implements the AT\#CGMR command and waits for OK answer /*! \details The command returns device software revision number. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::request_revision_identification_echo(tout_t aTimeout) -{ +{ return send_wait(F("AT#CGMR"),OK_STRING,aTimeout); } - + //! \brief Implements the AT\#CGSN command and waits for OK answer /*! \details The execution command returns the product serial number, in form of IMEI of the mobile, with #CGSN: command echo. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::request_psn_identification_echo(tout_t aTimeout) -{ +{ return send_wait(F("AT#CGSN"),OK_STRING,aTimeout); } @@ -382,31 +439,31 @@ ME310::return_t ME310::request_psn_identification_echo(tout_t aTimeout) Execution command returns the device product code without #CGMF: command echo. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::request_product_code(tout_t aTimeout) -{ +{ return send_wait(F("AT#CGMF"),OK_STRING,aTimeout); } - + //! \brief Implements the AT\#SWPKGV command and waits for OK answer /*! \details This command allows to retrieve the software package version. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::request_software_package_version(tout_t aTimeout) -{ +{ return send_wait(F("AT#SWPKGV"),OK_STRING,aTimeout); } - + //! \brief Implements the AT+CPAS command and waits for OK answer /*! \details Execution command reports the device status in the form shown in Additional info section. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phone_activity_status(tout_t aTimeout) -{ +{ return send_wait(F("AT+CPAS"),OK_STRING,aTimeout); } @@ -417,10 +474,10 @@ This command selects the level of functionality in the ME. * \param rst reset flag * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::set_phone_functionality(int fun ,int rst, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CFUN=%d,%d"), fun, rst); return send_wait((char*)mBuffer,OK_STRING,aTimeout); } @@ -435,10 +492,10 @@ This command configures sending of unsolicited result codes from TA to TE. * \param bfr TA buffer clearing * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mobile_equipment_event_reporting(int mode, int keyp, int disp, int ind, int bfr, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMER=%d,%d,%d,%d,%d"), mode, keyp, disp, ind, bfr); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -451,10 +508,10 @@ Command to set voice mail server number. * \param type string type phone number of format specified by * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::set_voice_mail_number(int mode, const char *number, int type, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSVM=%d,\"%s\",%d"), mode, number, type); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -469,10 +526,10 @@ This command returns the mailbox numbers stored on SIM. * \param mboxtype the message waiting group type of the mailbox, if available * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mailbox_numbers(int index, const char *number, int type, const char *text, const char *mboxtype, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MBN=%d,\"%s\",%d,\"%s\",\"%s\""), index, number, type, text, mboxtype); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -483,10 +540,10 @@ This command enables/disables the presentation of the Message Waiting Indicator * \param enable enables/disables the presentation of the #MWI: URC * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::message_waiting_indication(int enable, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MWI=%d"), enable); return send_wait((char*)mBuffer,OK_STRING,aTimeout); } @@ -496,9 +553,9 @@ ME310::return_t ME310::message_waiting_indication(int enable, tout_t aTimeout) This command shows the available AT commands list. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::available_at_commands(tout_t aTimeout) -{ +{ return send_wait(F("AT+CLAC"),OK_STRING,aTimeout); } @@ -508,10 +565,10 @@ Set command selects the currently used language for displaying different message * \param lan Selected language * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::select_language(const char *lan, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#LANG=\"%s\""), lan); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -522,10 +579,10 @@ The command enables the use of result code. * \param n enables/disables +CME ERROR: result code and selects the format * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::report_mobile_equipment_error(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMEE=%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -535,9 +592,9 @@ ME310::return_t ME310::report_mobile_equipment_error(int n, tout_t aTimeout) The command is related to extended numeric error report. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::extended_numeric_error_report(tout_t aTimeout) -{ +{ return send_wait(F("AT#CEER"),OK_STRING,aTimeout); } @@ -548,10 +605,10 @@ power saving mode. * \param n disables, enables/sets duration of the generated pulse * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::power_saving_mode_ring_indicator(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#PSMRI=%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -562,10 +619,10 @@ The command purpose is to set different character sets that are used by the devi * \param chset character set to be used by the device. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::select_te_character_set(const char* chset, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSCS=%s"), chset); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -584,10 +641,10 @@ This command is used to enable/disable the multiplexing protocol control channel * \param k window size * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::multiplexing_mode(int mode, int subset, int port_speed, int n1, int t1, int n2, int t2, int t3, int k, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMUX=%d,%d,%d,%d,%d,%d,%d,%d,%d"), mode, subset, port_speed, n1, t1, n2, t2, t3, k); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -598,10 +655,10 @@ This command sets USB configuration on the modem device. * \param mode USB configuration mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::usb_configuration(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#USBCFG=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -613,10 +670,10 @@ ports. * \param variant set port configuration * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::connect_physycal_port_sap(int variant, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#PORTCFG=%d"), variant); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -627,10 +684,10 @@ Set command sets a delay in second for the execution of successive AT command. * \param delay delay interval in 100 ms intervals * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::at_command_delay(int delay, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#ATDELAY=%d"), delay); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -642,10 +699,10 @@ The command stores a telephone number in the internal phonebook. * \param nr telephone number (maximum length 24 digits) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::store_telephone_number(int n, const char *nr, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT&Z%d=\"%s\""), n, nr); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -655,7 +712,7 @@ ME310::return_t ME310::store_telephone_number(int n, const char *nr, tout_t aTim The command displays last connection statistics. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::display_last_connection_statistics(tout_t aTimeout) { return send_wait(F("AT&V2"), OK_STRING, aTimeout); @@ -667,8 +724,8 @@ Execution command returns the International Mobile Station Equipment Identity an (IMEISV) of the module without +IMEISV: command echo. * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::request_imei_software_version(tout_t aTimeout) + */ +ME310::return_t ME310::request_imei_software_version(tout_t aTimeout) { return send_wait(F("AT+IMEISV"), OK_STRING, aTimeout); } @@ -678,7 +735,7 @@ ME310::return_t ME310::request_imei_software_version(tout_t aTimeout) This command returns the device model identification. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::request_model_identification_echo(tout_t aTimeout) { return send_wait(F("AT#CGMM"), OK_STRING, aTimeout); @@ -689,7 +746,7 @@ ME310::return_t ME310::request_model_identification_echo(tout_t aTimeout) The command displays current modem configuration and profile. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::display_current_configuration_profile(tout_t aTimeout) { return send_wait(F("AT&V0"), OK_STRING, aTimeout); @@ -703,10 +760,10 @@ images. * \param storage_conf selects storage type * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::set_active_firmware_image(int image_number, int storage_conf, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FWSWITCH=%d,%d"), image_number, storage_conf); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -718,10 +775,10 @@ command and appropriated context will be opened for IMS. * \param pdpApnName from 1 to 32 symbols ANSI fixed string. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ims_pdp_apn_number_set(const char* pdpApnName, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#IMSPDPSET=%s"), pdpApnName); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -731,8 +788,8 @@ ME310::return_t ME310::ims_pdp_apn_number_set(const char* pdpApnName, tout_t aTi The command returns Telit ID and version number. * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::request_telit_id(tout_t aTimeout) + */ +ME310::return_t ME310::request_telit_id(tout_t aTimeout) { return send_wait(F("AT#TID"), OK_STRING, aTimeout); } @@ -745,10 +802,10 @@ The command controls the automatic answering feature of the DCE. * \param n number of rings * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::number_rings_auto_answer(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATS0=%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -759,7 +816,7 @@ S1 is incremented each time the device detects the ring signal of an incoming ca ring occur. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ring_counter(tout_t aTimeout) { return send_wait(F("ATS1"), OK_STRING, aTimeout); @@ -771,10 +828,10 @@ The command manages the ASCII character used as escape character. * \param chr escape character decimal ASCII * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::escape_character(int chr, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATS2=%d"), chr); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -785,10 +842,10 @@ The command manages the character configured as command line terminator. * \param chr command line termination character (decimal ASCII) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::command_line_terminator_character(int chr, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATS3=%d"), chr); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -800,10 +857,10 @@ result codes and information text. * \param chr response formatting character (decimal ASCII) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::response_formatting_character(int chr, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATS4=%d"), chr); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -815,10 +872,10 @@ command line the immediately preceding character. * \param chr command line editing character (decimal ASCII) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::command_line_editing_character(int chr, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATS5=%d"), chr); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -832,10 +889,10 @@ time, the DCE disconnects from the line and returns a result code indicating the * \param tout defines time interval expressed in seconds * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::connection_completed_timeout(int tout, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATS7=%d"), tout); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -846,10 +903,10 @@ The command manages the prompt delay between two different escape characters. * \param time delay expressed in fiftieth of a second * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::escaper_prompt_delay(int time, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATS12=%d"), time); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -860,10 +917,10 @@ The command manages the amount of time that the device will ignore the DTR. * \param time expressed in hundredths of a second * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::delay_dtr_off(int time, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATS25=%d"), time); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -873,22 +930,22 @@ ME310::return_t ME310::delay_dtr_off(int time, tout_t aTimeout) The command displays the S registers values. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::s_registers_display(tout_t aTimeout) { return send_wait(F("ATS&V1"), OK_STRING, aTimeout); } - + //! \brief Implements the ATS10 command and waits for OK answer /*! \details The command is available only for backward compatibility * \param n dummy * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::carrier_off_firm_time(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATS10=%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -898,7 +955,7 @@ ME310::return_t ME310::carrier_off_firm_time(int n, tout_t aTimeout) The command displays the extended S registers values. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::extended_s_registers_display(tout_t aTimeout) { return send_wait(F("ATS&V3"), OK_STRING, aTimeout); @@ -912,10 +969,10 @@ This command allows to enable or disable the command echo. * \param n Configuration value * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::command_echo(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATE%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -926,10 +983,10 @@ This command allows to enable or disable the result code. * \param n enables/disables result codes * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::quiet_result_codes(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATQ%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -941,10 +998,10 @@ responses. It also determines if result codes are transmitted in a numeric form * \param n format of information responses and result codes. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::response_format(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATV%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -955,10 +1012,10 @@ This command returns identification information. * \param n information request * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::identification_information(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATI%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -969,10 +1026,10 @@ This set command controls the DCD output behavior of the AT commands serial port * \param n DCD output behavior * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::data_carrier_detect_control(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT&C%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -983,10 +1040,10 @@ This set command configures the behavior of the module according to the DTR cont * \param n defines the module behavior according to the DTR control line transitions * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::data_terminal_ready_control(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT&D%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -997,10 +1054,10 @@ Flow Control settings. * \param n flow control behavior * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::flow_control(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT&K%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1011,10 +1068,10 @@ Set DSR pin behavior. * \param n Configuration parameter * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::data_set_ready_control(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT&S%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1025,10 +1082,10 @@ The command sets the speed of the USIF0 serial port, see document [1]. * \param rate speed of the serial USIF0 port expressed in bit per second. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::uart_dce_interface_speed(int rate, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+IPR=%d"), rate); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1040,10 +1097,10 @@ This set command selects the flow control of the serial port in both directions. * \param byDCE specifies the method used by the device (DCE) to control the flow of data received from the DTE * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::dte_modem_local_control_flow(int byDTE, int byDCE, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+IFC=%d,%d"), byDTE, byDCE); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1055,10 +1112,10 @@ This set command selects the flow control of the serial port in both directions. * \param parity setting this sub parameter has no meaning * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::dte_modem_character_framing(int format, int parity, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+ICF=%d,%d"), format, parity); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1069,10 +1126,10 @@ This command enables/disables skipping the escape sequence. * \param mode enable/disable skipping the escape sequence (+++) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::skip_escape_sequence(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SKIPESC=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1084,10 +1141,10 @@ and return to on-line command mode. * \param gt sets a guard time in seconds * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::escape_sequence_guard_time(int gt, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#E2ESC=%d"), gt); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1099,10 +1156,10 @@ commands execution. * \param n configuration value * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::extended_result_codes(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("ATX=%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1113,8 +1170,8 @@ ME310::return_t ME310::extended_result_codes(int n, tout_t aTimeout) This command establishes a GPRS communication between the TE and the external PDN. * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::dialup_connection(tout_t aTimeout) + */ +ME310::return_t ME310::dialup_connection(tout_t aTimeout) { return send_wait(F("ATD"), NO_CARRIER_STRING, aTimeout); } @@ -1124,8 +1181,8 @@ ME310::return_t ME310::dialup_connection(tout_t aTimeout) This execution command hangs up/disconnects the current voice/data call or dial-up. * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::hang_up(tout_t aTimeout) + */ +ME310::return_t ME310::hang_up(tout_t aTimeout) { return send_wait(F("ATH"), OK_STRING, aTimeout); } @@ -1136,7 +1193,7 @@ This execution command is used, during a suspended data conversation, to return command mode. If there is no suspended conversation, it returns NO CARRIER * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::return_online(tout_t aTimeout) { return send_wait(F("ATO"), OK_STRING, aTimeout); @@ -1148,25 +1205,25 @@ This execution command sets command manages dialing modality. * \param mode sets dialing modality * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::set_dialing_mode(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#DIALMODE=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } -// Modulation and Compression Control ------------------------------------------ +// Modulation and Compression Control ------------------------------------------ //! \brief Implements the AT%E command and waits for OK answer /*! \details This command is used for line quality monitoring and auto retrain or fall back/fall forward. * \param n this parameter is not really used * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::line_quality_auto_retain(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT%%E%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1178,22 +1235,22 @@ ME310::return_t ME310::line_quality_auto_retain(int n, tout_t aTimeout) Execution command returns the MSISDN (if the phone number of the device has been stored in the SIM card) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::subscriber_number(tout_t aTimeout) { return send_wait(F("AT+CNUM"), 0, OK_STRING, aTimeout); -} +} //! \brief Implements the AT+COPN command and waits for OK answer /*! \details This command read operator names. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::read_operator_names(tout_t aTimeout) { return send_wait(F("AT+COPN"), 0, OK_STRING, aTimeout); -} +} //! \brief Implements the AT+CREG command and waits for OK answer /*! \details @@ -1202,10 +1259,10 @@ presentation format. * \param mode enables/disables the network registration unsolicited result code and selects one of the two formats: shot or long format * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::network_registration_status(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CREG=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1216,10 +1273,10 @@ The command selects a network operator and registers the module. * \param mode defines the operator selection: automatic or manual * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::operator_selection(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+COPS=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1233,10 +1290,10 @@ The command selects a network operator and registers the module. * \param act selects access technology * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::operator_selection(int mode, int format, const char *oper, int act, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+COPS=%d,%d,\"%s\",%d"), mode, format, oper,act ); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1250,10 +1307,10 @@ The command selects a network operator and registers the module. * \param act selects access technology * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::operator_selection(int mode, int format, int oper, int act, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+COPS=%d,%d,%d,%d"), mode, format, oper,act ); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1267,11 +1324,42 @@ This command is used to lock or unlock a ME on a network facility. * \param _class is a sum of integers, each representing an information class of which the command refers to * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::facility_lock_unlock(int fac, int mode, const char *password, int _class, tout_t aTimeout) + */ +ME310::return_t ME310::facility_lock_unlock(const char * fac, int mode, const char *password, int classType, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); - snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CLCK=%d,%d,\"%s\",%d"), fac, mode, password,_class ); + memset(mBuffer, 0, ME310_BUFFSIZE); + snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CLCK=\"%s\",%d,\"%s\",%d"), fac, mode, password, classType); + return send_wait((char*)mBuffer, OK_STRING, aTimeout); +} + +//! \brief Implements the AT+CLCK command and waits for OK answer +/*! \details +This command is used to lock or unlock a ME on a network facility. + * \param fac facility to lock, unlock or interrogate + * \param mode defines the operation to be done on the facility + * \param aTimeout timeout in ms + * \return return code + */ +ME310::return_t ME310::facility_lock_unlock(const char * fac, int mode,tout_t aTimeout) +{ + memset(mBuffer, 0, ME310_BUFFSIZE); + snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CLCK=\"%s\",%d"), fac, mode); + return send_wait((char*)mBuffer, OK_STRING, aTimeout); +} + +//! \brief Implements the AT+CLCK command and waits for OK answer +/*! \details +This command is used to lock or unlock a ME on a network facility. + * \param fac facility to lock, unlock or interrogate + * \param mode defines the operation to be done on the facility + * \param password shall be the same as password specified for the facility from the DTE user interface or with command Change Password +CPWD + * \param aTimeout timeout in ms + * \return return code + */ +ME310::return_t ME310::facility_lock_unlock(const char * fac, int mode, const char *password,tout_t aTimeout) +{ + memset(mBuffer, 0, ME310_BUFFSIZE); + snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CLCK=\"%s\",%d,\"%s\""), fac, mode, password); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1284,11 +1372,11 @@ command. * \param new_password new password * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::change_facility_password(int fac, const char *old_password, const char *new_password, tout_t aTimeout) + */ +ME310::return_t ME310::change_facility_password(const char * fac, const char *old_password, const char *new_password, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); - snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPWD=%d,\"%s\",\"%s\""), fac, old_password, new_password ); + memset(mBuffer, 0, ME310_BUFFSIZE); + snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPWD=\"%s\",\"%s\",\"%s\""), fac, old_password, new_password ); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1297,7 +1385,7 @@ ME310::return_t ME310::change_facility_password(int fac, const char *old_passwor This command returns the list of current calls and their characteristics * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::list_current_calls(tout_t aTimeout) { return send_wait(F("AT+CLCC"), OK_STRING, aTimeout); @@ -1316,10 +1404,10 @@ selected by the command +CPLS * \param e_utran_actn E-UTRAN access technology * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::preferred_operator_list(int index, int format, const char *oper, int gsm_act, int gsm_compact_cact, int utran_act, int e_utran_actn, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPOL=%d,%d,\"%s\",%d,%d,%d,%d"), index, format, oper, gsm_act, gsm_compact_cact, utran_act, e_utran_actn ); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1333,7 +1421,7 @@ selected by the command +CPLS */ ME310::return_t ME310::preferred_operator_list(tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPOL=")); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1344,10 +1432,10 @@ The command is used to select a list of preferred PLMNs in the SIM/USIM card. * \param list PLMNs list selector * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::selection_preferred_plmn_list(int list, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPLS=%d"), list ); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1358,22 +1446,22 @@ Execution command returns received signal strength indication and channel the MT. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::signal_quality(tout_t aTimeout) { return send_wait(F("AT+CSQ"), OK_STRING, aTimeout); -} - +} + //! \brief Implements the AT\#SERVINFO command and waits for OK answer /*! \details This command reports information about the serving cell. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::serving_cell_information(tout_t aTimeout) { return send_wait(F("AT#SERVINFO"), OK_STRING, aTimeout); -} +} //! \brief Implements the AT#BCCHLOCK command and waits for OK answer /*! \details @@ -1388,7 +1476,7 @@ This command enables/disable the single BCCH ARFCN locking. */ ME310::return_t ME310::lock_to_single_BCCH_ARFCN(int lockedBcch, int lockedUarfcn, int lockedPsc, int lockedEarfcn, const char *lockedPci, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#BCCHLOCK=%d,%d,%d,%d,%s"), lockedBcch, lockedUarfcn, lockedPsc, lockedEarfcn, lockedPci); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1399,10 +1487,10 @@ This command enables the unsolicited result code of emergency number update * \param en enables/disables unsolicited indication of emergency number update * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::network_emergency_number_update(int en, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#NWEN=%d"), en ); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1417,10 +1505,10 @@ system. * \param plmnname name of the PLMN; string value, max length 30 characters * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::update_plmn_list(int action, int mcc, int mnc, const char* plmnname, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#PLMNUPDATE%d,%d,%d,\"%s\""), action, mcc, mnc, plmnname ); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1432,10 +1520,10 @@ researches for operator name matching given MCC and MNC. * \param mode list of operator names to be used for internal search * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::plmn_list_selection(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#PLMNMODE=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1450,10 +1538,10 @@ This command selects RF bands * \param lte_band_over_64 indicates the LTE high supported bands expressed as the sum of Band number * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::select_band(int band, int umts_band, int lte_band, int tdscdma_band, int lte_band_over_64, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#BND=%d,%d,%d,%d,%d"), band, umts_band, lte_band, tdscdma_band, lte_band_over_64); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1464,10 +1552,10 @@ This command has no effect and is included only for backward compatibility. * \param value only for backward compatibility * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::automatic_band_selection(int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#AUTOBND=%d"), value); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1481,10 +1569,10 @@ file. * \param alpha alphanumeric string associated to * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::set_subscriber_number(int index, const char *number, const char *alpha, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SNUM=%d,\"%s\",\"%s\""), index, number, alpha); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1494,11 +1582,11 @@ ME310::return_t ME310::set_subscriber_number(int index, const char *number, cons The command is related to extended numeric error report. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::extended_numeric_error_report_net(tout_t aTimeout) { return send_wait(F("AT#CEERNET"), OK_STRING, aTimeout); -} +} //! \brief Implements the AT\#CEERNETEXT command and waits for OK answer /*! \details @@ -1506,10 +1594,10 @@ This command is both a set and an execution command. * \param func enable/disable the URC or delete the last network info * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::extended_error_report_network_reject_cause(int func, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CEERNETEXT=%d"), func); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1520,10 +1608,10 @@ This command enables/disables unsolicited result code for cipher indication. * \param mode enable/disable #CIPHIND: unsolicited result code * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ciphering_indication(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CIPHIND=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1534,10 +1622,10 @@ The command enables/disables unsolicited result code for packet service network * \param mode enables/disables PSNT unsolicited result code * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::packet_service_network_type(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#PSNT=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1549,10 +1637,10 @@ This command enables or disables the GSM and/or GPRS encryption algorithms suppo * \param encgprs The (one byte long) is a bit mask where each bit, when set, indicates the corresponding GPRS encryption algorithm * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::set_encryption_algorithm(int encgsm, int encgprs, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#ENCALG=%d,%d"), encgsm,encgprs); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1563,10 +1651,10 @@ This set command configures the mode of operation for EPS. * \param mode mode of operation * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::set_mode_operation_eps(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CEMODE=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1577,11 +1665,11 @@ Execution command returns received signal quality parameters according to the ne is registered. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::extended_signal_quality(tout_t aTimeout) { return send_wait(F("AT+CESQ"), OK_STRING, aTimeout); -} +} //! \brief Implements the AT\#ENS command and waits for OK answer /*! \details @@ -1589,10 +1677,10 @@ Set command is used to activate the Enhanced Network Selection (ENS) functionali * \param mode enable/disable ENS functionality * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::enhanced_network_selection(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#ENS=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1603,10 +1691,10 @@ This command selects the cellular network (Wireless Data Service, WDS). * \param value WDS-Side Stack to be used by the TA. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::select_wireless_network(int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+WS46=%d"), value); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1619,10 +1707,10 @@ This command controls the setting of the UEs eDRX parameters. * \param req_edrx half a byte in a 4-bit format * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::edrx_settings(int mode, int acttype, const char *req_edrx, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CEDRXS=%d,%d,\"%s\""), mode, acttype, req_edrx); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1632,10 +1720,10 @@ ME310::return_t ME310::edrx_settings(int mode, int acttype, const char *req_edrx This command controls the setting of the UEs eDRX parameters. * \param mode disable or enable the use of eDRX in the UE * \return return code - */ + */ ME310::return_t ME310::edrx_settings(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CEDRXS=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1646,10 +1734,10 @@ This command selects the IoT technology. * \param n select the technology to be used. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::select_iot_technology(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#WS46=%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1659,22 +1747,22 @@ ME310::return_t ME310::select_iot_technology(int n, tout_t aTimeout) This command returns a message related to Extended Discontinuous Reception (eDRX). * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::edrx_read_dynamic_parameters(tout_t aTimeout) { return send_wait(F("AT+CEDRXRDP"), OK_STRING, aTimeout); -} - +} + //! \brief Implements the AT+CEREG command and waits for OK answer /*! \details This command monitors the Evolved Packet System (EPS) network registration status in LTE. * \param mode enables/disables the network registration unsolicited result code * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::eps_network_registration_status(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CEREG=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1684,22 +1772,22 @@ ME310::return_t ME310::eps_network_registration_status(int mode, tout_t aTimeout Command reads current network status. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::read_current_network_status(tout_t aTimeout) { return send_wait(F("AT#RFSTS"), OK_STRING, aTimeout); -} - +} + //! \brief Implements the AT\#SPN command and waits for OK answer /*! \details This command reads SIM fields SPN. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::read_sim_field_spn(tout_t aTimeout) { return send_wait(F("AT#SPN"), OK_STRING, aTimeout); -} +} //! \brief Implements the AT\#CEDRXS command and waits for OK answer /*! \details @@ -1710,10 +1798,10 @@ This command controls the setting of the UEs eDRX parameters. * \param reqpagetimewindow half a byte in a 4-bit format * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::extended_edrx_settings(int mode, int acttype, const char *req_edrx, const char *reqpagetimewindow, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CEDRXS=%d,%d,\"%s\",\"%s\""), mode, acttype, req_edrx, reqpagetimewindow); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1724,10 +1812,10 @@ This command is both a set and an execution command. * \param number the parameter meaning depends on the network * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::cell_monitor(int number, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MONI=%d"), number); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1752,7 +1840,7 @@ This function sets command manages EFS file SNR_level_scan_scope. */ ME310::return_t ME310::SNR_set_level(int level, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SNRSET=%d"), level); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1766,29 +1854,45 @@ Set command configures the CAT-M1 and NB-IoT bands. * \param nb1_band_65_128 indicates the higher (65-128) NB-IoT supported bands * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::catm1_nbiot_band_setting(int m1_band_1_64, int m1_band_65_128, int nb1_band_1_64, int nb1_band_65_128, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#IOTBND=%d,%d,%d,%d"), m1_band_1_64, m1_band_65_128, nb1_band_1_64, nb1_band_65_128); return send_wait((char*)mBuffer,OK_STRING,aTimeout); } +//! \brief Implements the AT+CLIP command and waits for OK answer +/*! \details +This function refers to the supplementary service CLIP (Calling Line Identification Presentation) that enables +a called subscriber to get the calling line identity (CLI) of the calling party when receiving a mobile terminated +call. Only for firmware voice WWV. + * \param enable enables (1) or disables (0) the presentation of the CLI + * \param aTimeout timeout in ms + * \return return code + */ +ME310::return_t ME310::calling_line_identification_presentation (int enable, tout_t aTimeout) +{ + memset(mBuffer, 0, ME310_BUFFSIZE); + snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CLIP=%d"), enable); + return send_wait((char*)mBuffer,OK_STRING,aTimeout); +} + //! \brief Implements the AT\#IOTBND command and waits for OK answer /*! \details Set command configures the CAT-M1 and NB-IoT bands. * \return return code - */ + */ ME310::return_t ME310::catm1_nbiot_band_setting(tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#IOTBND=")); return send_wait((char*)mBuffer,OK_STRING,aTimeout); } //! \brief Implements the AT#IRATTIMER command and waits for OK answer /*! \details -This function sets command configures the IRAT timer and search alignment timer in dedicated +This function sets command configures the IRAT timer and search alignment timer in dedicated EFS file configures the CAT-M1 and NB-IoT bands. * \param m1_band_1_64 indicates the lower (1-64) CAT-M1 supported bands * \param m1_band_65_128 indicates the higher (65-128) CAT-M1 supported bands @@ -1796,10 +1900,10 @@ EFS file configures the CAT-M1 and NB-IoT bands. * \param nb1_band_65_128 indicates the higher (65-128) NB-IoT supported bands * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::inter_RAT_timer_setting(int irat_timer, int search_alignment, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#IRATTIMER=%d,%d"), irat_timer,search_alignment); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1810,10 +1914,10 @@ This function enables/disables NB2 mode. * \param ena Enable/Disable NB2 mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::enable_NB2_mode(int ena, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#NB2ENA=%d"), ena); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1825,10 +1929,10 @@ The command sends to the device a password which is necessary before it can be o * \param pin PIN required * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::enter_pin(const char *pin, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPIN=%s"), pin); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1836,14 +1940,14 @@ ME310::return_t ME310::enter_pin(const char *pin, tout_t aTimeout) //! \brief Implements the AT+CPIN command and waits for OK answer /*! \details The command sends to the device a password which is necessary before it can be operated. - * \param pin old PIN + * \param pin old PIN * \param newpin new PIN * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::enter_pin(const char *pin,const char *newpin, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPIN=%s,%s"), pin, newpin); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1853,21 +1957,21 @@ ME310::return_t ME310::enter_pin(const char *pin,const char *newpin, tout_t aTim This command reports the PIN/PUK or PIN2/PUK2 input remaining attempts, if +CPIN password is required. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::display_pin_counter(tout_t aTimeout) -{ +{ return send_wait(F("AT#PCT"), OK_STRING, aTimeout); } - + //! \brief Implements the AT+CCID command and waits for OK answer /*! \details Execution command reads on SIM the Integrated Circuit Card Identification (ICCID). It is the card identification number that provides a unique identification number for the SIM. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::read_iccid(tout_t aTimeout) -{ +{ return send_wait(F("AT+CCID"), OK_STRING, aTimeout); } @@ -1876,9 +1980,9 @@ ME310::return_t ME310::read_iccid(tout_t aTimeout) This command returns the International Mobile Subscriber Identity (IMSI number). * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::imsi(tout_t aTimeout) -{ +{ return send_wait(F("AT+CIMI"), OK_STRING, aTimeout); } @@ -1887,9 +1991,9 @@ ME310::return_t ME310::imsi(tout_t aTimeout) This command returns the International Mobile Subscriber Identity (IMSI number). * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::imsi_echo(tout_t aTimeout) -{ +{ return send_wait(F("AT#CIMI"), OK_STRING, aTimeout); } @@ -1899,10 +2003,10 @@ The command manages the SIM Detection mode. * \param mode the parameter can be used as shown in Values section * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::sim_detection_mode(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SIMDET=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1913,21 +2017,21 @@ The command enables/disables the SIM Presence Status unsolicited indication. * \param mode Specifies if notification must be enabled or disabled * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::sim_presence_status(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SIMPR=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } //! \brief Implements the AT\#SIMPR command and waits for OK answer /*! \details -Execution command reads on SIM the Integrated Circuit Card Identification (ICCID). +Execution command reads on SIM the Integrated Circuit Card Identification (ICCID). It is the card identification number that provides a unique identification number for the SIM. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::read_iccid_1(tout_t aTimeout) { return send_wait(F("AT#CCID"), OK_STRING, aTimeout); @@ -1939,10 +2043,10 @@ Query SIM Status. * \param mode Type of notification * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::query_sim_status(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#QSS=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1958,10 +2062,10 @@ The command transmits to the UICC some specific commands and their required para * \param data nformation to be read from UICC or written to the UICC (hexadecimal character format) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::restricted_sim_access(int command, int field, int p1, int p2, int p3, const char *data, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CRSM=%d,%d,%d,%d,%d,\"%s\""), command, field, p1, p2, p3, data); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1973,10 +2077,10 @@ This command sends a generic command to the UICC. * \param command command passed on by the MT to the UICC * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::generic_sim_access(int length, const char *command, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSIM=%d,%s"), length, command); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -1987,10 +2091,10 @@ Open Logical Channel. * \param dfname all selectable applications in the UICC are referenced by a DF name coded on 1 to 16 bytes * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::open_logical_channel(const char *dfname, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CCHO=\"%s\""), dfname); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2001,10 +2105,10 @@ Close a communication session. * \param sessionid a session Id to be used to target a specific application on the smart card * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::close_logical_channel(int sessionid, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CCHC=%d"), sessionid); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2017,21 +2121,21 @@ This command is used to control the currently selected UICC on the TE. * \param command command passed on by the MT to the UICC * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::generic_uicc_logical_channell_access(int sessionid, int length, const char *command, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGLA=%d,%d,\"%s\""), sessionid,length, command); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } //! \brief Implements the AT+ICCID command and waits for OK answer /*! \details -Execution command reads on SIM the Integrated Circuit Card Identification (ICCID). +Execution command reads on SIM the Integrated Circuit Card Identification (ICCID). It is the card identification number that provides a unique identification number for the SIM. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::read_iccid_2(tout_t aTimeout) { return send_wait(F("AT+ICCID"), OK_STRING, aTimeout); @@ -2043,10 +2147,10 @@ This command allows to set automatically the active firmware image in accordance * \param mode disable/enable automatic setting of active firmware image switch by SIM * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::automatic_switch_firmware(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FWAUTOSIM=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2058,15 +2162,15 @@ This command configures a GPIO pin as SIMIN pin. * \param simindetmode number of the GPIO pin used as SIMIN pin * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::simin_pin_configuration(int gpiopin, int simindetmode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SIMINCFG=%d,%d"), gpiopin, simindetmode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } -// SIM Toolkit ----------------------------------------------------------------- +// SIM Toolkit ----------------------------------------------------------------- //! \brief Implements the AT\#STIA command and waits for OK answer /*! \details The SIM/USIM Application Toolkit (SAT/USAT) provides an interface to the applications existing in the @@ -2075,10 +2179,10 @@ SIM/USIM device. The module must support the mechanisms required by the SIM/USIM * \param timeout timeout * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::simtoolkit_interface_action(int mode, int timeout, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#STIA=%d,%d"), mode, timeout); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2090,10 +2194,10 @@ proactive command. * \param cmdType proactive command code * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::simtoolkit_get_information(int cmdType, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#STGI=%d"), cmdType); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2107,14 +2211,14 @@ command. * \param data data entered by user * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::simtoolkit_send_response(int cmdType, int userAction, const char *data, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#STSR=%d,%d,\"%s\""), cmdType, userAction, data); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } - + // SMS & CB -------------------------------------------------------------------- //! \brief Implements the AT+CSMS command and waits for OK answer @@ -2123,10 +2227,10 @@ Set command selects messaging service * \param service Select Message Service * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::select_messaging_service(int service, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSMS=%d"), service); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2139,10 +2243,10 @@ The command selects the memory storage used by SMs (Short Messages). * \param mems memory to which received SMs are preferred to be stored * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::preferred_message_storage(const char *memr, const char *memw, const char *mems, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPMS=\"%s\",\"%s\",\"%s\""), memr, memw, mems); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2153,10 +2257,10 @@ Selects the format of SMS messages to be used in following SMS commands. * \param mode format to use for SMS operations * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::message_format(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMGF=%d"), mode ); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2168,10 +2272,10 @@ This command allows to set the Service Center Address for SMS transmissions. * \param type The type of number * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::service_center_address(const char *number, int type, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSCA=\"%s\",%d"), number, type); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2186,10 +2290,10 @@ mode is used (AT+CMGF=1). * \param dcs depending on the command or result code * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::set_text_mode_parameters(int fo, const char *vp, int pid, int dcs, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSMP=%d,\"%s\",%d,%d"), fo, vp, pid, dcs); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2204,10 +2308,10 @@ mode is used (AT+CMGF=1). * \param dcs depending on the command or result code * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::set_text_mode_parameters(int fo, int vp, int pid, int dcs, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSMP=%d,%d,%d,%d"), fo, vp, pid, dcs); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2218,10 +2322,10 @@ This command controls whether detailed header information is shown in text mode. * \param show control the display of the result codes * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::show_text_mode_parameters(int show, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSDH=%d"), show); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2233,10 +2337,10 @@ non-volatile memory. * \param profile Index of the profile where the settings are saved * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::save_settings(int profile, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSAS=%d"), profile); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2247,10 +2351,10 @@ Execution command restores message service settings saved by +CSAS command from * \param profile Defines which message service profiles to restore * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::restore_settings(int profile, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CRES=%d"), profile); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2262,16 +2366,16 @@ network) multiple messages can be sent much faster as link is kept open. * \param n enables/disables the relay protocol link continuity * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::more_message_send(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMMS=%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } //! \brief Implements the AT+CNMI command and waits for OK answer -/*! \details +/*! \details This command sets the parameters for receiving SMS messages. * \param mode unsolicited result codes buffering option * \param mt result code indication reporting for SMS-DELIVER @@ -2280,14 +2384,14 @@ This command sets the parameters for receiving SMS messages. * \param bfr buffered result codes handling method * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::new_message_indications_TE(int mode, int mt, int bm, int ds, int bfr, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CNMI=%d,%d,%d,%d,%d"), mode, mt, bm, ds, bfr); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } - + //! \brief Implements the AT+CNMA command and waits for OK answer /*! \details This command is used to confirm the correct reception of a new message. @@ -2295,10 +2399,10 @@ This command is used to confirm the correct reception of a new message. * \param length length of the PDU message * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::new_message_ack(int n, int length, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CNMA=%d,%d"), n, length); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2308,11 +2412,11 @@ ME310::return_t ME310::new_message_ack(int n, int length, tout_t aTimeout) This command is used to confirm the correct reception of a new message. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::new_message_ack(tout_t aTimeout) { return send_wait(F("AT+CNMA"), OK_STRING, aTimeout); -} +} //! \brief Implements the AT+CMGL command and waits for OK answer /*! \details @@ -2320,10 +2424,10 @@ This command is used to list the messages. * \param stat parameter type and the command output depend on the last settings of the +CMGF command * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::list_messages(int stat, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMGL=%d"), stat); return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); } @@ -2334,10 +2438,10 @@ This command is used to list the messages. * \param stat parameter type and the command output depend on the last settings of the +CMGF command * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::list_messages(const char *stat, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMGL=\"%s\""), stat); return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); } @@ -2347,10 +2451,10 @@ ME310::return_t ME310::list_messages(const char *stat, tout_t aTimeout) This command is used to list the messages. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::list_messages(tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMGL")); return send_wait((char*)mBuffer,0, OK_STRING, aTimeout); } @@ -2361,30 +2465,32 @@ This command is used to read a message. * \param index message index * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::read_message(int index, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMGR=%d"), index); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } - + //! \brief Implements the AT+CMGS command and waits for OK answer /*! \details The command is related to sending short messages. * \param length length in bytes of the PDU to be sent * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::send_short_message(int length, char *data, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + //read_message_format(); + //parsing response + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMGS=%d"), length); - ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); + ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); ret = send_wait((char*)mBuffer, OK_STRING, CTRZ, aTimeout); } @@ -2398,22 +2504,22 @@ The command is related to sending short messages. * \param toda type of destination address * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::send_short_message(const char *da, const char *toda, char *data, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); - snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMGS=\"%s\",%s"), da, toda); + memset(mBuffer, 0, ME310_BUFFSIZE); + snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMGS=\"%s\",%s"), da, toda); ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); ret = send_wait((char*)mBuffer, OK_STRING, CTRZ, aTimeout); } return ret; } - + //! \brief Implements the AT+CMSS command and waits for OK answer /*! \details This command sends to the network a message which is already stored in the storage. @@ -2422,14 +2528,14 @@ This command sends to the network a message which is already stored in the above "FD" * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phonebook_select_memory_storage(const char *storage, const char *password, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPBS=\"%s\",\"%s\""), storage, password); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } - + //! \brief Implements the AT+CPBS command and waits for OK answer /*! \details This set command selects phonebook memory storage, which will be used by other phonebook commands. @@ -2599,10 +2705,10 @@ This set command selects phonebook memory storage, which will be used by other p * \param password string type value representing the PIN2-code required when selecting PIN2-code locked above "FD" * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phonebook_select_memory_storage(const char *storage, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPBS=\"%s\""), storage); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2613,10 +2719,10 @@ The command reads phonebook entries. * \param index2 value in the range of location numbers of the currently selected phonebook memory storage * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phonebook_read_entries( int index1, int index2, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPBR=%d,%d"), index1, index2); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2627,28 +2733,28 @@ The command reads phonebook entries. * \param index1 value in the range of location numbers of the currently selected phonebook memory storage * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phonebook_read_entries( int index1, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPBR=%d"), index1); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } - + //! \brief Implements the AT+CPBF command and waits for OK answer /*! \details This command returns phonebook entries. * \param findtext string to be searched among the phonebook entries * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phonebook_find_entries(const char *findtext, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPBF=\"%s\""), findtext); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } - + //! \brief Implements the AT+CPBW command and waits for OK answer /*! \details This command writes phonebook entry in the current phonebook memory. @@ -2664,10 +2770,10 @@ This command writes phonebook entry in the current phonebook memory. * \param hidden indicates if the entry is hidden or not * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phonebook_write_entry(int index, const char *number, int type, const char *text, const char *group, const char * adnumber, int adtype, const char *secondtext, const char * email, int hidden, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPBW=%d,\"%s\",%d,\"%s\",\"%s\",\"%s\",%d,\"%s\",\"%s\",%d"), index, number, type, text, group, adnumber, adtype, secondtext, email, hidden); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2687,10 +2793,10 @@ This command writes phonebook entry in the current phonebook memory. * \param hidden indicates if the entry is hidden or not * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phonebook_write_entry(int index, const char *number, int type, const char *text, const char *group, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CPBW=%d,\"%s\",%d,\"%s\",\"%s\""), index, number, type, text, group); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2702,10 +2808,10 @@ This command returns Grouping information Alpha String (GAS) USIM file entries. * \param indexLast last location to be read * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phonebook_read_group_entries( int indexFirst, int indexLast, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CPBGR=%d,%d"), indexFirst, indexLast); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2716,14 +2822,14 @@ This command returns Grouping information Alpha String (GAS) USIM file entries. * \param index location to be read * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phonebook_read_group_entries( int index, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CPBGR=%d"), index); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } - + //! \brief Implements the AT+CPBGW command and waits for OK answer /*! \details Set command writes the name of a phonebook group in the Grouping information Alpha String (GAS) @@ -2732,10 +2838,10 @@ USIM file in a specified location number . * \param text text to be stored in the record * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phonebook_write_group_entry(int index, const char *text, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CPBGW=%d,\"%s\""), index, text); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2745,11 +2851,11 @@ ME310::return_t ME310::phonebook_write_group_entry(int index, const char *text, This command deletes all phonebook entries. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::phonebook_delete_all_entries(tout_t aTimeout) { return send_wait(F("AT#CPBD"), OK_STRING, aTimeout); -} +} // Time & Alarm ---------------------------------------------------------------- @@ -2759,10 +2865,10 @@ Set command sets the real-time clock of the module. * \param time Current time as quoted string in the format: "yy/MM/dd,hh:mm:ss±zz,d" * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::clock_management(const char *time, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CCLK=\"%s\""), time); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2779,10 +2885,10 @@ settings. * \param silent indicates if the alarm is silent or not * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::alarm_management(const char *time, int index, int type, const char *string, const char *recurr, int silent, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CALA=\"%s\",%d,%d,\"%s\",\"%s\",%d"), time, index, type, string, recurr, silent); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2793,10 +2899,10 @@ Set command postpones or dismisses a currently active alarm. * \param sec time in seconds to postpone the alarm * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::alarm_postpone(int sec, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CAPD=%d"), sec); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2808,10 +2914,10 @@ This command sets the date format of the date information presented to the user. * \param auxmode TE-TA interface data format * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::setting_date_format(int mode, int auxmode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSDF=%d,%d"), mode, auxmode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2822,10 +2928,10 @@ This command enables and disables the time zone change event reporting. * \param onoff enable/disable the time zone change event reporting * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::time_zone_reporting(int onoff, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CTZR=%d"), onoff); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2836,10 +2942,10 @@ Set command enables/disables the automatic time zone update via NITZ. * \param onoff enables/disables the automatic time zone update via NITZ * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::automatic_time_zone_update(int onoff, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CTZU=%d"), onoff); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2851,10 +2957,10 @@ This command handles Network Identity and Time Zone. * \param mode enables/disables the #NITZ URC * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::network_identity_time_zone(int val, int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#NITZ=%d,%d"), val, mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2865,24 +2971,24 @@ The command is related to real time clock management. * \param time Current time as quoted string in the format: "yy/MM/dd,hh:mm:ss±zz,d" * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::clock_management_ext(const char *time, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CCLK=\"%s\""), time); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } - + //! \brief Implements the AT\#CCLKMODE command and waits for OK answer /*! \details This command allows to enable the local time or the UTC time. * \param mode Time and date mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::clock_mode(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CCLKMODE=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2893,10 +2999,10 @@ Stop any alarm activity * \param opmode operating mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::wake_alarm_mode(int opmode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#WAKE=%d"), opmode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2908,10 +3014,10 @@ the parameter. * \param mode affects the time format on the phone display * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::setting_time_format(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSTF=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2922,10 +3028,10 @@ This command deletes an alarm in the ME. * \param n alarm index * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::alarm_delete(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CALD=%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2938,10 +3044,10 @@ This command enables/disables the muting of the uplink audio line during a voice * \param n controls the muting of the uplink audio line * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::microphone_mute_control(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CMUT=%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2952,10 +3058,10 @@ This command enables/disables the muting of the uplink audio line during a voice * \param mode enables/disables the Open Audio Path * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::open_audio_loop(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#OAP=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -2972,22 +3078,22 @@ This command enables/disables the muting of the uplink audio line during a voice */ ME310::return_t ME310::digital_voiceband_interface(int mode, int dviport, int clockmode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#DV=%d,%d,%d"), mode, dviport, clockmode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } -// HW and Radio Control -------------------------------------------------------- +// HW and Radio Control -------------------------------------------------------- //! \brief Implements the AT\#CBC command and waits for OK answer /*! \details This command returns the current Battery and Charger state. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::battery_charger_status(tout_t aTimeout) { return send_wait(F("AT#CBC"), OK_STRING, aTimeout); -} +} //! \brief Implements the AT\#GPIO command and waits for OK answer /*! \details @@ -2998,10 +3104,10 @@ Set the value of the general-purpose input/output GPIO pins. * \param save GPIO pin save configuration * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::gpio_control(int pin, int mode, int dir, int save, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#GPIO=%d,%d,%d,%d"), pin, mode, dir, save); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3012,10 +3118,10 @@ This command allows to configure the ALARM Pin. * \param pin GPIO pin number * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::alarm_pin_configuration(int pin, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#ALARMPIN=%d"), pin); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3028,10 +3134,10 @@ The command configures the behavior of the STAT_LED status. * \param offDuration duration of period in which STAT_LED pin is tied low * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::stat_led_gpio_setting(int mode,int onDuration, int offDuration, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SLED=%d,%d,%d"), mode,onDuration, offDuration); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3041,11 +3147,11 @@ ME310::return_t ME310::stat_led_gpio_setting(int mode,int onDuration, int offDur This command allows to save the current STAT_LED GPIO setting. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::stat_led_gpio_setting_save(tout_t aTimeout) { return send_wait(F("AT#SLEDSAV"), OK_STRING, aTimeout); -} +} //! \brief Implements the AT\#ADC command and waits for OK answer /*! \details @@ -3055,10 +3161,10 @@ This command returns the current voltage value of the specified ADC inputs, expr * \param dir direction * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::adc_read(int adc,int mode, int dir, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#ADC=%d,%d,%d"), adc, mode, dir); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3070,10 +3176,10 @@ This command sets the AT commands serial port interface output pins mode. * \param mode AT commands serial port interface hardware pins mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::v24_output_pin_configuration(int pin,int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#V24CFG=%d,%d"), pin, mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3085,10 +3191,10 @@ This command sets the state of the output pins of the AT commands serial port in * \param state State of AT commands serial port interface output hardware pins * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::v24_output_pin_control(int pin, int state, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#V24=%d,%d"), pin, state); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3103,11 +3209,11 @@ This command is used to send data to an I2C peripheral connected to module. * \param len number of data to send * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::i2c_write(int sdaPin,int sclPin, int deviceId, int registerId, int len, char* data, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#I2CWR=%d,%d,%x,%x,%d"), sdaPin, sclPin, deviceId, registerId, len); ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) @@ -3115,7 +3221,7 @@ ME310::return_t ME310::i2c_write(int sdaPin,int sclPin, int deviceId, int regist char dataF[ME310_BUFFSIZE-1]; strcat(dataF, data); strcat(dataF, "0x1A"); - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); ret = send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3132,10 +3238,10 @@ This command is used to read data from an I2C peripheral connected to module. * \param len Number of data to receive * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::i2c_read(int sdaPin,int sclPin, int deviceId, int registerId, int len, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#I2CRD=%d,%d,%x,%x,%d"), sdaPin, sclPin, deviceId, registerId, len); return send_wait((char*)mBuffer,0, OK_STRING, aTimeout); } @@ -3151,11 +3257,11 @@ module acts as an I2C master. * \param lenrd number of data to read * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::i2c_write_read(int sdaPin,int sclPin, int deviceId, int lenwr, int lenrd, char* data, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#I2CCF=%d,%d,%x,%d,%d"), sdaPin, sclPin, deviceId, lenwr, lenrd); if(lenwr > 0) { @@ -3165,7 +3271,7 @@ ME310::return_t ME310::i2c_write_read(int sdaPin,int sclPin, int deviceId, int l char dataF[ME310_BUFFSIZE-1]; strcat(dataF, data); strcat(dataF, "0x1A"); - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); ret = send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3183,27 +3289,27 @@ Set module in Test Mode for configuring and testing the POWER level (not signali * \param cmd dentifies one of the commands * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::test_mode_configuration(const char *cmd, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#TESTMODE=\"%s\""), cmd); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } - - + + // Power Down ------------------------------------------------------------------ //! \brief Implements the AT\#REBOOT command and waits for OK answer /*! \details Immediate module reboot. * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::module_reboot(tout_t aTimeout) + */ +ME310::return_t ME310::module_reboot(tout_t aTimeout) { return send_wait(F("AT#REBOOT"), OK_STRING, aTimeout); } - + //! \brief Implements the AT\#ENHRST command and waits for OK answer /*! \details Enable or Disable the one shot or periodic unit reset @@ -3211,10 +3317,10 @@ Enable or Disable the one shot or periodic unit reset * \param delay time interval in minutes after that the unit reboots * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::periodic_reset(int mode, int delay, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); if(mode == 0) { snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#ENHRST=%d"), mode); @@ -3232,7 +3338,7 @@ ME310::return_t ME310::periodic_reset(int mode, int delay, tout_t aTimeout) This command turns the module OFF. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::software_shutdown(tout_t aTimeout) { return send_wait(F("AT#SHDN"), OK_STRING, aTimeout); @@ -3244,7 +3350,7 @@ The execution command sets the module in SYSHALT state. To power down the module (ASC0) must have the control signals CTS, DTR, DCD and RING low. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::system_turnoff(tout_t aTimeout) { return send_wait(F("AT#SYSHALT"), OK_STRING, aTimeout); @@ -3259,10 +3365,10 @@ shutdown. * \param gpio selects the GPIO to execute the fast shutdown * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::fast_shutdown_configuration(int enable, int gpio, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FASTSHDN=%d,%d"), enable,gpio); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3274,7 +3380,7 @@ is forced a High to Low level transition. Or can be used as an execute command t shutdown. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::fast_shutdown_configuration(tout_t aTimeout) { return send_wait(F("AT#FASTSHDN"), OK_STRING, aTimeout); @@ -3289,10 +3395,10 @@ The command performs a survey on the selected band channels. * \param e ending channel * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::network_survey(int s, int e, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CSURV=%d,%d"),s ,e); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3302,7 +3408,7 @@ ME310::return_t ME310::network_survey(int s, int e, tout_t aTimeout) The command performs a survey on the selected band channels. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::network_survey(tout_t aTimeout) { return send_wait(F("AT#CSURV"), OK_STRING, aTimeout); @@ -3316,10 +3422,10 @@ format. * \param e ending channel * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::nertwork_survey_numeric_format(int s, int e, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CSURVC=%d,%d"), s,e); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3330,7 +3436,7 @@ This command performs a survey on the selected band channels. The return message format. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::nertwork_survey_numeric_format(tout_t aTimeout) { return send_wait(F("AT#CSURVC"), OK_STRING, aTimeout); @@ -3343,10 +3449,10 @@ bands channels. * \param format format of the numbers in each network survey information text line * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::network_survey_format(int format, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CSURVF=%d"), format); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3358,10 +3464,10 @@ line. * \param value enables/disables the automatic removing from each network survey information text line * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::network_survey_crlf(int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CSURVNLF=%d"), value); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3372,10 +3478,10 @@ The command is present only for backward compatibility. * \param value dummy parameter * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::network_survey_extended(int value, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CSURVEXT=%d"), value); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3393,10 +3499,10 @@ This command enables/disable jamming detection, and reports the relative result * \param p_rsrq_t4g Set the threshold of RSRQ * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::jamming_detect_report(int mode, int sat2G, int carrNum2G, int pRxLevT2G, int p_rssi_t4g, int p_rsrq_t4g, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#JDRENH2=%d,%d,0,%d,%d,0,0,0,%d,%d,0"), mode, sat2G, carrNum2G,pRxLevT2G, p_rssi_t4g, p_rsrq_t4g); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3411,10 +3517,10 @@ The command configures the LTE Jamming Detection thresholds. * \param p_rssi_s4g RSSI threshold level in dBm, above which the Jamming condition is detected * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::jamming_detect_threshold(int p_rsrp_t4g, int p_rsrq_t4g, int initial_delay, int sampling_number,int p_rssi_s4g, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#JDR4GCFG=%d,%d,%d,%d,%d"), p_rsrp_t4g, p_rsrq_t4g, initial_delay, sampling_number,p_rssi_s4g); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3429,13 +3535,13 @@ Define PDP Context. * \param apn (Access Point Name) a string parameter which is a logical name that is used to select the GGSN or the external packet data network * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::define_pdp_context(int cid, const char *pdp_type, const char * apn, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGDCONT=%d,\"%s\",\"%s\""), cid,pdp_type,apn); return send_wait((char*)mBuffer, OK_STRING, aTimeout); -} +} //! \brief Implements the AT+CGPADDR command and waits for OK answer /*! \details @@ -3443,10 +3549,10 @@ This command returns a list of PDP addresses for the specified context identifie * \param cid specifies a PDP context definition * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::show_pdp_address(int cid, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGPADDR=%d"), cid); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3456,10 +3562,10 @@ ME310::return_t ME310::show_pdp_address(int cid, tout_t aTimeout) This command returns a list of PDP addresses for the specified context identifiers. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::show_pdp_address(tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGPADDR=")); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3470,10 +3576,10 @@ Execution command has no effect and is included only for backward compatibility. * \param _auto dummy parameter * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::auto_attach_property(int _auto, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#AUTOATT=%d"), _auto); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3485,10 +3591,10 @@ Set command sets the GPRS multislot class. * \param autoattach specify when the new multislot class will be enabled * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::multislot_class_control(int _class, int autoattach, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MSCLASS=%d,%d"), _class, autoattach); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3499,10 +3605,10 @@ This command sets the authentication type used in PDP Context Activation during * \param type authentication type used in PDP Context Activation during PPP-PS connections * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::ppp_data_connection_auth_type(int type, tout_t aTimeout) + */ +ME310::return_t ME310::ppp_data_connection_auth_type(int type, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#GAUTH=%d"), type); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3516,10 +3622,10 @@ This command allows the TE to specify authentication parameters for a PDP contex * \param password Password for access to the IP network * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::define_pdp_context_auth_params(int cid, int auth_type, const char *username, const char *password, tout_t aTimeout) + */ +ME310::return_t ME310::define_pdp_context_auth_params(int cid, int auth_type, const char *username, const char *password, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGAUTH=%d,%d,\"%s\",\"%s\""), cid, auth_type, username, password); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3530,8 +3636,8 @@ The execution command returns the relevant information for a PDP Context establi * \param value parameter * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::pdp_context_read_dynamic_parameters( tout_t aTimeout) + */ +ME310::return_t ME310::pdp_context_read_dynamic_parameters( tout_t aTimeout) { return send_wait(F("AT+CGCONTRDP"), OK_STRING, aTimeout); } @@ -3542,10 +3648,10 @@ The execution command returns the relevant information for a PDP Context establi * \param cid identifies a non secondary PDP context definition * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::pdp_context_read_dynamic_parameters(int cid, tout_t aTimeout) + */ +ME310::return_t ME310::pdp_context_read_dynamic_parameters(int cid, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGCONTRDP=%d"), cid); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3559,10 +3665,10 @@ This command selects the printout format of the IPv6 address. * \param ipv6_compressZeros selects whether 1-n instances of 16-bit- zero values are replaced by only "::" * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::printing_ip_address_format(int ipv6_addressFormat, int ipv6_subnetNotation, int ipv6_leadingZeros, int ipv6_compressZeros, tout_t aTimeout) + */ +ME310::return_t ME310::printing_ip_address_format(int ipv6_addressFormat, int ipv6_subnetNotation, int ipv6_leadingZeros, int ipv6_compressZeros, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGPIAF=%d,%d,%d,%d"), ipv6_addressFormat, ipv6_subnetNotation, ipv6_leadingZeros, ipv6_compressZeros); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3574,10 +3680,10 @@ This command activates or deactivates the specified PDP context(s). * \param cid specifies a PDP context definition * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::pdp_context_activate(int cid, int state, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGACT=%d,%d"), state, cid); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3589,12 +3695,12 @@ This command activates or deactivates the specified PDP context(s). * \param cid specifies a PDP context definition * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::pdp_context_activate(tout_t aTimeout) { ME310::return_t ret; int state = 1; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); for(int i = 1; i < 4; i++) { snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGACT=%d,%d"), state, i); @@ -3610,10 +3716,10 @@ This command enables or disables the presentation of unsolicited result codes. * \param bfr controls the effect on buffered codes when 1 or 2 is entered * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::packet_domain_event_reporting(int mode, int bfr, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGEREP=%d,%d"), mode,bfr); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3624,10 +3730,10 @@ This command configures the PPP mode. * \param mode sets PPP mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ppp_configuration(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#PPPCFG=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3638,10 +3744,10 @@ Set command controls the presentation of the +CGREG: unsolicited result code * \param mode enables/disables the network registration unsolicited result code (URC), and selects one of the available formats * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::gprs_network_registration_status(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGREG=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3653,10 +3759,10 @@ Packet Domain service. * \param state state of PS attachment * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ps_attach_detach(int state, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CGATT=%d"), state); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3672,13 +3778,13 @@ The set command is used by the TE to transmit data over control plane to network * \param typeOfUserData indicates whether the user data that is transmitted is regular or exceptional * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::sending_originating_data(int cid, int cpdataLength, const char *cpdata, int rai, int typeOfUserData, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CSODCP=%d,%d,\"%s\",%d,%d"), cid, cpdataLength, cpdata, rai, typeOfUserData); return send_wait((char*)mBuffer, OK_STRING, aTimeout); -} +} //! \brief Implements the AT+CRTDCP command and waits for OK answer /*! \details @@ -3687,10 +3793,10 @@ transmitted via the control plane in downlink direction. * \param reporting controlling reporting of mobile terminated control plane data events * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::reporting_terminating_data(int reporting, tout_t aTimeout) + */ +ME310::return_t ME310::reporting_terminating_data(int reporting, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CRTDCP=%d"), reporting); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3706,10 +3812,10 @@ This command enables/disables the PDP context activation. * \param pwd password, used only if the context requires it * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::context_activation(int cid, int stat, const char *userid, const char *pwd, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SGACT=%d,%d,\"%s\",\"%s\""), cid, stat, userid, pwd); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3721,10 +3827,10 @@ This command enables/disables the PDP context activation. * \param stat activates/disactivates the PDP context specified * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::context_activation(int cid, int stat, tout_t aTimeout) + */ +ME310::return_t ME310::context_activation(int cid, int stat, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SGACT=%d,%d"), cid, stat); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3735,10 +3841,10 @@ This command sets the authentication type for IP Easy * \param type authentication type for IP Easy * \param aTimeout timeout in ms * \return return code - */ -ME310::return_t ME310::pdp_context_auth_type(int type, tout_t aTimeout) + */ +ME310::return_t ME310::pdp_context_auth_type(int type, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SGACTAUTH=%d"), type); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3752,10 +3858,10 @@ This command configures the automatic activation/reactivation of the specified P * \param urcmode URC presentation mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::pdp_automatic_context_activation(int cid, int retry, int delay, int urcmode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SGACTCFG=%d,%d,%d,%d"), cid, retry, delay, urcmode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3767,10 +3873,10 @@ This command manages the extended configuration of context activation. * \param abortAttemptEnable enables/disables abort during context activation attempt * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::extended_pdp_context_activation(int cid, int abortAttemptEnable, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SGACTCFGEXT=%d,%d"), cid, abortAttemptEnable); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3786,10 +3892,10 @@ The command sets the configuration for the socket. * \param txTo data sending timeout; data are sent even if they are less than max packet size, after this period * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_configuration(int connId, int cid, int pktSz, int maxTo, int connTo, int txTo, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SCFG=%d,%d,%d,%d,%d,%d"), connId, cid, pktSz, maxTo, connTo, txTo); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3805,10 +3911,10 @@ This command sets the socket configuration extended parameters. * \param sendDataMode Data mode for sending data in command mode (#SSEND) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_configuration_extended(int connId, int srMode, int recvDataMode, int keepalive, int listenAutoRsp, int sendDataMode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SCFGEXT=%d,%d,%d,%d,%d,%d"), connId, srMode, recvDataMode, keepalive, listenAutoRsp, sendDataMode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3821,13 +3927,13 @@ Socket Configuration Extended. * \param abortConnAttempt enable the abort of an ongoing connection attempt started by #SD command and before the reception of the CONNECT message (in online mode) or OK message (in command mode). * \param unusedB reserved for future use * \param unusedC reserved for future use - * \param noCarrierMode select the NO CARRIER message format received when the socket is closed + * \param noCarrierMode select the NO CARRIER message format received when the socket is closed * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_configuration_extended_2(int connId, int bufferStart, int abortConnAttempt, int unusedB, int unusedC, int noCarrierMode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SCFGEXT2=%d,%d,%d,%d,%d,%d"), connId, bufferStart, abortConnAttempt, unusedB, unusedC, noCarrierMode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3837,7 +3943,7 @@ ME310::return_t ME310::socket_configuration_extended_2(int connId, int bufferSta Socket Parameters Reset * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_parameters_reset(tout_t aTimeout) { return send_wait(F("AT#SKTRST"), OK_STRING, aTimeout); @@ -3857,15 +3963,19 @@ Execution command opens a remote connection via socket. * \param userIpType ip type for socket to open * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_dial(int connId, int txProt, int rPort, const char *IPaddr, int closureType, int lPort, int connMode, int txTime, int userIpType, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SD=%d,%d,%d,\"%s\",%d,%d,%d,%d,%d"), connId, txProt, rPort, IPaddr, closureType, lPort, connMode, txTime, userIpType); if(connMode == 1) + { return send_wait((char*)mBuffer, OK_STRING, aTimeout); + } else + { return send_wait((char*)mBuffer, CONNECT_STRING, aTimeout); + } } //! \brief Implements the AT\#SD command and waits for CONNECT answer @@ -3877,10 +3987,10 @@ Execution command opens a remote connection via socket. * \param IPaddr IP address of the remote host * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_dial(int connId, int txProt, int rPort, const char *IPaddr, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SD=%d,%d,%d,\"%s\""), connId, txProt, rPort, IPaddr); return send_wait((char*)mBuffer, CONNECT_STRING, aTimeout); } @@ -3892,10 +4002,10 @@ escape sequence. * \param connId socket connection identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_restore(int connId, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SO=%d"), connId); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3906,10 +4016,10 @@ The set command closes a socket. * \param connId socket connection identifier to be closed * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_shutdown(int connId, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SH=%d"), connId); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3923,10 +4033,10 @@ The command opens/closes socket listening. * \param lingerT linger time * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_listen(int connId, int listenState, int listenPort, int lingerT, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SL=%d,%d,%d,%d"), connId, listenState, listenPort, lingerT); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3939,10 +4049,10 @@ This command opens/closes a socket listening for an incoming UDP connection on a * \param listenPort local listening port * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_listen_UDP(int connId, int listenState, int listenPort, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SLUDP=%d,%d,%d"), connId, listenState, listenPort); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3954,10 +4064,10 @@ Execution command accepts an incoming socket connection. * \param connMode Connection mode, as for command #SD * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_accept(int connId, int connMode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SA=%d,%d"), connId, connMode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -3969,17 +4079,44 @@ This command is used to send data through a connected socket. * \param rai RAI (Release Assistance Indication) configuration * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_send_data_command_mode(int connId, char* data, int rai, tout_t aTimeout) { + int i = 0; ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + string tmp_str; + char* tmp_data; + /*IS IRA*/ + read_socket_configuration_extended(); + /*Control if size is > 1500 if is not IRA >3000 if is IRA*/ + while(buffer_cstr(i) != NULL) + { + tmp_str = buffer_cstr(i); + string searchedString = "#SCFGEXT: "; + searchedString.append(std::to_string(connId)); + size_t foundString = tmp_str.find(searchedString); + if(foundString != string::npos) + { + break; + } + i++; + } + CheckIRAOption((char*)tmp_str.c_str()); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSEND=%d,%d"), connId, rai); ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); - snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); + memset(mBuffer, 0, ME310_BUFFSIZE); + if(!_isIRATx) + { + if(strlen(data)> ME310_SEND_BUFFSIZE) + { + ret = RETURN_ERROR; + return ret; + } + } + snprintf((char *)mBuffer, ME310_SEND_BUFFSIZE - 1, data); ret = send_wait((char*)mBuffer, OK_STRING, CTRZ, aTimeout); } return ret; @@ -3994,17 +4131,17 @@ This command allows to send data through a connected socket including all possib * \param rai RAI (Release Assistance Indication) configuration * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_send_data_command_mode_extended(int connId, int bytesToSend, char* data, int rai, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSENDEXT=%d,%d,%d"), connId, bytesToSend, rai); ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); - snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); + memset(mBuffer, 0, ME310_BUFFSIZE); + memcpy(mBuffer, data, bytesToSend); ret = send_wait((char*)mBuffer, OK_STRING, aTimeout); } return ret; @@ -4019,10 +4156,35 @@ command mode. * \param udpInfo enables/disables the visualization of UDP datagram information * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_receive_data_command_mode(int connId, int maxByte, int udpInfo, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + int i = 0; + memset(mBuffer, 0, ME310_BUFFSIZE); + string tmp_str; + if(udpInfo == 1) + { + SET_BIT_MASK(_option,_UDP_INFO_BIT); + } + else + { + UNSET_BIT_MASK(_option,_UDP_INFO_BIT); + } + read_socket_configuration_extended(); + /*Control if size is > 1500 if is not IRA >3000 if is IRA*/ + while(buffer_cstr(i) != NULL) + { + tmp_str = buffer_cstr(i); + string searchedString = "#SCFGEXT: "; + searchedString.append(std::to_string(connId)); + size_t foundString = tmp_str.find(searchedString); + if(foundString != string::npos) + { + break; + } + i++; + } + CheckIRAOption((char*)tmp_str.c_str()); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SRECV=%d,%d,%d"), connId, maxByte, udpInfo); return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); } @@ -4036,16 +4198,16 @@ This command allows to send data over UDP to a specific remote host. * \param rai RAI (Release Assistance Indication) configuration * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_send_udp_data_specific_remote_host(int connId, const char *remoteIP, int remotePort, int rai, char* data, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSENDUDP=%d,\"%s\"%d,%d"), connId, remoteIP, remotePort, rai); ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); ret = send_wait((char*)mBuffer, OK_STRING, TERMINATION_STRING, aTimeout); } @@ -4063,16 +4225,16 @@ host including all possible octets (from 0x00 to 0xFF) * \param rai RAI (Release Assistance Indication) configuration * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_send_udp_data_specific_remote_host_extended(int connId, int bytes_to_send, const char *remoteIP, int remotePort, int rai, char* data, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSENDUDPEXT=%d,%d,\"%s\"%d,%d"), connId, bytes_to_send, remoteIP, remotePort, rai); ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); ret = send_wait((char*)mBuffer, OK_STRING, TERMINATION_STRING, aTimeout); } @@ -4085,10 +4247,10 @@ The command detects the cause of a socket disconnection. * \param connId socket connection identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_detect_cause_disconnection(int connId, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SLASTCLOSURE=%d"), connId); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4098,7 +4260,7 @@ ME310::return_t ME310::socket_detect_cause_disconnection(int connId, tout_t aTim Execution command reports the current sockets status. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_status(tout_t aTimeout) { return send_wait(F("AT#SS"),OK_STRING,aTimeout); @@ -4110,10 +4272,10 @@ Execution command reports the current sockets status. * \param connId socket connection identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_status(int connId, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SS=%d"), connId); return send_wait((char*)mBuffer, OK_STRING, aTimeout); //return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); @@ -4125,10 +4287,10 @@ This command is used to get socket information. * \param connId socket connection identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_info(int connId, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SI=%d"), connId); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4138,7 +4300,7 @@ ME310::return_t ME310::socket_info(int connId, tout_t aTimeout) This command is used to get socket information. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_info(tout_t aTimeout) { return send_wait(F("AT#SI"), OK_STRING, aTimeout); @@ -4150,10 +4312,10 @@ Socket Type * \param connId socket connection identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_type(int connId, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#ST=%d"), connId); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4163,7 +4325,7 @@ ME310::return_t ME310::socket_type(int connId, tout_t aTimeout) Socket Type * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_type(tout_t aTimeout) { return send_wait(F("AT#ST"), OK_STRING, aTimeout); @@ -4175,10 +4337,10 @@ This command sets features of the pending data flush to socket, opened with #SD * \param mode enable/disable forwarding * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::pad_command_features(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#PADCMD=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4190,10 +4352,10 @@ PAD forward character * \param mode flush mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::pad_forward_character(int _char, int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#PADFWD=%d,%d"), _char, mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4206,10 +4368,10 @@ This command is used to enable or disable base64 encoding and decoding data of a * \param dec selects the decoding standard * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::base64_encode(int connId, int enc, int dec, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#BASE64=%d,%d,%d"), connId, enc, dec); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4222,10 +4384,10 @@ Set command controls the internal firewall settings * \param net_mask mask to be applied on the * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::firewall_setup(int action, const char *ip_addr, const char *net_mask, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FRWL=%d,\"%s\",\"%s\""), action, ip_addr, net_mask); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4237,10 +4399,10 @@ enabled, the duration of the negative going pulse generated on receipt of connec * \param n RI enabling * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_listen_ring_indicator(int n, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#E2SLRI=%d"), n); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4251,10 +4413,10 @@ Set command enables/disables the ICMP Ping support. * \param mode ICMP mode selection * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ping_support(int mode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#ICMP=%d"), mode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4269,10 +4431,10 @@ This command is used to send Ping Echo Request. * \param ttl time to live * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ping(const char *ipaddr, int retryNum, int len, int timeout, int ttl, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#PING=\"%s\",%d,%d,%d,%d"), ipaddr, retryNum, len, timeout, ttl); return send_wait((char*)mBuffer,0, OK_STRING, aTimeout); } @@ -4283,10 +4445,10 @@ This command is used to send Ping Echo Request. * \param ipaddr address of the remote host, string type * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ping(const char *ipaddr, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#PING=\"%s\""), ipaddr); //return send_wait((char*)mBuffer, OK_STRING, aTimeout); return send_wait((char*)mBuffer,0, OK_STRING, aTimeout); @@ -4299,10 +4461,10 @@ query is successful, then the IP address will be reported in the result code * \param host_name Host name string * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::dns_query(const char *host_name, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#QDNS=\"%s\""), host_name); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4314,10 +4476,10 @@ identifiers * \param cid Generic context identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::dns_from_network(int cid, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#NWDNS=%d"), cid); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4328,7 +4490,7 @@ The command allows to get the primary and secondary DNS addresses for selected G identifiers * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::dns_from_network(tout_t aTimeout) { return send_wait(F("AT#NWDNS="), OK_STRING, aTimeout); @@ -4344,10 +4506,10 @@ The command handles the date and time update using NTP protocol. * \param timezone Time Zone: indicates the difference, expressed in quarter of an hour, between the local time and GMT. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ntp(const char *ntpaddress, int ntpport, int updModClock, int timeout, int timezone, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#NTP=\"%s\",%d,%d,%d,%d"), ntpaddress, ntpport, updModClock, timeout, timezone); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4359,10 +4521,10 @@ This set command allows to configure additional parameters to be used for NTP op * \param authType authentication type to be used with NTP server * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::configure_ntp_parameters(int cid, int authType, int keyID, char* keysFilePath, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); if(authType == 0) { snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#NTPCFG=%d,%d"), cid, authType); @@ -4385,10 +4547,10 @@ command nor in #SCFGEXT2 command. * \param ssendTimeout timeout for #SSEND * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::socket_configuration_extended3(int connId, int immRsp, int closureType, int fastSRing, int ssendTimeout, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SCFGEXT3=%d,%d,%d,%d,%d"), connId, immRsp, closureType, fastSRing, ssendTimeout); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4402,18 +4564,18 @@ This command is used to append data to an already existing file via FTP during a * \param connMode the connection mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_append(const char *fileName, char* data, int connMode, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPAPP=\"%s\",%d"), fileName,connMode); if(connMode == 1) { ret = send_wait((char*)mBuffer, OK_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); ret = send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4423,7 +4585,7 @@ ME310::return_t ME310::ftp_append(const char *fileName, char* data, int connMode ret = send_wait((char*)mBuffer, CONNECT_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); ret = send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4438,16 +4600,16 @@ The command sends data on a FTP data port while the module is in command mode. * \param eof data port closure * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_append_extended(int bytesToSend, char* data, int eof, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPAPPEXT=%d,%d"), bytesToSend,eof); ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); ret = send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4459,7 +4621,7 @@ ME310::return_t ME310::ftp_append_extended(int bytesToSend, char* data, int eof, The command purpose is to close the previously open FTP connection. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_close(tout_t aTimeout) { return send_wait(F("AT#FTPCLOSE"), OK_STRING, aTimeout); @@ -4471,10 +4633,10 @@ Command to change the working directory on FTP server. * \param dirname Name of the new working directory * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_change_working_directory(const char *dirname, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPCWD=\"%s\""), dirname); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4485,7 +4647,7 @@ Command to change the working directory on FTP server. * \param dirname Name of the new working directory * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_change_working_directory(tout_t aTimeout) { return send_wait(F("AT#FTPCWD="), OK_STRING, aTimeout); @@ -4497,10 +4659,10 @@ This command, issued during a FTP connection, allows to delete a file from the r * \param filename Name of the file that must be deleted * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_delete(const char *filename, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPDELE=\"%s\""), filename); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4511,10 +4673,10 @@ This command returns the size of a file located on a FTP server. * \param filename the name of the file that you want to know the size * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_get_file_size(const char *filename, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPFSIZE=\"%s\""), filename); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4525,10 +4687,10 @@ This command executes the FTP Get function during an FTP connection. * \param filename file name to get from server * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_get(const char *filename, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPGET=\"%s\""), filename); return send_wait((char*)mBuffer, CONNECT_STRING, aTimeout); } @@ -4540,10 +4702,10 @@ FTP gets in command mode. * \param viewMode choose the view mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_get_command_mode(const char *filename, int viewMode,tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPGETPKT=\"%s\",%d"), filename, viewMode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4554,11 +4716,11 @@ This command is used during a FTP connection. * \param name is the name of the directory or file * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_list(const char *name, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPLIST=\"%s\""), name); return send_wait((char*)mBuffer, 0, NO_CARRIER_STRING, aTimeout); } @@ -4568,7 +4730,7 @@ ME310::return_t ME310::ftp_list(const char *name, tout_t aTimeout) This command is used during a FTP connection. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_list(tout_t aTimeout) { return ftp_list(".", aTimeout); @@ -4579,7 +4741,7 @@ ME310::return_t ME310::ftp_list(tout_t aTimeout) This command returns the last response received from the FTP server. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_read_message(tout_t aTimeout) { return send_wait(F("AT#FTPMSG"),0, OK_STRING, aTimeout); @@ -4595,10 +4757,10 @@ This execution command opens an FTP connection toward the FTP server. * \param cid PDP context identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_open(const char *server_port, const char *username, const char *password, int viewMode, int cid, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPOPEN=\"%s\",\"%s\",\"%s\",%d,%d"), server_port, username, password, viewMode, cid); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4610,10 +4772,10 @@ This command sends a file to the FTP server. * \param connMode select online or command mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_put(const char *filename, int connMode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPPUT=\"%s\",%d"), filename, connMode); if(connMode == 1) { @@ -4630,7 +4792,7 @@ ME310::return_t ME310::ftp_put(const char *filename, int connMode, tout_t aTimeo This command, issued during an FTP connection, shows the current working directory on FTP server. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_print_working_directory(tout_t aTimeout) { return send_wait(F("AT#FTPPWD"), OK_STRING, aTimeout); @@ -4642,10 +4804,10 @@ The command permits the user to read a given amount of data already transferred * \param block_size maximum number of bytes to read * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_receive_data_command_mode(int block_size, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPRECV=%d"), block_size); return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); } @@ -4657,10 +4819,10 @@ restart a previously interrupted FTP download from the selected position in byte * \param restartPosition position in byte of restarting for successive #FTPGET (or #FTPGETPKT) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_restart_posizion_get(int restartPosition, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPREST=%d"), restartPosition); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4671,10 +4833,10 @@ Set the FTP time out. * \param tout time out in 100 milliseconds units * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_time_out(int tout, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPTO=%d"), tout); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4685,10 +4847,10 @@ This command sets the FTP file transfer type. * \param type file transfer type * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_type(int type, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPTYPE=%d"), type); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4702,10 +4864,10 @@ This command sets the time-out used when opening either the FTP control channel * \param ftpext PORT/PASV and EPRT/EPSV commands * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ftp_configuration(int tout , int ipPIgnoring, int ftpSen, int ftpext, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FTPCFG=%d,%d,%d,%d"), tout, ipPIgnoring, ftpSen, ftpext); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4724,17 +4886,17 @@ ME310::return_t ME310::manual_dns(int cid, const char *primary, const char *seco } */ // SMTP ------------------------------------------------------------------------ - + //! \brief Implements the AT\#ESMTP command and waits for OK answer /*! \details This command allows to set the SMTP server address for e-mail sending. * \param smtp SMTP server address * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::smtp_mail_server(const char *smtp, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#ESMTP=\"%s\""), smtp); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4744,7 +4906,7 @@ ME310::return_t ME310::smtp_mail_server(const char *smtp, tout_t aTimeout) The command returns the last response from SMTP server * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::smtp_read_message(tout_t aTimeout) { return send_wait(F("AT#EMAILMSG"), OK_STRING, aTimeout); @@ -4761,10 +4923,10 @@ Configure SMTP parameters * \param cid PDP context identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::smtp_configure(int ssl_enabled, int port, int mode, int un1, int un2, int cid, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SMTPCFG=%d,%d,%d,%d,%d,%d"), ssl_enabled, port, mode, un1, un2, cid); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4774,7 +4936,7 @@ ME310::return_t ME310::smtp_configure(int ssl_enabled, int port, int mode, int u This execution command resets the e-mail parameters to the "factory default" configuration. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::smtp_reset_parameters(tout_t aTimeout) { return send_wait(F("AT#ERST"), OK_STRING, aTimeout); @@ -4786,10 +4948,10 @@ This command sets the user identification string to be used during the SMTP auth * \param eUser string containing the e-mail authentication User ID * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::smtp_user(const char *eUser, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#EUSER=\"%s\""), eUser); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4799,7 +4961,7 @@ ME310::return_t ME310::smtp_user(const char *eUser, tout_t aTimeout) This execution command stores the e-mail parameters in the NVM. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::smtp_save_parameters(tout_t aTimeout) { return send_wait(F("AT#ESAV"), OK_STRING, aTimeout); @@ -4811,10 +4973,10 @@ This command sets the password string to be used during the authentication step * \param ePwd e-mail authentication password that can have any string value up to max length reported by test command * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::smtp_password(const char *ePwd, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#EPASSW=\"%s\""), ePwd); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4826,16 +4988,16 @@ This command sends an e-mail message. * \param subj subject of the message (maximum length 100 characters) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::smtp_mail_send(const char *da, const char *subj, char* data, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#EMAILD=\"%s\",\"%s\""), da, subj); ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); ret = send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4848,10 +5010,10 @@ This command sets the sender address string to be used for sending the e-mail. * \param eAddr sender address * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::smtp_sender_address(const char *eAddr, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#EADDR=\"%s\""), eAddr); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4873,10 +5035,10 @@ This command sets the parameters needed to the HTTP connection. * \param pkt_size size for data sending (#HTTPSND) or receiving (#HTTPRCV) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::configure_http_parameters(int prof_id, const char *server_address, int server_port, int auth_type, const char *username, const char *password, int ssl_enabled, int timeout, int cid, int pkt_size, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#HTTPCFG=%d,\"%s\",%d,%d,\"%s\",\"%s\",%d,%d,%d,%d"), prof_id, server_address, server_port, auth_type, username, password, ssl_enabled, timeout, cid, pkt_size); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4893,10 +5055,10 @@ This command sets the parameters needed to the HTTP connection. * \param cid PDP context identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::configure_http_parameters(int prof_id, const char *server_address, int server_port, int auth_type, int ssl_enabled, int timeout, int cid, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#HTTPCFG=%d,\"%s\",%d,%d,,,%d,%d,%d"), prof_id, server_address, server_port, auth_type, ssl_enabled, timeout, cid); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4910,10 +5072,10 @@ This command performs a GET, HEAD or DELETE request to HTTP server. * \param extra_header_line is the optional HTTP header line * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::send_http_query(int prof_id, int command, const char *resource, const char *extra_header_line, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#HTTPQRY=%d,%d,\"%s\",\"%s\""), prof_id, command, resource, extra_header_line); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4926,10 +5088,10 @@ This command performs a GET, HEAD or DELETE request to HTTP server. * \param resource is the HTTP resource (URI), object of the request * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::send_http_query(int prof_id, int command, const char *resource, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#HTTPQRY=%d,%d,\"%s\""), prof_id, command, resource); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -4945,11 +5107,11 @@ This command performs a POST or PUT request to HTTP server and starts sending da * \param extra_header_line optional HTTP header line * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::send_http_send(int prof_id, int command, const char *resource, int data_len, char *data, const char *post_param, const char *extra_header_line, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#HTTPSND=%d,%d,\"%s\",%d,\"%s\",\"%s\""), prof_id, command, resource, data_len, post_param, extra_header_line); ret = send_wait((char*)mBuffer,SEQUENCE_STRING,aTimeout); if ((ret == RETURN_VALID)) @@ -4967,10 +5129,10 @@ This command permits the user to read data from HTTP server in response to a pre request. Returns immediately. * \param prof_id profile identifier * \param max_byte max number of bytes to read at a time - */ + */ void ME310::receive_http_data_start(int prof_id, int max_byte) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#HTTPRCV=%d,%d"), prof_id, max_byte); send((char*)mBuffer); } @@ -4983,10 +5145,10 @@ request. * \param max_byte max number of bytes to read at a time * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::receive_http_data(int prof_id, int max_byte, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#HTTPRCV=%d,%d"), prof_id, max_byte); return send_wait((char*)mBuffer,0, OK_STRING, aTimeout); } @@ -5007,10 +5169,10 @@ This command configures SSL connection parameters. * \param equalizeTx enable/disable equalized data transmission * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_configure_general_param(int ssid , int cid, int pktSx, int maxTo, int defTo, int txTo, int SSLSRingMode, int noCarrierMode, int skipHostMismatch , int equalizeTx, int unused1, int unused2, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLCFG=%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"), ssid, cid, pktSx, maxTo, defTo, txTo, SSLSRingMode, noCarrierMode, skipHostMismatch, equalizeTx, unused1, unused2); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5023,10 +5185,10 @@ This command allows configuring SSL connection parameters. * \param authMode authentication mode * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_configure_security_param(int ssid, int cipherSuite, int authMode, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLSECCFG=%d,%d,%d"), ssid, cipherSuite, authMode); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5038,10 +5200,10 @@ This command activates/deactivates a socket secured by SSL. * \param enable activate/deactivate secure socket * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_enable(int ssid, int enable, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLEN=%d,%d"), ssid, enable); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5053,14 +5215,14 @@ This command opens a remote connection via socket secured through SSL. * \param rPort Remote TCP port to contact * \param IPAddress address of SSL server * \param closureType Closure type - * \param connMode connection mode + * \param connMode connection mode (0 online mode, 1 command mode) * \param timeout It represents the maximum allowed TCP inter-packet delay * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_socket_open(int ssid, int rPort, const char *IPAddress, int closureType, int connMode, int timeout, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLD=%d,%d,\"%s\",%d,%d,%d"), ssid, rPort, IPAddress, closureType, connMode, timeout); if(connMode == 1) { @@ -5078,10 +5240,10 @@ This command restores a SSL connection (online mode) suspended by an escape sequ * \param ssid Secure Socket Identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_socket_restore(int ssid, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLO=%d"), ssid); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5093,10 +5255,10 @@ This command allows closing the SSL connection. * \param closureType type of socket closure * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_socket_close(int ssid, int closureType, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLH=%d,%d"), ssid, closureType); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5108,16 +5270,16 @@ This command allows sending data through a secure socket. * \param timeout socket send timeout * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_socket_send_data(int ssid, char *data, int timeout, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLSEND=%d,%d"), ssid, timeout); ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); ret = send_wait((char*)mBuffer, OK_STRING, CTRZ, aTimeout); } @@ -5132,10 +5294,10 @@ This command reads data from a SSL socket. * \param timeout time-out in 100 ms units * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_socket_receive_data(int ssid, int maxNumByte, int timeout, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLRECV=%d,%d,%d"), ssid, maxNumByte, timeout); return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); } @@ -5146,24 +5308,24 @@ This command reports the status of secure sockets. * \param ssid Secure Socket Identifier. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_socket_status(int ssid, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLS=%d"), ssid); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } - + //! \brief Implements the AT\#SSLI command and waits for OK answer /*! \details This command is used to get information about secure socket data traffic. * \param ssid Secure Socket Identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_socket_info(int ssid, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLI=%d"), ssid); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5173,7 +5335,7 @@ ME310::return_t ME310::ssl_socket_info(int ssid, tout_t aTimeout) This command is used to get information about secure socket data traffic. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_socket_info(tout_t aTimeout) { return send_wait(F("AT#SSLI"), OK_STRING, aTimeout); @@ -5187,18 +5349,18 @@ This command sends data through a secure socket. * \param timeout time-out in 100 ms units * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_socket_send_data_command_mode(int ssid, int bytestosend, char* data, int timeout, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLSENDEXT=%d,%d,%d"), ssid, bytestosend, timeout); ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); - ret = send_wait((char*)mBuffer, OK_STRING, aTimeout); + ret = send_wait((char*)mBuffer, OK_STRING, CTRZ, aTimeout); } return ret; } @@ -5213,30 +5375,32 @@ The command stores, reads, and deletes security data (Certificate, CA certificat * \param md5WhenReading handling of RSA Private key reading when is 2 * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_security_data(int ssid, int action, int dataType, int size, int md5WhenReading, char* data, tout_t aTimeout) { - ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + ME310::return_t ret = RETURN_TOUT; + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLSECDATA=%d,%d,%d,%d,%d"), ssid, action, dataType, size, md5WhenReading); if(action == 1 || action == 3) { - return send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); + ret = send_wait((char*)mBuffer, WAIT_DATA_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, data); - ret = send_wait((char*)mBuffer, OK_STRING, aTimeout); + ret = send_wait((char*)mBuffer, 0, OK_STRING, CTRZ, aTimeout); + return ret; } } else if(action == 2) { return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); - } + } else { return send_wait((char*)mBuffer, OK_STRING, aTimeout); } + return ret; } //! \brief Implements the AT\#SSLSECCFG2 command and waits for OK answer @@ -5247,10 +5411,10 @@ This command allows configuring additional SSL security parameters. * \param SNI enable/disable Service Name Indication * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ssl_additional_parameters(int ssid, int version, int SNI, int preloadedCA, int customCA, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#SSLSECCFG2=%d,%d,%d,%d,%d"), ssid,version, SNI, preloadedCA, customCA); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5264,10 +5428,10 @@ This command controls CIoT EPS (Cellular Internet of Things, Evolved Packet Syst * \param preferredUEopt indicates the UE's preference for CIoT EPS optimizations * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ciot_optimization_configuration(int n, int supportedUEopt, int preferredUEopt, tout_t aTimeout ) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+CCIOTOPT=%d,%d,%d"), n, supportedUEopt, preferredUEopt); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5278,10 +5442,10 @@ This command controls CIoT EPS (Cellular Internet of Things, Evolved Packet Syst * \param bitmask used to store the mask in NVM for subsequent use by protocol stack * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ciot_optimization_configuration2(char *bitmask, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#CCIOTOPT=%s"), bitmask); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5298,10 +5462,10 @@ change * \param hostSwVersion contains a string, between double quotes, with the host software version identifier * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::odis_command_saving_retrieving_parameters(char* hostUniqueDevId, char *hostManufacturer, char* hostModel, char *hostSwVersion, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+ODIS=%s,%s,%s,%s"), hostUniqueDevId, hostManufacturer, hostModel, hostSwVersion); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5314,10 +5478,10 @@ operations. Those settings are generally neither related nor manageable with oth * \param enable enable/disable extended URCs * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::FOTA_set_extended_URC(int enable, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#FOTAURC=%d"), enable); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5328,10 +5492,10 @@ Execution command starts injection of a delta file into the device * \param size size in bytes of data to be injected * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::OTA_delta_write(int size, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#OTAUPW=%d"), size); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5345,10 +5509,10 @@ The command manages the Host Odis parameters related to AT&T OMA-DM Client * \param instance instance number * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::odis_parameters_management(int param, int action, char* value, int instance, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); if(action == 0) { snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#HOSTODIS=%d,%d,%s,%d"), param, action, value, instance); @@ -5360,9 +5524,13 @@ ME310::return_t ME310::odis_parameters_management(int param, int action, char* v return send_wait((char*)mBuffer, OK_STRING, aTimeout); } -/*! \brief This function enables the LWM2M Client - * \param enable contains the value that enables/disables the LWM2M client +/*! \brief Implements the AT#LWM2MENA command and waits for unsolicited message +/*! \details +This function enables the Telit LwM2M Client feature. + * \param enable contains the value that enables the LWM2M client * \param ctxID contains the PDP context identifier + * \param aTimeout timeout in ms + * \return return code */ ME310::return_t ME310::enableLWM2M(int enable, int ctxID,tout_t aTimeout) { @@ -5372,15 +5540,18 @@ ME310::return_t ME310::enableLWM2M(int enable, int ctxID,tout_t aTimeout) ret = send_wait((char*)mBuffer,OK_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); ret = wait_for_unsolicited(aTimeout); } return ret; } -/*! \brief This function disables the LWM2M Client +/*! \brief Implements the AT#LWM2MENA command and waits for unsolicited message /*! \details +This function disable the Telit LwM2M Client feature. * \param disable contains the value that disables the LWM2M client + * \param aTimeout timeout in ms + * \return return code */ ME310::return_t ME310::disableLWM2M(int disable, tout_t aTimeout) { @@ -5390,54 +5561,63 @@ ME310::return_t ME310::disableLWM2M(int disable, tout_t aTimeout) ret = send_wait((char*)mBuffer,OK_STRING, aTimeout); if ((ret == RETURN_VALID)) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); ret = wait_for_unsolicited(aTimeout); } return ret; } -/*! \brief This function writes a integer value in a LWM2M resource -/*! \details +/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \details +This function selects the parameters for the write operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. * \param agent specifies the agent (0=telit agent) - * \param objID indentifies the object ID + * \param objID identifies the object ID * \param instanceID identifies the object instance * \param resourceID identifies the resource ID - * \param resourceInstance identifies the resource's instance + * \param resourceInstance identifies the resource instance * \param value sets the resource value - * \param tout_t specifies the timeout + * \param aTimeout timeout in ms + * \return return code */ - ME310::return_t ME310::writeResource(int agent,int objID,int instanceID,int resourceID, int resourceInstance,int value, tout_t aTimeout) + ME310::return_t ME310::writeResource(int agent, int objID, int instanceID,int resourceID, int resourceInstance, int value, tout_t aTimeout) { memset(mBuffer,0,ME310_BUFFSIZE); snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MW=%d,%d,%d,%d,%d,%d"), agent,objID,instanceID,resourceID, resourceInstance,value); return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief This function writes a float value in a LWM2M resource -/*! \details +/*! \brief Implements the AT#LWM2MW command and wait OK answer +/*! \details +This function selects the parameters for the write operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. * \param agent specifies the agent (0=telit agent) - * \param objID indentifies the object ID + * \param objID identifies the object ID * \param instanceID identifies the object instance * \param resourceID identifies the resource ID - * \param resourceInstance identifies the resource's instance - * \param value sets the resource value - * \param tout_t specifies the timeout + * \param resourceInstance identifies the resource instance + * \param value sets the resource value (float) + * \param aTimeout timeout in ms + * \return return code */ -ME310::return_t ME310::writeResourcefloat(int agent,int objID,int instanceID,int resourceID, int resourceInstance,float value, tout_t aTimeout) +ME310::return_t ME310::writeResourcefloat(int agent, int objID, int instanceID,int resourceID, int resourceInstance, float value, tout_t aTimeout) { memset(mBuffer,0,ME310_BUFFSIZE); snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MW=%d,%d,%d,%d,%d,%f"), agent,objID,instanceID,resourceID, resourceInstance,value); return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief This function sets a float value in a LWM2M resource +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. * \param type specifies the type of data to insert * \param objID identifies the object LWM2M * \param instanceID identifies the instance of the object * \param resourceID identifies the resource of the object * \param resourceInstance identifies the instance of the resource * \param value identifies the value to be set - * \param tout_t specifies the timeout + * \param aTimeout specifies the timeout + * \return return code */ ME310::return_t ME310::setResourcefloat(int type,int objID,int instanceID,int resourceID, int resourceInstance,float value, tout_t aTimeout) { @@ -5446,14 +5626,17 @@ ME310::return_t ME310::writeResourcefloat(int agent,int objID,int instanceID,int return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief This function sets a boolean value in a LWM2M resource +/*! \brief Implements the AT#LWM2MSET command and wait OK answer +/*! \details +This function sets a user defined value to the specified resource, if whitelisted. * \param type specifies the type of data to insert * \param objID identifies the object LWM2M * \param instanceID identifies the instance of the object * \param resourceID identifies the resource of the object * \param resourceInstance identifies the instance of the resource - * \param value identifies the value to be set - * \param tout_t specifies the timeout + * \param value identifies the value to be set (int) + * \param aTimeout specifies the timeout + * \return return code */ ME310::return_t ME310::setResourceBool(int type,int objID,int instanceID,int resourceID, int resourceInstance,int value, tout_t aTimeout) { @@ -5461,16 +5644,20 @@ ME310::return_t ME310::setResourceBool(int type,int objID,int instanceID,int res snprintf((char*)mBuffer, ME310_BUFFSIZE-1,F("AT#LWM2MSET=%d,%d,%d,%d,%d,%d"), type,objID,instanceID,resourceID, resourceInstance,value); return send_wait((char*)mBuffer,OK_STRING, aTimeout); } -/*! \brief This function reads a float value in a LWM2M resource + +/*! \brief Implements the AT#LWM2MR command and wait OK answer +/*! \details +This function selects the parameters for the read operation on the lwm2m agent, it requires the +correspondent lwm2m agent enabled and working. * \param type specifies the type of data to insert * \param objID identifies the object LWM2M * \param instanceID identifies the instance of the object * \param resourceID identifies the resource of the object * \param resourceInstance identifies the instance of the resource - * \param value identifies the value to be set - * \param tout_t specifies the timeout + * \param value identifies the value to be set (int) + * \param aTimeout specifies the timeout + * \return return code */ - ME310::return_t ME310::readResourcefloat(int agent,int objID,int instanceID,int resourceID, int resourceInstance, tout_t aTimeout) { memset(mBuffer,0,ME310_BUFFSIZE); @@ -5486,10 +5673,10 @@ This command manages the M2M File System. * \param path directory name * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_chdir(const char *path, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#M2MCHDIR=\"%s\""), path); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5500,10 +5687,10 @@ This command manages the M2M File System. * \param directory_name directory name * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_mkdir(const char *directory_name, ME310::tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#M2MMKDIR=\"%s\""), directory_name); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5514,10 +5701,10 @@ This command manages the M2M File System and backup partition. * \param enable set/reset the BACKUP permission * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_set_backup(int enable, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#M2MBACKUP=%d"), enable); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5528,10 +5715,10 @@ This command removes a directory in the M2M file system. * \param directory_name directory name * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_rmdir(const char *directory_name, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#M2MRMDIR=\"%s\""), directory_name); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5543,10 +5730,10 @@ This command enable/disable the M2M Application execution start mode. * \param delay M2M application execution start time-out expressed in seconds * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_application_execution(int mode, int delay, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); if(mode == 4) { snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+M2M=%d,%d"), mode, delay); @@ -5554,7 +5741,7 @@ ME310::return_t ME310::m2m_application_execution(int mode, int delay, tout_t aTi else { snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+M2M=%d"), mode); - } + } return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5567,10 +5754,10 @@ extension, stored in the directory /mod. It supports the multi-app feature. * \param delay s the delay parameter if the is present * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_set_run_file_permission(int mode, const char * file_bin, int delay, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT+M2MRUN=%d,\"%s\",%d"), mode, delay); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5581,10 +5768,10 @@ This command deletes specified file stored in the File System. * \param file_name file name * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_delete(const char *file_name, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#M2MDEL=\"%s\""), file_name); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5597,11 +5784,11 @@ This command stores a file in the file system. * \param binToMod if is provided as filename with ".bin" extension, using set to 1, force the file to be automatically written on "/mod" folder whichever is the current directory * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_write_file(const char *file_name, int size, int binToMod, char* data, tout_t aTimeout) { ME310::return_t ret; - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); if(ME310_BUFFSIZE-1 < size) { ret = RETURN_ERROR; @@ -5633,10 +5820,10 @@ This command lists the contents of a folder in the File System. * \param path directory name * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_list(const char *path, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#M2MLIST=\"%s\""), path); return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); } @@ -5646,7 +5833,7 @@ ME310::return_t ME310::m2m_list(const char *path, tout_t aTimeout) This command lists the contents of a folder in the File System. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_list(tout_t aTimeout) { return m2m_list(".", aTimeout); @@ -5657,10 +5844,10 @@ This command reports the content of a file stored in the File System. * \param file_name file name * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_read(const char *file_name, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); PathParsing strPar((char*)file_name); m2m_list(strPar.getPath()); int fileSize = strPar.getFileSize((char*)buffer_cstr_raw()); @@ -5677,7 +5864,7 @@ ME310::return_t ME310::m2m_read(const char *file_name, tout_t aTimeout) The execution command returns information on RAM memory for AppZone applications. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_ram_info(tout_t aTimeout) { return send_wait(F("AT#M2MRAM"), OK_STRING, aTimeout); @@ -5689,10 +5876,10 @@ This command reports the content of a file stored in the File System. * \param file_bin executable file name selected for arguments setting/resetting * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::m2m_set_arguments(const char* file_bin, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#M2MARG -=\"%s\""), file_bin); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5706,10 +5893,10 @@ This command initializes a MQTT client and allocates the necessary resources. * \param enable selects if client must be activated or deactivated * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mqtt_enable(int instanceNumber, int enable, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQEN=%d,%d"), instanceNumber, enable); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5724,10 +5911,10 @@ This sets the connection parameters for the selected MQTT client. * \param sslEn enable/disable SSL * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mqtt_configure(int instanceNumber, const char *hostname, int port, int cid, int sslEn, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQCFG=%d,\"%s\",%d,%d,%d"), instanceNumber, hostname, port, cid, sslEn); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5740,10 +5927,10 @@ This command sets the optional connection parameters for the selected MQTT clien * \param cleanSession Indicates whether a persistent connection is required * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mqtt_configure_2(int instanceNumber, int keepalive, int cleanSession, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQCFG2=%d,%d,%d"), instanceNumber, keepalive, cleanSession); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5759,10 +5946,10 @@ This command sets Last Will and Testament for the selected MQTT client. * \param willMessage Last Will message. Unused. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mqtt_configure_lastwill_testament(int instanceNumber, int willFlag, int willRetain, int willQos, const char *willTopic, const char *willMessage, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQWCFG=%d,%d,%d,%d,\"%s\",\"%s\""), instanceNumber, willFlag, willRetain, willQos, willTopic, willMessage); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5774,10 +5961,10 @@ This command writes the timeout options for the specified client. * \param pktTimeout timeout of the packet delivery * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mqtt_configure_timeout(int instanceNumber, int pktTimeout, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQTCFG=%d,%d"), instanceNumber, pktTimeout); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5791,10 +5978,10 @@ This command performs the connection and login to the MQTT broker. * \param password authentication and authorization * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mqtt_connect(int instanceNumber, const char *clientId, const char *username, const char *password, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQCONN=%d,\"%s\",\"%s\",\"%s\""), instanceNumber, clientId, username, password); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5805,10 +5992,10 @@ This command performs the logout and disconnection from to the MQTT broker. * \param instanceNumber selects the client instance * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mqtt_disconnect(int instanceNumber, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQDISC=%d"), instanceNumber); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5820,10 +6007,10 @@ This command performs the subscription to a MQTT topic * \param topic name of the topic * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mqtt_topic_subscribe(int instanceNumber, const char *topic, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQSUB=%d,\"%s\""), instanceNumber, topic); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5835,10 +6022,10 @@ This command revokes the subscription to a MQTT topic. * \param topic name of the topic * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mqtt_topic_unsubscribe(int instanceNumber, const char *topic, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQUNS=%d,\"%s\""), instanceNumber, topic); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5853,10 +6040,10 @@ This command publishes an ASCII string to the specified MQTT topic. * \param message message to publish on the topic. Maximum 140 characters, printable ASCII. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mqtt_publish(int instanceNumber, const char *topic, int retain, int qos, const char *message, tout_t aTimeout) { - memset(mBuffer, 0, ME310_BUFFSIZE); + memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQPUBS=%d,\"%s\",%d,%d,\"%s\""), instanceNumber, topic, retain, qos, message); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } @@ -5868,11 +6055,11 @@ This command reads the message payload from the queue slot provided. * \param mId message slot Id to be read. The read operation will free the slot resource * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::mqtt_read(int instanceNumber, int mId, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); - snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQREAD=%d,%d"), instanceNumber, mId); + snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT#MQREAD=%d,%d"), instanceNumber, mId); return send_wait((char*)mBuffer, 0, OK_STRING, aTimeout); } @@ -5886,7 +6073,7 @@ constellation. It needs a reboot to make effective the setting. * \param value value depends on the first parameter * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::gnss_configuration(int parameter, int value, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -5899,7 +6086,7 @@ ME310::return_t ME310::gnss_configuration(int parameter, int value, tout_t aTime This command resets the GNSS parameters to "Factory Default" configuration. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::gnss_restore_default_GPS_parameters(tout_t aTimeout) { return send_wait(F("AT$GPSRST"), OK_STRING, aTimeout); @@ -5910,7 +6097,7 @@ ME310::return_t ME310::gnss_restore_default_GPS_parameters(tout_t aTimeout) This command stores the current GNSS parameters in the NVM of the cellular module. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::gnss_save_parameters_configuration( tout_t aTimeout) { return send_wait(F("AT$GPSSAV"), OK_STRING, aTimeout); @@ -5922,20 +6109,20 @@ This command powers on/off GNSS controller . * \param status indicates the power status that has to be set * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::gnss_controller_power_management(int status, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); snprintf((char *)mBuffer, ME310_BUFFSIZE-1, F("AT$GPSP=%d"), status); return send_wait((char*)mBuffer, OK_STRING, aTimeout); } - + //! \brief Implements the AT$GPSSW command and waits for OK answer /*! \details This command provides the GNSS module software version. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::gnss_software_version(tout_t aTimeout) { return send_wait(F("AT$GPSSW"), OK_STRING, aTimeout); @@ -5968,7 +6155,7 @@ port and defines which NMEA sentences will be available. * \param vtg enable/disable the presence of the GNSS Course Over Ground and Ground Speed NMEA sentence (VTG) in the GNSS data stream * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::gnss_nmea_data_configuration(int enable, int gga, int gll, int gsa, int gsv, int rmc, int vtg, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -5995,7 +6182,7 @@ through the NMEA port and defines which NMEA extended sentences will be availabl * \param gngga GNSS fix data * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::gnss_nmea_extended_data_configuration(int gngns, int gngsa, int glgsv, int gpgrs, int gagsv, int gagsa, int gavtg, int gpgga, int pqgsa, int pqgsv, int gnvtg, int gnrmc, int gngga, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -6008,7 +6195,7 @@ ME310::return_t ME310::gnss_nmea_extended_data_configuration(int gngns, int gngs Execute command returns a position based on cellular database from GTP (Global Terrestrial Positioning) WWAN service. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::get_position_GTP_WWAN_service(tout_t aTimeout) { return send_wait(F("AT#GTP"), OK_STRING, aTimeout); @@ -6019,7 +6206,7 @@ ME310::return_t ME310::get_position_GTP_WWAN_service(tout_t aTimeout) This command returns information about the last GPS position. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::enable_GTP_WWAN_service(int enable, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -6032,7 +6219,7 @@ ME310::return_t ME310::enable_GTP_WWAN_service(int enable, tout_t aTimeout) This command returns information about the last GPS position. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::gps_get_acquired_position(tout_t aTimeout) { return send_wait(F("AT$GPSACP"), OK_STRING, aTimeout); @@ -6045,7 +6232,7 @@ This command set the AGNSS providers enable or disable. * \param status set the AGNSS provider enable status * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::gnss_set_agnss_enable(int provider, int status, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -6062,7 +6249,7 @@ This command sets up an Ethernet Control Model (ECM) session. * \param did device id, currently limited to 0 (only one device) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ecm_setup(int cid, int did, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -6076,7 +6263,7 @@ This command is used to shutdown an Ethernet Control Model (ECM) session. * \param did Device id, currently limited to 0 (only one device) * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ecm_shutdown(int did, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -6093,7 +6280,7 @@ registration information. * \param mode enables or disables reporting of changes in the MT's IMS registration information. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::ims_registration_status(int mode, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -6101,7 +6288,7 @@ ME310::return_t ME310::ims_registration_status(int mode, tout_t aTimeout) return send_wait((char*)mBuffer, OK_STRING, aTimeout); } -// PSM ------------------------------------------------------------------------- +// PSM ------------------------------------------------------------------------- //! \brief Implements the AT+CPSMS command and waits for OK answer /*! \details @@ -6113,7 +6300,7 @@ This command enables/disables Power Saving Mode (PSM) mode. * \param reqActiveTime Requested Active Time value * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::psm_setting(int mode, const char *reqPeriodicRau, const char *reqGPRSreadyTimer, const char *reqPeriodicTau, const char *reqActiveTime, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -6133,7 +6320,7 @@ ME310::return_t ME310::psm_setting(int mode, const char *reqPeriodicRau, const c * \param psmThreshold Minimum duration threshold (in sec) to enter PSM * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::psm_setting2(int mode, int reqPeriodicRau, int reqGPRSreadyTimer, int reqPeriodicTau, int reqActiveTime, int psmVersion, int psmThreshold, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -6147,7 +6334,7 @@ ME310::return_t ME310::psm_setting2(int mode, int reqPeriodicRau, int reqGPRSrea * \param en enable/disable URC message * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::psm_URC(int en, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -6164,7 +6351,7 @@ ME310::return_t ME310::psm_URC(int en, tout_t aTimeout) * \param configuration_string enables/disables a set of trace outputs. * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::set_trace(int mode, char* configuration_string, tout_t aTimeout) { memset(mBuffer, 0, ME310_BUFFSIZE); @@ -6176,7 +6363,7 @@ ME310::return_t ME310::set_trace(int mode, char* configuration_string, tout_t aT /*! * \param aIndex string index * \return address of the string buffer - */ + */ const char *ME310::buffer_cstr(int aIndex) { if(mBuffLen) @@ -6201,8 +6388,8 @@ const char *ME310::buffer_cstr(int aIndex) //! \brief Returns the string received from the ME310 serial connection /*! * \return address of the string buffer - */ -const char *ME310::buffer_cstr_raw() + */ +const char *ME310::buffer_cstr_raw() { if(mBuffLen) { @@ -6220,7 +6407,7 @@ const char *ME310::buffer_cstr_raw() /*! * \param aCommand command to be sent * \param aTerm termination character (CR or LF or CRLF or other) - */ + */ void ME310::send(const char *aCommand, const char *aTerm) { on_command(aCommand); //callback @@ -6234,7 +6421,7 @@ void ME310::send(const char *aCommand, const char *aTerm) * \param aAnswer answer string to wait for * \param aTimeout answer timeout * \return return code - */ + */ ME310::return_t ME310::read_send_wait(const char *aCommand, const char *aAnswer, ME310::tout_t aTimeout) { send(aCommand, F("?\r")); @@ -6247,7 +6434,7 @@ ME310::return_t ME310::read_send_wait(const char *aCommand, const char *aAnswer, * \param aAnswer answer string to wait for * \param aTimeout answer timeout * \return return code - */ + */ ME310::return_t ME310::test_send_wait(const char *aCommand, const char *aAnswer, ME310::tout_t aTimeout) { send(aCommand, F("=?\r")); @@ -6260,7 +6447,7 @@ ME310::return_t ME310::test_send_wait(const char *aCommand, const char *aAnswer, * \param aAnswer answer string to wait for * \param aTimeout answer timeout * \return return code - */ + */ ME310::return_t ME310::send_wait(const char *aCommand, const char *aAnswer, ME310::tout_t aTimeout) { send(aCommand,F("\r")); // send with terminator @@ -6274,7 +6461,7 @@ ME310::return_t ME310::send_wait(const char *aCommand, const char *aAnswer, ME31 * \param term termination character (CR or LF or CRLF or other) * \param aTimeout answer timeout * \return return code - */ + */ ME310::return_t ME310::send_wait(const char *aCommand, const char *aAnswer, const char* term, ME310::tout_t aTimeout) { send(aCommand,term); // send with terminator @@ -6287,19 +6474,35 @@ ME310::return_t ME310::send_wait(const char *aCommand, const char *aAnswer, cons * \param aAnswer answer string to wait for * \param aTimeout answer timeout * \return return code - */ + */ ME310::return_t ME310::send_wait(const char *aCommand, int flag, const char *aAnswer, ME310::tout_t aTimeout) { send(aCommand,F("\r")); // send with terminator - return wait_for(aCommand, flag, aAnswer, aTimeout); + return wait_for(aCommand, flag, aAnswer, aTimeout); +} + +//! \brief Sends an AT command and waits for answer or timeout +/*! + * \param flag flag to select wait for + * \param aCommand command string to send + * \param aAnswer answer string to wait for + * \param term termination character (CR or LF or CRLF or other) + * \param aTimeout answer timeout + * \return return code + */ +ME310::return_t ME310::send_wait(const char *aCommand, int flag, const char *aAnswer, const char* term, ME310::tout_t aTimeout) +{ + send(aCommand,term); // send with terminator + return wait_for(aCommand, flag, aAnswer, aTimeout); } + //! \brief Waits for the answer to an AT command or timeouts /*! * \param aAnswer answer string to wait for * \param aTimeout answer timeout * \return return code - */ + */ ME310::return_t ME310::wait_for(const char *aAnswer, ME310::tout_t aTimeout) { on_receive(); @@ -6364,10 +6567,10 @@ return RETURN_TOUT; * \param aAnswer answer string to wait for * \param aTimeout answer timeout * \return return code - */ + */ ME310::return_t ME310::wait_for(const char* aCommand, int flag, const char *aAnswer, ME310::tout_t aTimeout) { - + /*TODO Check SRING SSLRING*/ char cmd[64]; strcpy(cmd, aCommand); ATCommandDataParsing* dataParsing; @@ -6389,14 +6592,14 @@ ME310::return_t ME310::wait_for(const char* aCommand, int flag, const char *aAns if(mBuffLen != ME310_BUFFSIZE) { int bytesRead = mSerial.readBytes(mpBuffer, ME310_BUFFSIZE-mBuffLen-1); - if(bytesRead>1) // if full string add to buffer - { + if(bytesRead > 1) /* if full string add to buffer */ + { mpBuffer[bytesRead+1] = '\0'; - bytesRead++; + bytesRead++; pBuffer = mpBuffer; strcat(tmp_str, (char*)mpBuffer); mpBuffer += bytesRead; - mBuffLen += bytesRead; + mBuffLen += bytesRead; rc = on_message((const char *)pBuffer); ResponseFind rf; if(rf.findResponse((char*)pBuffer)) @@ -6404,7 +6607,7 @@ ME310::return_t ME310::wait_for(const char* aCommand, int flag, const char *aAns break; } } - else if(bytesRead == 1) // if empty string do no add to buffer + else if(bytesRead == 1) /* if empty string do no add to buffer */ {} else { @@ -6418,10 +6621,10 @@ ME310::return_t ME310::wait_for(const char* aCommand, int flag, const char *aAns mpBuffer = mBuffer; memset(mBuffer,0,ME310_BUFFSIZE); memset(tmp_str,0,ME310_BUFFSIZE); - } - }while(timeout < aTimeout); - - dataParsing = new ATCommandDataParsing((char*) cmd, tmp_str, flag); + } + } + while(timeout < aTimeout); + dataParsing = new ATCommandDataParsing((char*) cmd, tmp_str, flag, _option); if(dataParsing->parserIs()) { receivedDataLen = dataParsing->receivedBytes(); @@ -6433,11 +6636,11 @@ ME310::return_t ME310::wait_for(const char* aCommand, int flag, const char *aAns if(str_equal(dataParsing->commandResponseString(), OK_STRING)) { rc = RETURN_VALID; - } + } else if(str_equal(dataParsing->commandResponseString(), NO_CARRIER_STRING)) { rc = RETURN_VALID; - } + } else if (str_equal(dataParsing->commandResponseString(), ERROR_STRING)) { rc = RETURN_ERROR; @@ -6451,7 +6654,7 @@ ME310::return_t ME310::wait_for(const char* aCommand, int flag, const char *aAns { rc = RETURN_ERROR; } - } + } else { rc = RETURN_ERROR; @@ -6462,6 +6665,7 @@ ME310::return_t ME310::wait_for(const char* aCommand, int flag, const char *aAns rc = RETURN_ERROR; } on_timeout(); + delete dataParsing; return rc; } @@ -6469,9 +6673,9 @@ ME310::return_t ME310::wait_for(const char* aCommand, int flag, const char *aAns /*! * \param aTimeout answer timeout * \return return code - */ + */ ME310::return_t ME310::wait_for_unsolicited(ME310::tout_t aTimeout) -{ +{ char cmd[64]; return_t rc; const uint8_t *pBuffer; @@ -6492,13 +6696,13 @@ ME310::return_t ME310::wait_for_unsolicited(ME310::tout_t aTimeout) { int bytesRead = mSerial.readBytes(mpBuffer, ME310_BUFFSIZE-mBuffLen-1); if(bytesRead>1) // if full string add to buffer - { + { mpBuffer[bytesRead+1] = '\0'; - bytesRead++; + bytesRead++; pBuffer = mpBuffer; strcat(tmp_str, (char*)mpBuffer); mpBuffer += bytesRead; - mBuffLen += bytesRead; + mBuffLen += bytesRead; rc = on_message((const char *)pBuffer); } else if(bytesRead == 1) // if empty string do no add to buffer @@ -6515,7 +6719,7 @@ ME310::return_t ME310::wait_for_unsolicited(ME310::tout_t aTimeout) mpBuffer = mBuffer; memset(mBuffer,0,ME310_BUFFSIZE); memset(tmp_str,0,ME310_BUFFSIZE); - } + } }while(timeout < aTimeout); _payloadData = (uint8_t *) tmp_str; on_timeout(); @@ -6527,7 +6731,7 @@ ME310::return_t ME310::wait_for_unsolicited(ME310::tout_t aTimeout) * \param aAnswer string waiting for * \param aTimeout timeout in ms * \return return code - */ + */ ME310::return_t ME310::read_line(const char *aAnswer, ME310::tout_t aTimeout) { @@ -6545,7 +6749,7 @@ ME310::return_t ME310::read_line(const char *aAnswer, ME310::tout_t aTimeout) return_t rc = on_message((const char *)mBuffer); if(rc != RETURN_CONTINUE) { - return rc; + return rc; } if(str_equal((const char *)mBuffer,aAnswer)) { @@ -6570,14 +6774,14 @@ ME310::return_t ME310::read_line(const char *aAnswer, ME310::tout_t aTimeout) } } on_timeout(); -return RETURN_TOUT; +return RETURN_TOUT; } //! \brief Returns a string with return_t codes /*! * \param rc return code * \return pointer to string - */ + */ const char *ME310::return_string(return_t rc) { switch(rc) @@ -6586,24 +6790,24 @@ const char *ME310::return_string(return_t rc) return F("VALID"); break; case RETURN_ERROR: - return F("ERROR"); + return F("ERROR"); break; case RETURN_DATA: - return F("DATA"); + return F("DATA"); break; case RETURN_TOUT: - return F("TIMEOUT"); + return F("TIMEOUT"); break; case RETURN_CONTINUE: - return F("CONTINUE"); + return F("CONTINUE"); break; case RETURN_ASYNC: - return F("ASYNC"); + return F("ASYNC"); break; case RETURN_NO_CARRIER: return F("NO CARRIER"); break; - default: + default: return F("CODE NOT DEFINED"); break; } @@ -6611,16 +6815,16 @@ const char *ME310::return_string(return_t rc) //! \brief Compares 2 strings for inclusion from start /*! * \param buffer string buffer where to search the string - * \param string string to search for + * \param string string to search for * \return return NULL if string not included, pointer to start of string in buffer if string is included - */ + */ const char *ME310::str_start(const char *buffer, const char *string) { - if(!buffer) + if(!buffer) { return NULL; } - if(!string) + if(!string) { return NULL; } @@ -6638,9 +6842,9 @@ const char *ME310::str_start(const char *buffer, const char *string) //! \brief Compares 2 strings from start /*! * \param buffer string buffer where to search the string - * \param string string to search for + * \param string string to search for * \return return NULL if different, pointer to start of string in buffer if string is equal - */ + */ const char *ME310::str_equal(const char *buffer, const char *string) { if(!buffer) @@ -6665,5 +6869,122 @@ const char *ME310::str_equal(const char *buffer, const char *string) else { return rc; - } + } +} + +/*! \brief Check IRA Option +/*! \details +This method checks if is IRA mode + * \param str string of configuration command +*/ +void ME310::CheckIRAOption(char* str) +{ + string tmp_str; + tmp_str = str; + char isIRARX[8]; + char isIRATX[8]; + std::size_t posComma = tmp_str.find_first_of(","); + if(posComma != string::npos) + { + posComma = tmp_str.find_first_of(",", posComma + 1); + if(posComma != string::npos) + { + std::size_t posIRARx = tmp_str.find_first_of(",", posComma + 1); + if(posIRARx != string::npos) + { + int len = tmp_str.copy(isIRARX, posIRARx - (posComma + 1), posComma + 1); + isIRARX[len] = '\0'; + int IRA_rx = atoi(isIRARX); + + posComma = posIRARx; + posComma = tmp_str.find_first_of(",", posComma + 1); + if(posComma != string::npos) + { + posComma = tmp_str.find_first_of(",", posComma + 1); + if(posComma != string::npos) + { + len = tmp_str.copy(isIRATX, tmp_str.length() - (posComma+1), posComma + 1); + isIRATX[len] = '\0'; + int IRA_tx = atoi(isIRATX); + if(IRA_rx == 1) + { + SET_BIT_MASK(_option, _IS_IRA_RX_BIT); + _isIRARx = true; + } + else + { + UNSET_BIT_MASK(_option, _IS_IRA_RX_BIT); + _isIRARx = false; + } + if(IRA_tx == 1) + { + SET_BIT_MASK(_option, _IS_IRA_TX_BIT); + _isIRATx = true; + } + else + { + UNSET_BIT_MASK(_option, _IS_IRA_TX_BIT); + _isIRATx = false; + } + } + else + { + UNSET_BIT_MASK(_option, _IS_IRA_RX_BIT); + UNSET_BIT_MASK(_option, _IS_IRA_TX_BIT); + _isIRATx = false; + _isIRARx = false; + } + } + else + { + UNSET_BIT_MASK(_option, _IS_IRA_RX_BIT); + UNSET_BIT_MASK(_option, _IS_IRA_TX_BIT); + _isIRATx = false; + _isIRARx = false; + } + } + else + { + UNSET_BIT_MASK(_option, _IS_IRA_RX_BIT); + UNSET_BIT_MASK(_option, _IS_IRA_TX_BIT); + _isIRATx = false; + _isIRARx = false; + } + } + else + { + UNSET_BIT_MASK(_option, _IS_IRA_RX_BIT); + UNSET_BIT_MASK(_option, _IS_IRA_TX_BIT); + _isIRATx = false; + _isIRARx = false; + } + } + else + { + UNSET_BIT_MASK(_option, _IS_IRA_RX_BIT); + UNSET_BIT_MASK(_option, _IS_IRA_TX_BIT); + _isIRATx = false; + _isIRARx = false; + } } + +/*! \brief Convert buffer in IRA mode +/*! \details +This method converts buffer in IRA mode + * \param recv_buf pointer of received buffer + * \param out_buf pointer of output buffer + * \param size size of received buffer +*/ +void ME310::ConvertBufferToIRA(uint8_t* recv_buf, uint8_t* out_buf, int size) +{ + /*TODO check out_buf len and return size*2*/ + memset(out_buf, 0, (size*2)+1); + for (unsigned int i = 0; i < size; i++) + { + byte nib1 = (recv_buf[i] >> 4) & 0x0F; + byte nib2 = (recv_buf[i] >> 0) & 0x0F; + out_buf[i*2+0] = nib1 < 0xA ? '0' + nib1 : 'A' + nib1 - 0xA; + out_buf[i*2+1] = nib2 < 0xA ? '0' + nib2 : 'A' + nib2 - 0xA; + } + out_buf[size*2] = '\0'; +} \ No newline at end of file diff --git a/src/ME310.h b/src/ME310.h index cc44b77..deab8e0 100644 --- a/src/ME310.h +++ b/src/ME310.h @@ -13,7 +13,7 @@ It makes it easy to build Arduino applications that use the full power of ME310 module @version - 2.2.1 + 2.4.0 @note Dependencies: @@ -35,7 +35,8 @@ namespace me310 { - #define ME310_BUFFSIZE 2046 ///< Exchange buffer size + #define ME310_BUFFSIZE 3100 ///< Exchange buffer size + #define ME310_SEND_BUFFSIZE 1500 #define F(A) A @@ -82,7 +83,7 @@ namespace me310 typedef enum { - TOUT_100MS = 100, TOUT_200MS = 200, TOUT_300MS = 300, TOUT_400MS = 400, TOUT_500MS = 500, TOUT_600MS = 600, TOUT_700MS = 700, TOUT_800MS = 800, TOUT_900MS = 900, + TOUT_0MS = 0, TOUT_100MS = 100, TOUT_200MS = 200, TOUT_300MS = 300, TOUT_400MS = 400, TOUT_500MS = 500, TOUT_600MS = 600, TOUT_700MS = 700, TOUT_800MS = 800, TOUT_900MS = 900, TOUT_1SEC = 1000, TOUT_2SEC = 2000, TOUT_3SEC = 3000, TOUT_4SEC = 4000, TOUT_5SEC = 5000, TOUT_6SEC = 6000, TOUT_7SEC = 7000, TOUT_8SEC = 8000, TOUT_9SEC = 9000, TOUT_10SEC = 10000, TOUT_20SEC = 20000, TOUT_30SEC = 30000, TOUT_45SEC = 45000, TOUT_1MIN = 60000, TOUT_2MIN = 120000 @@ -97,7 +98,14 @@ namespace me310 ~ME310(); + #ifdef ARDUINO_TELIT_SAMD_CHARLIE + void powerOn(unsigned int onoff_gpio = ON_OFF); + #else + void powerOn(unsigned int onoff_gpio); + #endif + void begin(unsigned long baudRate); + void end(); // Command Line Prefixes ------------------------------------------------------- return_t attention(tout_t aTimeout = TOUT_100MS); @@ -159,25 +167,25 @@ namespace me310 _TEST(request_psn_identification_echo,"AT#CGSN",TOUT_100MS) return_t request_product_code(tout_t aTimeout = TOUT_100MS); - _TEST(request_product_code,"AT#CGMF",TOUT_100MS) - + _TEST(request_product_code,"AT#CGMF",TOUT_100MS) + return_t request_software_package_version(tout_t aTimeout = TOUT_100MS); - _TEST(request_software_package_version,"AT#SWPKGV",TOUT_100MS) - + _TEST(request_software_package_version,"AT#SWPKGV",TOUT_100MS) + return_t phone_activity_status(tout_t aTimeout = TOUT_100MS); - _TEST(phone_activity_status,"AT+CPAS",TOUT_100MS) + _TEST(phone_activity_status,"AT+CPAS",TOUT_100MS) - return_t set_phone_functionality(int fun = 1,int rst = 0,tout_t aTimeout = TOUT_100MS); - _READ_TEST(set_phone_functionality,"AT+CFUN",TOUT_100MS) + return_t set_phone_functionality(int fun = 1,int rst = 0, tout_t aTimeout = TOUT_100MS); + _READ_TEST(set_phone_functionality,"AT+CFUN",TOUT_100MS) - return_t mobile_equipment_event_reporting(int mode = 0,int keyp = 0,int disp = 0, int ind = 0, int bfr = 0, tout_t aTimeout = TOUT_100MS); - _READ_TEST(mobile_equipment_event_reporting,"AT+CMER",TOUT_100MS) + return_t mobile_equipment_event_reporting(int mode = 0, int keyp = 0, int disp = 0, int ind = 0, int bfr = 0, tout_t aTimeout = TOUT_100MS); + _READ_TEST(mobile_equipment_event_reporting,"AT+CMER",TOUT_100MS) - return_t set_voice_mail_number(int mode = 0,const char *number = "",int type = 129, tout_t aTimeout = TOUT_100MS); - _READ_TEST(set_voice_mail_number,"AT+CSVM",TOUT_100MS) + return_t set_voice_mail_number(int mode = 0,const char *number = "", int type = 129, tout_t aTimeout = TOUT_100MS); + _READ_TEST(set_voice_mail_number,"AT+CSVM",TOUT_100MS) - return_t mailbox_numbers(int index = 0,const char *number = "",int type = 129, const char *text ="", const char *mboxtype="", tout_t aTimeout = TOUT_100MS); - _TEST(mailbox_numbers,"AT#MBN",TOUT_100MS) + return_t mailbox_numbers(int index = 0, const char *number = "", int type = 129, const char *text ="", const char *mboxtype="", tout_t aTimeout = TOUT_100MS); + _TEST(mailbox_numbers,"AT#MBN",TOUT_100MS) return_t message_waiting_indication(int enable = 1, tout_t aTimeout = TOUT_100MS); _READ_TEST(message_waiting_indication,"AT#MWI",TOUT_100MS) @@ -321,10 +329,12 @@ namespace me310 return_t operator_selection(int mode, int format, int oper, int act, tout_t aTimeout = TOUT_100MS); _READ_TEST(operator_selection,"AT+COPS",TOUT_100MS) - return_t facility_lock_unlock(int fac, int mode, const char *password, int _class, tout_t aTimeout = TOUT_100MS); + return_t facility_lock_unlock(const char * fac, int mode, const char *password, int classType, tout_t aTimeout = TOUT_100MS); + return_t facility_lock_unlock(const char * fac, int mode, tout_t aTimeout = TOUT_100MS); + return_t facility_lock_unlock(const char * fac, int mode, const char *password, tout_t aTimeout = TOUT_100MS); _TEST(facility_lock_unlock,"AT+CLCK",TOUT_100MS) - return_t change_facility_password(int fac, const char *old_password, const char *new_password, tout_t aTimeout = TOUT_100MS); + return_t change_facility_password(const char * fac, const char *old_password, const char *new_password, tout_t aTimeout = TOUT_100MS); _TEST(change_facility_password,"AT+CPWD",TOUT_100MS) return_t list_current_calls(tout_t aTimeout = TOUT_100MS); @@ -395,6 +405,9 @@ namespace me310 return_t edrx_settings(int mode, int acttype, const char * req_edrx, tout_t aTimeout = TOUT_100MS); _READ_TEST(edrx_settings,"AT+CEDRXS",TOUT_100MS) + return_t calling_line_identification_presentation (int enable = 0, tout_t aTimeout = TOUT_100MS); + _READ_TEST(calling_line_identification_presentation, "AT+CLIP", TOUT_100MS) + return_t select_iot_technology(int n , tout_t aTimeout = TOUT_100MS); _READ_TEST(select_iot_technology,"AT#WS46",TOUT_100MS) @@ -798,7 +811,7 @@ namespace me310 return_t extended_pdp_context_activation(int cid, int abortAttemptEnable = 0, tout_t aTimeout = TOUT_1SEC); _READ_TEST(extended_pdp_context_activation,"AT#SGACTCFGEXT",TOUT_100MS) - return_t socket_configuration(int connId, int cid, int pktSz = 300, int maxTo = 90, int connTo =600, int txTo = 50, tout_t aTimeout = TOUT_1SEC); + return_t socket_configuration(int connId, int cid, int pktSz = 300, int maxTo = 90, int connTo = 600, int txTo = 50, tout_t aTimeout = TOUT_1SEC); _READ_TEST(socket_configuration,"AT#SCFG",TOUT_100MS) return_t socket_configuration_extended(int connId = 1, int srMode = 0, int recvDataMode = 0, int keepalive = 0, int listenAutoRsp = 0, int sendDataMode = 0, tout_t aTimeout = TOUT_1SEC); @@ -1235,10 +1248,10 @@ namespace me310 size_t length(void) { return mBuffLen;} //!< Returns length of local buffer const char * buffer_cstr(int aIndex = 0); const char * buffer_cstr_raw(); - + void ConvertBufferToIRA(uint8_t* recv_buf, uint8_t* out_buf, int size); - virtual void on_command(const char *aCommand) {} //!< Callback function on command issued - virtual void on_receive() {} //!< Callback function on string received + virtual void on_command(const char *aCommand) {/*Serial.println(aCommand);*/} //!< Callback function on command issued + virtual void on_receive() {} //!< Callback function on string received virtual void on_error(const char *aMessage) {} //!< Callback function on error string received virtual void on_valid(const char *aMessage) {} //!< Callback function on valid string received virtual void on_timeout(void) {} //!< Callback function on receive timeout event @@ -1266,13 +1279,21 @@ namespace me310 return_t send_wait(const char *aCommand, const char *aAnswer = OK_STRING, tout_t aTimeout = TOUT_200MS); return_t send_wait(const char *aCommand, int flag, const char *aAnswer = OK_STRING, tout_t aTimeout = TOUT_200MS ); return_t send_wait(const char *aCommand, const char *aAnswer = OK_STRING, const char* term = TERMINATION_STRING, tout_t aTimeout = TOUT_200MS); + return_t send_wait(const char *aCommand, int flag, const char *aAnswer = OK_STRING, const char* term = TERMINATION_STRING, tout_t aTimeout = TOUT_200MS); + + void CheckIRAOption(char* str); + Uart &mSerial; //!< Reference to Uart used for communication + uint32_t mBaudrate; //! uint8_t mBuffer[ME310_BUFFSIZE]; //!< Transmission buffer uint8_t *mpBuffer = 0; //!< Pointer to free position in buffer size_t mBuffLen = 0; //!< Buffer length uint8_t *_payloadData = 0; //!< Pointer to free position in buffer for payload data + uint32_t _option = 0; + bool _isIRARx, _isIRATx; + static const char CTRZ[1]; static const char *OK_STRING; diff --git a/src/Parser.cpp b/src/Parser.cpp index 6238f18..874b1ef 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -38,6 +38,34 @@ namespace telitAT const char *Parser::CME_ERROR_STRING = "+CME ERROR: "; ///< String for +CME ERROR modem answer const char *Parser::NO_CARRIER_STRING = "NO CARRIER"; ///< String for NO CARRIER modem answer + static uint8_t ASC_to_DEC(char ch) + { + if (ch >= '0' && ch <= '9') + return ch - '0'; + if (ch >= 'a' && ch <= 'f') + return ch - 'a' + 10; + if (ch >= 'A' && ch <= 'F') + return ch - 'A' + 10; + return 0; + } + + static void ConvertBufferIRAToOctet(uint8_t* in, uint8_t* out, unsigned int len) + { + uint8_t LV_reg; + uint8_t *Buffer = in; + uint32_t BufferIndex = len; + uint8_t *Dst = out; + uint32_t Size = BufferIndex / 2; + while (Size>0) + { + LV_reg = 0; + LV_reg = ASC_to_DEC(*Buffer++) << 4; + LV_reg += ASC_to_DEC(*Buffer++); + *Dst++=LV_reg; + Size--; + } + *Dst = '\0'; //terminate string + } //! \brief Implements the parse method. /*! \details @@ -45,10 +73,10 @@ namespace telitAT * \param str string to parse. * \return 0 if the string is different from null, else -1. */ - int Parser::parse(char* str) + int Parser::parse(string str) { _rawData = str; - if(_rawData != NULL) + if (_rawData.size() != 0) { _recvBytes = receivedBytes(); _startPayloadOffset = findPayloadStart(); @@ -59,7 +87,7 @@ namespace telitAT else { return -1; - } + } } //! \brief Class Destructor @@ -67,8 +95,6 @@ namespace telitAT */ Parser::~Parser() { - delete _payload; - delete _rawData; } /*=================================*/ @@ -137,6 +163,26 @@ namespace telitAT SRECVParser class methods =======================================*/ + SRECVParser::SRECVParser(uint32_t option) + { + if(option == 0) + { + _isIRA = false; + _UDPInfo = false; + } + else + { + if(IS_BIT_SET(option, _IS_IRA_TX_BIT)) + { + _isIRA = true; + } + if(IS_BIT_SET(option, _UDP_INFO_BIT)) + { + _UDPInfo = true; + } + } + + } //! \brief Implements the search for payload string /*! \details This method parses the string to search the payload string, it is specific for #SRECV AT command. @@ -171,21 +217,22 @@ namespace telitAT { string tmp_str; tmp_str = _rawData; - char expBytes[32]; - - size_t posComma = tmp_str.find_first_of(","); + char expBytes[16]; + size_t posComma = 0; + + posComma = tmp_str.find_first_of(",", posComma + 1); if(posComma != string::npos) { size_t posSecondComma = tmp_str.find_first_of(",", posComma+1); if(posSecondComma != string::npos) { - int len = tmp_str.copy(expBytes, ((posSecondComma-1) - posComma), posComma+1); + int len = tmp_str.copy(expBytes, ((posSecondComma-1) - posComma), posComma+1); expBytes[len] = '\0'; return atoi(expBytes); } else { - return posSecondComma; + return posSecondComma; } } else @@ -205,12 +252,19 @@ namespace telitAT memset(_payloadData, 0, MAX_PAYLOAD); string tmp_str; tmp_str = _rawData; - char pl[MAX_PAYLOAD]; - int len = tmp_str.copy(pl, _recvBytes, _startPayloadOffset+1); + int tmp_recvBytes = _recvBytes; + if(_isIRA) + { + tmp_recvBytes = tmp_recvBytes * 2; + } + int len = tmp_str.copy((char*)_payloadData, tmp_recvBytes, _startPayloadOffset+1); if(len != string::npos) { - pl[len] = '\0'; - memcpy(_payloadData, pl, len); + _payloadData[len] = '\0'; + if(_isIRA) + { + ConvertBufferIRAToOctet(_payloadData, _payloadData, len); + } return _payloadData; } else @@ -229,40 +283,45 @@ namespace telitAT string tmp_str; tmp_str = _rawData; char recvBytes[32]; - size_t posNewRow = tmp_str.find_first_of("\n"); - if(posNewRow != string::npos) + size_t posDots = tmp_str.find_first_of(":"); + if(posDots != string::npos) { - size_t posDots = tmp_str.find_first_of(":", posNewRow+1); - if(posDots != string::npos) + size_t posComma = posDots; + if(_UDPInfo) { - size_t posComma = tmp_str.find_first_of(",", posDots+1); + posComma = tmp_str.find_first_of(",", posComma + 1); if(posComma != string::npos) { - size_t posSecondNewRow = tmp_str.find_first_of("\n", posComma+1); - if(posSecondNewRow != string::npos) - { - int len = tmp_str.copy(recvBytes, ((posSecondNewRow-1) - posComma), posComma+1); - recvBytes[len] = '\0'; - return atoi(recvBytes); - } - else - { - return posSecondNewRow; - } - } - else + posComma = tmp_str.find_first_of(",", posComma + 1); + } + if(posComma == string::npos) { return posComma; } + } + posComma = tmp_str.find_first_of(",", posComma + 1); + if(posComma != string::npos) + { + size_t posSecondNewRow = tmp_str.find_first_of("\n", posComma + 1); + if(posSecondNewRow != string::npos) + { + int len = tmp_str.copy(recvBytes, ((posSecondNewRow-1) - posComma), posComma+1); + recvBytes[len] = '\0'; + return atoi(recvBytes); + } + else + { + return posSecondNewRow; + } } else { - return posDots; + return posComma; } - } + } else { - return posNewRow; + return posDots; } } @@ -309,7 +368,6 @@ namespace telitAT } } - /*==================================== FTPRECVParser class methods =====================================*/ @@ -358,7 +416,7 @@ namespace telitAT std::size_t posNewRow = tmp_str.find_first_of("\n", posEq+1); if(posNewRow != string::npos) { - int len = tmp_str.copy(expBytes, (posNewRow - posEq+1), posEq+1); + int len = tmp_str.copy(expBytes, (posNewRow - posEq+1), posEq+1); expBytes[len] = '\0'; return atoi(expBytes); } @@ -447,7 +505,7 @@ namespace telitAT memset(_commandResponse, 0, MAX_CMD_RESPONSE); string tmp_str; tmp_str = _rawData; - int len = tmp_str.copy(_commandResponse, tmp_str.length() - (_startPayloadOffset + _recvBytes), _startPayloadOffset + _recvBytes); + int len = tmp_str.copy(_commandResponse, tmp_str.length() - (_startPayloadOffset + _recvBytes), _startPayloadOffset + _recvBytes); if(len != string::npos) { _commandResponse[len] = '\0'; @@ -597,7 +655,7 @@ namespace telitAT std::size_t posSecondNewRow = tmp_str.find_first_of("\n", posSecondComma+1); if(posSecondNewRow != string::npos) { - int len = tmp_str.copy(recvBytes, ((posSecondNewRow-1) - posSecondComma), posSecondComma+1); + int len = tmp_str.copy(recvBytes, ((posSecondNewRow-1) - posSecondComma), posSecondComma+1); recvBytes[len] = '\0'; return atoi(recvBytes); } @@ -784,7 +842,7 @@ namespace telitAT else { return false; - } + } } else { @@ -808,9 +866,7 @@ namespace telitAT */ int PingParser::findPayloadStart() { - string tmp_str; - tmp_str = _rawData; - std::size_t posNewRow = tmp_str.find_first_of("\n"); + std::size_t posNewRow = _rawData.find_first_of("\n"); if(posNewRow != string::npos) { return posNewRow++; @@ -843,7 +899,7 @@ namespace telitAT string tmp_str; tmp_str = _rawData; char pl[MAX_PAYLOAD]; - int len = tmp_str.copy(pl, _recvBytes, _startPayloadOffset); + int len = tmp_str.copy(pl, _recvBytes, _startPayloadOffset); if(len != string::npos) { pl[len] = '\0'; @@ -862,7 +918,7 @@ namespace telitAT while(pos != string::npos) { pos = tmp.find(":"); - tmp = tmp.substr(pos+2); + tmp = tmp.substr(pos+2); std::size_t pos2 = tmp.find("#"); tmp1 = tmp.substr(0, pos2); pld.insert(pld.length(),tmp1); @@ -921,7 +977,7 @@ namespace telitAT memset(_commandResponse, 0, MAX_CMD_RESPONSE); string tmp_str; tmp_str = _rawData; - int len = tmp_str.copy(_commandResponse, tmp_str.length() - (_startPayloadOffset + _recvBytes), _startPayloadOffset + _recvBytes); + int len = tmp_str.copy(_commandResponse, tmp_str.length() - (_startPayloadOffset + _recvBytes), _startPayloadOffset + _recvBytes); if(len != string::npos) { _commandResponse[len] = '\0'; @@ -952,6 +1008,121 @@ namespace telitAT } } + /*----------------------------------- + SMSListParser class methods + -----------------------------------*/ + //! \brief Implements the search for payload string + /*! \details + This method parses the string to search the payload string, it is specific for a generic AT command. + /*! \return start position to payload string if the format is right otherwise return npos (-1). + */ + int SMSListParser::findPayloadStart() + { + std::size_t posNewRow = _rawData.find_first_of("\n"); + if(posNewRow != string::npos) + { + posNewRow++; + return posNewRow; + } + else + { + return posNewRow; + } + } + + //! \brief Implements the search for expected bytes + /*! \details + This method parses the string to search the expected bytes, it is specific for a generic AT command. + /*! \return 0 + */ + int SMSListParser::expectedBytes() + { + return 0; + } + + //! \brief Implements the search for payload data + /*! \details + This method parses the string to search the payload data, it is specific for a generic AT command. + /*! \return pointer to payload data string if the format is right otherwise return null pointer. + */ + uint8_t * SMSListParser::extractedData() + { + memset(_payloadData, 0, MAX_PAYLOAD); + int len = _rawData.copy((char*)_payloadData, _recvBytes, _startPayloadOffset); + if(len != string::npos) + { + return _payloadData; + } + else + { + return nullptr; + } + } + + //! \brief Implements the search for received bytes + /*! \details + This method parses the string to search the received bytes, it is specific for a generic AT command. + /*! \return number of expected bytes if the format is right otherwise return npos (-1). + */ + int SMSListParser::receivedBytes() + { + char tmp_data[MAX_PAYLOAD]; + std::size_t posNewRow = _rawData.find_first_of("\n"); + if(posNewRow != string::npos) + { + std::size_t lastOKPos = _rawData.find_last_of("OK"); + lastOKPos = lastOKPos - 4; + if(lastOKPos != string::npos) + { + int len = _rawData.copy(tmp_data, lastOKPos - posNewRow, posNewRow); + return len; + } + return lastOKPos; + } + else + { + return posNewRow; + } + } + + //! \brief Implements the search for command response string + /*! \details + This method parses the string to search the command response, it is specific for a generic AT command. + /*! \return true if the format is right otherwise return false. + */ + bool SMSListParser::searchCommandResponseString() + { + memset(_commandResponse, 0, MAX_CMD_RESPONSE); + std::size_t posResponse = _rawData.find(OK_STRING); + if(posResponse != string::npos) + { + strcpy(_commandResponse, OK_STRING); + _posCommandResponse = posResponse; + return true; + } + posResponse = _rawData.find(ERROR_STRING); + if(posResponse != string::npos) + { + strcpy(_commandResponse, ERROR_STRING); + _posCommandResponse = posResponse; + return true; + } + posResponse = _rawData.find(NO_CARRIER_STRING); + if(posResponse != string::npos) + { + strcpy(_commandResponse, NO_CARRIER_STRING); + _posCommandResponse = posResponse; + return true; + } + posResponse = _rawData.find(CME_ERROR_STRING); + if(posResponse != string::npos) + { + strcpy(_commandResponse, CME_ERROR_STRING); + _posCommandResponse = posResponse; + return true; + } + return false; + } /*----------------------------------- GenericParser class methods -----------------------------------*/ @@ -963,9 +1134,7 @@ namespace telitAT */ int GenericParser::findPayloadStart() { - string tmp_str; - tmp_str = _rawData; - std::size_t posNewRow = tmp_str.find_first_of("\n"); + std::size_t posNewRow = _rawData.find_first_of("\n"); if(posNewRow != string::npos) { posNewRow++; @@ -995,14 +1164,9 @@ namespace telitAT uint8_t * GenericParser::extractedData() { memset(_payloadData, 0, MAX_PAYLOAD); - string tmp_str; - tmp_str = _rawData; - char pl[MAX_PAYLOAD]; - int len = tmp_str.copy(pl, _recvBytes, _startPayloadOffset); + int len = _rawData.copy((char*)_payloadData, _recvBytes, _startPayloadOffset); if(len != string::npos) { - pl[len] = '\0'; - memcpy(_payloadData, pl, len); return _payloadData; } else @@ -1018,13 +1182,11 @@ namespace telitAT */ int GenericParser::receivedBytes() { - string tmp_str; - tmp_str = _rawData; char tmp_data[MAX_PAYLOAD]; - std::size_t posNewRow = tmp_str.find_first_of("\n"); + std::size_t posNewRow = _rawData.find_first_of("\n"); if(posNewRow != string::npos) { - int len = tmp_str.copy(tmp_data, tmp_str.length() - posNewRow, posNewRow); + int len = _rawData.copy(tmp_data, _rawData.length() - posNewRow, posNewRow); return len; } else @@ -1041,30 +1203,28 @@ namespace telitAT bool GenericParser::searchCommandResponseString() { memset(_commandResponse, 0, MAX_CMD_RESPONSE); - string tmp_str; - tmp_str = _rawData; - std::size_t posResponse = tmp_str.find(OK_STRING); + std::size_t posResponse = _rawData.find(OK_STRING); if(posResponse != string::npos) { strcpy(_commandResponse, OK_STRING); _posCommandResponse = posResponse; return true; } - posResponse = tmp_str.find(ERROR_STRING); + posResponse = _rawData.find(ERROR_STRING); if(posResponse != string::npos) { strcpy(_commandResponse, ERROR_STRING); _posCommandResponse = posResponse; return true; } - posResponse = tmp_str.find(NO_CARRIER_STRING); + posResponse = _rawData.find(NO_CARRIER_STRING); if(posResponse != string::npos) { strcpy(_commandResponse, NO_CARRIER_STRING); _posCommandResponse = posResponse; return true; } - posResponse = tmp_str.find(CME_ERROR_STRING); + posResponse = _rawData.find(CME_ERROR_STRING); if(posResponse != string::npos) { strcpy(_commandResponse, CME_ERROR_STRING); diff --git a/src/Parser.h b/src/Parser.h index 0c6ee33..a48e482 100644 --- a/src/Parser.h +++ b/src/Parser.h @@ -13,7 +13,7 @@ Parser is an abstract class and handles common methods, like gets and parse.\n The concrete classes, derived by Parser, implement the parsing methods for the specific AT command.\n @version - 1.0.0 + 1.1.0 @note Dependencies: @@ -37,9 +37,19 @@ /* Using namespace ================================================================================*/ using namespace std; -#define MAX_PAYLOAD 2048 //!< max payload len +#define MAX_PAYLOAD 3100 //!< max payload len + #define MAX_CMD_RESPONSE 64 //!< max command response len +#define _IS_IRA_TX_BIT 0x00 +#define _IS_IRA_RX_BIT 0x01 +#define _UDP_INFO_BIT 0x02 + + +#define SET_BIT_MASK(m, L) (m |= (1 << L)) +#define UNSET_BIT_MASK(m, L) (m &= (~(1<< L))) +#define IS_BIT_SET(m, L) ((m & (1 << L)) == (1 << L)) + /* Start telitAT namespace ========================================================================*/ namespace telitAT { @@ -55,7 +65,7 @@ namespace telitAT class Parser { public: - virtual int parse(char* str); + virtual int parse(string str); virtual int getReceivedBytes(); virtual uint8_t * getPayload(); virtual int getPayloadStart(); @@ -73,7 +83,7 @@ namespace telitAT uint8_t _payloadData[MAX_PAYLOAD]; //!< Payload buffer char _commandResponse[MAX_CMD_RESPONSE]; //!< Command Response buffer uint8_t *_payload; //!< Pointer to payload string - char *_rawData; //!< Pointer to string data received + string _rawData; //!< Pointer to string data received int _recvBytes; //!< Received bytes int _startPayloadOffset; //!< Start position to payload offset bool _response; //!< Command Response flag @@ -97,6 +107,7 @@ namespace telitAT class SRECVParser : public Parser { public: + SRECVParser(uint32_t option = 0); ~SRECVParser(){} protected: @@ -105,6 +116,10 @@ namespace telitAT uint8_t * extractedData(); int receivedBytes(); bool searchCommandResponseString(); + + private: + bool _isIRA; + bool _UDPInfo; }; /*--------------------------------- @@ -201,6 +216,30 @@ namespace telitAT bool searchCommandResponseString(); }; + /*--------------------------------- + SMSListParser class + ----------------------------------*/ + /*! \class SMSListParser + \brief Class to parse received string, specific to parsing +CMGL AT command + \details + This is a derivated class by Parser, specific to parsing +CMGL AT command.\n + It offers a series of methods that allow to parse a string obtained as a response following an AT+CMGL command.\n + */ + class SMSListParser : public Parser + { + public: + ~SMSListParser(){} + + protected: + int findPayloadStart(); + int expectedBytes(); + uint8_t * extractedData(); + int receivedBytes(); + bool searchCommandResponseString(); + + private: + int _posCommandResponse; + }; /*----------------------------------- GenericParser class -----------------------------------*/ diff --git a/src/PathParsing.cpp b/src/PathParsing.cpp index 1862fbb..f8cf46b 100644 --- a/src/PathParsing.cpp +++ b/src/PathParsing.cpp @@ -1,3 +1,30 @@ +/*Copyright (C) 2020 Telit Communications S.p.A. Italy - All Rights Reserved.*/ +/* See LICENSE file in the project root for full license information. */ + +/** + @file + PathParsing.cpp + + @brief + PathParsing interface for AT command + + @details + This library contains a interface that implements a parsing functions for path.\n + + @version + 1.0.0 + + @note + Dependencies: + PathParsing.h + + @author + Cristina Desogus + + @date + 02/23/2021 +*/ + #include "PathParsing.h" #include #include "Arduino.h" diff --git a/src/PathParsing.h b/src/PathParsing.h index 9407cc9..129342d 100644 --- a/src/PathParsing.h +++ b/src/PathParsing.h @@ -2,7 +2,7 @@ /* >>> Copyright (C) Telit Communications S.p.A. Italy All Rights Reserved. <<< */ /*! @file - StringParsing.h + PathParsing.h @brief Parsing string