From 4d431cd1aeac4a5a78945f2dff6ee44fde18ebd3 Mon Sep 17 00:00:00 2001 From: Ari Parkkila Date: Mon, 25 Jun 2018 14:05:12 +0300 Subject: [PATCH 1/2] Cellular: Removed max_packet_size --- .../at/at_cellularstack/test_at_cellularstack.cpp | 6 ------ features/cellular/framework/AT/AT_CellularStack.cpp | 5 +---- features/cellular/framework/AT/AT_CellularStack.h | 5 ----- .../QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp | 11 +++-------- .../targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.h | 3 --- .../QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp | 5 ----- .../targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.h | 3 --- 7 files changed, 4 insertions(+), 34 deletions(-) diff --git a/features/cellular/UNITTESTS/at/at_cellularstack/test_at_cellularstack.cpp b/features/cellular/UNITTESTS/at/at_cellularstack/test_at_cellularstack.cpp index 331dde5027d..a489faf474c 100644 --- a/features/cellular/UNITTESTS/at/at_cellularstack/test_at_cellularstack.cpp +++ b/features/cellular/UNITTESTS/at/at_cellularstack/test_at_cellularstack.cpp @@ -34,7 +34,6 @@ class MyStack : public AT_CellularStack { bool bool_value; bool max_sock_value; nsapi_error_t create_error; - int max_packet_size; CellularSocket socket; MyStack(ATHandler &atr, int cid, nsapi_ip_stack_t typ) : AT_CellularStack(atr, cid, typ) @@ -42,13 +41,10 @@ class MyStack : public AT_CellularStack { bool_value = false; max_sock_value = 0; create_error = NSAPI_ERROR_OK; - max_packet_size = 0; } virtual int get_max_socket_count(){return max_sock_value;} - virtual int get_max_packet_size(){return max_packet_size;} - virtual bool is_protocol_supported(nsapi_protocol_t protocol){return bool_value;} virtual nsapi_error_t socket_close_impl(int sock_id){return NSAPI_ERROR_OK;} @@ -266,7 +262,6 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_sendto() CHECK(NSAPI_ERROR_CONNECTION_LOST == st.socket_sendto(sock, addr, "addr", 4)); st.create_error = NSAPI_ERROR_OK; - st.max_packet_size = 6; CHECK(NSAPI_ERROR_OK == st.socket_sendto(sock, addr, "addr", 4)); } @@ -301,7 +296,6 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_recvfrom() CHECK(NSAPI_ERROR_CONNECTION_LOST == st.socket_recvfrom(sock, &addr, table, 4)); st.create_error = NSAPI_ERROR_OK; - st.max_packet_size = 6; CHECK(NSAPI_ERROR_OK == st.socket_recvfrom(sock, &addr, table, 4)); } diff --git a/features/cellular/framework/AT/AT_CellularStack.cpp b/features/cellular/framework/AT/AT_CellularStack.cpp index df9753fa0a1..df6f1c9348e 100644 --- a/features/cellular/framework/AT/AT_CellularStack.cpp +++ b/features/cellular/framework/AT/AT_CellularStack.cpp @@ -257,11 +257,8 @@ nsapi_size_or_error_t AT_CellularStack::socket_sendto(nsapi_socket_t handle, con } } - unsigned max_packet_size = get_max_packet_size(); - /* Check parameters */ - if (addr.get_ip_version() == NSAPI_UNSPEC || - size > max_packet_size) { + if (addr.get_ip_version() == NSAPI_UNSPEC) { return NSAPI_ERROR_DEVICE_ERROR; } diff --git a/features/cellular/framework/AT/AT_CellularStack.h b/features/cellular/framework/AT/AT_CellularStack.h index 04682f26031..5f3cf5e1d31 100644 --- a/features/cellular/framework/AT/AT_CellularStack.h +++ b/features/cellular/framework/AT/AT_CellularStack.h @@ -105,11 +105,6 @@ class AT_CellularStack : public NetworkStack, public AT_CellularBase */ virtual int get_max_socket_count() = 0; - /** - * Gets maximum packet size - */ - virtual int get_max_packet_size() = 0; - /** * Checks if modem supports the given protocol * diff --git a/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp b/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp index ccdcb05a10e..b8c3bcc13ca 100644 --- a/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp +++ b/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp @@ -61,11 +61,6 @@ int QUECTEL_BC95_CellularStack::get_max_socket_count() return BC95_SOCKET_MAX; } -int QUECTEL_BC95_CellularStack::get_max_packet_size() -{ - return BC95_MAX_PACKET_SIZE; -} - bool QUECTEL_BC95_CellularStack::is_protocol_supported(nsapi_protocol_t protocol) { return (protocol == NSAPI_UDP); @@ -146,7 +141,7 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSoc { int sent_len = 0; - char *hexstr = new char[BC95_MAX_PACKET_SIZE*2+1]; + char *hexstr = new char[size*2+1]; int hexlen = char_str_to_hex_str((const char*)data, size, hexstr); // NULL terminated for write_string hexstr[hexlen] = 0; @@ -154,7 +149,7 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSoc _at.write_int(socket->id); _at.write_string(address.get_ip_address(), false); _at.write_int(address.get_port()); - _at.write_int(size <= BC95_MAX_PACKET_SIZE ? size : BC95_MAX_PACKET_SIZE); + _at.write_int(size); _at.write_string(hexstr, false); _at.cmd_stop(); _at.resp_start(); @@ -181,7 +176,7 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_recvfrom_impl(CellularS _at.cmd_start("AT+NSORF="); _at.write_int(socket->id); - _at.write_int(size <= BC95_MAX_PACKET_SIZE ? size : BC95_MAX_PACKET_SIZE); + _at.write_int(size); _at.cmd_stop(); _at.resp_start(); // receiving socket id diff --git a/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.h b/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.h index 616240b41da..91dc7499a93 100644 --- a/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.h +++ b/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.h @@ -21,7 +21,6 @@ #include "AT_CellularStack.h" #define BC95_SOCKET_MAX 7 -#define BC95_MAX_PACKET_SIZE 1358 namespace mbed { @@ -42,8 +41,6 @@ class QUECTEL_BC95_CellularStack : public AT_CellularStack virtual int get_max_socket_count(); - virtual int get_max_packet_size(); - virtual bool is_protocol_supported(nsapi_protocol_t protocol); virtual nsapi_error_t socket_close_impl(int sock_id); diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp index 12120bb59c3..deb03b55e85 100644 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp @@ -64,11 +64,6 @@ int QUECTEL_BG96_CellularStack::get_max_socket_count() return BG96_SOCKET_MAX; } -int QUECTEL_BG96_CellularStack::get_max_packet_size() -{ - return BG96_MAX_PACKET_SIZE; -} - bool QUECTEL_BG96_CellularStack::is_protocol_supported(nsapi_protocol_t protocol) { return (protocol == NSAPI_UDP); diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.h b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.h index af243ccfab7..1553e00153c 100644 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.h +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.h @@ -23,7 +23,6 @@ namespace mbed { #define BG96_SOCKET_MAX 12 -#define BG96_MAX_PACKET_SIZE 1460 #define BG96_CREATE_SOCKET_TIMEOUT 150000 //150 seconds class QUECTEL_BG96_CellularStack : public AT_CellularStack @@ -43,8 +42,6 @@ class QUECTEL_BG96_CellularStack : public AT_CellularStack virtual int get_max_socket_count(); - virtual int get_max_packet_size(); - virtual bool is_protocol_supported(nsapi_protocol_t protocol); virtual nsapi_error_t socket_close_impl(int sock_id); From ee4101530424d7091cec5bff2b94a02559e9e6fb Mon Sep 17 00:00:00 2001 From: Mirela Chirica Date: Wed, 11 Jul 2018 13:45:00 +0300 Subject: [PATCH 2/2] Cellular: Fix socket_send unit test --- .../UNITTESTS/at/at_cellularstack/test_at_cellularstack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/cellular/UNITTESTS/at/at_cellularstack/test_at_cellularstack.cpp b/features/cellular/UNITTESTS/at/at_cellularstack/test_at_cellularstack.cpp index a489faf474c..973b3fdd081 100644 --- a/features/cellular/UNITTESTS/at/at_cellularstack/test_at_cellularstack.cpp +++ b/features/cellular/UNITTESTS/at/at_cellularstack/test_at_cellularstack.cpp @@ -239,7 +239,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_send() nsapi_socket_t sock = &st.socket; st.socket_open(&sock, NSAPI_TCP); st.socket_connect(sock, addr); - CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_send(sock, "addr", 4)); + CHECK(NSAPI_ERROR_OK == st.socket_send(sock, "addr", 4)); } void Test_AT_CellularStack::test_AT_CellularStack_socket_sendto()