mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: Refactor get_max_socket_count() into CellularProperty
parent
b96d3ad5be
commit
e2cb18061e
|
@ -77,10 +77,6 @@ protected:
|
|||
class my_stack : public AT_CellularStack {
|
||||
public:
|
||||
my_stack(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularStack(atHandler, 1, IPV4_STACK, device) {}
|
||||
virtual int get_max_socket_count()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
virtual int get_max_packet_size()
|
||||
{
|
||||
return 200;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "ATHandler_stub.h"
|
||||
#include "SocketAddress.h"
|
||||
#include "CellularDevice_stub.h"
|
||||
#include "AT_CellularDevice_stub.h"
|
||||
#include "myCellularDevice.h"
|
||||
|
||||
using namespace mbed;
|
||||
|
@ -34,22 +35,15 @@ using namespace events;
|
|||
class MyStack : public AT_CellularStack {
|
||||
public:
|
||||
bool bool_value;
|
||||
bool max_sock_value;
|
||||
nsapi_error_t create_error;
|
||||
CellularSocket socket;
|
||||
|
||||
MyStack(ATHandler &atr, int cid, nsapi_ip_stack_t typ, AT_CellularDevice &device) : AT_CellularStack(atr, cid, typ, device)
|
||||
{
|
||||
bool_value = false;
|
||||
max_sock_value = 0;
|
||||
create_error = NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
virtual int get_max_socket_count()
|
||||
{
|
||||
return max_sock_value;
|
||||
}
|
||||
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol)
|
||||
{
|
||||
return bool_value;
|
||||
|
@ -211,15 +205,17 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_open)
|
|||
EXPECT_EQ(st.socket_open(NULL, NSAPI_TCP), NSAPI_ERROR_UNSUPPORTED);
|
||||
|
||||
st.bool_value = true;
|
||||
st.max_sock_value = 0;
|
||||
AT_CellularDevice_stub::max_sock_value = 0;
|
||||
nsapi_socket_t sock = &st.socket;
|
||||
EXPECT_EQ(st.socket_open(&sock, NSAPI_TCP), NSAPI_ERROR_NO_SOCKET);
|
||||
|
||||
MyStack st2(at, 0, IPV6_STACK, *_dev);
|
||||
st2.bool_value = true;
|
||||
st2.max_sock_value = 1;
|
||||
AT_CellularDevice_stub::max_sock_value = 1;
|
||||
sock = &st2.socket;
|
||||
EXPECT_EQ(st2.socket_open(&sock, NSAPI_TCP), NSAPI_ERROR_OK);
|
||||
|
||||
AT_CellularDevice_stub::max_sock_value = 0;
|
||||
}
|
||||
|
||||
TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_close)
|
||||
|
@ -233,13 +229,13 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_close)
|
|||
|
||||
nsapi_socket_t sock = &st.socket;
|
||||
st.bool_value = true;
|
||||
st.max_sock_value = 1;
|
||||
AT_CellularDevice_stub::max_sock_value = 1;
|
||||
EXPECT_EQ(st.socket_open(&sock, NSAPI_TCP), NSAPI_ERROR_OK);
|
||||
st.max_sock_value = 0;
|
||||
AT_CellularDevice_stub::max_sock_value = 0;
|
||||
EXPECT_EQ(st.socket_close(sock), NSAPI_ERROR_DEVICE_ERROR);
|
||||
|
||||
MyStack st2(at, 0, IPV6_STACK, *_dev);
|
||||
st2.max_sock_value = 1;
|
||||
AT_CellularDevice_stub::max_sock_value = 1;
|
||||
st2.bool_value = true;
|
||||
sock = &st2.socket;
|
||||
EXPECT_EQ(st2.socket_open(&sock, NSAPI_TCP), NSAPI_ERROR_OK);
|
||||
|
@ -306,7 +302,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_send)
|
|||
EXPECT_EQ(st.socket_send(&st.socket, "addr", 4), NSAPI_ERROR_NO_CONNECTION);
|
||||
|
||||
SocketAddress addr("fc00::", 123);
|
||||
st.max_sock_value = 1;
|
||||
AT_CellularDevice_stub::max_sock_value = 1;
|
||||
st.bool_value = true;
|
||||
nsapi_socket_t sock = &st.socket;
|
||||
st.socket_open(&sock, NSAPI_TCP);
|
||||
|
@ -325,7 +321,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_sendto)
|
|||
SocketAddress addr("fc00::", 123);
|
||||
EXPECT_EQ(st.socket_sendto(NULL, addr, "addr", 4), NSAPI_ERROR_NO_SOCKET);
|
||||
|
||||
st.max_sock_value = 1;
|
||||
AT_CellularDevice_stub::max_sock_value = 1;
|
||||
st.bool_value = true;
|
||||
nsapi_socket_t sock = &st.socket;
|
||||
st.socket_open(&sock, NSAPI_TCP);
|
||||
|
@ -359,7 +355,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_recvfrom)
|
|||
EXPECT_EQ(st.socket_recvfrom(NULL, NULL, table, 4), NSAPI_ERROR_NO_SOCKET);
|
||||
|
||||
SocketAddress addr;
|
||||
st.max_sock_value = 1;
|
||||
AT_CellularDevice_stub::max_sock_value = 1;
|
||||
st.bool_value = true;
|
||||
nsapi_socket_t sock = &st.socket;
|
||||
st.socket_open(&sock, NSAPI_TCP);
|
||||
|
@ -380,7 +376,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_attach)
|
|||
MyStack st(at, 0, IPV6_STACK, *_dev);
|
||||
|
||||
st.socket_attach(NULL, NULL, NULL);
|
||||
st.max_sock_value = 1;
|
||||
AT_CellularDevice_stub::max_sock_value = 1;
|
||||
st.bool_value = true;
|
||||
nsapi_socket_t sock = &st.socket;
|
||||
st.socket_open(&sock, NSAPI_TCP);
|
||||
|
|
|
@ -31,6 +31,7 @@ int AT_CellularDevice_stub::set_pin_failure_count = 0;
|
|||
int AT_CellularDevice_stub::get_sim_failure_count = 0;
|
||||
bool AT_CellularDevice_stub::pin_needed = false;
|
||||
bool AT_CellularDevice_stub::supported_bool = false;
|
||||
int AT_CellularDevice_stub::max_sock_value = 0;
|
||||
|
||||
AT_CellularDevice::AT_CellularDevice(FileHandle *fh) : CellularDevice(fh),
|
||||
#if MBED_CONF_CELLULAR_USE_SMS
|
||||
|
@ -293,6 +294,8 @@ intptr_t AT_CellularDevice::get_property(CellularProperty key)
|
|||
return true;
|
||||
} else if (key == PROPERTY_IPV4_PDP_TYPE) {
|
||||
return true;
|
||||
} else if (key == PROPERTY_SOCKET_COUNT) {
|
||||
return AT_CellularDevice_stub::max_sock_value;
|
||||
}
|
||||
|
||||
return AT_CellularDevice_stub::supported_bool;
|
||||
|
|
|
@ -28,6 +28,7 @@ extern int set_pin_failure_count;
|
|||
extern int get_sim_failure_count;
|
||||
extern bool pin_needed;
|
||||
extern bool supported_bool;
|
||||
extern int max_sock_value;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP?
|
||||
PROPERTY_AT_CGEREP, // 0 = not supported, 1 = supported. Does modem support AT command AT+CGEREP.
|
||||
PROPERTY_AT_COPS_FALLBACK_AUTO, // 0 = not supported, 1 = supported. Does modem support mode 4 of AT+COPS= ?
|
||||
|
||||
PROPERTY_SOCKET_COUNT, // The number of sockets of modem IP stack
|
||||
PROPERTY_MAX
|
||||
};
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ using namespace mbed_cellular_util;
|
|||
using namespace mbed;
|
||||
|
||||
AT_CellularStack::AT_CellularStack(ATHandler &at, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
|
||||
_socket(NULL), _socket_count(0), _cid(cid),
|
||||
_socket(NULL), _cid(cid),
|
||||
_stack_type(stack_type), _ip_ver_sendto(NSAPI_UNSPEC), _at(at), _device(device)
|
||||
{
|
||||
memset(_ip, 0, PDP_IPV6_SIZE);
|
||||
|
@ -33,22 +33,21 @@ AT_CellularStack::AT_CellularStack(ATHandler &at, int cid, nsapi_ip_stack_t stac
|
|||
|
||||
AT_CellularStack::~AT_CellularStack()
|
||||
{
|
||||
for (int i = 0; i < _socket_count; i++) {
|
||||
if (_socket[i]) {
|
||||
delete _socket[i];
|
||||
_socket[i] = NULL;
|
||||
if (_socket) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
if (_socket[i]) {
|
||||
delete _socket[i];
|
||||
_socket[i] = NULL;
|
||||
}
|
||||
}
|
||||
delete [] _socket;
|
||||
_socket = NULL;
|
||||
}
|
||||
_socket_count = 0;
|
||||
|
||||
delete [] _socket;
|
||||
_socket = NULL;
|
||||
}
|
||||
|
||||
int AT_CellularStack::find_socket_index(nsapi_socket_t handle)
|
||||
{
|
||||
int max_socket_count = get_max_socket_count();
|
||||
for (int i = 0; i < max_socket_count; i++) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
if (_socket[i] == handle) {
|
||||
return i;
|
||||
}
|
||||
|
@ -162,8 +161,6 @@ nsapi_error_t AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protoc
|
|||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int max_socket_count = get_max_socket_count();
|
||||
|
||||
_socket_mutex.lock();
|
||||
|
||||
if (!_socket) {
|
||||
|
@ -172,9 +169,8 @@ nsapi_error_t AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protoc
|
|||
return NSAPI_ERROR_NO_SOCKET;
|
||||
}
|
||||
|
||||
_socket = new CellularSocket*[max_socket_count];
|
||||
_socket_count = max_socket_count;
|
||||
for (int i = 0; i < max_socket_count; i++) {
|
||||
_socket = new CellularSocket*[_device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT)];
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
_socket[i] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -435,8 +431,7 @@ void AT_CellularStack::socket_attach(nsapi_socket_t handle, void (*callback)(voi
|
|||
|
||||
int AT_CellularStack::get_socket_index_by_port(uint16_t port)
|
||||
{
|
||||
int max_socket_count = get_max_socket_count();
|
||||
for (int i = 0; i < max_socket_count; i++) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
if (_socket[i]->localAddress.get_port() == port) {
|
||||
return i;
|
||||
}
|
||||
|
@ -447,7 +442,7 @@ int AT_CellularStack::get_socket_index_by_port(uint16_t port)
|
|||
AT_CellularStack::CellularSocket *AT_CellularStack::find_socket(int sock_id)
|
||||
{
|
||||
CellularSocket *sock = NULL;
|
||||
for (int i = 0; i < _socket_count; i++) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
if (_socket[i] && _socket[i]->id == sock_id) {
|
||||
sock = _socket[i];
|
||||
break;
|
||||
|
|
|
@ -135,11 +135,6 @@ protected:
|
|||
bool txfull_event; // socket event after wouldblock
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets maximum number of sockets modem supports
|
||||
*/
|
||||
virtual int get_max_socket_count() = 0;
|
||||
|
||||
/**
|
||||
* Checks if modem supports the given protocol
|
||||
*
|
||||
|
@ -218,9 +213,6 @@ protected:
|
|||
// socket container
|
||||
CellularSocket **_socket;
|
||||
|
||||
// number of socket slots allocated in socket container
|
||||
int _socket_count;
|
||||
|
||||
// IP address
|
||||
char _ip[PDP_IPV6_SIZE];
|
||||
|
||||
|
|
|
@ -113,6 +113,7 @@ void GEMALTO_CINTERION::init_module_bgs2()
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
10, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
set_cellular_properties(cellular_properties);
|
||||
_module = ModuleBGS2;
|
||||
|
@ -138,6 +139,7 @@ void GEMALTO_CINTERION::init_module_els61()
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
10, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
set_cellular_properties(cellular_properties);
|
||||
_module = ModuleELS61;
|
||||
|
@ -163,6 +165,7 @@ void GEMALTO_CINTERION::init_module_ems31()
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
10, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
set_cellular_properties(cellular_properties);
|
||||
_module = ModuleEMS31;
|
||||
|
@ -188,6 +191,7 @@ void GEMALTO_CINTERION::init_module_ehs5e()
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
10, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
set_cellular_properties(cellular_properties);
|
||||
_module = ModuleEHS5E;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "CellularLog.h"
|
||||
|
||||
// defines as per ELS61-E2_ATC_V01.000 and BGS2-W_ATC_V00.100
|
||||
#define SOCKET_MAX 10
|
||||
#define UDP_PACKET_SIZE 1460
|
||||
#define FAILURE_TIMEOUT (30*1000) // failure timeout in milliseconds on modem side
|
||||
|
||||
|
@ -122,7 +121,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_stack_init()
|
|||
_at.set_urc_handler("^SISR:", mbed::Callback<void()>(this, &GEMALTO_CINTERION_CellularStack::urc_sisr));
|
||||
} else { // recovery cleanup
|
||||
// close all Internet and connection profiles
|
||||
for (int i = 0; i < SOCKET_MAX; i++) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
_at.clear_error();
|
||||
socket_close_impl(i);
|
||||
}
|
||||
|
@ -133,11 +132,6 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_stack_init()
|
|||
return err;
|
||||
}
|
||||
|
||||
int GEMALTO_CINTERION_CellularStack::get_max_socket_count()
|
||||
{
|
||||
return SOCKET_MAX;
|
||||
}
|
||||
|
||||
bool GEMALTO_CINTERION_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
|
||||
{
|
||||
return (protocol == NSAPI_UDP || protocol == NSAPI_TCP);
|
||||
|
|
|
@ -32,8 +32,6 @@ protected:
|
|||
|
||||
virtual nsapi_error_t socket_stack_init();
|
||||
|
||||
virtual int get_max_socket_count();
|
||||
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol);
|
||||
|
||||
virtual nsapi_error_t socket_close_impl(int sock_id);
|
||||
|
|
|
@ -38,6 +38,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
0, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
|
||||
GENERIC_AT3GPP::GENERIC_AT3GPP(FileHandle *fh) : AT_CellularDevice(fh)
|
||||
|
|
|
@ -38,6 +38,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
0, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
|
||||
SARA4_PPP::SARA4_PPP(FileHandle *fh) : AT_CellularDevice(fh)
|
||||
|
|
|
@ -45,6 +45,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
1, // PROPERTY_NON_IP_PDP_TYPE
|
||||
0, // PROPERTY_AT_CGEREP,
|
||||
0, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
7, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
|
||||
QUECTEL_BC95::QUECTEL_BC95(FileHandle *fh) : AT_CellularDevice(fh)
|
||||
|
|
|
@ -95,7 +95,7 @@ void QUECTEL_BC95_CellularStack::urc_nsonmi()
|
|||
{
|
||||
int sock_id = _at.read_int();
|
||||
|
||||
for (int i = 0; i < get_max_socket_count(); i++) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
CellularSocket *sock = _socket[i];
|
||||
if (sock && sock->id == sock_id) {
|
||||
if (sock->_cb) {
|
||||
|
@ -128,11 +128,6 @@ void QUECTEL_BC95_CellularStack::urc_nsocli()
|
|||
}
|
||||
|
||||
|
||||
int QUECTEL_BC95_CellularStack::get_max_socket_count()
|
||||
{
|
||||
return BC95_SOCKET_MAX;
|
||||
}
|
||||
|
||||
bool QUECTEL_BC95_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
|
||||
{
|
||||
return (protocol == NSAPI_UDP || protocol == NSAPI_TCP);
|
||||
|
@ -308,7 +303,7 @@ void QUECTEL_BC95_CellularStack::txfull_event_timeout()
|
|||
{
|
||||
_socket_mutex.lock();
|
||||
_txfull_event_id = 0;
|
||||
for (int i = 0; i < get_max_socket_count(); i++) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
CellularSocket *sock = _socket[i];
|
||||
if (sock && sock->_cb && sock->txfull_event) {
|
||||
sock->txfull_event = false;
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include "AT_CellularStack.h"
|
||||
|
||||
#define BC95_SOCKET_MAX 7
|
||||
|
||||
namespace mbed {
|
||||
|
||||
class QUECTEL_BC95_CellularStack : public AT_CellularStack {
|
||||
|
@ -40,8 +38,6 @@ protected: // NetworkStack
|
|||
|
||||
protected: // AT_CellularStack
|
||||
|
||||
virtual int get_max_socket_count();
|
||||
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol);
|
||||
|
||||
virtual nsapi_error_t socket_close_impl(int sock_id);
|
||||
|
|
|
@ -62,6 +62,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
1, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP,
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
12, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
|
||||
QUECTEL_BG96::QUECTEL_BG96(FileHandle *fh, PinName pwr, bool active_high, PinName rst)
|
||||
|
|
|
@ -222,11 +222,6 @@ void QUECTEL_BG96_CellularStack::urc_qiurc(urc_type_t urc_type)
|
|||
}
|
||||
}
|
||||
|
||||
int QUECTEL_BG96_CellularStack::get_max_socket_count()
|
||||
{
|
||||
return BG96_SOCKET_MAX;
|
||||
}
|
||||
|
||||
bool QUECTEL_BG96_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
|
||||
{
|
||||
return (protocol == NSAPI_UDP || protocol == NSAPI_TCP);
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
#define BG96_SOCKET_MAX 12
|
||||
#define BG96_CREATE_SOCKET_TIMEOUT 150000 //150 seconds
|
||||
#define BG96_CLOSE_SOCKET_TIMEOUT 20000 // TCP socket max timeout is >10sec
|
||||
#define BG96_MAX_RECV_SIZE 1500
|
||||
|
@ -60,8 +59,6 @@ protected: // NetworkStack
|
|||
|
||||
protected: // AT_CellularStack
|
||||
|
||||
virtual int get_max_socket_count();
|
||||
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol);
|
||||
|
||||
virtual nsapi_error_t socket_close_impl(int sock_id);
|
||||
|
|
|
@ -63,6 +63,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP,
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
0, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
|
||||
QUECTEL_EC2X::QUECTEL_EC2X(FileHandle *fh, PinName pwr, bool active_high, PinName rst)
|
||||
|
|
|
@ -41,6 +41,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
6, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
|
||||
QUECTEL_M26::QUECTEL_M26(FileHandle *fh) : AT_CellularDevice(fh)
|
||||
|
|
|
@ -116,7 +116,7 @@ void QUECTEL_M26_CellularStack::urc_qiurc()
|
|||
(void) _at.skip_param(); /*<tlen>*/
|
||||
_at.unlock();
|
||||
|
||||
for (int i = 0; i < get_max_socket_count(); i++) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
CellularSocket *sock = _socket[i];
|
||||
if (sock && sock->id == sock_id) {
|
||||
if (sock->_cb) {
|
||||
|
@ -217,11 +217,6 @@ nsapi_error_t QUECTEL_M26_CellularStack::socket_stack_init()
|
|||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
int QUECTEL_M26_CellularStack::get_max_socket_count()
|
||||
{
|
||||
return M26_SOCKET_MAX;
|
||||
}
|
||||
|
||||
bool QUECTEL_M26_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
|
||||
{
|
||||
return (protocol == NSAPI_UDP || protocol == NSAPI_TCP);
|
||||
|
@ -328,7 +323,7 @@ nsapi_error_t QUECTEL_M26_CellularStack::create_socket_impl(CellularSocket *sock
|
|||
int potential_sid = -1;
|
||||
int index = find_socket_index(socket);
|
||||
|
||||
for (int i = 0; i < get_max_socket_count(); i++) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
CellularSocket *sock = _socket[i];
|
||||
if (sock && sock != socket && sock->id == index) {
|
||||
duplicate = true;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
#define M26_SOCKET_MAX 6
|
||||
#define M26_CREATE_SOCKET_TIMEOUT 75000 //75 seconds
|
||||
#define M26_SENT_BYTE_MAX 1460
|
||||
#define M26_RECV_BYTE_MAX 1024
|
||||
|
@ -47,8 +46,6 @@ protected: // AT_CellularStack
|
|||
|
||||
virtual nsapi_error_t socket_stack_init();
|
||||
|
||||
virtual int get_max_socket_count();
|
||||
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol);
|
||||
|
||||
virtual nsapi_error_t socket_close_impl(int sock_id);
|
||||
|
|
|
@ -43,6 +43,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP,
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
0, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
|
||||
QUECTEL_UG96::QUECTEL_UG96(FileHandle *fh) : AT_CellularDevice(fh)
|
||||
|
|
|
@ -45,6 +45,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
0, // PROPERTY_AT_CGEREP
|
||||
0, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
7, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
|
||||
RM1000_AT::RM1000_AT(FileHandle *fh) : AT_CellularDevice(fh)
|
||||
|
|
|
@ -87,12 +87,6 @@ void RM1000_AT_CellularStack::RUSOCL_URC()
|
|||
clear_socket(socket);
|
||||
}
|
||||
|
||||
int RM1000_AT_CellularStack::get_max_socket_count()
|
||||
{
|
||||
tr_debug("RM1000_AT_CellularStack::get_max_socket_count");
|
||||
return RM1000_MAX_SOCKET;
|
||||
}
|
||||
|
||||
bool RM1000_AT_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
|
||||
{
|
||||
return (protocol == NSAPI_UDP || protocol == NSAPI_TCP);
|
||||
|
@ -117,7 +111,7 @@ nsapi_error_t RM1000_AT_CellularStack::create_socket_impl(CellularSocket *socket
|
|||
}
|
||||
|
||||
// Check for duplicate socket id delivered by modem
|
||||
for (int i = 0; i < RM1000_MAX_SOCKET; i++) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
CellularSocket *sock = _socket[i];
|
||||
if (sock && sock != socket && sock->id == sock_id) {
|
||||
return NSAPI_ERROR_NO_SOCKET;
|
||||
|
|
|
@ -56,17 +56,11 @@ protected: // AT_CellularStack
|
|||
*/
|
||||
static const int SOCKET_TIMEOUT = 1000;
|
||||
|
||||
/** Maximum allowed sockets.
|
||||
*/
|
||||
static const int RM1000_MAX_SOCKET = 7;
|
||||
|
||||
/** The maximum number of bytes in a packet that can be write/read from
|
||||
* the AT interface in one go.
|
||||
*/
|
||||
static const int RM1000_MAX_PACKET_SIZE = 1024;
|
||||
|
||||
virtual int get_max_socket_count();
|
||||
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol);
|
||||
|
||||
virtual nsapi_error_t create_socket_impl(CellularSocket *socket);
|
||||
|
|
|
@ -38,6 +38,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP,
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
0, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
|
||||
TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh)
|
||||
|
|
|
@ -59,6 +59,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
0, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
|
||||
//the delay between sending AT commands
|
||||
|
|
|
@ -38,6 +38,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
7, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_G3XX)
|
||||
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
||||
|
@ -61,6 +62,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
7, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
#else
|
||||
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
||||
|
@ -80,6 +82,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
0, // PROPERTY_AT_CGEREP
|
||||
0, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
0, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -107,11 +107,6 @@ void UBLOX_AT_CellularStack::UUPSDD_URC()
|
|||
clear_socket(socket);
|
||||
}
|
||||
|
||||
int UBLOX_AT_CellularStack::get_max_socket_count()
|
||||
{
|
||||
return UBLOX_MAX_SOCKET;
|
||||
}
|
||||
|
||||
bool UBLOX_AT_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
|
||||
{
|
||||
return (protocol == NSAPI_UDP || protocol == NSAPI_TCP);
|
||||
|
@ -133,7 +128,7 @@ nsapi_error_t UBLOX_AT_CellularStack::create_socket_impl(CellularSocket *socket)
|
|||
}
|
||||
|
||||
// Check for duplicate socket id delivered by modem
|
||||
for (int i = 0; i < UBLOX_MAX_SOCKET; i++) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
CellularSocket *sock = _socket[i];
|
||||
if (sock && sock != socket && sock->id == sock_id) {
|
||||
return NSAPI_ERROR_NO_SOCKET;
|
||||
|
@ -378,7 +373,7 @@ UBLOX_AT_CellularStack::CellularSocket *UBLOX_AT_CellularStack::find_socket(int
|
|||
{
|
||||
CellularSocket *socket = NULL;
|
||||
|
||||
for (unsigned int x = 0; (socket == NULL) && (x < UBLOX_MAX_SOCKET); x++) {
|
||||
for (unsigned int x = 0; (socket == NULL) && (x < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT)); x++) {
|
||||
if (_socket) {
|
||||
if (_socket[x]->id == id) {
|
||||
socket = (_socket[x]);
|
||||
|
|
|
@ -60,17 +60,11 @@ protected:
|
|||
*/
|
||||
static const int SOCKET_TIMEOUT = 1000;
|
||||
|
||||
/** Maximum allowed sockets.
|
||||
*/
|
||||
static const int UBLOX_MAX_SOCKET = 7;
|
||||
|
||||
/** The maximum number of bytes in a packet that can be write/read from
|
||||
* the AT interface in one go.
|
||||
*/
|
||||
static const int UBLOX_MAX_PACKET_SIZE = 1024;
|
||||
|
||||
virtual int get_max_socket_count();
|
||||
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol);
|
||||
|
||||
virtual nsapi_error_t create_socket_impl(CellularSocket *socket);
|
||||
|
|
|
@ -37,6 +37,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
1, // PROPERTY_NON_IP_PDP_TYPE
|
||||
0, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
7, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
|
||||
UBLOX_N2XX::UBLOX_N2XX(FileHandle *fh): AT_CellularDevice(fh)
|
||||
|
|
|
@ -64,11 +64,6 @@ void UBLOX_N2XX_CellularStack::NSONMI_URC()
|
|||
}
|
||||
}
|
||||
|
||||
int UBLOX_N2XX_CellularStack::get_max_socket_count()
|
||||
{
|
||||
return N2XX_MAX_SOCKET;
|
||||
}
|
||||
|
||||
bool UBLOX_N2XX_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
|
||||
{
|
||||
return (protocol == NSAPI_UDP);
|
||||
|
@ -97,7 +92,7 @@ nsapi_error_t UBLOX_N2XX_CellularStack::create_socket_impl(CellularSocket *socke
|
|||
_at.unlock();
|
||||
|
||||
// Check for duplicate socket id delivered by modem
|
||||
for (int i = 0; i < N2XX_MAX_SOCKET; i++) {
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
CellularSocket *sock = _socket[i];
|
||||
if (sock && sock != socket && sock->id == sock_id) {
|
||||
return NSAPI_ERROR_NO_SOCKET;
|
||||
|
|
|
@ -47,17 +47,11 @@ protected:
|
|||
*/
|
||||
static const int SOCKET_TIMEOUT = 1000;
|
||||
|
||||
/** Maximum allowed sockets.
|
||||
*/
|
||||
static const int N2XX_MAX_SOCKET = 7;
|
||||
|
||||
/** The maximum number of bytes in a packet that can be write/read from
|
||||
* the AT interface in one go.
|
||||
*/
|
||||
static const int N2XX_MAX_PACKET_SIZE = 512;
|
||||
|
||||
virtual int get_max_socket_count();
|
||||
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol);
|
||||
|
||||
virtual nsapi_error_t create_socket_impl(CellularSocket *socket);
|
||||
|
|
|
@ -39,6 +39,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
0, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_G3XX)
|
||||
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
||||
|
@ -62,6 +63,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
1, // PROPERTY_AT_CGEREP
|
||||
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
0, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
#else
|
||||
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
||||
|
@ -81,6 +83,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
0, // PROPERTY_NON_IP_PDP_TYPE
|
||||
0, // PROPERTY_AT_CGEREP
|
||||
0, // PROPERTY_AT_COPS_FALLBACK_AUTO
|
||||
0, // PROPERTY_SOCKET_COUNT
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue