From 5d157b4f7ecea4793c9da5c33a890d4ea4afc545 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 17 May 2020 04:03:16 +0200 Subject: power management implemented; net protocol change --- code/esp32/components/eos/include/at_cmd.h | 19 +++++++++++++++++++ code/esp32/components/eos/include/at_urc.h | 17 ----------------- code/esp32/components/eos/include/cell.h | 17 +++++++++-------- code/esp32/components/eos/include/eos.h | 9 +++++---- code/esp32/components/eos/include/net.h | 13 +++++++++---- code/esp32/components/eos/include/power.h | 13 +++++++++++++ 6 files changed, 55 insertions(+), 33 deletions(-) create mode 100644 code/esp32/components/eos/include/at_cmd.h delete mode 100644 code/esp32/components/eos/include/at_urc.h create mode 100644 code/esp32/components/eos/include/power.h (limited to 'code/esp32/components/eos/include') diff --git a/code/esp32/components/eos/include/at_cmd.h b/code/esp32/components/eos/include/at_cmd.h new file mode 100644 index 0000000..ca46e23 --- /dev/null +++ b/code/esp32/components/eos/include/at_cmd.h @@ -0,0 +1,19 @@ +#include +#include +#include + +#define AT_SIZE_NMATCH 4 +#define AT_SIZE_PATTERN 64 + +#define AT_SIZE_URC_LIST 16 + +#define AT_URC_OK 0 +#define AT_URC_MORE 1 + +typedef int (*at_urc_cb_t) (char *, regmatch_t[]); + +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 diff --git a/code/esp32/components/eos/include/at_urc.h b/code/esp32/components/eos/include/at_urc.h deleted file mode 100644 index 9a4c641..0000000 --- a/code/esp32/components/eos/include/at_urc.h +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include - -#define AT_SIZE_NMATCH 4 -#define AT_SIZE_PATTERN 64 - -#define AT_SIZE_URC_LIST 16 - -#define AT_URC_OK 0 -#define AT_URC_MORE 1 - -typedef int (*at_urc_cb_t) (char *, regmatch_t[]); - -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); \ No newline at end of file diff --git a/code/esp32/components/eos/include/cell.h b/code/esp32/components/eos/include/cell.h index 3a9e955..17847ce 100644 --- a/code/esp32/components/eos/include/cell.h +++ b/code/esp32/components/eos/include/cell.h @@ -1,13 +1,14 @@ #include -#define EOS_CELL_MTYPE_DATA 0 -#define EOS_CELL_MTYPE_AUDIO 1 +#define EOS_CELL_MTYPE_READY 0 +#define EOS_CELL_MTYPE_DATA 1 +#define EOS_CELL_MTYPE_AUDIO 2 -#define EOS_CELL_MTYPE_DATA_START 2 -#define EOS_CELL_MTYPE_DATA_STOP 3 +#define EOS_CELL_MTYPE_DATA_START 4 +#define EOS_CELL_MTYPE_DATA_STOP 5 -#define EOS_CELL_MTYPE_AUDIO_START 4 -#define EOS_CELL_MTYPE_AUDIO_STOP 5 +#define EOS_CELL_MTYPE_AUDIO_START 6 +#define EOS_CELL_MTYPE_AUDIO_STOP 7 #define EOS_CELL_UART_MODE_NONE 0 #define EOS_CELL_UART_MODE_ATCMD 1 @@ -31,11 +32,11 @@ 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(void); +int eos_modem_take(uint32_t timeout); void eos_modem_give(void); void eos_modem_sleep(void); -void eos_modem_wake(void); +void eos_modem_wake(uint8_t source); void eos_ppp_set_apn(char *apn); void eos_ppp_set_auth(char *user, char *pass); diff --git a/code/esp32/components/eos/include/eos.h b/code/esp32/components/eos/include/eos.h index 87ac9f3..0e660fb 100644 --- a/code/esp32/components/eos/include/eos.h +++ b/code/esp32/components/eos/include/eos.h @@ -1,22 +1,23 @@ #define EOS_OK 0 #define EOS_ERR -1 #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_BUSY -13 #define EOS_TASK_PRIORITY_UART 1 -#define EOS_TASK_PRIORITY_UART_RI 1 +#define EOS_TASK_PRIORITY_MODEM 1 #define EOS_TASK_PRIORITY_I2S 1 #define EOS_TASK_PRIORITY_NET_XCHG 1 #define EOS_TASK_PRIORITY_UDP_RCVR 1 +#define EOS_TASK_PRIORITY_PWR 1 #define EOS_TASK_SSIZE_UART 4096 -#define EOS_TASK_SSIZE_UART_RI 4096 +#define EOS_TASK_SSIZE_MODEM 4096 #define EOS_TASK_SSIZE_I2S 4096 #define EOS_TASK_SSIZE_NET_XCHG 8192 #define EOS_TASK_SSIZE_UDP_RCVR 4096 - +#define EOS_TASK_SSIZE_PWR 4096 diff --git a/code/esp32/components/eos/include/net.h b/code/esp32/components/eos/include/net.h index df1bd0d..818776e 100644 --- a/code/esp32/components/eos/include/net.h +++ b/code/esp32/components/eos/include/net.h @@ -1,7 +1,10 @@ #include +/* common */ +#define EOS_NET_SIZE_BUF 1500 + #define EOS_NET_MTYPE_SOCK 1 -#define EOS_NET_MTYPE_AUDIO 2 +#define EOS_NET_MTYPE_POWER 4 #define EOS_NET_MTYPE_WIFI 5 #define EOS_NET_MTYPE_CELL 6 @@ -10,9 +13,9 @@ #define EOS_NET_MAX_MTYPE 8 -#define EOS_NET_MTYPE_FLAG_ONEW 0x10 +#define EOS_NET_MTYPE_FLAG_ONEW 0x80 -#define EOS_NET_SIZE_BUF 1500 +/* esp32 specific */ #define EOS_NET_SIZE_BUFQ 4 #define EOS_NET_SIZE_SNDQ 4 @@ -25,4 +28,6 @@ void eos_net_init(void); unsigned char *eos_net_alloc(void); void eos_net_free(unsigned char *buf); int eos_net_send(unsigned char mtype, unsigned char *buffer, uint16_t len, uint8_t flags); -void eos_net_set_handler(unsigned char mtype, eos_net_fptr_t handler); \ No newline at end of file +void eos_net_set_handler(unsigned char mtype, eos_net_fptr_t handler); +void eos_net_sleep_done(void); +void eos_net_wake(uint8_t source); diff --git a/code/esp32/components/eos/include/power.h b/code/esp32/components/eos/include/power.h new file mode 100644 index 0000000..3f44507 --- /dev/null +++ b/code/esp32/components/eos/include/power.h @@ -0,0 +1,13 @@ +#include + +#define EOS_PWR_MTYPE_BUTTON 0 + +#define EOS_PWR_WAKE_BTN 1 +#define EOS_PWR_WAKE_NET 2 +#define EOS_PWR_WAKE_MSG 3 +#define EOS_PWR_WAKE_UART 4 + +void eos_power_init(void); +void eos_power_sleep(void); +void eos_power_wake(uint8_t source); +void eos_power_1v8rdy(void); \ No newline at end of file -- cgit v1.2.3