add support for multi sal devices concurrently

This commit is contained in:
mculover666
2020-08-13 17:51:05 +08:00
parent 772d714a20
commit 122fa9fd03
12 changed files with 588 additions and 356 deletions

View File

@@ -25,10 +25,10 @@
#define AT_AGENT_ECHO_FAIL "FAIL"
#define AT_AGENT_ECHO_ERROR "ERROR"
#define AT_DATA_CHANNEL_NUM 6
#define AT_DATA_CHANNEL_FIFO_BUFFER_SIZE (2048 + 1024)
#define AT_DATA_CHANNEL_NUM 2
#define AT_DATA_CHANNEL_FIFO_BUFFER_SIZE (2048)
#define AT_UART_RX_FIFO_BUFFER_SIZE (2048 + 1024)
#define AT_UART_RX_FIFO_BUFFER_SIZE (2048)
#define AT_RECV_CACHE_SIZE 2048
#define AT_CMD_BUFFER_SIZE 512
@@ -128,14 +128,13 @@ typedef struct at_agent_st {
uint8_t *uart_rx_fifo_buffer;
} at_agent_t;
#define AT_AGENT ((at_agent_t *)(&at_agent))
/**
* @brief Write data to a channel.
* Write data to a channel with certain id.
*
* @attention None
*
* @param[in] at_agent at agent object
* @param[in] channel_id id of the channel.
* @param[in] buffer data buffer to write.
* @param[in] buffer_len length of the buffer.
@@ -144,7 +143,7 @@ typedef struct at_agent_st {
* @retval -1 write failed(error).
* @retval none -1 the number of bytes written.
*/
__API__ int tos_at_channel_write(int channel_id, uint8_t *buffer, size_t buffer_len);
__API__ int tos_at_channel_write(at_agent_t *at_agent, int channel_id, uint8_t *buffer, size_t buffer_len);
/**
* @brief Read data from a channel.
@@ -161,7 +160,7 @@ __API__ int tos_at_channel_write(int channel_id, uint8_t *buffer, size_t buffer_
* @retval -1 read failed(error).
* @retval none -1 the number of bytes read.
*/
__API__ int tos_at_channel_read_timed(int channel_id, uint8_t *buffer, size_t buffer_len, uint32_t timeout);
__API__ int tos_at_channel_read_timed(at_agent_t *at_agent, int channel_id, uint8_t *buffer, size_t buffer_len, uint32_t timeout);
/**
* @brief Read data from a channel.
@@ -177,7 +176,7 @@ __API__ int tos_at_channel_read_timed(int channel_id, uint8_t *buffer, size_t bu
* @retval -1 read failed(error).
* @retval none -1 the number of bytes read.
*/
__API__ int tos_at_channel_read(int channel_id, uint8_t *buffer, size_t buffer_len);
__API__ int tos_at_channel_read(at_agent_t *at_agent, int channel_id, uint8_t *buffer, size_t buffer_len);
/**
* @brief Allocate a channel.
@@ -193,7 +192,7 @@ __API__ int tos_at_channel_read(int channel_id, uint8_t *buffer, size_t buffer_l
* @retval -1 allocate failed(error).
* @retval none -1 the id of the channel.
*/
__API__ int tos_at_channel_alloc_id(int channel_id, const char *ip, const char *port);
__API__ int tos_at_channel_alloc_id(at_agent_t *at_agent, int channel_id, const char *ip, const char *port);
/**
* @brief Allocate a channel.
@@ -208,7 +207,7 @@ __API__ int tos_at_channel_alloc_id(int channel_id, const char *ip, const char *
* @retval -1 allocate failed(error).
* @retval none -1 the id of the channel.
*/
__API__ int tos_at_channel_alloc(const char *ip, const char *port);
__API__ int tos_at_channel_alloc(at_agent_t *at_agent, const char *ip, const char *port);
/**
* @brief Free a channel.
@@ -222,7 +221,7 @@ __API__ int tos_at_channel_alloc(const char *ip, const char *port);
* @retval -1 free failed(error).
* @retval 0 free successfully.
*/
__API__ int tos_at_channel_free(int channel_id);
__API__ int tos_at_channel_free(at_agent_t *at_agent, int channel_id);
/**
* @brief Set channel broken.
@@ -235,7 +234,7 @@ __API__ int tos_at_channel_free(int channel_id);
* @retval -1 set failed(error).
* @retval 0 set successfully.
*/
__API__ int tos_at_channel_set_broken(int channel_id);
__API__ int tos_at_channel_set_broken(at_agent_t *at_agent, int channel_id);
/**
* @brief Judge whether channel is working.
@@ -246,7 +245,7 @@ __API__ int tos_at_channel_set_broken(int channel_id);
*
* @return at channel status(type of at_channel_status_t)
*/
__API__ int tos_at_channel_is_working(int channel_id);
__API__ int tos_at_channel_is_working(at_agent_t *at_agent, int channel_id);
/**
* @brief Initialize the at framework.
@@ -261,7 +260,7 @@ __API__ int tos_at_channel_is_working(int channel_id);
* @retval -1 initialize failed(error).
* @retval 0 initialize successfully.
*/
__API__ int tos_at_init(hal_uart_port_t uart_port, at_event_t *event_table, size_t event_table_size);
__API__ int tos_at_init(at_agent_t *at_agent, k_stack_t *stk, hal_uart_port_t uart_port, at_event_t *event_table, size_t event_table_size);
/**
* @brief De-initialize the at framework.
@@ -271,7 +270,7 @@ __API__ int tos_at_init(hal_uart_port_t uart_port, at_event_t *event_table, size
* @return
None
*/
__API__ void tos_at_deinit(void);
__API__ void tos_at_deinit(at_agent_t *at_agent);
/**
* @brief Create a echo struct.
@@ -318,7 +317,7 @@ __API__ int tos_at_echo_fuzzy_matching_create(at_echo_t *echo, char *buffer, siz
* @retval -1 execute failed(error).
* @retval 0 execute successfully.
*/
__API__ int tos_at_cmd_exec(at_echo_t *echo, uint32_t timeout, const char *cmd, ...);
__API__ int tos_at_cmd_exec(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const char *cmd, ...);
/**
* @brief Execute an at command.
@@ -334,7 +333,7 @@ __API__ int tos_at_cmd_exec(at_echo_t *echo, uint32_t timeout, const char *cmd,
* @retval -1 execute failed(error).
* @retval 0 execute successfully.
*/
__API__ int tos_at_cmd_exec_until(at_echo_t *echo, uint32_t timeout, const char *cmd, ...);
__API__ int tos_at_cmd_exec_until(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const char *cmd, ...);
/**
* @brief Send raw data througth uart.
@@ -350,7 +349,7 @@ __API__ int tos_at_cmd_exec_until(at_echo_t *echo, uint32_t timeout, const char
* @retval -1 execute failed(error).
* @retval 0 execute successfully.
*/
__API__ int tos_at_raw_data_send(at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size);
__API__ int tos_at_raw_data_send(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size);
/**
* @brief Send raw data througth uart.
@@ -367,7 +366,7 @@ __API__ int tos_at_raw_data_send(at_echo_t *echo, uint32_t timeout, const uint8_
* @retval -1 execute failed(error).
* @retval 0 execute successfully.
*/
__API__ int tos_at_raw_data_send_until(at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size);
__API__ int tos_at_raw_data_send_until(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size);
/**
* @brief Write byte to the at uart.
@@ -379,7 +378,7 @@ __API__ int tos_at_raw_data_send_until(at_echo_t *echo, uint32_t timeout, const
*
* @return None
*/
__API__ void tos_at_uart_input_byte(uint8_t data);
__API__ void tos_at_uart_input_byte(at_agent_t *at_agent, uint8_t data);
/**
* @brief A global lock provided by at framework.
@@ -393,7 +392,7 @@ __API__ void tos_at_uart_input_byte(uint8_t data);
* @retval -1 pend failed(error).
* @retval 0 pend successfully.
*/
__API__ int tos_at_global_lock_pend(void);
__API__ int tos_at_global_lock_pend(at_agent_t *at_agent);
/**
* @brief A global lock provided by at framework.
@@ -407,7 +406,7 @@ __API__ int tos_at_global_lock_pend(void);
* @retval -1 post failed(error).
* @retval 0 post successfully.
*/
__API__ int tos_at_global_lock_post(void);
__API__ int tos_at_global_lock_post(at_agent_t *at_agent);
/**
* @brief Read data from the uart.
@@ -420,7 +419,7 @@ __API__ int tos_at_global_lock_post(void);
*
* @return length of the data read from the uart.
*/
__API__ int tos_at_uart_read(uint8_t *buffer, size_t buffer_len);
__API__ int tos_at_uart_read(at_agent_t *at_agent, uint8_t *buffer, size_t buffer_len);
/**
* @brief Read data from the uart.
@@ -433,7 +432,7 @@ __API__ int tos_at_uart_read(uint8_t *buffer, size_t buffer_len);
*
* @return length of the data read from the uart.
*/
__API__ int tos_at_uart_readline(uint8_t *buffer, size_t buffer_len);
__API__ int tos_at_uart_readline(at_agent_t *at_agent, uint8_t *buffer, size_t buffer_len);
/**
* @brief Read data from the uart.
@@ -446,7 +445,7 @@ __API__ int tos_at_uart_readline(uint8_t *buffer, size_t buffer_len);
*
* @return length of the data read from the uart.
*/
__API__ int tos_at_uart_drain(uint8_t *buffer, size_t buffer_len);
__API__ int tos_at_uart_drain(at_agent_t *at_agent, uint8_t *buffer, size_t buffer_len);
/**
* @brief Get the remote ip of a channel.