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 | 23 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/at_cmd.h | 18 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/cell.h | 91 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/eos.h | 27 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/gsm.h | 139 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/i2c.h | 9 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/msgq.h | 31 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/net.h | 34 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/power.h | 20 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/sock.h | 18 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/tun.h | 1 | ||||
| l--------- | fw/esp32/components/eos/include/unicode.h | 1 | ||||
| -rw-r--r-- | fw/esp32/components/eos/include/wifi.h | 13 | 
14 files changed, 426 insertions, 0 deletions
diff --git a/fw/esp32/components/eos/include/_net.h b/fw/esp32/components/eos/include/_net.h new file mode 100644 index 0000000..35b5308 --- /dev/null +++ b/fw/esp32/components/eos/include/_net.h @@ -0,0 +1 @@ +#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 new file mode 100644 index 0000000..2033b2b --- /dev/null +++ b/fw/esp32/components/eos/include/app.h @@ -0,0 +1,23 @@ +#include <stdint.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 + +#define EOS_APP_MTYPE_FLAG_MASK     0xc0 + +/* esp32 specific */ +#define EOS_APP_SIZE_BUFQ           4 +#define EOS_APP_SIZE_SNDQ           4 + +typedef void (*eos_app_fptr_t) (unsigned char, unsigned char *, uint16_t); + +void eos_app_init(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); diff --git a/fw/esp32/components/eos/include/at_cmd.h b/fw/esp32/components/eos/include/at_cmd.h new file mode 100644 index 0000000..2d0813e --- /dev/null +++ b/fw/esp32/components/eos/include/at_cmd.h @@ -0,0 +1,18 @@ +#include <sys/types.h> +#include <stdint.h> +#include <regex.h> + +#define AT_SIZE_NMATCH      4 +#define AT_SIZE_PATTERN     64 + +#define AT_SIZE_URC_LIST    32 + +typedef void (*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); +void at_cmd(char *cmd); +int at_expect(char *str_ok, char *str_err, uint32_t timeout); +int at_expect_match(char *str_ok, char *str_err, char **buf, regmatch_t match[], size_t match_size, int flags, uint32_t timeout); diff --git a/fw/esp32/components/eos/include/cell.h b/fw/esp32/components/eos/include/cell.h new file mode 100644 index 0000000..fa9a0e2 --- /dev/null +++ b/fw/esp32/components/eos/include/cell.h @@ -0,0 +1,91 @@ +#include <sys/types.h> +#include <stdint.h> + +#define EOS_CELL_MTYPE_DEV              0x10 +#define EOS_CELL_MTYPE_VOICE            0x20 +#define EOS_CELL_MTYPE_SMS              0x30 +#define EOS_CELL_MTYPE_CBS              0x40 +#define EOS_CELL_MTYPE_USSD             0x50 +#define EOS_CELL_MTYPE_PDP              0x60 + +#define EOS_CELL_MTYPE_MASK             0xf0 +#define EOS_CELL_MAX_MTYPE              8 + +/* EOS_CELL_MTYPE_DEV subtypes */ +#define EOS_CELL_MTYPE_READY            1 +#define EOS_CELL_MTYPE_UART_DATA        2 +#define EOS_CELL_MTYPE_UART_TAKE        3 +#define EOS_CELL_MTYPE_UART_GIVE        4 +#define EOS_CELL_MTYPE_RESET            5 + +#define EOS_CELL_MTYPE_VOICE_PCM        1 +#define EOS_CELL_MTYPE_VOICE_DIAL       2 +#define EOS_CELL_MTYPE_VOICE_RING       3 +#define EOS_CELL_MTYPE_VOICE_ANSWER     4 +#define EOS_CELL_MTYPE_VOICE_HANGUP     5 +#define EOS_CELL_MTYPE_VOICE_BEGIN      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_LIST         1 +#define EOS_CELL_MTYPE_SMS_SEND         2 +#define EOS_CELL_MTYPE_SMS_MSG_NEW      3 +#define EOS_CELL_MTYPE_SMS_MSG_ITEM     4 + +#define EOS_CELL_MTYPE_USSD_REQUEST     1 +#define EOS_CELL_MTYPE_USSD_REPLY       2 +#define EOS_CELL_MTYPE_USSD_CANCEL      3 + +#define EOS_CELL_MTYPE_PDP_CONFIG       1 +#define EOS_CELL_MTYPE_PDP_CONNECT      2 +#define EOS_CELL_MTYPE_PDP_DISCONNECT   3 + +#define EOS_CELL_SMS_ADDRTYPE_INTL      1 +#define EOS_CELL_SMS_ADDRTYPE_ALPHA     2 +#define EOS_CELL_SMS_ADDRTYPE_OTHER     3 + +#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_UART_MODE_UNDEF        0xff + +#define EOS_CELL_UART_SIZE_BUF          1024 + +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); +int eos_modem_reset(void); + +void eos_ppp_set_apn(char *apn); +void eos_ppp_set_auth(char *user, char *pass); +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_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_pdp_handler(unsigned char mtype, unsigned char *buffer, uint16_t size); + +void eos_cell_voice_init(void); +void eos_cell_sms_init(void); +void eos_cell_ussd_init(void); diff --git a/fw/esp32/components/eos/include/eos.h b/fw/esp32/components/eos/include/eos.h new file mode 100644 index 0000000..6f420ea --- /dev/null +++ b/fw/esp32/components/eos/include/eos.h @@ -0,0 +1,27 @@ +#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_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_SSIZE_NET_XCHG     8192 +#define EOS_TASK_SSIZE_APP_XCHG     8192 +#define EOS_TASK_SSIZE_UDP_RCVR     4096 +#define EOS_TASK_SSIZE_UART         4096 +#define EOS_TASK_SSIZE_MODEM        4096 +#define EOS_TASK_SSIZE_I2S          4096 +#define EOS_TASK_SSIZE_CELL         4096 +#define EOS_TASK_SSIZE_PWR          4096 + diff --git a/fw/esp32/components/eos/include/gsm.h b/fw/esp32/components/eos/include/gsm.h new file mode 100644 index 0000000..7864b09 --- /dev/null +++ b/fw/esp32/components/eos/include/gsm.h @@ -0,0 +1,139 @@ +#define GSM_OK                      0 +#define GSM_ERR                     -1 +#define GSM_ERR_SIZE                -10 +#define GSM_ERR_NOT_SUPPORTED       -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 */ +#define GSM_MTI                     0x03 +#define GSM_MTI_DELIVER             0x00 +#define GSM_MTI_DELIVER_REPORT      0x00 +#define GSM_MTI_SUBMIT              0x01 +#define GSM_MTI_SUBMIT_REPORT       0x01 +#define GSM_MTI_COMMAND             0x02 +#define GSM_MTI_COMMAND_REPORT      0x02 + +#define GSM_MMS                     0x04    /* More-Messages-to-Send */ +#define GSM_RD                      0x04    /* Reject-Duplicates */ +#define GSM_LP                      0x08    /* Loop-Prevention */ + +/* Validity-Period-Format */ +#define GSM_VPF                     0x18 +#define GSM_VPF_NONE                0x00 +#define GSM_VPF_ENHANCED            0x08 +#define GSM_VPF_RELATIVE            0x10 +#define GSM_VPF_ABSOLUTE            0x18 + +#define GSM_SRI                     0x20    /* Status-Report-Indication */ +#define GSM_SRR                     0x20    /* Status-Report-Request */ +#define GSM_SRQ                     0x20    /* Status-Report-Qualifier */ +#define GSM_UDHI                    0x40    /* User-Data-Header-Indicator  */ +#define GSM_RP                      0x80    /* Reply-Path */ + +/* Type-of-Number */ +#define GSM_TON                     0x70 +#define GSM_TON_UNKNOWN             0x00 +#define GSM_TON_INTERNATIONAL       0x10 +#define GSM_TON_NATIONAL            0x20 +#define GSM_TON_NETWORK             0x30 +#define GSM_TON_SUBSCRIBER          0x40 +#define GSM_TON_ALPHANUMERIC        0x50 +#define GSM_TON_ABBRREVIATED        0x60 + +/* Numbering-Plan-Identification */ +#define GSM_NPI                     0x0f +#define GSM_NPI_UNKNOWN             0x00 +#define GSM_NPI_TELEPHONE           0x01 +#define GSM_NPI_DATA                0x03 +#define GSM_NPI_TELEX               0x04 +#define GSM_NPI_SCS1                0x05 +#define GSM_NPI_SCS2                0x06 +#define GSM_NPI_NATIONAL            0x08 +#define GSM_NPI_PRIVATE             0x09 +#define GSM_NPI_ERMES               0x0a + +#define GSM_EXT                     0x80 + +/* Protocol-Identifier */ +#define GSM_PID_DEFAULT             0 +#define GSM_PID_TYPE0               64 + +/* Data-Coding-Scheme */ +#define GSM_DCS_CLASS               0x03 +#define GSM_DCS_ENC                 0x0c + +#define GSM_DCS_CLASS_IND           0x10 +#define GSM_DCS_COMPRESS_IND        0x20 +#define GSM_DCS_DELETE_IND          0x40 +#define GSM_DCS_GENERAL_IND         0x80 +#define GSM_DCS_GROUP               0xf0 + +#define GSM_DCS_MWI_DISCARD         0xc0 +#define GSM_DCS_MWI_STORE_GSM7      0xd0 +#define GSM_DCS_MWI_STORE_UCS2      0xe0 +#define GSM_DCS_MWI_SENSE           0x08 +#define GSM_DCS_MWI_TYPE            0x03 + +#define GSM_DCS_ENCLASS             0xf0 +#define GSM_DCS_ENCLASS_ENC         0x04 + +/* Parameter-Indicator */ +#define GSM_PI_PID                  0x01 +#define GSM_PI_DCS                  0x02 +#define GSM_PI_UD                   0x04 +#define GSM_PI_EXT                  0x08 + +/* character set */ +#define GSM_ENC_7BIT                0x00 +#define GSM_ENC_8BIT                0x04 +#define GSM_ENC_UCS2                0x08 + +/* message waiting indication */ +#define GSM_MWI_TYPE_VOICEMAIL      0x00 +#define GSM_MWI_TYPE_FAX            0x01 +#define GSM_MWI_TYPE_EMAIL          0x02 +#define GSM_MWI_TYPE_OTHER          0x03 + +/* flags */ +#define GSM_FLAG_COMPRESS           0x0001 +#define GSM_FLAG_DELETE             0x0002 +#define GSM_FLAG_DISCARD            0x0004 +#define GSM_FLAG_TYPE0              0x0008 +#define GSM_FLAG_STATUS_REPORT      0x0010 +#define GSM_FLAG_REPLY_PATH         0x0020 + +/* message class */ +#define GSM_FLAG_CLASS              0x0400 +#define GSM_FLAG_CLASS0             0x0000  /* Flash */ +#define GSM_FLAG_CLASS1             0x0100  /* ME-specific */ +#define GSM_FLAG_CLASS2             0x0200  /* (U)SIM-specific */ +#define GSM_FLAG_CLASS4             0x0300  /* TE-specific */ +#define GSM_FLAG_CLASS_MASK         0x0f00 + +/* message waiting indication */ +#define GSM_FLAG_MWI                0x4000 +#define GSM_FLAG_MWI_SENSE          0x8000 +#define GSM_FLAG_MWI_VOICEMAIL      0x0000 +#define GSM_FLAG_MWI_FAX            0x1000 +#define GSM_FLAG_MWI_EMAIL          0x2000 +#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); diff --git a/fw/esp32/components/eos/include/i2c.h b/fw/esp32/components/eos/include/i2c.h new file mode 100644 index 0000000..f014141 --- /dev/null +++ b/fw/esp32/components/eos/include/i2c.h @@ -0,0 +1,9 @@ +#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 new file mode 100644 index 0000000..bbfe041 --- /dev/null +++ b/fw/esp32/components/eos/include/msgq.h @@ -0,0 +1,31 @@ +#include <stdint.h> + +typedef struct EOSMsgItem { +    unsigned char type; +    unsigned char *buffer; +    uint16_t len; +} EOSMsgItem; + +typedef struct EOSMsgQ { +    uint8_t idx_r; +    uint8_t idx_w; +    uint8_t size; +    EOSMsgItem *array; +} 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); + +typedef struct EOSBufQ { +    uint8_t idx_r; +    uint8_t idx_w; +    uint8_t size; +    unsigned char **array; +} EOSBufQ; + +void eos_bufq_init(EOSBufQ *bufq, unsigned char **array, uint8_t size); +int eos_bufq_push(EOSBufQ *bufq, unsigned char *buffer); +unsigned char *eos_bufq_pop(EOSBufQ *bufq); +uint8_t eos_bufq_len(EOSBufQ *bufq); diff --git a/fw/esp32/components/eos/include/net.h b/fw/esp32/components/eos/include/net.h new file mode 100644 index 0000000..cf0cb6b --- /dev/null +++ b/fw/esp32/components/eos/include/net.h @@ -0,0 +1,34 @@ +#include <stdint.h> + +/* common */ +#define EOS_NET_MTU                 1500 +#define EOS_NET_SIZE_BUF            EOS_NET_MTU + +#define EOS_NET_MTYPE_SOCK          1 +#define EOS_NET_MTYPE_POWER         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           8 + +#define EOS_NET_MTYPE_FLAG_ONEW     0x40 +#define EOS_NET_MTYPE_FLAG_REPW     0x80 +#define EOS_NET_MTYPE_FLAG_MASK     0xc0 + +/* esp32 specific */ +#define EOS_NET_SIZE_BUFQ           4 +#define EOS_NET_SIZE_SNDQ           4 + +typedef void (*eos_net_fptr_t) (unsigned char, unsigned char *, uint16_t); + +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); +void eos_net_set_handler(unsigned char mtype, eos_net_fptr_t handler); +void eos_net_sleep_done(uint8_t mode); +void eos_net_wake(uint8_t source, uint8_t mode); diff --git a/fw/esp32/components/eos/include/power.h b/fw/esp32/components/eos/include/power.h new file mode 100644 index 0000000..3d2e0bc --- /dev/null +++ b/fw/esp32/components/eos/include/power.h @@ -0,0 +1,20 @@ +#include <stdint.h> + +#define EOS_PWR_MTYPE_BUTTON    1 + +#define EOS_PWR_WAKE_RST        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 + +#define EOS_PWR_SMODE_LIGHT     1 +#define EOS_PWR_SMODE_DEEP      2 + +void eos_power_init(void); + +void eos_power_wait4init(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 diff --git a/fw/esp32/components/eos/include/sock.h b/fw/esp32/components/eos/include/sock.h new file mode 100644 index 0000000..7e937cb --- /dev/null +++ b/fw/esp32/components/eos/include/sock.h @@ -0,0 +1,18 @@ +#include <stdint.h> + +#define EOS_SOCK_MTYPE_PKT          0 +#define EOS_SOCK_MTYPE_OPEN_DGRAM   1 +#define EOS_SOCK_MTYPE_CLOSE        127 + +#define EOS_SOCK_MAX_SOCK           2 + +#define EOS_SOCK_SIZE_UDP_HDR       8 + +#define EOS_IPv4_ADDR_SIZE          4 + +typedef struct EOSNetAddr { +    unsigned char host[EOS_IPv4_ADDR_SIZE]; +    uint16_t port; +} EOSNetAddr; + +void eos_sock_init(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 new file mode 100644 index 0000000..3acb2a6 --- /dev/null +++ b/fw/esp32/components/eos/include/tun.h @@ -0,0 +1 @@ +void eos_tun_init(void);
\ No newline at end of file diff --git a/fw/esp32/components/eos/include/unicode.h b/fw/esp32/components/eos/include/unicode.h new file mode 120000 index 0000000..e859a65 --- /dev/null +++ b/fw/esp32/components/eos/include/unicode.h @@ -0,0 +1 @@ +../../../../fe310/eos/unicode.h
\ No newline at end of file diff --git a/fw/esp32/components/eos/include/wifi.h b/fw/esp32/components/eos/include/wifi.h new file mode 100644 index 0000000..11bccec --- /dev/null +++ b/fw/esp32/components/eos/include/wifi.h @@ -0,0 +1,13 @@ +#define EOS_WIFI_MTYPE_SCAN         1 +#define EOS_WIFI_MTYPE_CONFIG       2 +#define EOS_WIFI_MTYPE_CONNECT      3 +#define EOS_WIFI_MTYPE_DISCONNECT   4 + +#define EOS_WIFI_MAX_MTYPE          5 + +void eos_wifi_init(void); + +int eos_wifi_scan(void); +int eos_wifi_set_config(char *ssid, char *pass); +int eos_wifi_connect(void); +int eos_wifi_disconnect(void);  | 
