summaryrefslogtreecommitdiff
path: root/fw/esp32/components/eos/include
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2026-01-07 22:13:36 +0100
committerUros Majstorovic <majstor@majstor.org>2026-01-07 22:13:36 +0100
commit285ddd410a559449b7e2cbab9b2b10e850efbd08 (patch)
treed6cfe1577675c3478444f0b82b7c5f56bd6b174f /fw/esp32/components/eos/include
parent2357302c5e0228c1209b747cc5e0b11d7bef0a02 (diff)
added APP <-> FE310 bridge SPI messages; enabled esp32 wake from deep sleep; IP tunnel for app module supports NAT and port forwadring; introduced EOSMessage struct for SPI messages;
Diffstat (limited to 'fw/esp32/components/eos/include')
-rw-r--r--fw/esp32/components/eos/include/app.h17
-rw-r--r--fw/esp32/components/eos/include/cell.h14
-rw-r--r--fw/esp32/components/eos/include/eos.h16
-rw-r--r--fw/esp32/components/eos/include/msgq.h25
-rw-r--r--fw/esp32/components/eos/include/net.h38
-rw-r--r--fw/esp32/components/eos/include/net_priv.h15
-rw-r--r--fw/esp32/components/eos/include/power.h3
-rw-r--r--fw/esp32/components/eos/include/tun.h4
-rw-r--r--fw/esp32/components/eos/include/wifi.h4
9 files changed, 81 insertions, 55 deletions
diff --git a/fw/esp32/components/eos/include/app.h b/fw/esp32/components/eos/include/app.h
index b6dba99..38fba1a 100644
--- a/fw/esp32/components/eos/include/app.h
+++ b/fw/esp32/components/eos/include/app.h
@@ -2,25 +2,20 @@
#include "net.h"
-/* common */
-#define EOS_APP_MTU 1500
-#define EOS_APP_SIZE_BUF EOS_APP_MTU
-
#define EOS_APP_MTYPE_TUN 1
#define EOS_APP_MAX_MTYPE 8
-/* esp32 specific */
-#define EOS_APP_SIZE_BUFQ 4
-#define EOS_APP_SIZE_SNDQ 4
-
void eos_app_init(void);
void eos_app_run(void);
-unsigned char *eos_app_alloc(void);
-void eos_app_free(unsigned char *buf);
+void eos_app_alloc(EOSMessage *msg);
+void eos_app_free(EOSMessage *msg);
-int eos_app_send(unsigned char mtype, unsigned char *buffer, uint16_t buf_len);
+int eos_app_send(unsigned char mtype, EOSMessage *msg, uint16_t len);
void eos_app_sleep_req(void);
void eos_app_wake(void);
+void eos_app_deep_sleep(void);
+void eos_app_deep_wake(void);
+
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 c1e7545..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
@@ -95,6 +99,8 @@ void eos_modem_give(void);
void eos_modem_sleep_req(void);
void eos_modem_wake(void);
+void eos_modem_deep_sleep(void);
+void eos_modem_deep_wake(void);
void eos_ppp_get_apn(char *apn);
void eos_ppp_set_apn(char *apn);
@@ -110,10 +116,10 @@ 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 e772637..3f9755d 100644
--- a/fw/esp32/components/eos/include/eos.h
+++ b/fw/esp32/components/eos/include/eos.h
@@ -11,14 +11,14 @@
#define EOS_ERR_NOMEM -100
-#define EOS_TASK_PRIORITY_NET 1
-#define EOS_TASK_PRIORITY_APP 1
-#define EOS_TASK_PRIORITY_SOCK 1
-#define EOS_TASK_PRIORITY_UART 1
-#define EOS_TASK_PRIORITY_MODEM 1
-#define EOS_TASK_PRIORITY_PCM 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 8192
#define EOS_TASK_SSIZE_APP 8192
diff --git a/fw/esp32/components/eos/include/msgq.h b/fw/esp32/components/eos/include/msgq.h
index b5ae9ac..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;
@@ -15,8 +34,8 @@ typedef struct EOSMsgQ {
void eos_msgq_init(EOSMsgQ *msgq, EOSMsgItem *array, uint8_t size);
uint8_t eos_msgq_len(EOSMsgQ *msgq);
-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);
+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;
@@ -29,3 +48,5 @@ 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);
+
+#endif /* _EOS_MSGQ_H_ */
diff --git a/fw/esp32/components/eos/include/net.h b/fw/esp32/components/eos/include/net.h
index b500e82..edf1a58 100644
--- a/fw/esp32/components/eos/include/net.h
+++ b/fw/esp32/components/eos/include/net.h
@@ -1,40 +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_WIFI 2
-#define EOS_NET_MTYPE_CELL 3
-#define EOS_NET_MTYPE_APP 4
-#define EOS_NET_MTYPE_RNG 5
+#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_MAX_MTYPE 5
-#define EOS_NET_MTYPE_SLEEP 0x10 /* does not have net handler */
+#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_MASK 0x3F /* 0x0F if mtype is handled by evtq */
+#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_handler_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);
-unsigned char *eos_net_alloc(void);
-void eos_net_free(unsigned char *buf);
+void eos_net_alloc(EOSMessage *msg);
+void eos_net_free(EOSMessage *msg);
-int eos_net_send(unsigned char mtype, unsigned char *buffer, uint16_t buf_len);
-void eos_net_reply(unsigned char mtype, unsigned char *buffer, uint16_t buf_len);
+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);
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
index fa1de61..5627e12 100644
--- a/fw/esp32/components/eos/include/net_priv.h
+++ b/fw/esp32/components/eos/include/net_priv.h
@@ -5,29 +5,26 @@ typedef struct NETConfig {
int sleep;
int sleep_req;
int present;
- int gpio_mosi;
- int gpio_miso;
- int gpio_sclk;
- int gpio_cs;
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;
- spi_slave_transaction_t *spi_tr_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 msg_handler;
+ eos_net_handler_t handler;
} NETConfig;
void _eos_net_init_gpio(NETConfig *config);
-unsigned char *_eos_net_alloc(NETConfig *config);
-void _eos_net_free(NETConfig *config, unsigned char *buf);
-int _eos_net_send(NETConfig *config, unsigned char mtype, unsigned char *buffer, uint16_t buf_len);
+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 2590b80..c7d184c 100644
--- a/fw/esp32/components/eos/include/power.h
+++ b/fw/esp32/components/eos/include/power.h
@@ -20,6 +20,7 @@ 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_sleep_req(uint8_t mode, uint32_t dev);
+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/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 d080e25..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
@@ -20,6 +22,6 @@ 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);