From 9da5f8409c85637361d7bc69b721f6d9d3087b7b Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 4 Sep 2024 21:07:29 +0200 Subject: esp32 cellular modem driver fix --- fw/esp32/components/eos/include/at_cmd.h | 1 + fw/esp32/components/eos/include/cell.h | 19 ++++++++++------ fw/esp32/components/eos/include/eos.h | 10 ++++++--- fw/esp32/components/eos/include/gsm.h | 37 +++++++++++++++++++------------- 4 files changed, 42 insertions(+), 25 deletions(-) (limited to 'fw/esp32/components/eos/include') diff --git a/fw/esp32/components/eos/include/at_cmd.h b/fw/esp32/components/eos/include/at_cmd.h index 2d0813e..9dd355b 100644 --- a/fw/esp32/components/eos/include/at_cmd.h +++ b/fw/esp32/components/eos/include/at_cmd.h @@ -6,6 +6,7 @@ #define AT_SIZE_PATTERN 64 #define AT_SIZE_URC_LIST 32 +#define AT_SIZE_CMD_BUF 256 typedef void (*at_urc_cb_t) (char *, regmatch_t[]); diff --git a/fw/esp32/components/eos/include/cell.h b/fw/esp32/components/eos/include/cell.h index af2dda8..cb9f49c 100644 --- a/fw/esp32/components/eos/include/cell.h +++ b/fw/esp32/components/eos/include/cell.h @@ -55,19 +55,24 @@ #define EOS_CELL_SMS_ADDRTYPE_ALPHA 2 #define EOS_CELL_SMS_ADDRTYPE_OTHER 3 -#define EOS_CELL_PDP_SIZE_APN 64 -#define EOS_CELL_PDP_SIZE_USR 64 -#define EOS_CELL_PDP_SIZE_PWD 64 -#define EOS_CELL_PDP_SIZE_ARG 64 +#define EOS_CELL_SIZE_PHNUM 16 + +#define EOS_CELL_SMS_SIZE_ADDR 20 +#define EOS_CELL_SMS_SIZE_TS 25 +#define EOS_CELL_SMS_SIZE_TXT 160 + +#define EOS_CELL_USSD_SIZE_REQ 128 + +#define EOS_CELL_PDP_SIZE_APN 63 +#define EOS_CELL_PDP_SIZE_USR 63 +#define EOS_CELL_PDP_SIZE_PWD 63 +#define EOS_CELL_PDP_SIZE_ARG 63 #define EOS_CELL_UART_MODE_NONE 0 #define EOS_CELL_UART_MODE_ATCMD 1 #define EOS_CELL_UART_MODE_PPP 2 #define EOS_CELL_UART_MODE_RELAY 3 -#define EOS_CELL_MAX_USSD_STR 128 -#define EOS_CELL_MAX_DIAL_STR 16 - #define EOS_CELL_UART_SIZE_BUF 1024 void eos_cell_init(void); diff --git a/fw/esp32/components/eos/include/eos.h b/fw/esp32/components/eos/include/eos.h index 6f420ea..bc9dc51 100644 --- a/fw/esp32/components/eos/include/eos.h +++ b/fw/esp32/components/eos/include/eos.h @@ -3,9 +3,13 @@ #define EOS_ERR_TIMEOUT -2 #define EOS_ERR_BUSY -3 -#define EOS_ERR_FULL -10 -#define EOS_ERR_EMPTY -11 -#define EOS_ERR_NOTFOUND -12 +#define EOS_ERR_SIZE -10 +#define EOS_ERR_FULL -11 +#define EOS_ERR_EMPTY -12 +#define EOS_ERR_NOTFOUND -13 +#define EOS_ERR_NOTSUPPORTED -14 + +#define EOS_ERR_NOMEM -100 #define EOS_TASK_PRIORITY_NET_XCHG 1 #define EOS_TASK_PRIORITY_APP_XCHG 1 diff --git a/fw/esp32/components/eos/include/gsm.h b/fw/esp32/components/eos/include/gsm.h index 7864b09..eb893d6 100644 --- a/fw/esp32/components/eos/include/gsm.h +++ b/fw/esp32/components/eos/include/gsm.h @@ -1,12 +1,14 @@ +#include +#include + #define GSM_OK 0 #define GSM_ERR -1 #define GSM_ERR_SIZE -10 -#define GSM_ERR_NOT_SUPPORTED -11 +#define GSM_ERR_NOTSUPPORTED -11 #define GSM_TS_SIZE 25 #define GSM_UD_SIZE 160 #define GSM_UDH_SIZE 140 -#define GSM_MSG_SIZE GSM_UD_SIZE #define GSM_ADDR_SIZE 20 /* Message-Type-Indicator */ @@ -124,16 +126,21 @@ #define GSM_FLAG_MWI_OTHER 0x3000 #define GSM_FLAG_MWI_MASK 0xf000 -uint8_t pdu_getc(char *pdu); -void pdu_putc(uint8_t ch, char *pdu); -void pdu_gets(char *pdu, uint8_t *s, int s_len); -void pdu_puts(uint8_t *s, int s_len, char *pdu); -int gsm_ucs2_to_7bit(uint16_t ucs2, char *gsm7, int gsm7_size); -int gsm_7bit_to_ucs2(char *gsm7, int gsm7_len, uint16_t *ucs2); - -int gsm_7bit_enc(char *text, int text_len, char *pdu, int padb); -int gsm_7bit_dec(char *pdu, char *text, int text_len, int padb); -int gsm_addr_enc(char *addr, int addr_len, uint8_t addr_type, char *pdu, int pdu_size); -int gsm_addr_dec(char *pdu, int pdu_len, char *addr, int *addr_len, uint8_t *addr_type); -int gsm_sms_enc(char *addr, int addr_len, uint8_t addr_type, uint8_t *udh, int udh_len, uint8_t *msg, int msg_len, uint8_t enc, uint16_t flags, char *pdu, int pdu_size); -int gsm_sms_dec(char *pdu, int pdu_len, char *addr, int *addr_len, uint8_t *addr_type, uint8_t *udh, int *udh_len, uint8_t *msg, int *msg_len, char *ts, uint8_t *enc, uint16_t *flags); +size_t pdu_putc(char *pdu, uint8_t ch); +ssize_t pdu_getc(char *pdu, uint8_t *ch); +size_t pdu_puts(char *pdu, uint8_t *s, size_t s_len); +ssize_t pdu_gets(char *pdu, uint8_t *s, size_t s_len); +size_t pdu_7bit_enc(char *pdu, char *text, size_t text_len, int padb); +ssize_t pdu_7bit_dec(char *pdu, char *text, size_t text_len, int padb); + +void gsm_dcs_enc(uint8_t enc, uint16_t flags, uint8_t *dcs); +void gsm_dcs_dec(uint8_t dcs, uint8_t *enc, uint16_t *flags); +ssize_t gsm_ts_enc(char *pdu, size_t pdu_size, char *ts); +ssize_t gsm_ts_dec(char *pdu, size_t pdu_len, char *ts); +int gsm_addr_enc(char *pdu, size_t pdu_size, char *addr, size_t addr_len, uint8_t addr_type); +int gsm_addr_dec(char *pdu, size_t pdu_len, char *addr, size_t *addr_len, uint8_t *addr_type); +int gsm_sms_enc(char *pdu, size_t pdu_size, char *addr, size_t addr_len, uint8_t addr_type, uint8_t *udh, size_t udh_len, uint8_t *txt, size_t txt_len, uint8_t enc, uint16_t flags); +int gsm_sms_dec(char *pdu, size_t pdu_len, char *addr, size_t *addr_len, uint8_t *addr_type, uint8_t *udh, size_t *udh_len, uint8_t *txt, size_t *txt_len, uint8_t *enc, char *ts, uint16_t *flags); + +int gsm_ucs2_to_7bit(char *gsm7, size_t gsm7_size, uint16_t ucs2); +int gsm_7bit_to_ucs2(char *gsm7, size_t gsm7_len, uint16_t *ucs2); -- cgit v1.2.3