From 6a4b3ef0e72ee134b81a523ce41fd4c45f3b4429 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 4 Sep 2022 18:43:50 +0200 Subject: fixed wifi and cell --- fw/esp32/components/eos/cell_voice.c | 38 ++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'fw/esp32/components/eos/cell_voice.c') diff --git a/fw/esp32/components/eos/cell_voice.c b/fw/esp32/components/eos/cell_voice.c index c0b9a7d..89233f0 100644 --- a/fw/esp32/components/eos/cell_voice.c +++ b/fw/esp32/components/eos/cell_voice.c @@ -2,6 +2,9 @@ #include #include +#include +#include + #include #include @@ -16,8 +19,10 @@ static int cmd_len; void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len) { int rv; + buffer++; + buf_len--; switch (mtype) { - case EOS_CELL_MTYPE_VOICE_DIAL: + case EOS_CELL_MTYPE_VOICE_DIAL: { if (buf_len > EOS_CELL_MAX_DIAL_STR) return; buffer[buf_len] = '\0'; @@ -33,19 +38,21 @@ void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t eos_modem_give(); eos_cell_pcm_start(); break; + } - case EOS_CELL_MTYPE_VOICE_ANSWER: + case EOS_CELL_MTYPE_VOICE_ANSWER: { rv = eos_modem_take(1000); if (rv) return; at_cmd("ATA\r"); - rv = at_expect("^OK", "^ERROR", 1000); + rv = at_expect("^OK", "^NO CARRIER", 1000); eos_modem_give(); eos_cell_pcm_start(); break; + } - case EOS_CELL_MTYPE_VOICE_HANGUP: + case EOS_CELL_MTYPE_VOICE_HANGUP: { eos_cell_pcm_stop(); rv = eos_modem_take(1000); @@ -56,10 +63,12 @@ void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t eos_modem_give(); break; + } - case EOS_CELL_MTYPE_VOICE_PCM: + case EOS_CELL_MTYPE_VOICE_PCM: { eos_cell_pcm_push(buffer, buf_len); break; + } } } @@ -74,7 +83,7 @@ static void ring_handler(char *urc, regmatch_t m[]) { buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_RING; len = 1; rv = at_expect_match("^\\+CLIP: \"(\\+?[0-9]+)\"", NULL, &ring_buf, match, 2, REG_EXTENDED, 1000); - if (rv == 1) { + if (!rv) { ring_buf[match[1].rm_eo] = '\0'; strcpy((char *)buf + 1, ring_buf + match[1].rm_so); len += 1 + match[1].rm_eo - match[1].rm_so; @@ -88,6 +97,23 @@ static void call_begin_handler(char *urc, regmatch_t m[]) { 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); + + at_cmd("AT+CECDT=0x0000\r"); + at_expect("^OK", "^ERROR", 1000); + + at_cmd("AT+CECWB=0x0000\r"); + at_expect("^OK", "^ERROR", 1000); + + at_cmd("AT+CNSLIM=0x0000\r"); + at_expect("^OK", "^ERROR", 1000); + /* + at_cmd("AT+CECRX=0\r"); + at_expect("^OK", "^ERROR", 1000); + */ } static void call_end_handler(char *urc, regmatch_t m[]) { -- cgit v1.2.3