diff --git a/lib/TinyGSM/src/TinyGsmClientA7608.h b/lib/TinyGSM/src/TinyGsmClientA7608.h index fd78dd3..e7ccb7d 100644 --- a/lib/TinyGSM/src/TinyGsmClientA7608.h +++ b/lib/TinyGSM/src/TinyGsmClientA7608.h @@ -372,6 +372,54 @@ class TinyGsmA7608 : public TinyGsmModem, } return true; } + + /* + * Return code: + * -1 ping failed + * 1 Ping success + * 2 Ping time out + * 3 Ping result + * * */ + int ping(const char *url, String &resolved_ip_addr, + uint32_t &rep_data_packet_size, + uint32_t &tripTime, + uint8_t &TTL) + { + uint8_t dest_addr_type = 1; + uint8_t num_pings = 1; + uint8_t data_packet_size = 64; + uint32_t interval_time = 1000; + uint32_t wait_time = 10000; + uint8_t ttl = 0xFF; + int result_type = -1; + + sendAT("+CPING=\"", url, "\"", ",", dest_addr_type, ",", + num_pings, ",", data_packet_size, ",", + interval_time, ",", wait_time, ",", ttl); + + if (waitResponse() != 1) { + return -1; + } + if (waitResponse(10000UL, "+CPING: ") == 1) { + result_type = streamGetIntBefore(','); + switch (result_type) { + case 1: + resolved_ip_addr = stream.readStringUntil(','); + rep_data_packet_size = streamGetIntBefore(','); + tripTime = streamGetIntBefore(','); + TTL = streamGetIntBefore('\n'); + break; + case 2: + break; + case 3: + break; + default: + break; + } + } + return result_type; + } + /* * GPRS functions */ diff --git a/lib/TinyGSM/src/TinyGsmClientA7670.h b/lib/TinyGSM/src/TinyGsmClientA7670.h index aafc9a8..3a7db7e 100644 --- a/lib/TinyGSM/src/TinyGsmClientA7670.h +++ b/lib/TinyGSM/src/TinyGsmClientA7670.h @@ -373,6 +373,54 @@ class TinyGsmA7670 : public TinyGsmModem, return true; } + /* + * Return code: + * -1 ping failed + * 1 Ping success + * 2 Ping time out + * 3 Ping result + * * */ + int ping(const char *url, String &resolved_ip_addr, + uint32_t &rep_data_packet_size, + uint32_t &tripTime, + uint8_t &TTL) + { + uint8_t dest_addr_type = 1; + uint8_t num_pings = 1; + uint8_t data_packet_size = 64; + uint32_t interval_time = 1000; + uint32_t wait_time = 10000; + uint8_t ttl = 0xFF; + int result_type = -1; + + sendAT("+CPING=\"", url, "\"", ",", dest_addr_type, ",", + num_pings, ",", data_packet_size, ",", + interval_time, ",", wait_time, ",", ttl); + + if (waitResponse() != 1) { + return -1; + } + if (waitResponse(10000UL, "+CPING: ") == 1) { + result_type = streamGetIntBefore(','); + switch (result_type) { + case 1: + resolved_ip_addr = stream.readStringUntil(','); + rep_data_packet_size = streamGetIntBefore(','); + tripTime = streamGetIntBefore(','); + TTL = streamGetIntBefore('\n'); + break; + case 2: + break; + case 3: + break; + default: + break; + } + } + return result_type; + } + + /* * GPRS functions */ diff --git a/lib/TinyGSM/src/TinyGsmClientSIM7672.h b/lib/TinyGSM/src/TinyGsmClientSIM7672.h index b9d50a2..281f37b 100644 --- a/lib/TinyGSM/src/TinyGsmClientSIM7672.h +++ b/lib/TinyGSM/src/TinyGsmClientSIM7672.h @@ -319,6 +319,54 @@ class TinyGsmSim7672 : public TinyGsmModem, } return true; } + + /* + * Return code: + * -1 ping failed + * 1 Ping success + * 2 Ping time out + * 3 Ping result + * * */ + int ping(const char *url, String &resolved_ip_addr, + uint32_t &rep_data_packet_size, + uint32_t &tripTime, + uint8_t &TTL) + { + uint8_t dest_addr_type = 1; + uint8_t num_pings = 1; + uint8_t data_packet_size = 64; + uint32_t interval_time = 1000; + uint32_t wait_time = 10000; + uint8_t ttl = 0xFF; + int result_type = -1; + + sendAT("+CPING=\"", url, "\"", ",", dest_addr_type, ",", + num_pings, ",", data_packet_size, ",", + interval_time, ",", wait_time, ",", ttl); + + if (waitResponse() != 1) { + return -1; + } + if (waitResponse(10000UL, "+CPING: ") == 1) { + result_type = streamGetIntBefore(','); + switch (result_type) { + case 1: + resolved_ip_addr = stream.readStringUntil(','); + rep_data_packet_size = streamGetIntBefore(','); + tripTime = streamGetIntBefore(','); + TTL = streamGetIntBefore('\n'); + break; + case 2: + break; + case 3: + break; + default: + break; + } + } + return result_type; + } + /* * GPRS functions */