mirror of https://github.com/ARMmbed/mbed-os.git
temp
parent
702efc1de5
commit
2b14a9ee5f
|
|
@ -68,6 +68,18 @@ CellularConnectionFSM::CellularConnectionFSM() :
|
|||
CellularConnectionFSM::~CellularConnectionFSM()
|
||||
{
|
||||
stop();
|
||||
delete _cellularDevice;
|
||||
}
|
||||
|
||||
void CellularConnectionFSM::stop()
|
||||
{
|
||||
tr_info("CellularConnectionUtil::stop");
|
||||
_cellularDevice->close_power();
|
||||
_cellularDevice->close_network();
|
||||
if (_queue_thread) {
|
||||
_queue_thread->terminate();
|
||||
_queue_thread = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
nsapi_error_t CellularConnectionFSM::init()
|
||||
|
|
@ -98,6 +110,10 @@ nsapi_error_t CellularConnectionFSM::init()
|
|||
|
||||
_at_queue.chain(&_queue);
|
||||
|
||||
_network->set_registration_urc(CellularNetwork::C_EREG, true);
|
||||
_network->set_registration_urc(CellularNetwork::C_GREG, true);
|
||||
_network->set_registration_urc(CellularNetwork::C_REG, true);
|
||||
|
||||
_retry_count = 0;
|
||||
_state = STATE_INIT;
|
||||
_next_state = STATE_INIT;
|
||||
|
|
@ -522,17 +538,6 @@ nsapi_error_t CellularConnectionFSM::start_dispatch()
|
|||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
void CellularConnectionFSM::stop()
|
||||
{
|
||||
tr_info("CellularConnectionUtil::stop");
|
||||
_cellularDevice->close_power();
|
||||
_cellularDevice->close_network();
|
||||
if (_queue_thread) {
|
||||
_queue_thread->terminate();
|
||||
_queue_thread = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CellularConnectionFSM::set_serial(UARTSerial *serial)
|
||||
{
|
||||
_serial = serial;
|
||||
|
|
|
|||
|
|
@ -208,7 +208,6 @@ public:
|
|||
NWModeManualAutomatic // if manual fails, fallback to automatic
|
||||
};
|
||||
|
||||
lisää gettter rat
|
||||
|
||||
/** Request registering to network.
|
||||
*
|
||||
|
|
@ -224,7 +223,7 @@ public:
|
|||
*/
|
||||
virtual nsapi_error_t get_network_registering_mode(NWRegisteringMode& mode) = 0;
|
||||
|
||||
virtual nsapi_error_t set_registration_urc(bool on) = 0;
|
||||
virtual nsapi_error_t set_registration_urc(RegistrationType type, bool on) = 0;
|
||||
|
||||
/** Gets the network registration status.
|
||||
*
|
||||
|
|
@ -289,10 +288,12 @@ public:
|
|||
|
||||
/** Sets radio access technology.
|
||||
*
|
||||
* @param op_rat Radio access technology
|
||||
* @return zero on success
|
||||
* @param rat Radio access technology
|
||||
* @return zero on success
|
||||
*/
|
||||
virtual nsapi_error_t set_access_technology(RadioAccessTechnology op_rat) = 0;
|
||||
virtual nsapi_error_t set_access_technology(RadioAccessTechnology rat) = 0;
|
||||
|
||||
virtual nsapi_error_t get_access_technology(RadioAccessTechnology& rat) = 0;
|
||||
|
||||
/** Scans for operators module can reach.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -181,7 +181,15 @@ void ATHandler::set_urc_handler(const char *prefix, mbed::Callback<void()> callb
|
|||
|
||||
bool ATHandler::check_urc_existance(const char *prefix, mbed::Callback<void()> callback)
|
||||
{
|
||||
struct oob_t *oob = _oobs;
|
||||
while (oob) {
|
||||
if (strcmp(prefix, oob->prefix) == 0 && oob->cb == callback) {
|
||||
return true;
|
||||
}
|
||||
oob = oob->next;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ATHandler::event()
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ struct at_reg_t {
|
|||
|
||||
static const at_reg_t at_reg[] = {
|
||||
{ CellularNetwork::C_EREG, "AT+CEREG", "+CEREG:", AT_CellularNetwork::urc_creg},
|
||||
{ CellularNetwork::C_GREG, "AT+CGREG"},
|
||||
{ CellularNetwork::C_REG, "AT+CREG"}
|
||||
{ CellularNetwork::C_GREG, "AT+CGREG", "+CGREG:", AT_CellularNetwork::urc_cgreg},
|
||||
{ CellularNetwork::C_REG, "AT+CREG", "+CREG:", AT_CellularNetwork::urc_creg}
|
||||
};
|
||||
|
||||
AT_CellularNetwork::AT_CellularNetwork(ATHandler &atHandler) : AT_CellularBase(atHandler),
|
||||
|
|
@ -46,6 +46,7 @@ AT_CellularNetwork::AT_CellularNetwork(ATHandler &atHandler) : AT_CellularBase(a
|
|||
{
|
||||
|
||||
_at.set_urc_handler("NO CARRIER", callback(this, &AT_CellularNetwork::urc_no_carrier));
|
||||
_at.set_urc_handler("NO CARRIER", callback(this, &AT_CellularNetwork::urc_no_carrier));
|
||||
}
|
||||
|
||||
AT_CellularNetwork::~AT_CellularNetwork()
|
||||
|
|
@ -342,9 +343,6 @@ nsapi_connection_status_t AT_CellularNetwork::get_connection_status() const
|
|||
nsapi_error_t AT_CellularNetwork::set_blocking(bool blocking)
|
||||
{
|
||||
_async = !blocking;
|
||||
if (_async) {
|
||||
|
||||
}
|
||||
#if NSAPI_PPP_AVAILABLE
|
||||
return nsapi_ppp_set_blocking(blocking);
|
||||
#else
|
||||
|
|
@ -567,31 +565,30 @@ nsapi_ip_stack_t AT_CellularNetwork::string_to_stack_type(const char* pdp_type)
|
|||
return stack;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_registration_urc(bool urc_on)
|
||||
nsapi_error_t AT_CellularNetwork::set_registration_urc(RegistrationType type, bool urc_on)
|
||||
{
|
||||
_at.lock();
|
||||
|
||||
/*_at.set_urc_handler("+CEREG:", callback(this, &AT_CellularNetwork::urc_cereg));
|
||||
_at.set_urc_handler("+CGREG:", callback(this, &AT_CellularNetwork::urc_cgreg));
|
||||
_at.set_urc_handler("+CREG:", callback(this, &AT_CellularNetwork::urc_creg));
|
||||
*/
|
||||
for (unsigned int i = 0; i < sizeof(at_reg)/sizeof(at_reg[0]); i++) {
|
||||
if (has_registration(at_reg[i].type)) {
|
||||
_last_reg_type = at_reg[i].type;
|
||||
if (urc_on) {
|
||||
_at.cmd_start(at_reg[i].cmd);
|
||||
_at.write_string("=2", false);
|
||||
_at.cmd_stop();
|
||||
} else {
|
||||
_at.cmd_start(at_reg[i].cmd);
|
||||
_at.write_string("=0", false);
|
||||
_at.cmd_stop();
|
||||
}
|
||||
MBED_ASSERT(type >= 0 && type < C_MAX);
|
||||
|
||||
_at.resp_start();
|
||||
_at.resp_stop();
|
||||
if (has_registration(type)) {
|
||||
_last_reg_type = type;
|
||||
if (urc_on) {
|
||||
_at.set_urc_handler(at_reg[type].urc, at_reg[type].urc_handler);
|
||||
_at.cmd_start(at_reg[type].cmd);
|
||||
_at.write_string("=2", false);
|
||||
_at.cmd_stop();
|
||||
} else {
|
||||
_at.cmd_start(at_reg[type].cmd);
|
||||
_at.write_string("=0", false);
|
||||
_at.cmd_stop();
|
||||
}
|
||||
|
||||
_at.resp_start();
|
||||
_at.resp_stop();
|
||||
}
|
||||
return _at.get_last_error();
|
||||
|
||||
return _at.unlock_return_error();
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::get_network_registering_mode(NWRegisteringMode& mode)
|
||||
|
|
@ -611,11 +608,6 @@ nsapi_error_t AT_CellularNetwork::set_registration(const char *plmn)
|
|||
{
|
||||
_at.lock();
|
||||
|
||||
nsapi_error_t ret = set_registration_urc(_async);
|
||||
if (ret) {
|
||||
_at.clear_error(); // allow temporary failures here
|
||||
}
|
||||
|
||||
if (!plmn) {
|
||||
tr_debug("Automatic network registration");
|
||||
_at.cmd_start("AT+COPS?");
|
||||
|
|
@ -857,6 +849,12 @@ nsapi_error_t AT_CellularNetwork::set_access_technology_impl(RadioAccessTechnolo
|
|||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::get_access_technology(RadioAccessTechnology& rat)
|
||||
{
|
||||
rat = _current_act;
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_access_technology(RadioAccessTechnology opAct)
|
||||
{
|
||||
if (opAct == RAT_UNKNOWN) {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ public: // CellularNetwork
|
|||
|
||||
virtual const char *get_ip_address();
|
||||
|
||||
virtual nsapi_error_t set_access_technology(RadioAccessTechnology op_rat);
|
||||
virtual nsapi_error_t set_access_technology(RadioAccessTechnology rat);
|
||||
virtual nsapi_error_t get_access_technology(RadioAccessTechnology& rat);
|
||||
|
||||
virtual nsapi_error_t scan_plmn(operList_t &operators, int &ops_count);
|
||||
|
||||
|
|
@ -109,7 +110,7 @@ public: // CellularNetwork
|
|||
|
||||
virtual nsapi_error_t get_operator_params(int &format, operator_t &operator_params);
|
||||
|
||||
virtual nsapi_error_t set_registration_urc(bool on);
|
||||
virtual nsapi_error_t set_registration_urc(RegistrationType type, bool on);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue