mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: Fix Gemalto/Cinterion driver
parent
b1b0673622
commit
89b66465c2
|
@ -127,6 +127,10 @@ void GEMALTO_CINTERION::init_module_els61()
|
|||
0, // AT_CGSN_WITH_TYPE
|
||||
1, // AT_CGDATA
|
||||
1, // AT_CGAUTH
|
||||
1, // AT_CNMI
|
||||
1, // AT_CSMP
|
||||
1, // AT_CMGF
|
||||
1, // AT_CSDH
|
||||
1, // PROPERTY_IPV4_STACK
|
||||
1, // PROPERTY_IPV6_STACK
|
||||
0, // PROPERTY_IPV4V6_STACK
|
||||
|
@ -147,6 +151,10 @@ void GEMALTO_CINTERION::init_module_ems31()
|
|||
1, // AT_CGSN_WITH_TYPE
|
||||
1, // AT_CGDATA
|
||||
1, // AT_CGAUTH
|
||||
1, // AT_CNMI
|
||||
1, // AT_CSMP
|
||||
1, // AT_CMGF
|
||||
1, // AT_CSDH
|
||||
1, // PROPERTY_IPV4_STACK
|
||||
1, // PROPERTY_IPV6_STACK
|
||||
1, // PROPERTY_IPV4V6_STACK
|
||||
|
|
|
@ -25,11 +25,6 @@
|
|||
#define UDP_PACKET_SIZE 1460
|
||||
#define FAILURE_TIMEOUT (30*1000) // failure timeout in milliseconds on modem side
|
||||
|
||||
/*
|
||||
* Use connection profile 0 and Internet service profiles starting from 0 for sockets.
|
||||
*/
|
||||
#define CONNECTION_PROFILE_ID 0
|
||||
|
||||
using namespace mbed;
|
||||
|
||||
GEMALTO_CINTERION_CellularStack::GEMALTO_CINTERION_CellularStack(ATHandler &atHandler, const char *apn, const char *user, const char *password,
|
||||
|
@ -109,8 +104,7 @@ void GEMALTO_CINTERION_CellularStack::sisr_urc_handler(int sock_id, int urc_code
|
|||
nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_stack_init()
|
||||
{
|
||||
_at.lock();
|
||||
int connection_profile_id = CONNECTION_PROFILE_ID;
|
||||
nsapi_error_t err = create_connection_profile(connection_profile_id);
|
||||
nsapi_error_t err = create_connection_profile(_cid);
|
||||
if (!err) {
|
||||
_at.set_urc_handler("^SIS:", mbed::Callback<void()>(this, &GEMALTO_CINTERION_CellularStack::urc_sis));
|
||||
_at.set_urc_handler("^SISW:", mbed::Callback<void()>(this, &GEMALTO_CINTERION_CellularStack::urc_sisw));
|
||||
|
@ -122,7 +116,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_stack_init()
|
|||
socket_close_impl(i);
|
||||
}
|
||||
_at.clear_error();
|
||||
close_connection_profile(connection_profile_id);
|
||||
close_connection_profile(_cid);
|
||||
}
|
||||
_at.unlock();
|
||||
return err;
|
||||
|
@ -157,8 +151,6 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_close_impl(int sock_id)
|
|||
|
||||
nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket *socket, const SocketAddress *address)
|
||||
{
|
||||
int connection_profile_id = CONNECTION_PROFILE_ID;
|
||||
|
||||
int retry_open = 1;
|
||||
retry_open:
|
||||
// setup internet session profile
|
||||
|
@ -193,7 +185,7 @@ retry_open:
|
|||
}
|
||||
if (strcmp(paramTag, "conId") == 0) {
|
||||
char buf[10];
|
||||
std::sprintf(buf, "%d", connection_profile_id);
|
||||
std::sprintf(buf, "%d", _cid);
|
||||
if (strcmp(paramValue, buf) == 0) {
|
||||
foundConIdType = true;
|
||||
}
|
||||
|
@ -209,7 +201,7 @@ retry_open:
|
|||
}
|
||||
|
||||
if (!foundConIdType) {
|
||||
_at.at_cmd_discard("^SISS", "=", "%d%s%d", internet_service_id, "conId", connection_profile_id);
|
||||
_at.at_cmd_discard("^SISS", "=", "%d%s%d", internet_service_id, "conId", _cid);
|
||||
}
|
||||
|
||||
// host address (IPv4) and local+remote port is needed only for BGS2 which does not support UDP server socket
|
||||
|
@ -238,7 +230,7 @@ retry_open:
|
|||
_at.at_cmd_discard("^SISO", "=", "%d", internet_service_id);
|
||||
|
||||
if (_at.get_last_error()) {
|
||||
tr_error("Socket %d open failed!", socket->id);
|
||||
tr_error("Socket %d open failed!", internet_service_id);
|
||||
_at.clear_error();
|
||||
socket_close_impl(internet_service_id); // socket may already be open on modem if app and modem are not in sync, as a recovery, try to close the socket so open succeeds the next time
|
||||
if (retry_open--) {
|
||||
|
@ -390,7 +382,7 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_recvfrom_impl(Cell
|
|||
if (!socket->pending_bytes) {
|
||||
_at.process_oob(); // check for ^SISR URC
|
||||
if (!socket->pending_bytes) {
|
||||
tr_debug("Socekt %d recv would block", socket->id);
|
||||
tr_debug("Socket %d recv would block", socket->id);
|
||||
return NSAPI_ERROR_WOULD_BLOCK;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue