summaryrefslogtreecommitdiff
path: root/fw/esp32/components/eos/cell_ussd.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-03-30 13:22:57 +0200
committerUros Majstorovic <majstor@majstor.org>2022-03-30 13:22:57 +0200
commit55474b81146327e8cfa7702fa9366cc7da6562e7 (patch)
treeb6bf9fe0258ab88d12717bb31ecdf4eda0ffa073 /fw/esp32/components/eos/cell_ussd.c
parentc6962c5700f99441538dafa346626bb7e6d12488 (diff)
sock api fixed; net reply messages fixed
Diffstat (limited to 'fw/esp32/components/eos/cell_ussd.c')
-rw-r--r--fw/esp32/components/eos/cell_ussd.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/fw/esp32/components/eos/cell_ussd.c b/fw/esp32/components/eos/cell_ussd.c
index 195feaf..5b90e35 100644
--- a/fw/esp32/components/eos/cell_ussd.c
+++ b/fw/esp32/components/eos/cell_ussd.c
@@ -14,16 +14,14 @@ static const char *TAG = "EOS USSD";
static char cmd[256];
static int cmd_len;
-void eos_cell_ussd_handler(unsigned char mtype, unsigned char *buffer, uint16_t size) {
+void eos_cell_ussd_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len) {
int rv;
- buffer += 1;
- size -= 1;
switch (mtype) {
case EOS_CELL_MTYPE_USSD_REQUEST:
- if (size == 0) return;
+ if (buf_len > EOS_CELL_MAX_USSD_STR) return;
- buffer[size] = '\0';
+ buffer[buf_len] = '\0';
cmd_len = snprintf(cmd, sizeof(cmd), "AT+CUSD=1,\"%s\",15\r", buffer);
if ((cmd_len < 0) || (cmd_len >= sizeof(cmd))) return;
@@ -89,7 +87,7 @@ static void ussd_reply_handler(char *urc, regmatch_t m[]) {
} while (1);
if (rv) {
- ESP_LOGE(TAG, "USSD error");
+ ESP_LOGE(TAG, "error");
eos_net_free(buf);
} else {
eos_net_send(EOS_NET_MTYPE_CELL, buf, len);