[net][at] update AT component V1.3.0, change as follows:

- AT Socket feature supports multi-client connections;
- Fix `send data error, current socket (0) state (0) is error` issue when the socket is closed;
- Improve dirty data processing when AT device hard reset;
- Improve `at_obj_set_urc_table()` fucntion, Support for setting multiple URC tables;
- Improve RAW data print format;
This commit is contained in:
chenyong committed 2019-05-27 12:03:04 +08:00
1 parent 3d960cc178
commit b5ad12573f
6 files changed
+406 -224

No files matched your search

+1 -1
View File
@@ -83,7 +83,7 @@ if RT_USING_AT
config AT_SW_VERSION_NUM
hex
default 0x10200
default 0x10300
help
sfotware module version number
File diff suppressed because it is too large. Load diff
+17 -8
View File
@@ -36,6 +36,7 @@ extern "C" {
enum at_socket_state
{
AT_SOCKET_NONE,
AT_SOCKET_OPEN,
AT_SOCKET_LISTEN,
AT_SOCKET_CONNECT,
AT_SOCKET_CLOSED
@@ -54,18 +55,19 @@ typedef enum
AT_SOCKET_EVT_CLOSED,
} at_socket_evt_t;
typedef void (*at_evt_cb_t)(int socket, at_socket_evt_t event, const char *buff, size_t bfsz);
struct at_socket;
typedef void (*at_evt_cb_t)(struct at_socket *socket, at_socket_evt_t event, const char *buff, size_t bfsz);
/* A callback prototype to inform about events for AT socket */
typedef void (* at_socket_callback)(struct at_socket *conn, int event, uint16_t len);
/* AT device socket options function */
struct at_device_ops
/* AT socket operations function */
struct at_socket_ops
{
int (*at_connect)(int socket, char *ip, int32_t port, enum at_socket_type type, rt_bool_t is_client);
int (*at_closesocket)(int socket);
int (*at_send)(int socket, const char *buff, size_t bfsz, enum at_socket_type type);
int (*at_connect)(struct at_socket *socket, char *ip, int32_t port, enum at_socket_type type, rt_bool_t is_client);
int (*at_closesocket)(struct at_socket *socket);
int (*at_send)(struct at_socket *socket, const char *buff, size_t bfsz, enum at_socket_type type);
int (*at_domain_resolve)(const char *name, char ip[16]);
void (*at_set_event_cb)(at_socket_evt_t event, at_evt_cb_t cb);
};
@@ -86,10 +88,14 @@ struct at_socket
uint32_t magic;
int socket;
/* device releated information for the socket */
void *device;
/* type of the AT socket (TCP, UDP or RAW) */
enum at_socket_type type;
/* current state of the AT socket */
enum at_socket_state state;
/* sockets operations */
const struct at_socket_ops *ops;
/* receive semaphore, received data release semaphore */
rt_sem_t recv_notice;
rt_mutex_t recv_lock;
@@ -111,6 +117,10 @@ struct at_socket
#ifdef SAL_USING_POSIX
rt_wqueue_t wait_head;
#endif
rt_slist_t list;
/* user-specific data */
void *user_data;
};
int at_socket(int domain, int type, int protocol);
@@ -129,7 +139,6 @@ int at_getaddrinfo(const char *nodename, const char *servname, const struct addr
void at_freeaddrinfo(struct addrinfo *ai);
struct at_socket *at_get_socket(int socket);
void at_socket_device_register(const struct at_device_ops *ops);
#ifndef RT_USING_SAL
+22 -8
View File
@@ -18,7 +18,7 @@
extern "C" {
#endif
#define AT_SW_VERSION "1.2.0"
#define AT_SW_VERSION "1.3.0"
#define AT_CMD_NAME_LEN 16
#define AT_END_MARK_LEN 4
@@ -124,9 +124,11 @@ struct at_response
{
/* response buffer */
char *buf;
/* the maximum response buffer size */
/* the maximum response buffer size, it set by `at_create_resp()` function */
rt_size_t buf_size;
/* the number of setting response lines
/* the length of current response buffer */
rt_size_t buf_len;
/* the number of setting response lines, it set by `at_create_resp()` function
* == 0: the response data will auto return when received 'OK' or 'ERROR'
* != 0: the response data will return when received setting lines number data */
rt_size_t line_num;
@@ -138,15 +140,24 @@ struct at_response
typedef struct at_response *at_response_t;
struct at_client;
/* URC(Unsolicited Result Code) object, such as: 'RING', 'READY' request by AT server */
struct at_urc
{
const char *cmd_prefix;
const char *cmd_suffix;
void (*func)(const char *data, rt_size_t size);
void (*func)(struct at_client *client, const char *data, rt_size_t size);
};
typedef struct at_urc *at_urc_t;
struct at_urc_table
{
size_t urc_size;
const struct at_urc *urc;
};
typedef struct at_urc *at_urc_table_t;
struct at_client
{
rt_device_t device;
@@ -154,9 +165,12 @@ struct at_client
at_status_t status;
char end_sign;
char *recv_buffer;
/* the current received one line data buffer */
char *recv_line_buf;
/* The length of the currently received one line data */
rt_size_t recv_line_len;
/* The maximum supported receive data length */
rt_size_t recv_bufsz;
rt_size_t cur_recv_len;
rt_sem_t rx_notice;
rt_mutex_t lock;
@@ -164,7 +178,7 @@ struct at_client
rt_sem_t resp_notice;
at_resp_status_t resp_status;
const struct at_urc *urc_table;
struct at_urc_table *urc_table;
rt_size_t urc_table_size;
rt_thread_t parser;
@@ -207,7 +221,7 @@ rt_size_t at_client_obj_recv(at_client_t client, char *buf, rt_size_t size, rt_i
void at_obj_set_end_sign(at_client_t client, char ch);
/* Set URC(Unsolicited Result Code) table */
void at_obj_set_urc_table(at_client_t client, const struct at_urc * table, rt_size_t size);
int at_obj_set_urc_table(at_client_t client, const struct at_urc * table, rt_size_t size);
/* AT client send commands to AT server and waiter response */
int at_obj_exec_cmd(at_client_t client, at_response_t resp, const char *cmd_expr, ...);
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -70,7 +70,7 @@ rt_size_t at_vprintf(rt_device_t device, const char *format, va_list args)
last_cmd_len = vsnprintf(send_buf, sizeof(send_buf), format, args);
#ifdef AT_PRINT_RAW_CMD
at_print_raw_cmd("send", send_buf, last_cmd_len);
at_print_raw_cmd("sendline", send_buf, last_cmd_len);
#endif
return rt_device_write(device, 0, send_buf, last_cmd_len);