diff options
author | Uros Majstorovic <majstor@majstor.org> | 2022-10-24 19:59:27 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2022-10-24 19:59:27 +0200 |
commit | b74b1c08b76e448df27b6fff50cca6fed3e4e7a7 (patch) | |
tree | 763f116e381e1b7442dbee63cafa9a14cdd8a7da /fw/esp32/components/eos/cell_voice.c | |
parent | a5a94dea7043fa6b65693cf0cc11d426d49c637d (diff) |
fixed cell voice and sms driver
Diffstat (limited to 'fw/esp32/components/eos/cell_voice.c')
-rw-r--r-- | fw/esp32/components/eos/cell_voice.c | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/fw/esp32/components/eos/cell_voice.c b/fw/esp32/components/eos/cell_voice.c index 89233f0..7a9b823 100644 --- a/fw/esp32/components/eos/cell_voice.c +++ b/fw/esp32/components/eos/cell_voice.c @@ -84,13 +84,43 @@ static void ring_handler(char *urc, regmatch_t m[]) { len = 1; rv = at_expect_match("^\\+CLIP: \"(\\+?[0-9]+)\"", NULL, &ring_buf, match, 2, REG_EXTENDED, 1000); 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; + regoff_t num_len; + + num_len = match[1].rm_eo - match[1].rm_so; + if (num_len > EOS_CELL_MAX_DIAL_STR) { + eos_net_free(buf); + return; + } + memcpy(buf + 1, ring_buf + match[1].rm_so, num_len); + len += num_len; } eos_net_send(EOS_NET_MTYPE_CELL, buf, len); } +static void busy_handler(char *urc, regmatch_t m[]) { + unsigned char *buf; + uint16_t len; + + eos_cell_pcm_stop(); + + buf = eos_net_alloc(); + buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_BUSY; + len = 1; + eos_net_send(EOS_NET_MTYPE_CELL, buf, len); +} + +static void miss_handler(char *urc, regmatch_t m[]) { + unsigned char *buf; + uint16_t len; + + eos_cell_pcm_stop(); + + buf = eos_net_alloc(); + buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_MISS; + len = 1; + eos_net_send(EOS_NET_MTYPE_CELL, buf, len); +} + static void call_begin_handler(char *urc, regmatch_t m[]) { unsigned char *buf; @@ -132,23 +162,11 @@ static void call_end_handler(char *urc, regmatch_t m[]) { eos_net_send(EOS_NET_MTYPE_CELL, buf, 5); } -static void call_missed_handler(char *urc, regmatch_t m[]) { - unsigned char *buf; - uint16_t len; - - eos_cell_pcm_stop(); - - buf = eos_net_alloc(); - buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_MISS; - urc[m[1].rm_eo] = '\0'; - strcpy((char *)buf + 1, urc + m[1].rm_so); - len = 2 + m[1].rm_eo - m[1].rm_so; - eos_net_send(EOS_NET_MTYPE_CELL, buf, len); -} - void eos_cell_voice_init(void) { at_urc_insert("^RING", ring_handler, REG_EXTENDED); + at_urc_insert("^BUSY", busy_handler, REG_EXTENDED); + at_urc_insert("^NO CARRIER", miss_handler, REG_EXTENDED); + at_urc_insert("^MISSED.CALL: [^ ]+ (\\+?[0-9]+)$", miss_handler, REG_EXTENDED); at_urc_insert("^VOICE CALL: BEGIN", call_begin_handler, REG_EXTENDED); at_urc_insert("^VOICE CALL: END: ([0-9]{6}$)$", call_end_handler, REG_EXTENDED); - at_urc_insert("^MISSED.CALL: [^ ]+ (\\+?[0-9]+)$", call_missed_handler, REG_EXTENDED); }
\ No newline at end of file |