Skip to content

Cellular: Allow cellular modules to override network registration mode #7860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ class my_AT_CN : public AT_CellularNetwork {
return _stack;
}
}
virtual bool has_registration(RegistrationType reg_type)
virtual AT_CellularNetwork::RegistrationMode has_registration(RegistrationType reg_type)
{
if (reg_type == C_GREG) {
return false;
return RegistrationModeDisable;
}
return true;
return RegistrationModeLAC;
}
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat)
{
Expand All @@ -108,12 +108,12 @@ class my_AT_CNipv6 : public AT_CellularNetwork {
return _stack;
}
}
virtual bool has_registration(RegistrationType reg_type)
virtual AT_CellularNetwork::RegistrationMode has_registration(RegistrationType reg_type)
{
if (reg_type == C_GREG) {
return false;
return RegistrationModeDisable;
}
return true;
return RegistrationModeLAC;
}
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat)
{
Expand Down
4 changes: 2 additions & 2 deletions features/cellular/UNITTESTS/stubs/AT_CellularNetwork_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ nsapi_error_t AT_CellularNetwork::get_cell_id(int &cell_id)
return NSAPI_ERROR_OK;
}

bool AT_CellularNetwork::has_registration(RegistrationType reg_type)
AT_CellularNetwork::RegistrationMode AT_CellularNetwork::has_registration(RegistrationType reg_type)
{
return false;
return RegistrationModeDisable;
}

nsapi_error_t AT_CellularNetwork::set_attach(int timeout)
Expand Down
17 changes: 10 additions & 7 deletions features/cellular/framework/AT/AT_CellularNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ AT_CellularNetwork::~AT_CellularNetwork()
#endif // NSAPI_PPP_AVAILABLE

for (int type = 0; type < CellularNetwork::C_MAX; type++) {
if (has_registration((RegistrationType)type)) {
if (has_registration((RegistrationType)type) != RegistrationModeDisable) {
_at.remove_urc_handler(at_reg[type].urc_prefix, _urc_funcs[type]);
}
}
Expand All @@ -72,7 +72,7 @@ nsapi_error_t AT_CellularNetwork::init()
_urc_funcs[C_REG] = callback(this, &AT_CellularNetwork::urc_creg);

for (int type = 0; type < CellularNetwork::C_MAX; type++) {
if (has_registration((RegistrationType)type)) {
if (has_registration((RegistrationType)type) != RegistrationModeDisable) {
if (_at.set_urc_handler(at_reg[type].urc_prefix, _urc_funcs[type]) != NSAPI_ERROR_OK) {
return NSAPI_ERROR_NO_MEMORY;
}
Expand Down Expand Up @@ -703,13 +703,16 @@ nsapi_error_t AT_CellularNetwork::set_registration_urc(RegistrationType type, bo
int index = (int)type;
MBED_ASSERT(index >= 0 && index < C_MAX);

if (!has_registration(type)) {
RegistrationMode mode = has_registration(type);
if (mode == RegistrationModeDisable) {
return NSAPI_ERROR_UNSUPPORTED;
} else {
_at.lock();
if (urc_on) {
_at.cmd_start(at_reg[index].cmd);
_at.write_string("=2", false);
const uint8_t ch_eq = '=';
_at.write_bytes(&ch_eq, 1);
_at.write_int((int)mode);
_at.cmd_stop();
} else {
_at.cmd_start(at_reg[index].cmd);
Expand Down Expand Up @@ -801,7 +804,7 @@ nsapi_error_t AT_CellularNetwork::get_registration_status(RegistrationType type,
int i = (int)type;
MBED_ASSERT(i >= 0 && i < C_MAX);

if (!has_registration(at_reg[i].type)) {
if (has_registration(at_reg[i].type) == RegistrationModeDisable) {
return NSAPI_ERROR_UNSUPPORTED;
}

Expand Down Expand Up @@ -835,10 +838,10 @@ nsapi_error_t AT_CellularNetwork::get_cell_id(int &cell_id)
return NSAPI_ERROR_OK;
}

bool AT_CellularNetwork::has_registration(RegistrationType reg_type)
AT_CellularNetwork::RegistrationMode AT_CellularNetwork::has_registration(RegistrationType reg_type)
{
(void)reg_type;
return true;
return RegistrationModeLAC;
}

nsapi_error_t AT_CellularNetwork::set_attach(int /*timeout*/)
Expand Down
9 changes: 7 additions & 2 deletions features/cellular/framework/AT/AT_CellularNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,14 @@ class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase {
/** Check if modem supports given registration type.
*
* @param reg_type enum RegistrationType
* @return true if given registration type is supported by modem
* @return mode supported on given reg_type as per 3GPP TS 27.007, 0 when unsupported
*/
virtual bool has_registration(RegistrationType reg_type);
enum RegistrationMode {
RegistrationModeDisable = 0,
RegistrationModeEnable, // <stat>
RegistrationModeLAC, // <stat>[,<[lac>,]<[ci>],[<AcT>],[<rac>]]
};
virtual RegistrationMode has_registration(RegistrationType reg_type);

/** Sets access technology to be scanned. Modem specific implementation.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ bool QUECTEL_BC95_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t request
return requested_stack == IPV4_STACK ? true : false;
}

bool QUECTEL_BC95_CellularNetwork::has_registration(RegistrationType reg_tech)
AT_CellularNetwork::RegistrationMode QUECTEL_BC95_CellularNetwork::has_registration(RegistrationType reg_tech)
{
return (reg_tech == C_EREG);
return (reg_tech == C_EREG) ? RegistrationModeLAC : RegistrationModeDisable;
}

nsapi_error_t QUECTEL_BC95_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class QUECTEL_BC95_CellularNetwork : public AT_CellularNetwork {

virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack);

virtual bool has_registration(RegistrationType reg_type);
virtual RegistrationMode has_registration(RegistrationType reg_type);
};
} // namespace mbed
#endif // QUECTEL_BC95_CELLULAR_NETWORK_H_
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ bool QUECTEL_UG96_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t request
return requested_stack == IPV4_STACK ? true : false;
}

bool QUECTEL_UG96_CellularNetwork::has_registration(RegistrationType reg_type)
AT_CellularNetwork::RegistrationMode QUECTEL_UG96_CellularNetwork::has_registration(RegistrationType reg_type)
{
return (reg_type == C_REG || reg_type == C_GREG);
return (reg_type == C_REG || reg_type == C_GREG) ? RegistrationModeLAC : RegistrationModeDisable;
}

nsapi_error_t QUECTEL_UG96_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class QUECTEL_UG96_CellularNetwork : public AT_CellularNetwork {
protected:
virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack);

virtual bool has_registration(RegistrationType rat);
virtual RegistrationMode has_registration(RegistrationType rat);

virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opRat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ bool TELIT_HE910_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requeste
return requested_stack == IPV4_STACK ? true : false;
}

bool TELIT_HE910_CellularNetwork::has_registration(RegistrationType reg_type)
AT_CellularNetwork::RegistrationMode TELIT_HE910_CellularNetwork::has_registration(RegistrationType reg_type)
{
return (reg_type == C_REG || reg_type == C_GREG);
return (reg_type == C_REG || reg_type == C_GREG) ? RegistrationModeLAC : RegistrationModeDisable;
}

nsapi_error_t TELIT_HE910_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TELIT_HE910_CellularNetwork : public AT_CellularNetwork {

virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack);

virtual bool has_registration(RegistrationType rat);
virtual RegistrationMode has_registration(RegistrationType rat);

virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opRat);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ bool UBLOX_AT_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requested_s
return requested_stack == IPV4_STACK ? true : false;
}

bool UBLOX_AT_CellularNetwork::has_registration(RegistrationType reg_type)
AT_CellularNetwork::RegistrationMode UBLOX_AT_CellularNetwork::has_registration(RegistrationType reg_type)
{
return (reg_type == C_REG || reg_type == C_GREG);
return (reg_type == C_REG || reg_type == C_GREG) ? RegistrationModeLAC : RegistrationModeDisable;
}

nsapi_error_t UBLOX_AT_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class UBLOX_AT_CellularNetwork : public AT_CellularNetwork

virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack);

virtual bool has_registration(RegistrationType rat);
virtual RegistrationMode has_registration(RegistrationType rat);

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ bool UBLOX_PPP_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requested_
return requested_stack == IPV4_STACK ? true : false;
}

bool UBLOX_PPP_CellularNetwork::has_registration(RegistrationType reg_type)
AT_CellularNetwork::RegistrationMode UBLOX_PPP_CellularNetwork::has_registration(RegistrationType reg_type)
{
return (reg_type == C_REG || reg_type == C_GREG);
return (reg_type == C_REG || reg_type == C_GREG) ? RegistrationModeLAC : RegistrationModeDisable;
}

nsapi_error_t UBLOX_PPP_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class UBLOX_PPP_CellularNetwork : public AT_CellularNetwork {
protected:
virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack);

virtual bool has_registration(RegistrationType rat);
virtual RegistrationMode has_registration(RegistrationType rat);

virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opRat);
};
Expand Down