Skip to content

Cellular: Remove max_packet_size #7318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,17 @@ 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)
{
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;}
Expand Down Expand Up @@ -243,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()
Expand All @@ -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));
}

Expand Down Expand Up @@ -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));
}

Expand Down
5 changes: 1 addition & 4 deletions features/cellular/framework/AT/AT_CellularStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 0 additions & 5 deletions features/cellular/framework/AT/AT_CellularStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -146,15 +141,15 @@ 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;
_at.cmd_start("AT+NSOST=");
_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();
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "AT_CellularStack.h"

#define BC95_SOCKET_MAX 7
#define BC95_MAX_PACKET_SIZE 1358

namespace mbed {

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down