summaryrefslogtreecommitdiff
path: root/fw/esp32/components/eos/cell_voice.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/esp32/components/eos/cell_voice.c')
-rw-r--r--fw/esp32/components/eos/cell_voice.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/fw/esp32/components/eos/cell_voice.c b/fw/esp32/components/eos/cell_voice.c
index 7a9b823..2a7bb18 100644
--- a/fw/esp32/components/eos/cell_voice.c
+++ b/fw/esp32/components/eos/cell_voice.c
@@ -13,8 +13,7 @@
#include "at_cmd.h"
#include "cell.h"
-static char cmd[256];
-static int cmd_len;
+extern char *at_cmd_buf;
void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len) {
int rv;
@@ -23,17 +22,17 @@ void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t
buf_len--;
switch (mtype) {
case EOS_CELL_MTYPE_VOICE_DIAL: {
- if (buf_len > EOS_CELL_MAX_DIAL_STR) return;
+ if (buf_len > EOS_CELL_SIZE_PHNUM) return;
buffer[buf_len] = '\0';
- cmd_len = snprintf(cmd, sizeof(cmd), "ATD%s;\r", buffer);
- if ((cmd_len < 0) || (cmd_len >= sizeof(cmd))) return;
+ rv = snprintf(at_cmd_buf, AT_SIZE_CMD_BUF, "ATD%s;\r", buffer);
+ if ((rv < 0) || (rv >= AT_SIZE_CMD_BUF)) return;
rv = eos_modem_take(1000);
if (rv) return;
- at_cmd(cmd);
- rv = at_expect("^OK", "^ERROR", 1000);
+ at_cmd(at_cmd_buf);
+ rv = at_expect("^OK", "^(ERROR|\\+CME ERROR: [0-9]+)", 1000);
eos_modem_give();
eos_cell_pcm_start();
@@ -45,7 +44,7 @@ void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t
if (rv) return;
at_cmd("ATA\r");
- rv = at_expect("^OK", "^NO CARRIER", 1000);
+ // Response will be picked up by urc handler
eos_modem_give();
eos_cell_pcm_start();
@@ -59,7 +58,7 @@ void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t
if (rv) return;
at_cmd("AT+CHUP\r");
- rv = at_expect("^OK", "^ERROR", 1000);
+ // Response will be picked up by urc handler
eos_modem_give();
break;
@@ -87,7 +86,7 @@ static void ring_handler(char *urc, regmatch_t m[]) {
regoff_t num_len;
num_len = match[1].rm_eo - match[1].rm_so;
- if (num_len > EOS_CELL_MAX_DIAL_STR) {
+ if (num_len > EOS_CELL_SIZE_PHNUM) {
eos_net_free(buf);
return;
}
@@ -124,10 +123,6 @@ static void miss_handler(char *urc, regmatch_t m[]) {
static void call_begin_handler(char *urc, regmatch_t m[]) {
unsigned char *buf;
- buf = eos_net_alloc();
- buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_BEGIN;
- eos_net_send(EOS_NET_MTYPE_CELL, buf, 1);
-
vTaskDelay(100 / portTICK_PERIOD_MS);
at_cmd("AT+CECH=0x0000\r");
at_expect("^OK", "^ERROR", 1000);
@@ -144,6 +139,10 @@ static void call_begin_handler(char *urc, regmatch_t m[]) {
at_cmd("AT+CECRX=0\r");
at_expect("^OK", "^ERROR", 1000);
*/
+
+ buf = eos_net_alloc();
+ buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_BEGIN;
+ eos_net_send(EOS_NET_MTYPE_CELL, buf, 1);
}
static void call_end_handler(char *urc, regmatch_t m[]) {