From ba38183139e19d5e07a4f30822eb285dde9bd7ca Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 5 Aug 2020 03:08:22 +0200 Subject: cell urc buffer handling fixed; added sms/ussd/voice/data stubs --- code/esp32/components/eos/include/_net.h | 1 + code/esp32/components/eos/include/at_cmd.h | 3 +- code/esp32/components/eos/include/cell.h | 53 +++++++++++++++++++++--------- 3 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 code/esp32/components/eos/include/_net.h (limited to 'code/esp32/components/eos/include') diff --git a/code/esp32/components/eos/include/_net.h b/code/esp32/components/eos/include/_net.h new file mode 100644 index 0000000..35b5308 --- /dev/null +++ b/code/esp32/components/eos/include/_net.h @@ -0,0 +1 @@ +#include "net.h" \ No newline at end of file diff --git a/code/esp32/components/eos/include/at_cmd.h b/code/esp32/components/eos/include/at_cmd.h index ca46e23..615a1c1 100644 --- a/code/esp32/components/eos/include/at_cmd.h +++ b/code/esp32/components/eos/include/at_cmd.h @@ -16,4 +16,5 @@ void at_init(void); int at_urc_process(char *urc); int at_urc_insert(char *pattern, at_urc_cb_t cb, int flags); int at_urc_delete(char *pattern); -int at_expect(char *str_ok, char *str_err, uint32_t timeout); \ No newline at end of file +void at_cmd(char *cmd); +int at_expect(char *str_ok, char *str_err, uint32_t timeout); diff --git a/code/esp32/components/eos/include/cell.h b/code/esp32/components/eos/include/cell.h index 23adecf..3bf6b32 100644 --- a/code/esp32/components/eos/include/cell.h +++ b/code/esp32/components/eos/include/cell.h @@ -1,47 +1,68 @@ #include +#include + +#define EOS_CELL_MTYPE_DEV 0x00 +#define EOS_CELL_MTYPE_VOICE 0x10 +#define EOS_CELL_MTYPE_SMS 0x20 +#define EOS_CELL_MTYPE_CBS 0x30 +#define EOS_CELL_MTYPE_USSD 0x40 +#define EOS_CELL_MTYPE_DATA 0x70 + +#define EOS_CELL_MTYPE_MASK 0xf0 +#define EOS_CELL_MAX_MTYPE 8 #define EOS_CELL_MTYPE_READY 0 -#define EOS_CELL_MTYPE_DATA 1 -#define EOS_CELL_MTYPE_AUDIO 2 +#define EOS_CELL_MTYPE_UART_DATA 1 +#define EOS_CELL_MTYPE_UART_TAKE 2 +#define EOS_CELL_MTYPE_UART_GIVE 3 +#define EOS_CELL_MTYPE_PCM_DATA 4 +#define EOS_CELL_MTYPE_PCM_START 5 +#define EOS_CELL_MTYPE_PCM_STOP 6 -#define EOS_CELL_MTYPE_DATA_START 4 -#define EOS_CELL_MTYPE_DATA_STOP 5 +#define EOS_CELL_MTYPE_VOICE_DIAL 1 +#define EOS_CELL_MTYPE_VOICE_RING 2 +#define EOS_CELL_MTYPE_VOICE_ANSWER 3 +#define EOS_CELL_MTYPE_VOICE_HANGUP 4 +#define EOS_CELL_MTYPE_VOICE_BEGIN 5 +#define EOS_CELL_MTYPE_VOICE_END 6 -#define EOS_CELL_MTYPE_AUDIO_START 6 -#define EOS_CELL_MTYPE_AUDIO_STOP 7 +#define EOS_CELL_MTYPE_USSD_REQUEST 1 +#define EOS_CELL_MTYPE_USSD_REPLY 2 #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 -void eos_pcm_init(void); +#define EOS_CELL_UART_SIZE_BUF 128 -ssize_t eos_pcm_read(unsigned char *data, size_t size); -int eos_pcm_push(unsigned char *data, size_t size); -void eos_pcm_start(void); -void eos_pcm_stop(void); +void eos_cell_init(void); void eos_modem_init(void); - void eos_modem_flush(void); size_t eos_modem_write(void *data, size_t size); size_t eos_modem_read(void *data, size_t size, uint32_t timeout); int eos_modem_readln(char *buf, size_t buf_size, uint32_t timeout); int eos_modem_resp(char *ok_str, char *err_str, uint32_t timeout); - uint8_t eos_modem_get_mode(void); int eos_modem_set_mode(uint8_t mode); int eos_modem_take(uint32_t timeout); void eos_modem_give(void); - void eos_modem_sleep(uint8_t mode); void eos_modem_wake(uint8_t source, uint8_t mode); void eos_ppp_set_apn(char *apn); void eos_ppp_set_auth(char *user, char *pass); - int eos_ppp_connect(void); int eos_ppp_disconnect(void); -void eos_cell_init(void); +void eos_cell_pcm_init(void); +ssize_t eos_cell_pcm_read(unsigned char *data, size_t size); +int eos_cell_pcm_push(unsigned char *data, size_t size); +void eos_cell_pcm_start(void); +void eos_cell_pcm_stop(void); + +void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t size); +void eos_cell_sms_handler(unsigned char mtype, unsigned char *buffer, uint16_t size); +void eos_cell_ussd_handler(unsigned char mtype, unsigned char *buffer, uint16_t size); +void eos_cell_data_handler(unsigned char mtype, unsigned char *buffer, uint16_t size); -- cgit v1.2.3