From 01c3e3af2394f863323b846fa304ff7e0a30e9df Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Tue, 16 Jan 2018 23:43:07 +0100 Subject: eos support --- code/esp32/components/eos/include/eos.h | 2 ++ code/esp32/components/eos/include/fe310.h | 18 ++++++++++++++++++ code/esp32/components/eos/include/msgq.h | 20 ++++++++++++++++++++ code/esp32/components/eos/include/transport.h | 13 +++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 code/esp32/components/eos/include/eos.h create mode 100644 code/esp32/components/eos/include/fe310.h create mode 100644 code/esp32/components/eos/include/msgq.h create mode 100644 code/esp32/components/eos/include/transport.h (limited to 'code/esp32/components/eos/include') diff --git a/code/esp32/components/eos/include/eos.h b/code/esp32/components/eos/include/eos.h new file mode 100644 index 0000000..a272ac8 --- /dev/null +++ b/code/esp32/components/eos/include/eos.h @@ -0,0 +1,2 @@ +#define EOS_OK 0 +#define EOS_ERR_Q_FULL -10 \ No newline at end of file diff --git a/code/esp32/components/eos/include/fe310.h b/code/esp32/components/eos/include/fe310.h new file mode 100644 index 0000000..f4bc787 --- /dev/null +++ b/code/esp32/components/eos/include/fe310.h @@ -0,0 +1,18 @@ +#include + +#define EOS_FE310_CMD_FLAG_ONEW 0x10 + +#define EOS_FE310_CMD_CONNECT 1 +#define EOS_FE310_CMD_DISCONNECT 2 +#define EOS_FE310_CMD_SCAN 3 +#define EOS_FE310_CMD_PKT 4 + +#define EOS_FE310_MAX_CMD 8 +#define EOS_FE310_SIZE_Q 64 +#define EOS_FE310_SIZE_BUF 2048 + +typedef void (*eos_fe310_fptr_t) (unsigned char, unsigned char *, uint16_t); + +void eos_fe310_init(void); +int eos_fe310_send(unsigned char cmd, unsigned char *buffer, uint16_t len); +void eos_fe310_set_handler(unsigned char cmd, eos_fe310_fptr_t handler); diff --git a/code/esp32/components/eos/include/msgq.h b/code/esp32/components/eos/include/msgq.h new file mode 100644 index 0000000..ebf54ce --- /dev/null +++ b/code/esp32/components/eos/include/msgq.h @@ -0,0 +1,20 @@ +#include + +#include "fe310.h" + +typedef struct EOSMsgItem { + unsigned char cmd; + unsigned char buffer[EOS_FE310_SIZE_BUF]; + 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 cmd, unsigned char *buffer, uint16_t len); +void eos_msgq_pop(EOSMsgQ *msgq, unsigned char *cmd, unsigned char **buffer, uint16_t *len); diff --git a/code/esp32/components/eos/include/transport.h b/code/esp32/components/eos/include/transport.h new file mode 100644 index 0000000..9d76d1b --- /dev/null +++ b/code/esp32/components/eos/include/transport.h @@ -0,0 +1,13 @@ +#include + +#define EOS_IPv4_ADDR_SIZE 4 + +typedef struct EOSNetAddr { + unsigned char host[EOS_IPv4_ADDR_SIZE]; + uint16_t port; +} EOSNetAddr; + +void eos_net_init(void); +void eos_net_connect(char *ssid, char *password); +void eos_net_disconnect(void); +ssize_t eos_net_send(void *msg, size_t msg_size, EOSNetAddr *addr); -- cgit v1.2.3