diff options
Diffstat (limited to 'fw/esp32/components/eos/include')
| -rw-r--r-- | fw/esp32/components/eos/include/_net.h | 1 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/app.h | 24 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/cell.h | 28 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/eos.h | 24 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/i2c.h | 9 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/msgq.h | 27 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/net.h | 52 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/net_priv.h | 30 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/power.h | 34 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/sock.h | 4 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/tun.h | 4 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/wifi.h | 7 |
12 files changed, 153 insertions, 91 deletions
diff --git a/fw/esp32/components/eos/include/_net.h b/fw/esp32/components/eos/include/_net.h deleted file mode 100644 index 35b5308..0000000 --- a/fw/esp32/components/eos/include/_net.h +++ /dev/null @@ -1 +0,0 @@ -#include "net.h"
\ No newline at end of file diff --git a/fw/esp32/components/eos/include/app.h b/fw/esp32/components/eos/include/app.h index 2033b2b..38fba1a 100644 --- a/fw/esp32/components/eos/include/app.h +++ b/fw/esp32/components/eos/include/app.h @@ -1,23 +1,21 @@ #include <stdint.h> -/* common */ -#define EOS_APP_MTU 1500 -#define EOS_APP_SIZE_BUF EOS_APP_MTU +#include "net.h" #define EOS_APP_MTYPE_TUN 1 #define EOS_APP_MAX_MTYPE 8 -#define EOS_APP_MTYPE_FLAG_MASK 0xc0 +void eos_app_init(void); +void eos_app_run(void); -/* esp32 specific */ -#define EOS_APP_SIZE_BUFQ 4 -#define EOS_APP_SIZE_SNDQ 4 +void eos_app_alloc(EOSMessage *msg); +void eos_app_free(EOSMessage *msg); -typedef void (*eos_app_fptr_t) (unsigned char, unsigned char *, uint16_t); +int eos_app_send(unsigned char mtype, EOSMessage *msg, uint16_t len); -void eos_app_init(void); +void eos_app_sleep_req(void); +void eos_app_wake(void); +void eos_app_deep_sleep(void); +void eos_app_deep_wake(void); -unsigned char *eos_app_alloc(void); -void eos_app_free(unsigned char *buf); -int eos_app_send(unsigned char mtype, unsigned char *buffer, uint16_t len); -void eos_app_set_handler(unsigned char mtype, eos_app_fptr_t handler); +void eos_app_set_handler(unsigned char mtype, eos_net_handler_t handler); diff --git a/fw/esp32/components/eos/include/cell.h b/fw/esp32/components/eos/include/cell.h index cb9f49c..30347c1 100644 --- a/fw/esp32/components/eos/include/cell.h +++ b/fw/esp32/components/eos/include/cell.h @@ -1,6 +1,10 @@ #include <sys/types.h> #include <stdint.h> +#include "net.h" + +#define EOS_CELL_MTU EOS_NET_MTU + #define EOS_CELL_MTYPE_DEV 0x10 #define EOS_CELL_MTYPE_VOICE 0x20 #define EOS_CELL_MTYPE_SMS 0x30 @@ -27,7 +31,6 @@ #define EOS_CELL_MTYPE_VOICE_END 7 #define EOS_CELL_MTYPE_VOICE_MISS 8 #define EOS_CELL_MTYPE_VOICE_BUSY 9 -#define EOS_CELL_MTYPE_VOICE_ERR 10 #define EOS_CELL_MTYPE_SMS_MSG 1 #define EOS_CELL_MTYPE_SMS_LIST 2 @@ -76,24 +79,28 @@ #define EOS_CELL_UART_SIZE_BUF 1024 void eos_cell_init(void); +void eos_cell_run(void); void eos_modem_init(void); +void eos_modem_run(void); int eos_modem_atinit(void); +void eos_modem_reset(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); int eos_modem_present(void); +int eos_modem_initialized(void); uint8_t eos_modem_get_mode(void); size_t eos_modem_get_status(unsigned char *buffer); int eos_modem_set_mode(uint8_t mode); int eos_modem_take(uint32_t timeout); void eos_modem_give(void); -void eos_modem_sleep(void); + +void eos_modem_sleep_req(void); +void eos_modem_wake(void); void eos_modem_deep_sleep(void); -void eos_modem_wake(uint8_t source, uint8_t mode); -int eos_modem_reset(void); +void eos_modem_deep_wake(void); void eos_ppp_get_apn(char *apn); void eos_ppp_set_apn(char *apn); @@ -105,15 +112,14 @@ int eos_ppp_connect(void); void eos_ppp_disconnect(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_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 buf_len); -void eos_cell_sms_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len); -void eos_cell_ussd_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len); -void eos_cell_pdp_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len); +void eos_cell_voice_handler(unsigned char mtype, EOSMessage *msg, uint16_t len); +void eos_cell_sms_handler(unsigned char mtype, EOSMessage *msg, uint16_t len); +void eos_cell_ussd_handler(unsigned char mtype, EOSMessage *msg, uint16_t len); +void eos_cell_pdp_handler(unsigned char mtype, EOSMessage *msg, uint16_t len); void eos_cell_voice_init(void); void eos_cell_sms_init(void); diff --git a/fw/esp32/components/eos/include/eos.h b/fw/esp32/components/eos/include/eos.h index bc9dc51..3f9755d 100644 --- a/fw/esp32/components/eos/include/eos.h +++ b/fw/esp32/components/eos/include/eos.h @@ -11,21 +11,21 @@ #define EOS_ERR_NOMEM -100 -#define EOS_TASK_PRIORITY_NET_XCHG 1 -#define EOS_TASK_PRIORITY_APP_XCHG 1 -#define EOS_TASK_PRIORITY_UDP_RCVR 1 -#define EOS_TASK_PRIORITY_UART 1 -#define EOS_TASK_PRIORITY_MODEM 1 -#define EOS_TASK_PRIORITY_I2S 1 -#define EOS_TASK_PRIORITY_CELL 1 -#define EOS_TASK_PRIORITY_PWR 1 +#define EOS_TASK_PRIORITY_NET 16 +#define EOS_TASK_PRIORITY_APP 17 +#define EOS_TASK_PRIORITY_SOCK 10 +#define EOS_TASK_PRIORITY_UART 10 +#define EOS_TASK_PRIORITY_MODEM 10 +#define EOS_TASK_PRIORITY_PCM 10 +#define EOS_TASK_PRIORITY_CELL 10 +#define EOS_TASK_PRIORITY_PWR 10 -#define EOS_TASK_SSIZE_NET_XCHG 8192 -#define EOS_TASK_SSIZE_APP_XCHG 8192 -#define EOS_TASK_SSIZE_UDP_RCVR 4096 +#define EOS_TASK_SSIZE_NET 8192 +#define EOS_TASK_SSIZE_APP 8192 +#define EOS_TASK_SSIZE_SOCK 4096 #define EOS_TASK_SSIZE_UART 4096 #define EOS_TASK_SSIZE_MODEM 4096 -#define EOS_TASK_SSIZE_I2S 4096 +#define EOS_TASK_SSIZE_PCM 4096 #define EOS_TASK_SSIZE_CELL 4096 #define EOS_TASK_SSIZE_PWR 4096 diff --git a/fw/esp32/components/eos/include/i2c.h b/fw/esp32/components/eos/include/i2c.h deleted file mode 100644 index f014141..0000000 --- a/fw/esp32/components/eos/include/i2c.h +++ /dev/null @@ -1,9 +0,0 @@ -#include <sys/types.h> -#include <stdint.h> - -void eos_i2c_init(void); - -int eos_i2c_read(uint8_t addr, uint8_t reg, uint8_t *data, size_t len); -int eos_i2c_write(uint8_t addr, uint8_t reg, uint8_t *data, size_t len); -int eos_i2c_read8(uint8_t addr, uint8_t reg, uint8_t *data); -int eos_i2c_write8(uint8_t addr, uint8_t reg, uint8_t data); diff --git a/fw/esp32/components/eos/include/msgq.h b/fw/esp32/components/eos/include/msgq.h index bbfe041..2b216d1 100644 --- a/fw/esp32/components/eos/include/msgq.h +++ b/fw/esp32/components/eos/include/msgq.h @@ -1,8 +1,27 @@ #include <stdint.h> +#ifndef _EOS_MSGQ_H_ +#define _EOS_MSGQ_H_ + +#define EOS_MSG_FLAG_WAKE 0x01 +#define EOS_MSG_FLAG_RPLY_REQ 0x02 +#define EOS_MSG_FLAG_RPLY_REP 0x04 + +typedef struct EOSMessage { + unsigned char *buffer; + uint16_t size; + uint8_t flags; +} EOSMessage; + +void eos_msg_init(EOSMessage *msg, unsigned char *buffer, uint16_t size); +void eos_msg_set_flags(EOSMessage *msg, uint8_t flags); +void eos_msg_clear_flags(EOSMessage *msg, uint8_t flags); +uint8_t eos_msg_flags(EOSMessage *msg); + typedef struct EOSMsgItem { unsigned char type; unsigned char *buffer; + uint16_t size; uint16_t len; } EOSMsgItem; @@ -14,9 +33,9 @@ typedef struct EOSMsgQ { } EOSMsgQ; void eos_msgq_init(EOSMsgQ *msgq, EOSMsgItem *array, uint8_t size); -int eos_msgq_push(EOSMsgQ *msgq, unsigned char type, unsigned char *buffer, uint16_t len); -void eos_msgq_pop(EOSMsgQ *msgq, unsigned char *type, unsigned char **buffer, uint16_t *len); uint8_t eos_msgq_len(EOSMsgQ *msgq); +int eos_msgq_push(EOSMsgQ *msgq, unsigned char type, EOSMessage *msg, uint16_t len); +void eos_msgq_pop(EOSMsgQ *msgq, unsigned char *type, EOSMessage *msg, uint16_t *len); typedef struct EOSBufQ { uint8_t idx_r; @@ -26,6 +45,8 @@ typedef struct EOSBufQ { } EOSBufQ; void eos_bufq_init(EOSBufQ *bufq, unsigned char **array, uint8_t size); +uint8_t eos_bufq_len(EOSBufQ *bufq); int eos_bufq_push(EOSBufQ *bufq, unsigned char *buffer); unsigned char *eos_bufq_pop(EOSBufQ *bufq); -uint8_t eos_bufq_len(EOSBufQ *bufq); + +#endif /* _EOS_MSGQ_H_ */ diff --git a/fw/esp32/components/eos/include/net.h b/fw/esp32/components/eos/include/net.h index 3e9e625..edf1a58 100644 --- a/fw/esp32/components/eos/include/net.h +++ b/fw/esp32/components/eos/include/net.h @@ -1,36 +1,40 @@ #include <stdint.h> -/* common */ +#include "msgq.h" + #define EOS_NET_MTU 1500 -#define EOS_NET_SIZE_BUF EOS_NET_MTU -#define EOS_NET_MTYPE_SOCK 1 -#define EOS_NET_MTYPE_RNG 3 -#define EOS_NET_MTYPE_POWER 4 +#define EOS_NET_MTYPE_BRIDGE 0 /* handler only */ +#define EOS_NET_MTYPE_WIFI 1 +#define EOS_NET_MTYPE_CELL 2 +#define EOS_NET_MTYPE_SOCK 3 +#define EOS_NET_MTYPE_RNG 4 -#define EOS_NET_MTYPE_WIFI 5 -#define EOS_NET_MTYPE_CELL 6 -#define EOS_NET_MTYPE_SIP 7 -#define EOS_NET_MTYPE_APP 8 +#define EOS_NET_MAX_MTYPE 5 -#define EOS_NET_MAX_MTYPE 8 +#define EOS_NET_MTYPE_SLEEP 0x20 /* does not have net handler */ -#define EOS_NET_MTYPE_FLAG_ONEW 0x40 -#define EOS_NET_MTYPE_FLAG_REPL 0x80 -#define EOS_NET_MTYPE_FLAG_MASK 0xc0 +#define EOS_NET_MTYPE_FLAG_ONEW 0x80 +#define EOS_NET_MTYPE_FLAG_REPL 0x40 +#define EOS_NET_MTYPE_FLAG_BRIDGE 0x08 -/* esp32 specific */ -#define EOS_NET_SIZE_BUFQ 4 -#define EOS_NET_SIZE_SNDQ 4 +#define EOS_NET_MTYPE_MASK 0x0F -typedef void (*eos_net_fptr_t) (unsigned char, unsigned char *, uint16_t); +typedef void (*eos_net_handler_t) (unsigned char, EOSMessage *msg, uint16_t); +void eos_net_xchg_task(void *param); void eos_net_init(void); +void eos_net_run(void); + +void eos_net_alloc(EOSMessage *msg); +void eos_net_free(EOSMessage *msg); + +int eos_net_send(unsigned char mtype, EOSMessage *msg, uint16_t len); +void eos_net_reply(unsigned char mtype, EOSMessage *msg, uint16_t len); + +void eos_net_sleep_req(void); +void eos_net_wake(void); +void eos_net_deep_sleep(void); +void eos_net_deep_wake(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); -void eos_net_reply(unsigned char mtype, unsigned char *buffer, uint16_t len); -void eos_net_set_handler(unsigned char mtype, eos_net_fptr_t handler); -void eos_net_sleep(void); -void eos_net_wake(uint8_t source, uint8_t mode); +void eos_net_set_handler(unsigned char mtype, eos_net_handler_t handler); diff --git a/fw/esp32/components/eos/include/net_priv.h b/fw/esp32/components/eos/include/net_priv.h new file mode 100644 index 0000000..5627e12 --- /dev/null +++ b/fw/esp32/components/eos/include/net_priv.h @@ -0,0 +1,30 @@ +#define NET_DEV_NET EOS_PWR_DEV_NET +#define NET_DEV_APP EOS_PWR_DEV_APP + +typedef struct NETConfig { + int sleep; + int sleep_req; + int present; + int gpio_rts; + int gpio_cts; + uint32_t dev; + spi_host_device_t spi_host; + spi_bus_config_t *spi_bus_cfg; + spi_slave_interface_config_t *spi_iface_cfg; + TaskHandle_t xchg_task_handle; + SemaphoreHandle_t mutex; + SemaphoreHandle_t bufq_mutex; + SemaphoreHandle_t bufq_semaph; + EOSBufQ *buf_q; + EOSMsgQ *send_q; + eos_net_handler_t handler; +} NETConfig; + +void _eos_net_init_gpio(NETConfig *config); +void _eos_net_alloc(NETConfig *config, EOSMessage *msg); +void _eos_net_free(NETConfig *config, EOSMessage *msg); +int _eos_net_send(NETConfig *config, unsigned char mtype, EOSMessage *msg, uint16_t len); +void _eos_net_sleep_req(NETConfig *config); +void _eos_net_wake(NETConfig *config); +void _eos_net_deep_sleep(NETConfig *config); +void _eos_net_deep_wake(NETConfig *config); diff --git a/fw/esp32/components/eos/include/power.h b/fw/esp32/components/eos/include/power.h index 2215907..c7d184c 100644 --- a/fw/esp32/components/eos/include/power.h +++ b/fw/esp32/components/eos/include/power.h @@ -1,22 +1,26 @@ #include <stdint.h> -#define EOS_PWR_MTYPE_BUTTON 1 +#define EOS_PWR_GPIO_NET 8 +#define EOS_PWR_GPIO_APP 10 +#define EOS_PWR_GPIO_MODEM 16 -#define EOS_PWR_WAKE_RST 0 -#define EOS_PWR_WAKE_BTN 1 -#define EOS_PWR_WAKE_UART 2 -#define EOS_PWR_WAKE_NET 3 -#define EOS_PWR_WAKE_NETQ 4 -#define EOS_PWR_WAKE_UNDEF 5 +#define EOS_PWR_DEV_NONE 0 +#define EOS_PWR_DEV_NET ((uint32_t)1 << EOS_PWR_GPIO_NET) +#define EOS_PWR_DEV_APP ((uint32_t)1 << EOS_PWR_GPIO_APP) +#define EOS_PWR_DEV_MODEM ((uint32_t)1 << EOS_PWR_GPIO_MODEM) +#define EOS_PWR_DEV_ALL (EOS_PWR_DEV_NET | EOS_PWR_DEV_APP | EOS_PWR_DEV_MODEM) -#define EOS_PWR_SMODE_LIGHT 1 -#define EOS_PWR_SMODE_DEEP 2 +#define EOS_PWR_SMODE_TICKLESS 1 +#define EOS_PWR_SMODE_LIGHT 2 +#define EOS_PWR_SMODE_DEEP 3 void eos_power_init(void); +void eos_power_run(void); +void eos_power_sys_sleep(uint8_t mode); +void eos_power_sys_wake(uint8_t mode) ; +uint32_t eos_power_wakeup_source(void); -void eos_power_wait4init(void); -void eos_power_wait4wake(void); -uint8_t eos_power_wakeup_cause(void); -void eos_power_sleep(void); -void eos_power_wake(uint8_t source); -void eos_power_net_ready(void);
\ No newline at end of file +void eos_power_set_mode(uint8_t mode); +void eos_power_sleep_req(uint32_t dev); +void eos_power_sleep_rdy(uint32_t dev); +void eos_power_wake(uint32_t dev); diff --git a/fw/esp32/components/eos/include/sock.h b/fw/esp32/components/eos/include/sock.h index 7e937cb..f2cf0c4 100644 --- a/fw/esp32/components/eos/include/sock.h +++ b/fw/esp32/components/eos/include/sock.h @@ -15,4 +15,6 @@ typedef struct EOSNetAddr { uint16_t port; } EOSNetAddr; -void eos_sock_init(void);
\ No newline at end of file +void eos_sock_init(void); +void eos_sock_run(void); +void eos_sock_reopen(void);
\ No newline at end of file diff --git a/fw/esp32/components/eos/include/tun.h b/fw/esp32/components/eos/include/tun.h index 3acb2a6..ab1e0f4 100644 --- a/fw/esp32/components/eos/include/tun.h +++ b/fw/esp32/components/eos/include/tun.h @@ -1 +1,5 @@ +#include <stdint.h> + +void eos_tun_portmap_add(uint32_t ext_addr); +void eos_tun_portmap_remove(void); void eos_tun_init(void);
\ No newline at end of file diff --git a/fw/esp32/components/eos/include/wifi.h b/fw/esp32/components/eos/include/wifi.h index c1819e7..0aae73a 100644 --- a/fw/esp32/components/eos/include/wifi.h +++ b/fw/esp32/components/eos/include/wifi.h @@ -1,3 +1,5 @@ +#include <sys/types.h> + #define EOS_WIFI_MTYPE_STATUS 0 #define EOS_WIFI_MTYPE_SCAN 1 #define EOS_WIFI_MTYPE_START 2 @@ -13,12 +15,13 @@ #define EOS_WIFI_MAX_SCAN_RECORDS 20 void eos_wifi_init(void); +void eos_wifi_run(void); int eos_wifi_scan(void); int eos_wifi_auth(char *ssid, char *pass); int eos_wifi_connect(void); int eos_wifi_disconnect(void); -ssize_t eos_wifi_get_status(unsigned char *buffer); +ssize_t eos_wifi_get_status(unsigned char *buffer, size_t size); void eos_wifi_send_status(void); -void eos_wifi_send_scan(void);
\ No newline at end of file +void eos_wifi_send_scan(void); |
