From d904b679682a26e00233c18b19ef56f6998e3895 Mon Sep 17 00:00:00 2001 From: luhuadong Date: Tue, 21 Jul 2020 00:32:07 +0800 Subject: [PATCH 1/3] [bc28] support alloc socket dynamically --- class/bc28/README.md | 15 ++++++++++++ class/bc28/at_socket_bc28.c | 46 +++++++++---------------------------- 2 files changed, 26 insertions(+), 35 deletions(-) create mode 100644 class/bc28/README.md diff --git a/class/bc28/README.md b/class/bc28/README.md new file mode 100644 index 00000000..f77cb3ff --- /dev/null +++ b/class/bc28/README.md @@ -0,0 +1,15 @@ +# BC28 + +## 注意事项 + +### 申请 socket + +- BC28 最多支持 7 个 socket,编号 0-6; +- 如果 BC28 使用支持 MQTT 或 CoAP 协议的固件,则相关服务会占用部分 socket,因此最小可用的 socket 并不一定是 0; +- 可以创建 1 个 UDP socket,多个 TCP socket; +- 另外,执行 DNS 域名解析时也会占用 socket; + +### 连接 socket + +- R02 的基线版本固件才支持 `AT+QTCPIND` 查询 TCP 连接情况,因此目前采用保守的 30 秒延时来确保连接状态; + diff --git a/class/bc28/at_socket_bc28.c b/class/bc28/at_socket_bc28.c index 3ec16a2c..52a9e9c6 100644 --- a/class/bc28/at_socket_bc28.c +++ b/class/bc28/at_socket_bc28.c @@ -20,6 +20,7 @@ * Change Logs: * Date Author Notes * 2020-02-13 luhuadong first version + * 2020-07-19 luhuadong support alloc socket */ #include @@ -194,7 +195,7 @@ static int bc28_socket_close(struct at_socket *socket) { int result = RT_EOK; at_response_t resp = RT_NULL; - int device_socket = (int) socket->user_data + AT_DEVICE_BC28_MIN_SOCKET; + int device_socket = (int) socket->user_data; struct at_device *device = (struct at_device *) socket->device; resp = at_create_resp(64, 0, rt_tick_from_millisecond(3000)); @@ -223,16 +224,16 @@ static int bc28_socket_close(struct at_socket *socket) * create socket by AT commands. * * @param type connect socket type(tcp, udp) - * @param port listen port (range: 0-65535), if 0 means get a random port * * @return >=0: create socket success, return the socket id (0-6) * -1: send or exec AT commands error * -5: no memory */ -static int bc28_socket_create(struct at_device *device, enum at_socket_type type, uint32_t port) +static int bc28_socket_create(struct at_device *device, enum at_socket_type type) { const char *type_str = RT_NULL; uint32_t protocol = 0; + uint32_t port = 0; /* range: 0-65535, if 0 means get a random port */ at_response_t resp = RT_NULL; int socket = -1, result = 0; @@ -309,7 +310,7 @@ static int bc28_socket_connect(struct at_socket *socket, char *ip, int32_t port, uint32_t event = 0; at_response_t resp = RT_NULL; int result = 0, event_result = 0; - int device_socket = (int) socket->user_data + AT_DEVICE_BC28_MIN_SOCKET; + int device_socket = (int) socket->user_data; int return_socket = -1; struct at_device *device = (struct at_device *) socket->device; @@ -328,32 +329,6 @@ static int bc28_socket_connect(struct at_socket *socket, char *ip, int32_t port, return -RT_ENOMEM; } - return_socket = bc28_socket_create(device, type, 0); - - if (return_socket != device_socket) - { - LOG_E("socket not match (request %d, return %d).", device_socket, return_socket); - - result = at_obj_exec_cmd(device->client, resp, "AT+NSOCL=%d", return_socket); - if (result < 0) - { - LOG_E("%s device close socket(%d) failed [%d].", device->name, return_socket, result); - } - else - { - LOG_D("%s device close socket(%d).", device->name, return_socket); - - /* notice the socket is disconnect by remote */ - if (at_evt_cb_set[AT_SOCKET_EVT_CLOSED]) - { - at_evt_cb_set[AT_SOCKET_EVT_CLOSED](socket, AT_SOCKET_EVT_CLOSED, NULL, 0); - } - } - - result = -RT_ERROR; - goto __exit; - } - /* if the protocol is not tcp, no need connect to server */ if (type != AT_SOCKET_TCP) { @@ -439,7 +414,7 @@ static int bc28_socket_send(struct at_socket *socket, const char *buff, int result = 0, event_result = 0; size_t cur_pkt_size = 0, sent_size = 0; at_response_t resp = RT_NULL; - int device_socket = (int) socket->user_data + AT_DEVICE_BC28_MIN_SOCKET; + int device_socket = (int) socket->user_data; struct at_device *device = (struct at_device *) socket->device; struct at_device_bc28 *bc28 = (struct at_device_bc28 *) device->user_data; rt_mutex_t lock = device->client->lock; @@ -748,10 +723,10 @@ static void urc_close_func(struct at_client *client, const char *data, rt_size_t bc28_socket_event_send(device, SET_EVENT(device_socket, BC28_EVENT_CONN_FAIL)); - if (device_socket - AT_DEVICE_BC28_MIN_SOCKET >= 0) + if (device_socket >= 0) { /* get at socket object by device socket descriptor */ - socket = &(device->sockets[device_socket - AT_DEVICE_BC28_MIN_SOCKET]); + socket = &(device->sockets[device_socket]); /* notice the socket is disconnect by remote */ if (at_evt_cb_set[AT_SOCKET_EVT_CLOSED]) @@ -828,7 +803,7 @@ static void urc_recv_func(struct at_client *client, const char *data, rt_size_t rt_free(hex_buf); /* get at socket object by device socket descriptor */ - socket = &(device->sockets[device_socket - AT_DEVICE_BC28_MIN_SOCKET]); + socket = &(device->sockets[device_socket]); /* notice the receive buffer and buffer size */ if (at_evt_cb_set[AT_SOCKET_EVT_RECV]) @@ -895,6 +870,7 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops bc28_socket_ops = { + bc28_socket_create, bc28_socket_connect, bc28_socket_close, bc28_socket_send, @@ -916,7 +892,7 @@ int bc28_socket_class_register(struct at_device_class *class) { RT_ASSERT(class); - class->socket_num = AT_DEVICE_BC28_SOCKETS_NUM - AT_DEVICE_BC28_MIN_SOCKET; + class->socket_num = AT_DEVICE_BC28_SOCKETS_NUM; class->socket_ops = &bc28_socket_ops; return RT_EOK; From ca9ef1997ed9b08282d170169d4a8523410e4155 Mon Sep 17 00:00:00 2001 From: luhuadong Date: Tue, 21 Jul 2020 00:35:52 +0800 Subject: [PATCH 2/3] Compatible with all devices while add new member function in at_socket_ops structure --- class/a9g/at_socket_a9g.c | 1 + class/air720/at_socket_air720.c | 13 +++++++------ class/bc26/at_socket_bc26.c | 1 + class/ec20/at_socket_ec20.c | 1 + class/ec200x/at_socket_ec200x.c | 1 + class/esp32/at_socket_esp32.c | 1 + class/esp8266/at_socket_esp8266.c | 1 + class/m26/at_socket_m26.c | 1 + class/m5311/at_socket_m5311.c | 1 + class/m6315/at_socket_m6315.c | 1 + class/me3616/at_socket_me3616.c | 1 + class/mw31/at_socket_mw31.c | 1 + class/n21/at_socket_n21.c | 13 +++++++------ class/n58/at_socket_n58.c | 13 +++++++------ class/rw007/at_socket_rw007.c | 1 + class/sim76xx/at_socket_sim76xx.c | 1 + class/sim800c/at_socket_sim800c.c | 1 + class/w60x/at_socket_w60x.c | 1 + 18 files changed, 36 insertions(+), 18 deletions(-) diff --git a/class/a9g/at_socket_a9g.c b/class/a9g/at_socket_a9g.c index aeb1ca02..7b67e176 100644 --- a/class/a9g/at_socket_a9g.c +++ b/class/a9g/at_socket_a9g.c @@ -593,6 +593,7 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops a9g_socket_ops = { + RT_NULL, a9g_socket_connect, a9g_socket_close, a9g_socket_send, diff --git a/class/air720/at_socket_air720.c b/class/air720/at_socket_air720.c index 20e53a41..04a9313f 100644 --- a/class/air720/at_socket_air720.c +++ b/class/air720/at_socket_air720.c @@ -645,12 +645,13 @@ static const struct at_urc urc_table[] = }; static const struct at_socket_ops air720_socket_ops = - { - air720_socket_connect, - air720_socket_close, - air720_socket_send, - air720_domain_resolve, - air720_socket_set_event_cb, +{ + RT_NULL, + air720_socket_connect, + air720_socket_close, + air720_socket_send, + air720_domain_resolve, + air720_socket_set_event_cb, }; int air720_socket_init(struct at_device *device) diff --git a/class/bc26/at_socket_bc26.c b/class/bc26/at_socket_bc26.c index 16f6d47c..3a46727f 100644 --- a/class/bc26/at_socket_bc26.c +++ b/class/bc26/at_socket_bc26.c @@ -759,6 +759,7 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops bc26_socket_ops = { + RT_NULL, bc26_socket_connect, bc26_socket_close, bc26_socket_send, diff --git a/class/ec20/at_socket_ec20.c b/class/ec20/at_socket_ec20.c index 8ecca834..22cccdf5 100644 --- a/class/ec20/at_socket_ec20.c +++ b/class/ec20/at_socket_ec20.c @@ -978,6 +978,7 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops ec20_socket_ops = { + RT_NULL, ec20_socket_connect, ec20_socket_close, ec20_socket_send, diff --git a/class/ec200x/at_socket_ec200x.c b/class/ec200x/at_socket_ec200x.c index c48098f4..887850e5 100644 --- a/class/ec200x/at_socket_ec200x.c +++ b/class/ec200x/at_socket_ec200x.c @@ -772,6 +772,7 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops ec200x_socket_ops = { + RT_NULL, ec200x_socket_connect, ec200x_socket_close, ec200x_socket_send, diff --git a/class/esp32/at_socket_esp32.c b/class/esp32/at_socket_esp32.c index 16daad33..65147045 100644 --- a/class/esp32/at_socket_esp32.c +++ b/class/esp32/at_socket_esp32.c @@ -388,6 +388,7 @@ static void esp32_socket_set_event_cb(at_socket_evt_t event, at_evt_cb_t cb) static const struct at_socket_ops esp32_socket_ops = { + RT_NULL, esp32_socket_connect, esp32_socket_close, esp32_socket_send, diff --git a/class/esp8266/at_socket_esp8266.c b/class/esp8266/at_socket_esp8266.c index 71ebd9d2..e1f02d09 100644 --- a/class/esp8266/at_socket_esp8266.c +++ b/class/esp8266/at_socket_esp8266.c @@ -388,6 +388,7 @@ static void esp8266_socket_set_event_cb(at_socket_evt_t event, at_evt_cb_t cb) static const struct at_socket_ops esp8266_socket_ops = { + RT_NULL, esp8266_socket_connect, esp8266_socket_close, esp8266_socket_send, diff --git a/class/m26/at_socket_m26.c b/class/m26/at_socket_m26.c index 75906f63..93fbefff 100644 --- a/class/m26/at_socket_m26.c +++ b/class/m26/at_socket_m26.c @@ -654,6 +654,7 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops m26_socket_ops = { + RT_NULL, m26_socket_connect, m26_socket_close, m26_socket_send, diff --git a/class/m5311/at_socket_m5311.c b/class/m5311/at_socket_m5311.c index a8cd92e9..c9d7c68f 100644 --- a/class/m5311/at_socket_m5311.c +++ b/class/m5311/at_socket_m5311.c @@ -656,6 +656,7 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops m5311_socket_ops = { + RT_NULL, m5311_socket_connect, m5311_socket_close, m5311_socket_send, diff --git a/class/m6315/at_socket_m6315.c b/class/m6315/at_socket_m6315.c index af460cc7..81be72b4 100644 --- a/class/m6315/at_socket_m6315.c +++ b/class/m6315/at_socket_m6315.c @@ -606,6 +606,7 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops m6315_socket_ops = { + RT_NULL, m6315_socket_connect, m6315_socket_close, m6315_socket_send, diff --git a/class/me3616/at_socket_me3616.c b/class/me3616/at_socket_me3616.c index 9c42422d..7d2720e1 100644 --- a/class/me3616/at_socket_me3616.c +++ b/class/me3616/at_socket_me3616.c @@ -561,6 +561,7 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops me3616_socket_ops = { + RT_NULL, me3616_socket_connect, me3616_socket_close, me3616_socket_send, diff --git a/class/mw31/at_socket_mw31.c b/class/mw31/at_socket_mw31.c index ffdb71cf..118f7a2a 100644 --- a/class/mw31/at_socket_mw31.c +++ b/class/mw31/at_socket_mw31.c @@ -361,6 +361,7 @@ static void mw31_socket_set_event_cb(at_socket_evt_t event, at_evt_cb_t cb) static const struct at_socket_ops mw31_socket_ops = { + RT_NULL, mw31_socket_connect, mw31_socket_close, mw31_socket_send, diff --git a/class/n21/at_socket_n21.c b/class/n21/at_socket_n21.c index 2ae01a8e..3657a01f 100644 --- a/class/n21/at_socket_n21.c +++ b/class/n21/at_socket_n21.c @@ -630,12 +630,13 @@ static const struct at_urc urc_table[] = }; static const struct at_socket_ops n21_socket_ops = - { - n21_socket_connect, - n21_socket_close, - n21_socket_send, - n21_domain_resolve, - n21_socket_set_event_cb, +{ + RT_NULL, + n21_socket_connect, + n21_socket_close, + n21_socket_send, + n21_domain_resolve, + n21_socket_set_event_cb, }; int n21_socket_init(struct at_device *device) diff --git a/class/n58/at_socket_n58.c b/class/n58/at_socket_n58.c index 6977061b..42a8c710 100644 --- a/class/n58/at_socket_n58.c +++ b/class/n58/at_socket_n58.c @@ -638,12 +638,13 @@ static const struct at_urc urc_table[] = }; static const struct at_socket_ops n58_socket_ops = - { - n58_socket_connect, - n58_socket_close, - n58_socket_send, - n58_domain_resolve, - n58_socket_set_event_cb, +{ + RT_NULL, + n58_socket_connect, + n58_socket_close, + n58_socket_send, + n58_domain_resolve, + n58_socket_set_event_cb, }; int n58_socket_init(struct at_device *device) diff --git a/class/rw007/at_socket_rw007.c b/class/rw007/at_socket_rw007.c index 2f6a20b6..e61c61c9 100644 --- a/class/rw007/at_socket_rw007.c +++ b/class/rw007/at_socket_rw007.c @@ -387,6 +387,7 @@ static void rw007_socket_set_event_cb(at_socket_evt_t event, at_evt_cb_t cb) static const struct at_socket_ops rw007_socket_ops = { + RT_NULL, rw007_socket_connect, rw007_socket_close, rw007_socket_send, diff --git a/class/sim76xx/at_socket_sim76xx.c b/class/sim76xx/at_socket_sim76xx.c index fa81529a..3d745935 100644 --- a/class/sim76xx/at_socket_sim76xx.c +++ b/class/sim76xx/at_socket_sim76xx.c @@ -671,6 +671,7 @@ static struct at_urc urc_table[] = static const struct at_socket_ops sim76xx_socket_ops = { + RT_NULL, sim76xx_socket_connect, sim76xx_socket_close, sim76xx_socket_send, diff --git a/class/sim800c/at_socket_sim800c.c b/class/sim800c/at_socket_sim800c.c index 06bffe7f..38da1759 100644 --- a/class/sim800c/at_socket_sim800c.c +++ b/class/sim800c/at_socket_sim800c.c @@ -611,6 +611,7 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops sim800c_socket_ops = { + RT_NULL, sim800c_socket_connect, sim800c_socket_close, sim800c_socket_send, diff --git a/class/w60x/at_socket_w60x.c b/class/w60x/at_socket_w60x.c index 5aa543d6..429fbd85 100644 --- a/class/w60x/at_socket_w60x.c +++ b/class/w60x/at_socket_w60x.c @@ -351,6 +351,7 @@ static void w60x_socket_set_event_cb(at_socket_evt_t event, at_evt_cb_t cb) static const struct at_socket_ops w60x_socket_ops = { + RT_NULL, w60x_socket_connect, w60x_socket_close, w60x_socket_send, From b23e2a845a80b67a5e38e9d660789099ed1bf0a7 Mon Sep 17 00:00:00 2001 From: luhuadong Date: Thu, 23 Jul 2020 01:09:00 +0800 Subject: [PATCH 3/3] Add version num judgement in at_socket_ops --- class/a9g/at_socket_a9g.c | 4 +++- class/air720/at_socket_air720.c | 4 +++- class/bc26/at_socket_bc26.c | 4 +++- class/bc28/at_device_bc28.c | 5 ++++- class/bc28/at_socket_bc28.c | 9 +++++++-- class/ec20/at_socket_ec20.c | 4 +++- class/ec200x/at_socket_ec200x.c | 4 +++- class/esp32/at_socket_esp32.c | 4 +++- class/esp8266/at_socket_esp8266.c | 4 +++- class/m26/at_socket_m26.c | 4 +++- class/m5311/at_socket_m5311.c | 4 +++- class/m6315/at_socket_m6315.c | 4 +++- class/me3616/at_socket_me3616.c | 4 +++- class/mw31/at_socket_mw31.c | 4 +++- class/n21/at_socket_n21.c | 23 ++++++++++++----------- class/n58/at_socket_n58.c | 24 ++++++++++++------------ class/rw007/at_socket_rw007.c | 4 +++- class/sim76xx/at_socket_sim76xx.c | 4 +++- class/sim800c/at_socket_sim800c.c | 4 +++- class/w60x/at_socket_w60x.c | 4 +++- 20 files changed, 83 insertions(+), 42 deletions(-) diff --git a/class/a9g/at_socket_a9g.c b/class/a9g/at_socket_a9g.c index 7b67e176..fce0d0e3 100644 --- a/class/a9g/at_socket_a9g.c +++ b/class/a9g/at_socket_a9g.c @@ -593,12 +593,14 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops a9g_socket_ops = { - RT_NULL, a9g_socket_connect, a9g_socket_close, a9g_socket_send, a9g_domain_resolve, a9g_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int a9g_socket_init(struct at_device *device) diff --git a/class/air720/at_socket_air720.c b/class/air720/at_socket_air720.c index 04a9313f..cd60c3b7 100644 --- a/class/air720/at_socket_air720.c +++ b/class/air720/at_socket_air720.c @@ -646,12 +646,14 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops air720_socket_ops = { - RT_NULL, air720_socket_connect, air720_socket_close, air720_socket_send, air720_domain_resolve, air720_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int air720_socket_init(struct at_device *device) diff --git a/class/bc26/at_socket_bc26.c b/class/bc26/at_socket_bc26.c index 3a46727f..bc9a53d0 100644 --- a/class/bc26/at_socket_bc26.c +++ b/class/bc26/at_socket_bc26.c @@ -759,12 +759,14 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops bc26_socket_ops = { - RT_NULL, bc26_socket_connect, bc26_socket_close, bc26_socket_send, bc26_domain_resolve, bc26_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int bc26_socket_init(struct at_device *device) diff --git a/class/bc28/at_device_bc28.c b/class/bc28/at_device_bc28.c index 04285ad5..d68b7a27 100644 --- a/class/bc28/at_device_bc28.c +++ b/class/bc28/at_device_bc28.c @@ -24,9 +24,12 @@ #include #include - #include +#if !defined(AT_SW_VERSION_NUM) || AT_SW_VERSION_NUM < 0x10301 +#error "This AT Client version is older, please check and update latest AT Client!" +#endif + #define LOG_TAG "at.dev.bc28" #include diff --git a/class/bc28/at_socket_bc28.c b/class/bc28/at_socket_bc28.c index 52a9e9c6..739f3977 100644 --- a/class/bc28/at_socket_bc28.c +++ b/class/bc28/at_socket_bc28.c @@ -25,9 +25,12 @@ #include #include - #include +#if !defined(AT_SW_VERSION_NUM) || AT_SW_VERSION_NUM < 0x10301 +#error "This AT Client version is older, please check and update latest AT Client!" +#endif + #define LOG_TAG "at.skt.bc28" #include @@ -870,12 +873,14 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops bc28_socket_ops = { - bc28_socket_create, bc28_socket_connect, bc28_socket_close, bc28_socket_send, bc28_domain_resolve, bc28_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + bc28_socket_create, +#endif }; int bc28_socket_init(struct at_device *device) diff --git a/class/ec20/at_socket_ec20.c b/class/ec20/at_socket_ec20.c index 22cccdf5..59150977 100644 --- a/class/ec20/at_socket_ec20.c +++ b/class/ec20/at_socket_ec20.c @@ -978,12 +978,14 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops ec20_socket_ops = { - RT_NULL, ec20_socket_connect, ec20_socket_close, ec20_socket_send, ec20_domain_resolve, ec20_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int ec20_socket_init(struct at_device *device) diff --git a/class/ec200x/at_socket_ec200x.c b/class/ec200x/at_socket_ec200x.c index 887850e5..582cf52e 100644 --- a/class/ec200x/at_socket_ec200x.c +++ b/class/ec200x/at_socket_ec200x.c @@ -772,12 +772,14 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops ec200x_socket_ops = { - RT_NULL, ec200x_socket_connect, ec200x_socket_close, ec200x_socket_send, ec200x_domain_resolve, ec200x_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int ec200x_socket_init(struct at_device *device) diff --git a/class/esp32/at_socket_esp32.c b/class/esp32/at_socket_esp32.c index 65147045..3147f570 100644 --- a/class/esp32/at_socket_esp32.c +++ b/class/esp32/at_socket_esp32.c @@ -388,12 +388,14 @@ static void esp32_socket_set_event_cb(at_socket_evt_t event, at_evt_cb_t cb) static const struct at_socket_ops esp32_socket_ops = { - RT_NULL, esp32_socket_connect, esp32_socket_close, esp32_socket_send, esp32_domain_resolve, esp32_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; static void urc_send_func(struct at_client *client, const char *data, rt_size_t size) diff --git a/class/esp8266/at_socket_esp8266.c b/class/esp8266/at_socket_esp8266.c index e1f02d09..c54dd128 100644 --- a/class/esp8266/at_socket_esp8266.c +++ b/class/esp8266/at_socket_esp8266.c @@ -388,12 +388,14 @@ static void esp8266_socket_set_event_cb(at_socket_evt_t event, at_evt_cb_t cb) static const struct at_socket_ops esp8266_socket_ops = { - RT_NULL, esp8266_socket_connect, esp8266_socket_close, esp8266_socket_send, esp8266_domain_resolve, esp8266_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; static void urc_send_func(struct at_client *client, const char *data, rt_size_t size) diff --git a/class/m26/at_socket_m26.c b/class/m26/at_socket_m26.c index 93fbefff..6e06bd86 100644 --- a/class/m26/at_socket_m26.c +++ b/class/m26/at_socket_m26.c @@ -654,12 +654,14 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops m26_socket_ops = { - RT_NULL, m26_socket_connect, m26_socket_close, m26_socket_send, m26_domain_resolve, m26_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int m26_socket_init(struct at_device *device) diff --git a/class/m5311/at_socket_m5311.c b/class/m5311/at_socket_m5311.c index c9d7c68f..7adb7385 100644 --- a/class/m5311/at_socket_m5311.c +++ b/class/m5311/at_socket_m5311.c @@ -656,12 +656,14 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops m5311_socket_ops = { - RT_NULL, m5311_socket_connect, m5311_socket_close, m5311_socket_send, m5311_domain_resolve, m5311_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int m5311_socket_init(struct at_device *device) diff --git a/class/m6315/at_socket_m6315.c b/class/m6315/at_socket_m6315.c index 81be72b4..4b67a0c7 100644 --- a/class/m6315/at_socket_m6315.c +++ b/class/m6315/at_socket_m6315.c @@ -606,12 +606,14 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops m6315_socket_ops = { - RT_NULL, m6315_socket_connect, m6315_socket_close, m6315_socket_send, m6315_domain_resolve, m6315_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int m6315_socket_init(struct at_device *device) diff --git a/class/me3616/at_socket_me3616.c b/class/me3616/at_socket_me3616.c index 7d2720e1..820ceaf5 100644 --- a/class/me3616/at_socket_me3616.c +++ b/class/me3616/at_socket_me3616.c @@ -561,12 +561,14 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops me3616_socket_ops = { - RT_NULL, me3616_socket_connect, me3616_socket_close, me3616_socket_send, me3616_domain_resolve, me3616_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int me3616_socket_init(struct at_device *device) diff --git a/class/mw31/at_socket_mw31.c b/class/mw31/at_socket_mw31.c index 118f7a2a..c912174d 100644 --- a/class/mw31/at_socket_mw31.c +++ b/class/mw31/at_socket_mw31.c @@ -361,12 +361,14 @@ static void mw31_socket_set_event_cb(at_socket_evt_t event, at_evt_cb_t cb) static const struct at_socket_ops mw31_socket_ops = { - RT_NULL, mw31_socket_connect, mw31_socket_close, mw31_socket_send, mw31_domain_resolve, mw31_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; static void urc_recv_func(struct at_client *client, const char *data, rt_size_t size) diff --git a/class/n21/at_socket_n21.c b/class/n21/at_socket_n21.c index 3657a01f..f2ab1563 100644 --- a/class/n21/at_socket_n21.c +++ b/class/n21/at_socket_n21.c @@ -617,26 +617,27 @@ static void urc_recv_func(struct at_client *client, const char *data, rt_size_t /* n21 device URC table for the socket data */ static const struct at_urc urc_table[] = - { - {"+TCPSETUP:", "\r\n", urc_connect_func}, - {"+UDPSETUP:", "\r\n", urc_connect_func}, - {"+TCPSEND:", "\r\n", urc_send_func}, - {"+UDPSEND:", "\r\n", urc_send_func}, - {"+TCPCLOSE:", "\r\n", urc_close_func}, - {"+UDPCLOSE:", "\r\n", urc_close_func}, - {"+TCPRECV:", "\r\n", urc_recv_func}, - {"+UDPRECV:", "\r\n", urc_recv_func}, - +{ + {"+TCPSETUP:", "\r\n", urc_connect_func}, + {"+UDPSETUP:", "\r\n", urc_connect_func}, + {"+TCPSEND:", "\r\n", urc_send_func}, + {"+UDPSEND:", "\r\n", urc_send_func}, + {"+TCPCLOSE:", "\r\n", urc_close_func}, + {"+UDPCLOSE:", "\r\n", urc_close_func}, + {"+TCPRECV:", "\r\n", urc_recv_func}, + {"+UDPRECV:", "\r\n", urc_recv_func}, }; static const struct at_socket_ops n21_socket_ops = { - RT_NULL, n21_socket_connect, n21_socket_close, n21_socket_send, n21_domain_resolve, n21_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int n21_socket_init(struct at_device *device) diff --git a/class/n58/at_socket_n58.c b/class/n58/at_socket_n58.c index 42a8c710..5f90011f 100644 --- a/class/n58/at_socket_n58.c +++ b/class/n58/at_socket_n58.c @@ -624,27 +624,27 @@ static void urc_recv_func(struct at_client *client, const char *data, rt_size_t /* n58 device URC table for the socket data */ static const struct at_urc urc_table[] = - { - - {"+TCPSETUP:", "\r\n", urc_connect_func}, - {"+UDPSETUP:", "\r\n", urc_connect_func}, - {"+TCPSEND:", "\r\n", urc_send_func}, - {"+UDPSEND:", "\r\n", urc_send_func}, - {"+TCPCLOSE:", "\r\n", urc_close_func}, - {"+UDPCLOSE:", "\r\n", urc_close_func}, - {"+TCPRECV:", "\r\n", urc_recv_func}, - {"+UDPRECV:", "\r\n", urc_recv_func}, - +{ + {"+TCPSETUP:", "\r\n", urc_connect_func}, + {"+UDPSETUP:", "\r\n", urc_connect_func}, + {"+TCPSEND:", "\r\n", urc_send_func}, + {"+UDPSEND:", "\r\n", urc_send_func}, + {"+TCPCLOSE:", "\r\n", urc_close_func}, + {"+UDPCLOSE:", "\r\n", urc_close_func}, + {"+TCPRECV:", "\r\n", urc_recv_func}, + {"+UDPRECV:", "\r\n", urc_recv_func}, }; static const struct at_socket_ops n58_socket_ops = { - RT_NULL, n58_socket_connect, n58_socket_close, n58_socket_send, n58_domain_resolve, n58_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int n58_socket_init(struct at_device *device) diff --git a/class/rw007/at_socket_rw007.c b/class/rw007/at_socket_rw007.c index e61c61c9..ab1defa5 100644 --- a/class/rw007/at_socket_rw007.c +++ b/class/rw007/at_socket_rw007.c @@ -387,12 +387,14 @@ static void rw007_socket_set_event_cb(at_socket_evt_t event, at_evt_cb_t cb) static const struct at_socket_ops rw007_socket_ops = { - RT_NULL, rw007_socket_connect, rw007_socket_close, rw007_socket_send, rw007_domain_resolve, rw007_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; static void urc_send_func(struct at_client *client, const char *data, rt_size_t size) diff --git a/class/sim76xx/at_socket_sim76xx.c b/class/sim76xx/at_socket_sim76xx.c index 3d745935..1de7417a 100644 --- a/class/sim76xx/at_socket_sim76xx.c +++ b/class/sim76xx/at_socket_sim76xx.c @@ -671,12 +671,14 @@ static struct at_urc urc_table[] = static const struct at_socket_ops sim76xx_socket_ops = { - RT_NULL, sim76xx_socket_connect, sim76xx_socket_close, sim76xx_socket_send, sim76xx_domain_resolve, sim76xx_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; /* initialize sim76xx device network URC feature */ diff --git a/class/sim800c/at_socket_sim800c.c b/class/sim800c/at_socket_sim800c.c index 38da1759..b65516ea 100644 --- a/class/sim800c/at_socket_sim800c.c +++ b/class/sim800c/at_socket_sim800c.c @@ -611,12 +611,14 @@ static const struct at_urc urc_table[] = static const struct at_socket_ops sim800c_socket_ops = { - RT_NULL, sim800c_socket_connect, sim800c_socket_close, sim800c_socket_send, sim800c_domain_resolve, sim800c_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; int sim800c_socket_init(struct at_device *device) diff --git a/class/w60x/at_socket_w60x.c b/class/w60x/at_socket_w60x.c index 429fbd85..113cbc79 100644 --- a/class/w60x/at_socket_w60x.c +++ b/class/w60x/at_socket_w60x.c @@ -351,12 +351,14 @@ static void w60x_socket_set_event_cb(at_socket_evt_t event, at_evt_cb_t cb) static const struct at_socket_ops w60x_socket_ops = { - RT_NULL, w60x_socket_connect, w60x_socket_close, w60x_socket_send, w60x_domain_resolve, w60x_socket_set_event_cb, +#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300 + RT_NULL, +#endif }; static void urc_recv_func(struct at_client *client, const char *data, rt_size_t size)