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.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/fw/esp32/components/eos/cell_voice.c b/fw/esp32/components/eos/cell_voice.c
index 2a7bb18..273b402 100644
--- a/fw/esp32/components/eos/cell_voice.c
+++ b/fw/esp32/components/eos/cell_voice.c
@@ -13,6 +13,8 @@
#include "at_cmd.h"
#include "cell.h"
+static const char *TAG = "EOS CELL VOICE";
+
extern char *at_cmd_buf;
void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len) {
@@ -93,35 +95,41 @@ static void ring_handler(char *urc, regmatch_t m[]) {
memcpy(buf + 1, ring_buf + match[1].rm_so, num_len);
len += num_len;
}
- eos_net_send(EOS_NET_MTYPE_CELL, buf, len);
+ rv = eos_net_send(EOS_NET_MTYPE_CELL, buf, len);
+ if (rv) ESP_LOGE(TAG, "NET SEND ERR:%d", rv);
}
static void busy_handler(char *urc, regmatch_t m[]) {
unsigned char *buf;
uint16_t len;
+ int rv;
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);
+ rv = eos_net_send(EOS_NET_MTYPE_CELL, buf, len);
+ if (rv) ESP_LOGE(TAG, "NET SEND ERR:%d", rv);
}
static void miss_handler(char *urc, regmatch_t m[]) {
unsigned char *buf;
uint16_t len;
+ int rv;
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);
+ rv = eos_net_send(EOS_NET_MTYPE_CELL, buf, len);
+ if (rv) ESP_LOGE(TAG, "NET SEND ERR:%d", rv);
}
static void call_begin_handler(char *urc, regmatch_t m[]) {
unsigned char *buf;
+ int rv;
vTaskDelay(100 / portTICK_PERIOD_MS);
at_cmd("AT+CECH=0x0000\r");
@@ -142,12 +150,14 @@ 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);
+ rv = eos_net_send(EOS_NET_MTYPE_CELL, buf, 1);
+ if (rv) ESP_LOGE(TAG, "NET SEND ERR:%d", rv);
}
static void call_end_handler(char *urc, regmatch_t m[]) {
unsigned char *buf;
int duration = 0;
+ int rv;
eos_cell_pcm_stop();
@@ -158,14 +168,29 @@ static void call_end_handler(char *urc, regmatch_t m[]) {
buf[2] = duration >> 16;
buf[3] = duration >> 8;
buf[4] = duration;
- eos_net_send(EOS_NET_MTYPE_CELL, buf, 5);
+ rv = eos_net_send(EOS_NET_MTYPE_CELL, buf, 5);
+ if (rv) ESP_LOGE(TAG, "NET SEND ERR:%d", rv);
}
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);
-} \ No newline at end of file
+ int rv;
+
+ rv = at_urc_insert("^RING", ring_handler, REG_EXTENDED);
+ assert(rv == EOS_OK);
+
+ rv = at_urc_insert("^BUSY", busy_handler, REG_EXTENDED);
+ assert(rv == EOS_OK);
+
+ rv = at_urc_insert("^NO CARRIER", miss_handler, REG_EXTENDED);
+ assert(rv == EOS_OK);
+
+ rv = at_urc_insert("^MISSED.CALL: [^ ]+ (\\+?[0-9]+)$", miss_handler, REG_EXTENDED);
+ assert(rv == EOS_OK);
+
+ rv = at_urc_insert("^VOICE CALL: BEGIN", call_begin_handler, REG_EXTENDED);
+ assert(rv == EOS_OK);
+
+ rv = at_urc_insert("^VOICE CALL: END: ([0-9]{6}$)$", call_end_handler, REG_EXTENDED);
+ assert(rv == EOS_OK);
+
+}