diff options
author | Uros Majstorovic <majstor@majstor.org> | 2020-08-05 03:39:22 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2020-08-05 03:39:22 +0200 |
commit | cf7c06297d04bade9cd04c056f9ed510e64dd7bd (patch) | |
tree | a3b8cc23574b98e10874b51d33c9fe1bfc012663 /fw/esp32/components/eos/include | |
parent | 5cd610a07468137066ea4daa5176c3e7045113b0 (diff) |
code -> fw
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/at_cmd.h | 20 | ||||
-rw-r--r-- | fw/esp32/components/eos/include/bq25895.h | 3 | ||||
-rw-r--r-- | fw/esp32/components/eos/include/cell.h | 68 | ||||
-rw-r--r-- | fw/esp32/components/eos/include/drv2605l.h | 3 | ||||
-rw-r--r-- | fw/esp32/components/eos/include/eos.h | 23 | ||||
-rw-r--r-- | fw/esp32/components/eos/include/gsm.h | 117 | ||||
-rw-r--r-- | fw/esp32/components/eos/include/i2c.h | 9 | ||||
-rw-r--r-- | fw/esp32/components/eos/include/msgq.h | 32 | ||||
-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 | ||||
l--------- | fw/esp32/components/eos/include/unicode.h | 1 | ||||
-rw-r--r-- | fw/esp32/components/eos/include/wifi.h | 12 |
14 files changed, 361 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/at_cmd.h b/fw/esp32/components/eos/include/at_cmd.h new file mode 100644 index 0000000..615a1c1 --- /dev/null +++ b/fw/esp32/components/eos/include/at_cmd.h @@ -0,0 +1,20 @@ +#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 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); +void at_cmd(char *cmd); +int at_expect(char *str_ok, char *str_err, uint32_t timeout); diff --git a/fw/esp32/components/eos/include/bq25895.h b/fw/esp32/components/eos/include/bq25895.h new file mode 100644 index 0000000..b5a7f92 --- /dev/null +++ b/fw/esp32/components/eos/include/bq25895.h @@ -0,0 +1,3 @@ +#include <stdint.h> + +void eos_bq25895_set_ilim(void);
\ No newline at end of file diff --git a/fw/esp32/components/eos/include/cell.h b/fw/esp32/components/eos/include/cell.h new file mode 100644 index 0000000..3bf6b32 --- /dev/null +++ b/fw/esp32/components/eos/include/cell.h @@ -0,0 +1,68 @@ +#include <sys/types.h> +#include <stdint.h> + +#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_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_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_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 + +#define EOS_CELL_UART_SIZE_BUF 128 + +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_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); diff --git a/fw/esp32/components/eos/include/drv2605l.h b/fw/esp32/components/eos/include/drv2605l.h new file mode 100644 index 0000000..de222e4 --- /dev/null +++ b/fw/esp32/components/eos/include/drv2605l.h @@ -0,0 +1,3 @@ +#include <stdint.h> + +void eos_drv2605l_test(void);
\ No newline at end of file diff --git a/fw/esp32/components/eos/include/eos.h b/fw/esp32/components/eos/include/eos.h new file mode 100644 index 0000000..0e660fb --- /dev/null +++ b/fw/esp32/components/eos/include/eos.h @@ -0,0 +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_TASK_PRIORITY_UART 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_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/fw/esp32/components/eos/include/gsm.h b/fw/esp32/components/eos/include/gsm.h new file mode 100644 index 0000000..2c4f7b4 --- /dev/null +++ b/fw/esp32/components/eos/include/gsm.h @@ -0,0 +1,117 @@ +#define GSM_OK 0 +#define GSM_ERR -1 + +/* 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 + +/* 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 + +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); diff --git a/fw/esp32/components/eos/include/i2c.h b/fw/esp32/components/eos/include/i2c.h new file mode 100644 index 0000000..144f5e1 --- /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); +uint8_t eos_i2c_read8(uint8_t addr, uint8_t reg); +int eos_i2c_write(uint8_t addr, uint8_t reg, uint8_t *data, size_t len); +void 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..86bb067 --- /dev/null +++ b/fw/esp32/components/eos/include/msgq.h @@ -0,0 +1,32 @@ +#include <stdint.h> + +typedef struct EOSMsgItem { + unsigned char type; + unsigned char *buffer; + uint16_t len; + uint8_t flags; +} 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, uint8_t flags); +void eos_msgq_pop(EOSMsgQ *msgq, unsigned char *type, unsigned char **buffer, uint16_t *len, uint8_t *flags); +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..54bad6d --- /dev/null +++ b/fw/esp32/components/eos/include/net.h @@ -0,0 +1,34 @@ +#include <stdint.h> + +/* common */ +#define EOS_NET_SIZE_BUF 1500 + +#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 0x80 + +/* esp32 specific */ +#define EOS_NET_SIZE_BUFQ 4 +#define EOS_NET_SIZE_SNDQ 4 + +#define EOS_NET_FLAG_BFREE 0x1 +#define EOS_NET_FLAG_BCOPY 0x2 + +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, uint8_t flags); +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..0a57b19 --- /dev/null +++ b/fw/esp32/components/eos/include/power.h @@ -0,0 +1,20 @@ +#include <stdint.h> + +#define EOS_PWR_MTYPE_BUTTON 0 + +#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/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..6009f7c --- /dev/null +++ b/fw/esp32/components/eos/include/wifi.h @@ -0,0 +1,12 @@ +#define EOS_WIFI_MTYPE_SCAN 0 +#define EOS_WIFI_MTYPE_CONNECT 1 +#define EOS_WIFI_MTYPE_DISCONNECT 2 + +#define EOS_WIFI_MAX_MTYPE 3 + +void eos_wifi_init(void); + +int eos_wifi_scan(void); +int eos_wifi_set_auth(char *ssid, char *pass); +int eos_wifi_connect(void); +int eos_wifi_disconnect(void); |