diff options
author | Uros Majstorovic <majstor@majstor.org> | 2022-03-30 13:22:57 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2022-03-30 13:22:57 +0200 |
commit | 55474b81146327e8cfa7702fa9366cc7da6562e7 (patch) | |
tree | b6bf9fe0258ab88d12717bb31ecdf4eda0ffa073 /fw/esp32/components/eos/cell_voice.c | |
parent | c6962c5700f99441538dafa346626bb7e6d12488 (diff) |
sock api fixed; net reply messages fixed
Diffstat (limited to 'fw/esp32/components/eos/cell_voice.c')
-rw-r--r-- | fw/esp32/components/eos/cell_voice.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/fw/esp32/components/eos/cell_voice.c b/fw/esp32/components/eos/cell_voice.c index f0655bd..c0b9a7d 100644 --- a/fw/esp32/components/eos/cell_voice.c +++ b/fw/esp32/components/eos/cell_voice.c @@ -10,40 +10,38 @@ #include "at_cmd.h" #include "cell.h" -static const char *TAG = "EOS VOICE"; - static char cmd[256]; static int cmd_len; -void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t size) { +void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len) { int rv; - buffer += 1; - size -= 1; switch (mtype) { case EOS_CELL_MTYPE_VOICE_DIAL: - if (size == 0) return; + if (buf_len > EOS_CELL_MAX_DIAL_STR) return; - buffer[size] = '\0'; + buffer[buf_len] = '\0'; cmd_len = snprintf(cmd, sizeof(cmd), "ATD%s;\r", buffer); if ((cmd_len < 0) || (cmd_len >= sizeof(cmd))) return; rv = eos_modem_take(1000); if (rv) return; + at_cmd(cmd); rv = at_expect("^OK", "^ERROR", 1000); - eos_modem_give(); + eos_modem_give(); eos_cell_pcm_start(); break; case EOS_CELL_MTYPE_VOICE_ANSWER: rv = eos_modem_take(1000); if (rv) return; + at_cmd("ATA\r"); rv = at_expect("^OK", "^ERROR", 1000); - eos_modem_give(); + eos_modem_give(); eos_cell_pcm_start(); break; @@ -52,14 +50,15 @@ void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t rv = eos_modem_take(1000); if (rv) return; + at_cmd("AT+CHUP\r"); rv = at_expect("^OK", "^ERROR", 1000); - eos_modem_give(); + eos_modem_give(); break; case EOS_CELL_MTYPE_VOICE_PCM: - eos_cell_pcm_push(buffer+1, size-1); + eos_cell_pcm_push(buffer, buf_len); break; } } |