mirror of https://github.com/ARMmbed/mbed-os.git
UBLOX cellular context activation updated for C030_R412M and updated AUTH configuration
parent
417a9fe2fb
commit
6cd60178fa
|
@ -54,7 +54,8 @@ public:
|
|||
enum AuthenticationType {
|
||||
NOAUTH = 0,
|
||||
PAP,
|
||||
CHAP
|
||||
CHAP,
|
||||
AUTOMATIC
|
||||
};
|
||||
|
||||
/* whether the additional exception reports are allowed to be sent when the maximum uplink rate is reached */
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
|
||||
#include "UBLOX_AT.h"
|
||||
#include "UBLOX_AT_CellularNetwork.h"
|
||||
#include "UBLOX_AT_CellularContext.h"
|
||||
|
||||
using namespace mbed;
|
||||
using namespace events;
|
||||
|
@ -72,7 +70,8 @@ AT_CellularNetwork *UBLOX_AT::open_network_impl(ATHandler &at)
|
|||
|
||||
AT_CellularContext *UBLOX_AT::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)
|
||||
{
|
||||
return new UBLOX_AT_CellularContext(at, this, apn, cp_req, nonip_req);
|
||||
ubx_context = new UBLOX_AT_CellularContext(at, this, apn, cp_req, nonip_req);
|
||||
return ubx_context;
|
||||
}
|
||||
|
||||
#if MBED_CONF_UBLOX_AT_PROVIDE_DEFAULT
|
||||
|
@ -89,3 +88,127 @@ CellularDevice *CellularDevice::get_default_instance()
|
|||
}
|
||||
#endif
|
||||
|
||||
nsapi_error_t UBLOX_AT::init()
|
||||
{
|
||||
_at->lock();
|
||||
_at->flush();
|
||||
_at->cmd_start("AT");
|
||||
_at->cmd_stop_read_resp();
|
||||
|
||||
#ifdef TARGET_UBLOX_C027
|
||||
_at->cmd_start("AT+CFUN=0");
|
||||
_at->cmd_stop_read_resp();
|
||||
if (_at->get_last_error() == NSAPI_ERROR_OK) {
|
||||
_at->cmd_start("ATE0"); // echo off
|
||||
_at->cmd_stop_read_resp();
|
||||
_at->cmd_start("AT+CMEE=1"); // verbose responses
|
||||
_at->cmd_stop_read_resp();
|
||||
config_authentication_parameters();
|
||||
_at->cmd_start("AT+CFUN=1"); // set full functionality
|
||||
_at->cmd_stop_read_resp();
|
||||
}
|
||||
#else
|
||||
_at->cmd_start("AT+CFUN=4");
|
||||
_at->cmd_stop_read_resp();
|
||||
if (_at->get_last_error() == NSAPI_ERROR_OK) {
|
||||
_at->cmd_start("ATE0"); // echo off
|
||||
_at->cmd_stop_read_resp();
|
||||
_at->cmd_start("AT+CMEE=1"); // verbose responses
|
||||
_at->cmd_stop_read_resp();
|
||||
config_authentication_parameters();
|
||||
_at->cmd_start("AT+CFUN=1"); // set full functionality
|
||||
_at->cmd_stop_read_resp();
|
||||
}
|
||||
#endif
|
||||
|
||||
return _at->unlock_return_error();
|
||||
}
|
||||
|
||||
nsapi_error_t UBLOX_AT::config_authentication_parameters()
|
||||
{
|
||||
char *config = NULL;
|
||||
nsapi_error_t err;
|
||||
char imsi[MAX_IMSI_LENGTH + 1];
|
||||
|
||||
if (apn == NULL) {
|
||||
err = get_imsi(imsi);
|
||||
if (err == NSAPI_ERROR_OK) {
|
||||
config = (char *)apnconfig(imsi);
|
||||
}
|
||||
}
|
||||
|
||||
ubx_context->get_next_credentials(&config);
|
||||
apn = ubx_context->get_apn();
|
||||
pwd = ubx_context->get_pwd();
|
||||
uname = ubx_context->get_uname();
|
||||
auth = ubx_context->get_auth();
|
||||
|
||||
auth = (*uname && *pwd) ? auth : CellularContext::NOAUTH;
|
||||
err = set_authentication_parameters(apn, uname, pwd, auth);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
nsapi_error_t UBLOX_AT::set_authentication_parameters(const char *apn,
|
||||
const char *username,
|
||||
const char *password,
|
||||
CellularContext::AuthenticationType auth)
|
||||
{
|
||||
int modem_security = ubx_context->nsapi_security_to_modem_security(auth);
|
||||
|
||||
_at->cmd_start("AT+CGDCONT=1,\"IP\",");
|
||||
_at->write_string(apn);
|
||||
_at->cmd_stop();
|
||||
_at->resp_start();
|
||||
_at->resp_stop();
|
||||
|
||||
if (_at->get_last_error() == NSAPI_ERROR_OK) {
|
||||
#ifdef TARGET_UBLOX_C030_R41XM
|
||||
if (modem_security == CellularContext::CHAP) {
|
||||
_at->cmd_start("AT+UAUTHREQ=1,");
|
||||
_at->write_int(modem_security);
|
||||
_at->write_string(password);
|
||||
_at->write_string(username);
|
||||
_at->cmd_stop();
|
||||
_at->resp_start();
|
||||
_at->resp_stop();
|
||||
} else if (modem_security == CellularContext::NOAUTH) {
|
||||
_at->cmd_start("AT+UAUTHREQ=1,");
|
||||
_at->write_int(modem_security);
|
||||
_at->cmd_stop();
|
||||
_at->resp_start();
|
||||
_at->resp_stop();
|
||||
} else {
|
||||
_at->cmd_start("AT+UAUTHREQ=1,");
|
||||
_at->write_int(modem_security);
|
||||
_at->write_string(username);
|
||||
_at->write_string(password);
|
||||
_at->cmd_stop();
|
||||
_at->resp_start();
|
||||
_at->resp_stop();
|
||||
}
|
||||
#else
|
||||
_at->cmd_start("AT+UAUTHREQ=1,");
|
||||
_at->write_int(modem_security);
|
||||
_at->write_string(username);
|
||||
_at->write_string(password);
|
||||
_at->cmd_stop();
|
||||
_at->resp_start();
|
||||
_at->resp_stop();
|
||||
#endif
|
||||
}
|
||||
|
||||
return _at->get_last_error();
|
||||
}
|
||||
|
||||
nsapi_error_t UBLOX_AT::get_imsi(char *imsi)
|
||||
{
|
||||
_at->lock();
|
||||
_at->cmd_start("AT+CIMI");
|
||||
_at->cmd_stop();
|
||||
_at->resp_start();
|
||||
_at->read_string(imsi, MAX_IMSI_LENGTH + 1);
|
||||
_at->resp_stop();
|
||||
|
||||
return _at->unlock_return_error();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,11 @@
|
|||
#endif
|
||||
#endif /* TARGET_FF_ARDUINO */
|
||||
|
||||
#include "APN_db.h"
|
||||
#include "AT_CellularDevice.h"
|
||||
#include "AT_CellularContext.h"
|
||||
#include "UBLOX_AT_CellularNetwork.h"
|
||||
#include "UBLOX_AT_CellularContext.h"
|
||||
|
||||
namespace mbed {
|
||||
|
||||
|
@ -40,6 +44,32 @@ protected: // AT_CellularDevice
|
|||
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
|
||||
public: // NetworkInterface
|
||||
void handle_urc(FileHandle *fh);
|
||||
|
||||
virtual nsapi_error_t init();
|
||||
|
||||
private:
|
||||
|
||||
UBLOX_AT_CellularContext *ubx_context;
|
||||
|
||||
/** Length of IMSI buffer.
|
||||
*/
|
||||
static const int MAX_IMSI_LENGTH = 15;
|
||||
|
||||
const char *apn;
|
||||
const char *uname;
|
||||
const char *pwd;
|
||||
|
||||
/** The type of authentication to use.
|
||||
*/
|
||||
CellularContext::AuthenticationType auth;
|
||||
|
||||
nsapi_error_t config_authentication_parameters();
|
||||
|
||||
nsapi_error_t set_authentication_parameters(const char *apn, const char *username, const char *password, CellularContext::AuthenticationType auth);
|
||||
|
||||
/** Read IMSI of modem.
|
||||
*/
|
||||
nsapi_error_t get_imsi(char *imsi);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -25,7 +25,7 @@ UBLOX_AT_CellularContext::UBLOX_AT_CellularContext(ATHandler &at, CellularDevice
|
|||
AT_CellularContext(at, device, apn, cp_req, nonip_req)
|
||||
{
|
||||
// The authentication to use
|
||||
_auth = NSAPI_SECURITY_UNKNOWN;
|
||||
_auth = NOAUTH;
|
||||
}
|
||||
|
||||
UBLOX_AT_CellularContext::~UBLOX_AT_CellularContext()
|
||||
|
@ -49,12 +49,42 @@ void UBLOX_AT_CellularContext::do_connect()
|
|||
{
|
||||
_at.lock();
|
||||
_cb_data.error = NSAPI_ERROR_NO_CONNECTION;
|
||||
CellularNetwork::RadioAccessTechnology rat = read_radio_technology();
|
||||
|
||||
// Attempt to establish a connection
|
||||
#ifdef TARGET_UBLOX_C030_R41XM
|
||||
#ifndef TARGET_UBLOX_C030_R41XM
|
||||
_cb_data.error = define_context();
|
||||
#elif TARGET_UBLOX_C030_R410M
|
||||
_is_context_active = true;
|
||||
_is_context_activated = true;
|
||||
_cb_data.error = NSAPI_ERROR_OK;
|
||||
#else
|
||||
_cb_data.error = open_data_channel();
|
||||
#elif TARGET_UBLOX_C030_R412M
|
||||
if (rat == CellularNetwork::RadioAccessTechnology::RAT_EGPRS) {
|
||||
if (!_is_context_active) {
|
||||
_at.set_at_timeout(150 * 1000);
|
||||
_at.cmd_start("AT+CGACT=1,1");
|
||||
_at.cmd_stop();
|
||||
_at.resp_start();
|
||||
_at.resp_stop();
|
||||
|
||||
_at.cmd_start("AT+CGACT?");
|
||||
_at.cmd_stop();
|
||||
_at.resp_start("+CGACT:");
|
||||
_at.skip_param(1);
|
||||
_is_context_activated = _at.read_int();
|
||||
_at.resp_stop();
|
||||
_at.restore_at_timeout();
|
||||
if (_is_context_activated == true) {
|
||||
_cid = 1;
|
||||
_is_context_active = true;
|
||||
_cb_data.error = NSAPI_ERROR_OK;
|
||||
}
|
||||
}
|
||||
} else if (rat == CellularNetwork::RadioAccessTechnology::RAT_CATM1 || rat == CellularNetwork::RadioAccessTechnology::RAT_NB1) {
|
||||
_is_context_active = true;
|
||||
_is_context_activated = true;
|
||||
_cb_data.error = NSAPI_ERROR_OK;
|
||||
}
|
||||
#endif
|
||||
if (_cb_data.error != NSAPI_ERROR_OK) {
|
||||
// If new PSD context was created and failed to activate, delete it
|
||||
|
@ -72,7 +102,8 @@ void UBLOX_AT_CellularContext::do_connect()
|
|||
}
|
||||
}
|
||||
|
||||
nsapi_error_t UBLOX_AT_CellularContext::open_data_channel()
|
||||
#ifndef TARGET_UBLOX_C030_R41XM
|
||||
nsapi_error_t UBLOX_AT_CellularContext::define_context()
|
||||
{
|
||||
bool success = false;
|
||||
int active = 0;
|
||||
|
@ -106,11 +137,11 @@ nsapi_error_t UBLOX_AT_CellularContext::open_data_channel()
|
|||
do {
|
||||
get_next_credentials(&config);
|
||||
if (_uname && _pwd) {
|
||||
_auth = (*_uname && *_pwd) ? _auth : NSAPI_SECURITY_NONE;
|
||||
_auth = (*_uname && *_pwd) ? _authentication_type : NOAUTH;
|
||||
} else {
|
||||
_auth = NSAPI_SECURITY_NONE;
|
||||
_auth = NOAUTH;
|
||||
}
|
||||
success = activate_profile(_apn, _uname, _pwd);
|
||||
success = activate_profile(_apn, _uname, _pwd, _auth);
|
||||
} while (!success && config && *config);
|
||||
} else {
|
||||
// If the profile is already active, we're good
|
||||
|
@ -124,7 +155,8 @@ nsapi_error_t UBLOX_AT_CellularContext::open_data_channel()
|
|||
|
||||
bool UBLOX_AT_CellularContext::activate_profile(const char *apn,
|
||||
const char *username,
|
||||
const char *password)
|
||||
const char *password,
|
||||
AuthenticationType auth)
|
||||
{
|
||||
bool activated = false;
|
||||
bool success = false;
|
||||
|
@ -175,15 +207,8 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn,
|
|||
_at.resp_start();
|
||||
_at.resp_stop();
|
||||
|
||||
// Set up the authentication protocol
|
||||
// 0 = none
|
||||
// 1 = PAP (Password Authentication Protocol)
|
||||
// 2 = CHAP (Challenge Handshake Authentication Protocol)
|
||||
for (int protocol = nsapi_security_to_modem_security(NSAPI_SECURITY_NONE);
|
||||
success && (protocol <= nsapi_security_to_modem_security(NSAPI_SECURITY_CHAP)); protocol++) {
|
||||
if ((_auth == NSAPI_SECURITY_UNKNOWN) || (nsapi_security_to_modem_security(_auth) == protocol)) {
|
||||
_at.cmd_start("AT+UPSD=" PROFILE ",6,");
|
||||
_at.write_int(protocol);
|
||||
_at.write_int(nsapi_security_to_modem_security(auth));
|
||||
_at.cmd_stop();
|
||||
_at.resp_start();
|
||||
_at.resp_stop();
|
||||
|
@ -211,39 +236,44 @@ bool UBLOX_AT_CellularContext::activate_profile(const char *apn,
|
|||
if (activated) { //If context is activated, exit while loop and return status
|
||||
break;
|
||||
}
|
||||
rtos::ThisThread::sleep_for(5000); //Wait for 5 seconds and then try again
|
||||
wait_ms(5000); //Wait for 5 seconds and then try again
|
||||
}
|
||||
t1.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return activated;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Convert nsapi_security_t to the modem security numbers
|
||||
int UBLOX_AT_CellularContext::nsapi_security_to_modem_security(nsapi_security_t nsapi_security)
|
||||
int UBLOX_AT_CellularContext::nsapi_security_to_modem_security(AuthenticationType nsapi_security)
|
||||
{
|
||||
int modem_security = 3;
|
||||
|
||||
switch (nsapi_security) {
|
||||
case NSAPI_SECURITY_NONE:
|
||||
case NOAUTH:
|
||||
modem_security = 0;
|
||||
break;
|
||||
case NSAPI_SECURITY_PAP:
|
||||
case PAP:
|
||||
modem_security = 1;
|
||||
break;
|
||||
case NSAPI_SECURITY_CHAP:
|
||||
case CHAP:
|
||||
modem_security = 2;
|
||||
break;
|
||||
case NSAPI_SECURITY_UNKNOWN:
|
||||
#ifndef TARGET_UBLOX_C030_R41XM
|
||||
case AUTOMATIC:
|
||||
modem_security = 3;
|
||||
break;
|
||||
default:
|
||||
modem_security = 3;
|
||||
break;
|
||||
#else
|
||||
default:
|
||||
modem_security = 0;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return modem_security;
|
||||
|
@ -274,10 +304,7 @@ nsapi_error_t UBLOX_AT_CellularContext::get_imsi(char *imsi)
|
|||
_at.cmd_start("AT+CIMI");
|
||||
_at.cmd_stop();
|
||||
_at.resp_start();
|
||||
int len = _at.read_string(imsi, MAX_IMSI_LENGTH);
|
||||
if (len > 0) {
|
||||
imsi[len] = '\0';
|
||||
}
|
||||
_at.read_string(imsi, MAX_IMSI_LENGTH + 1);
|
||||
_at.resp_stop();
|
||||
|
||||
return _at.unlock_return_error();
|
||||
|
@ -298,4 +325,62 @@ const char *UBLOX_AT_CellularContext::get_gateway()
|
|||
return get_ip_address();
|
||||
}
|
||||
|
||||
const char *UBLOX_AT_CellularContext::get_apn()
|
||||
{
|
||||
return _apn;
|
||||
}
|
||||
|
||||
const char *UBLOX_AT_CellularContext::get_uname()
|
||||
{
|
||||
return _uname;
|
||||
}
|
||||
|
||||
const char *UBLOX_AT_CellularContext::get_pwd()
|
||||
{
|
||||
return _pwd;
|
||||
}
|
||||
|
||||
CellularContext::AuthenticationType UBLOX_AT_CellularContext::get_auth()
|
||||
{
|
||||
return _authentication_type;
|
||||
}
|
||||
|
||||
CellularNetwork::RadioAccessTechnology UBLOX_AT_CellularContext::read_radio_technology()
|
||||
{
|
||||
int act;
|
||||
CellularNetwork::RadioAccessTechnology rat;
|
||||
|
||||
_at.cmd_start("AT+URAT?");
|
||||
_at.cmd_stop();
|
||||
_at.resp_start("+URAT:");
|
||||
act = _at.read_int();
|
||||
_at.resp_stop();
|
||||
|
||||
switch (act) {
|
||||
case 0:
|
||||
rat = CellularNetwork::RadioAccessTechnology::RAT_GSM;
|
||||
break;
|
||||
case 1:
|
||||
rat = CellularNetwork::RadioAccessTechnology::RAT_GSM;
|
||||
break;
|
||||
case 2:
|
||||
rat = CellularNetwork::RadioAccessTechnology::RAT_UTRAN;
|
||||
break;
|
||||
case 7:
|
||||
rat = CellularNetwork::RadioAccessTechnology::RAT_CATM1;
|
||||
break;
|
||||
case 8:
|
||||
rat = CellularNetwork::RadioAccessTechnology::RAT_NB1;
|
||||
break;
|
||||
case 9:
|
||||
rat = CellularNetwork::RadioAccessTechnology::RAT_EGPRS;
|
||||
break;
|
||||
default:
|
||||
rat = CellularNetwork::RadioAccessTechnology::RAT_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
return rat;
|
||||
}
|
||||
|
||||
} /* namespace mbed */
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#define UBLOX_AT_CELLULARCONTEXT_H_
|
||||
|
||||
#include "AT_CellularContext.h"
|
||||
#include "UBLOX_AT_CellularNetwork.h"
|
||||
|
||||
namespace mbed {
|
||||
|
||||
|
@ -29,9 +30,35 @@ public:
|
|||
virtual void do_connect();
|
||||
virtual const char *get_gateway();
|
||||
|
||||
const char *get_apn(void);
|
||||
const char *get_uname(void);
|
||||
const char *get_pwd(void);
|
||||
CellularContext::AuthenticationType get_auth(void);
|
||||
|
||||
/** Convert nsapi_security_t to the modem security numbers.
|
||||
*
|
||||
* @param nsapi_security Security protocol.
|
||||
* @return Modem security numbers.
|
||||
*/
|
||||
int nsapi_security_to_modem_security(AuthenticationType nsapi_security);
|
||||
|
||||
/** Get the next set of credentials from the database.
|
||||
*/
|
||||
void get_next_credentials(char **config);
|
||||
|
||||
CellularNetwork::RadioAccessTechnology read_radio_technology(void);
|
||||
|
||||
protected:
|
||||
virtual NetworkStack *get_stack();
|
||||
|
||||
/** Connect the on board IP stack of the modem.
|
||||
*
|
||||
* @return True if successful, otherwise false.
|
||||
*/
|
||||
#ifndef TARGET_UBLOX_C030_R41XM
|
||||
nsapi_error_t define_context();
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
/** Length of IMSI buffer.
|
||||
|
@ -40,13 +67,7 @@ private:
|
|||
|
||||
/** The type of authentication to use.
|
||||
*/
|
||||
nsapi_security_t _auth;
|
||||
|
||||
/** Connect the on board IP stack of the modem.
|
||||
*
|
||||
* @return True if successful, otherwise false.
|
||||
*/
|
||||
nsapi_error_t open_data_channel();
|
||||
AuthenticationType _auth;
|
||||
|
||||
/** Activate one of the on-board modem's connection profiles.
|
||||
*
|
||||
|
@ -54,18 +75,13 @@ private:
|
|||
* @param username The user name to use.
|
||||
* @param password The password to use.
|
||||
* @param auth The authentication method to use
|
||||
* (NSAPI_SECURITY_NONE, NSAPI_SECURITY_PAP,
|
||||
* NSAPI_SECURITY_CHAP or NSAPI_SECURITY_UNKNOWN).
|
||||
* (NOAUTH, PAP,
|
||||
* CHAP or AUTOMATIC).
|
||||
* @return True if successful, otherwise false.
|
||||
*/
|
||||
bool activate_profile(const char *apn, const char *username, const char *password);
|
||||
|
||||
/** Convert nsapi_security_t to the modem security numbers.
|
||||
*
|
||||
* @param nsapi_security Security protocol.
|
||||
* @return Modem security numbers.
|
||||
*/
|
||||
int nsapi_security_to_modem_security(nsapi_security_t nsapi_security);
|
||||
#ifndef TARGET_UBLOX_C030_R41XM
|
||||
bool activate_profile(const char *apn, const char *username, const char *password, AuthenticationType auth);
|
||||
#endif
|
||||
|
||||
/** Disconnect the on board IP stack of the modem.
|
||||
*
|
||||
|
@ -76,10 +92,6 @@ private:
|
|||
/** Read IMSI of modem.
|
||||
*/
|
||||
nsapi_error_t get_imsi(char *imsi);
|
||||
|
||||
/** Get the next set of credentials from the database.
|
||||
*/
|
||||
void get_next_credentials(char **config);
|
||||
};
|
||||
|
||||
} /* namespace mbed */
|
||||
|
|
|
@ -34,35 +34,74 @@ UBLOX_AT_CellularNetwork::~UBLOX_AT_CellularNetwork()
|
|||
nsapi_error_t UBLOX_AT_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat)
|
||||
{
|
||||
nsapi_error_t ret = NSAPI_ERROR_OK;
|
||||
CellularNetwork::AttachStatus status;
|
||||
|
||||
get_attach(status);
|
||||
if (status == Attached) {
|
||||
tr_debug("RAT should only be set in detached state");
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
_at.lock();
|
||||
switch (opRat) {
|
||||
#if defined(TARGET_UBLOX_C030_U201) || defined(TARGET_UBLOX_C027)
|
||||
case RAT_GSM:
|
||||
case RAT_GSM_COMPACT:
|
||||
break;
|
||||
case RAT_EGPRS:
|
||||
#if defined (TARGET_UBLOX_C030_R412M)
|
||||
_at.cmd_start("AT+URAT=9,8");
|
||||
_at.cmd_stop_read_resp();
|
||||
break;
|
||||
#endif
|
||||
#if defined(TARGET_UBLOX_C030_U201)
|
||||
case RAT_GSM:
|
||||
_at.cmd_start("AT+URAT=0,0");
|
||||
_at.cmd_stop_read_resp();
|
||||
break;
|
||||
#elif defined(TARGET_UBLOX_C030_U201)
|
||||
case RAT_UTRAN:
|
||||
break;
|
||||
case RAT_HSDPA:
|
||||
break;
|
||||
case RAT_HSUPA:
|
||||
break;
|
||||
case RAT_HSDPA_HSUPA:
|
||||
_at.cmd_start("AT+URAT=2,2");
|
||||
_at.cmd_stop_read_resp();
|
||||
break;
|
||||
#elif defined(TARGET_UBLOX_C030_R41XM)
|
||||
case RAT_CATM1:
|
||||
_at.cmd_start("AT+URAT=7,8");
|
||||
_at.cmd_stop_read_resp();
|
||||
break;
|
||||
#elif defined(TARGET_UBLOX_C030_R41XM) || defined(TARGET_UBLOX_C030_N211)
|
||||
case RAT_NB1:
|
||||
_at.cmd_start("AT+URAT=8,7");
|
||||
_at.cmd_stop_read_resp();
|
||||
break;
|
||||
#endif
|
||||
default: {
|
||||
default:
|
||||
_op_act = RAT_UNKNOWN;
|
||||
ret = NSAPI_ERROR_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_at.unlock();
|
||||
ubx_reboot();
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
nsapi_error_t UBLOX_AT_CellularNetwork::ubx_reboot()
|
||||
{
|
||||
_at.lock();
|
||||
_at.cmd_start("AT+CFUN=15");
|
||||
_at.cmd_stop_read_resp();
|
||||
|
||||
Timer t1;
|
||||
t1.start();
|
||||
while (!(t1.read() >= 30)) {
|
||||
_at.cmd_start("ATE0"); // echo off
|
||||
_at.cmd_stop_read_resp();
|
||||
if (_at.get_last_error() == NSAPI_ERROR_OK) {
|
||||
break;
|
||||
} else {
|
||||
_at.clear_error();
|
||||
wait_ms(1000);
|
||||
}
|
||||
}
|
||||
t1.stop();
|
||||
_at.unlock();
|
||||
return _at.get_last_error();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,11 @@
|
|||
#ifndef UBLOX_AT_CELLULAR_NETWORK_H_
|
||||
#define UBLOX_AT_CELLULAR_NETWORK_H_
|
||||
|
||||
#include "CellularLog.h"
|
||||
#include "drivers/Timer.h"
|
||||
#include "mbed_wait_api.h"
|
||||
#include "AT_CellularNetwork.h"
|
||||
#include "AT_CellularContext.h"
|
||||
|
||||
namespace mbed {
|
||||
|
||||
|
@ -27,6 +31,8 @@ public:
|
|||
UBLOX_AT_CellularNetwork(ATHandler &atHandler);
|
||||
virtual ~UBLOX_AT_CellularNetwork();
|
||||
|
||||
nsapi_error_t ubx_reboot();
|
||||
|
||||
protected:
|
||||
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opRat);
|
||||
};
|
||||
|
|
|
@ -68,7 +68,7 @@ nsapi_error_t UBLOX_N2XX::init()
|
|||
{
|
||||
_at->lock();
|
||||
_at->flush();
|
||||
_at->cmd_start("AT"); // echo off
|
||||
_at->cmd_start("AT");
|
||||
_at->cmd_stop_read_resp();
|
||||
|
||||
_at->cmd_start("AT+CMEE=1"); // verbose responses
|
||||
|
|
Loading…
Reference in New Issue