|
@@ -8,7 +8,7 @@
|
|
* 2018-03-30 chenyong first version
|
|
* 2018-03-30 chenyong first version
|
|
* 2018-04-12 chenyong add client implement
|
|
* 2018-04-12 chenyong add client implement
|
|
* 2018-08-17 chenyong multiple client support
|
|
* 2018-08-17 chenyong multiple client support
|
|
- * 2021-03-17 Meco Man fix a buf of leaking memory
|
|
|
|
|
|
+ * 2021-03-17 Meco Man fix a buf of leaking memory
|
|
*/
|
|
*/
|
|
|
|
|
|
#include <at.h>
|
|
#include <at.h>
|
|
@@ -28,6 +28,10 @@
|
|
|
|
|
|
static struct at_client at_client_table[AT_CLIENT_NUM_MAX] = { 0 };
|
|
static struct at_client at_client_table[AT_CLIENT_NUM_MAX] = { 0 };
|
|
|
|
|
|
|
|
+extern rt_size_t at_utils_send(rt_device_t dev,
|
|
|
|
+ rt_off_t pos,
|
|
|
|
+ const void *buffer,
|
|
|
|
+ rt_size_t size);
|
|
extern rt_size_t at_vprintfln(rt_device_t device, const char *format, va_list args);
|
|
extern rt_size_t at_vprintfln(rt_device_t device, const char *format, va_list args);
|
|
extern void at_print_raw_cmd(const char *type, const char *cmd, rt_size_t size);
|
|
extern void at_print_raw_cmd(const char *type, const char *cmd, rt_size_t size);
|
|
extern const char *at_get_last_cmd(rt_size_t *cmd_size);
|
|
extern const char *at_get_last_cmd(rt_size_t *cmd_size);
|
|
@@ -392,7 +396,7 @@ int at_client_obj_wait_connect(at_client_t client, rt_uint32_t timeout)
|
|
/* Check whether it is already connected */
|
|
/* Check whether it is already connected */
|
|
resp->buf_len = 0;
|
|
resp->buf_len = 0;
|
|
resp->line_counts = 0;
|
|
resp->line_counts = 0;
|
|
- rt_device_write(client->device, 0, "AT\r\n", 4);
|
|
|
|
|
|
+ at_utils_send(client->device, 0, "AT\r\n", 4);
|
|
|
|
|
|
if (rt_sem_take(client->resp_notice, resp->timeout) != RT_EOK)
|
|
if (rt_sem_take(client->resp_notice, resp->timeout) != RT_EOK)
|
|
continue;
|
|
continue;
|
|
@@ -433,7 +437,13 @@ rt_size_t at_client_obj_send(at_client_t client, const char *buf, rt_size_t size
|
|
at_print_raw_cmd("sendline", buf, size);
|
|
at_print_raw_cmd("sendline", buf, size);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- return rt_device_write(client->device, 0, buf, size);
|
|
|
|
|
|
+ rt_mutex_take(client->lock, RT_WAITING_FOREVER);
|
|
|
|
+
|
|
|
|
+ rt_size_t len = at_utils_send(client->device, 0, buf, size);
|
|
|
|
+
|
|
|
|
+ rt_mutex_release(client->lock);
|
|
|
|
+
|
|
|
|
+ return len;
|
|
}
|
|
}
|
|
|
|
|
|
static rt_err_t at_client_getchar(at_client_t client, char *ch, rt_int32_t timeout)
|
|
static rt_err_t at_client_getchar(at_client_t client, char *ch, rt_int32_t timeout)
|