Hello
I'm configuring Ping with AT command using API - nrf9160DK, zephyrOS. However, it doesn't go well. API reply "ERROR".
some other AT command goes well, but, Ping not.
( "AT+CPSI?" is also not good.)
Could you check and please let me know where is mistaken ?
Base code is from here - github.com/.../cellfund_less4_exer1_solution
and customized,
Here is snippet code
---------
#define AT_RESPONSE_MAX_LEN 512
#define PING_SERVER "8.8.8.8"
static int ping_server(const char *server_addr)
{
char at_cmd[128];
char *response_buffer = k_malloc(AT_RESPONSE_MAX_LEN);
if (response_buffer == NULL) {
LOG_ERR("Failed to allocate memory for response buffer");
return -1;
}
snprintf(at_cmd, sizeof(at_cmd), "AT#XPING=\"%s\",4,1000", server_addr); // Ping once with a 1000ms timeout
int err = nrf_modem_at_cmd(response_buffer, AT_RESPONSE_MAX_LEN, at_cmd);
if (err < 0 || !strstr(response_buffer, "#XPING: 1")) { // #XPING: 1 indicates a successful ping
LOG_ERR("Failed to ping server: %s, response: %s, err: %d", server_addr, response_buffer, err);
LOG_ERR("ERR Info (ERR: %d, ERR TYPE: %d)\n", nrf_modem_at_err(err), nrf_modem_at_err_type(err));
k_free(response_buffer);
return -1;
}
LOG_INF("Ping to %s successful: %s", server_addr, response_buffer);
k_free(response_buffer);
return 0;
}
-----------
void func (void) {
int pg_status = 0,
pg_status = ping_server(PING_SERVER);
........
.....
}
Error is below,
[00:00:06.873,565] <err> Lesson4_Exercise1: Failed to ping server: 8.8.8.8, response: ERROR
, err: 65536
[00:00:06.873,565] <err> Lesson4_Exercise1: ERR Info (ERR: 0, ERR TYPE: 1)