Cellular: Fixed network registration on Gemalto AT drivers

pull/7677/head
Ari Parkkila 2018-08-27 06:06:24 -07:00
parent 9d0e3d8797
commit 90fe9de8ed
4 changed files with 21 additions and 12 deletions

View File

@ -41,21 +41,28 @@ NetworkStack *GEMALTO_CINTERION_CellularNetwork::get_stack()
bool GEMALTO_CINTERION_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requested_stack) bool GEMALTO_CINTERION_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requested_stack)
{ {
#if NSAPI_PPP_AVAILABLE
return (requested_stack == IPV4_STACK || requested_stack == IPV6_STACK);
#else
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelBGS2) { if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelBGS2) {
return (requested_stack == IPV4_STACK); return (requested_stack == IPV4_STACK);
} }
return (requested_stack == IPV4_STACK || requested_stack == IPV6_STACK); return (requested_stack == IPV4_STACK || requested_stack == IPV6_STACK);
#endif
} }
bool GEMALTO_CINTERION_CellularNetwork::has_registration(RegistrationType reg_type) AT_CellularNetwork::RegistrationMode GEMALTO_CINTERION_CellularNetwork::has_registration(RegistrationType reg_type)
{ {
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelEMS31) { if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelEMS31) {
return (reg_type == C_EREG); return (reg_type == C_EREG) ? RegistrationModeLAC : RegistrationModeDisable;
} }
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelBGS2) { if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelBGS2) {
return (reg_type == C_REG || reg_type == C_GREG); if (reg_type == C_GREG) {
return RegistrationModeEnable;
}
return (reg_type == C_REG) ? RegistrationModeLAC : RegistrationModeDisable;
} }
return (reg_type == C_REG || reg_type == C_GREG || reg_type == C_EREG); return (reg_type == C_REG || reg_type == C_GREG || reg_type == C_EREG) ? RegistrationModeLAC : RegistrationModeDisable;
} }
nsapi_error_t GEMALTO_CINTERION_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opsAct) nsapi_error_t GEMALTO_CINTERION_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opsAct)

View File

@ -32,7 +32,7 @@ protected:
virtual NetworkStack *get_stack(); virtual NetworkStack *get_stack();
#endif // NSAPI_PPP_AVAILABLE #endif // NSAPI_PPP_AVAILABLE
virtual bool has_registration(RegistrationType reg_type); virtual RegistrationMode has_registration(RegistrationType reg_type);
virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack); virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack);

View File

@ -60,7 +60,6 @@ void GEMALTO_CINTERION_CellularStack::urc_sis()
{ {
int sock_id = _at.read_int(); int sock_id = _at.read_int();
int urc_code = _at.read_int(); int urc_code = _at.read_int();
//tr_debug("Socket ready: id=%d, urc=%d", sock_id, urc_code);
CellularSocket *sock = find_socket(sock_id); CellularSocket *sock = find_socket(sock_id);
if (sock) { if (sock) {
if (urc_code == 5) { // data available if (urc_code == 5) { // data available
@ -79,7 +78,6 @@ void GEMALTO_CINTERION_CellularStack::urc_sisw()
{ {
int sock_id = _at.read_int(); int sock_id = _at.read_int();
int urc_code = _at.read_int(); int urc_code = _at.read_int();
//tr_debug("TX event: socket=%d, urc=%d", sock_id, urc_code);
CellularSocket *sock = find_socket(sock_id); CellularSocket *sock = find_socket(sock_id);
if (sock) { if (sock) {
if (urc_code == 1) { // ready if (urc_code == 1) { // ready
@ -100,7 +98,6 @@ void GEMALTO_CINTERION_CellularStack::urc_sisr()
{ {
int sock_id = _at.read_int(); int sock_id = _at.read_int();
int urc_code = _at.read_int(); int urc_code = _at.read_int();
//tr_debug("RX event: socket=%d, urc=%d", sock_id, urc_code);
CellularSocket *sock = find_socket(sock_id); CellularSocket *sock = find_socket(sock_id);
if (sock) { if (sock) {
if (urc_code == 1) { // data available if (urc_code == 1) { // data available
@ -221,11 +218,9 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::create_socket_impl(CellularSocket
char paramTag[16]; char paramTag[16];
int paramTagLen = _at.read_string(paramTag, sizeof(paramTag)); int paramTagLen = _at.read_string(paramTag, sizeof(paramTag));
if (paramTagLen > 0) { if (paramTagLen > 0) {
//tr_debug("paramTag %s", paramTag);
char paramValue[100 + 1]; // APN may be up to 100 chars char paramValue[100 + 1]; // APN may be up to 100 chars
int paramValueLen = _at.read_string(paramValue, sizeof(paramValue)); int paramValueLen = _at.read_string(paramValue, sizeof(paramValue));
if (paramValueLen >= 0) { if (paramValueLen >= 0) {
//tr_debug("paramValue %s", paramValue);
if (strcmp(paramTag, "srvType") == 0) { if (strcmp(paramTag, "srvType") == 0) {
if (strcmp(paramValue, "Socket") == 0) { if (strcmp(paramValue, "Socket") == 0) {
tr_debug("srvType %s", paramValue); tr_debug("srvType %s", paramValue);
@ -298,13 +293,12 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_sendto_impl(Cellul
socket_close_impl(socket->id); socket_close_impl(socket->id);
_at.clear_error(); _at.clear_error();
} }
// socket->started = false;
if (socket_open_defer(socket, &address) != NSAPI_ERROR_OK) { if (socket_open_defer(socket, &address) != NSAPI_ERROR_OK) {
tr_error("Failed to open socket %d", socket->id); tr_error("Failed to open socket %d", socket->id);
return NSAPI_ERROR_NO_SOCKET; return NSAPI_ERROR_NO_SOCKET;
} }
socket->remoteAddress = address; socket->remoteAddress = address;
// return NSAPI_ERROR_WOULD_BLOCK;
_at.resp_start("^SISW:"); _at.resp_start("^SISW:");
int sock_id = _at.read_int(); int sock_id = _at.read_int();
int urc_code = _at.read_int(); int urc_code = _at.read_int();

View File

@ -46,13 +46,21 @@ protected:
void *buffer, nsapi_size_t size); void *buffer, nsapi_size_t size);
private: private:
// find the socket handle based on socket identifier
CellularSocket *find_socket(int sock_id); CellularSocket *find_socket(int sock_id);
// socket URC handlers as per Cinterion AT manuals
void urc_sis(); void urc_sis();
void urc_sisw(); void urc_sisw();
void urc_sisr(); void urc_sisr();
// sockets need a connection profile, one profile is enough to support single stack sockets
bool create_connection_profile(); bool create_connection_profile();
// socket open need to be deferred until sendto due to BGS2 does not support UDP server endpoint
nsapi_error_t socket_open_defer(CellularSocket *socket, const SocketAddress *address = NULL); nsapi_error_t socket_open_defer(CellularSocket *socket, const SocketAddress *address = NULL);
// connection profile configuration needs Access Point Name
const char *_apn; const char *_apn;
}; };