Skip to content

Commit

Permalink
Merge pull request #12020 from linlingao/fix_rat
Browse files Browse the repository at this point in the history
Fix issues in setting radio access technology
  • Loading branch information
0xc0170 committed Jan 2, 2020
2 parents 5f495db + 0bc8f4f commit 6baa5e4
Show file tree
Hide file tree
Showing 20 changed files with 146 additions and 23 deletions.
7 changes: 7 additions & 0 deletions features/cellular/framework/API/CellularNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ class CellularNetwork {
NWModeManualAutomatic // if manual fails, fallback to automatic
};

/// Operator name format
enum OperatorNameFormat {
OperatorNameAlphaLong = 0, // alphanumeric long form
OperatorNameAlphaShort, // alphanumeric short form
OperatorNameNumeric // numeric digits
};

/// Network registration information
struct registration_params_t {
RegistrationType _type;
Expand Down
31 changes: 16 additions & 15 deletions features/cellular/framework/AT/AT_CellularDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,22 @@ class AT_CellularDevice : public CellularDevice {
* to the end (just before PROPERTY_MAX). Do not modify any of the existing fields.
*/
enum CellularProperty {
PROPERTY_C_EREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_C_GREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_C_REG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
PROPERTY_AT_CNMI, // 0 = not supported, 1 = supported. New message (SMS) indication AT command
PROPERTY_AT_CSMP, // 0 = not supported, 1 = supported. Set text mode AT command
PROPERTY_AT_CMGF, // 0 = not supported, 1 = supported. Set preferred message format AT command
PROPERTY_AT_CSDH, // 0 = not supported, 1 = supported. Show text mode AT command
PROPERTY_IPV4_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4?
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4 and IPV6 simultaneously?
PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP?
PROPERTY_AT_CGEREP, // 0 = not supported, 1 = supported. Does modem support AT command AT+CGEREP.
PROPERTY_C_EREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_C_GREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_C_REG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
PROPERTY_AT_CNMI, // 0 = not supported, 1 = supported. New message (SMS) indication AT command
PROPERTY_AT_CSMP, // 0 = not supported, 1 = supported. Set text mode AT command
PROPERTY_AT_CMGF, // 0 = not supported, 1 = supported. Set preferred message format AT command
PROPERTY_AT_CSDH, // 0 = not supported, 1 = supported. Show text mode AT command
PROPERTY_IPV4_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4?
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4 and IPV6 simultaneously?
PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP?
PROPERTY_AT_CGEREP, // 0 = not supported, 1 = supported. Does modem support AT command AT+CGEREP.
PROPERTY_AT_COPS_FALLBACK_AUTO, // 0 = not supported, 1 = supported. Does modem support mode 4 of AT+COPS= ?

PROPERTY_MAX
};
Expand Down
14 changes: 11 additions & 3 deletions features/cellular/framework/AT/AT_CellularNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ nsapi_error_t AT_CellularNetwork::get_network_registering_mode(NWRegisteringMode
nsapi_error_t AT_CellularNetwork::set_registration(const char *plmn)
{

NWRegisteringMode mode = NWModeAutomatic;

if (!plmn) {
tr_debug("Automatic network registration");
NWRegisteringMode mode;
if (get_network_registering_mode(mode) != NSAPI_ERROR_OK) {
return NSAPI_ERROR_DEVICE_ERROR;
}
Expand All @@ -221,10 +222,17 @@ nsapi_error_t AT_CellularNetwork::set_registration(const char *plmn)
return NSAPI_ERROR_OK;
} else {
tr_debug("Manual network registration to %s", plmn);
mode = NWModeManual;
OperatorNameFormat format = OperatorNameNumeric;
#ifdef MBED_CONF_CELLULAR_PLMN_FALLBACK_AUTO
if (_device.get_property(AT_CellularDevice::PROPERTY_AT_COPS_FALLBACK_AUTO)) {
mode = NWModeManualAutomatic;
}
#endif
if (_op_act != RAT_UNKNOWN) {
return _at.at_cmd_discard("+COPS", "=1,2,", "%s%d", plmn, _op_act);
return _at.at_cmd_discard("+COPS", "=", "%d%d%s%d", mode, format, plmn, _op_act);
} else {
return _at.at_cmd_discard("+COPS", "=1,2,", "%s", plmn);
return _at.at_cmd_discard("+COPS", "=", "%d%d%s", mode, format, plmn);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
1, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
};

GENERIC_AT3GPP::GENERIC_AT3GPP(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
};

SARA4_PPP::SARA4_PPP(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
1, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
0, // PROPERTY_AT_CGEREP
0, // PROPERTY_AT_CGEREP,
0, // PROPERTY_AT_COPS_FALLBACK_AUTO
};

QUECTEL_BC95::QUECTEL_BC95(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
1, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
1, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
1, // PROPERTY_AT_CGEREP,
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
};

QUECTEL_BG96::QUECTEL_BG96(FileHandle *fh, PinName pwr, bool active_high, PinName rst)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
1, // PROPERTY_IPV6_STACK
1, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
1, // PROPERTY_AT_CGEREP,
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
};

QUECTEL_EC2X::QUECTEL_EC2X(FileHandle *fh, PinName pwr, bool active_high, PinName rst)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
};

QUECTEL_M26::QUECTEL_M26(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
1, // PROPERTY_AT_CGEREP,
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
};

QUECTEL_UG96::QUECTEL_UG96(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
1, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
0, // PROPERTY_AT_CGEREP
0, // PROPERTY_AT_COPS_FALLBACK_AUTO
};

RM1000_AT::RM1000_AT(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
1, // PROPERTY_AT_CGEREP,
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
};

TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "TELIT_ME910.h"
#include "TELIT_ME910_CellularContext.h"
#include "TELIT_ME910_CellularNetwork.h"
#include "AT_CellularNetwork.h"
#include "PinNames.h"
#include "rtos/ThisThread.h"
Expand Down Expand Up @@ -57,6 +58,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
1, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
};

//the delay between sending AT commands
Expand Down Expand Up @@ -187,3 +189,8 @@ nsapi_error_t TELIT_ME910::soft_power_off()
{
return AT_CellularDevice::soft_power_off();
}

AT_CellularNetwork *TELIT_ME910::open_network_impl(ATHandler &at)
{
return new TELIT_ME910_CellularNetwork(at, *this);
}
2 changes: 2 additions & 0 deletions features/cellular/framework/targets/TELIT/ME910/TELIT_ME910.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class TELIT_ME910 : public AT_CellularDevice {
virtual nsapi_error_t hard_power_off();
virtual nsapi_error_t soft_power_on();
virtual nsapi_error_t soft_power_off();
virtual AT_CellularNetwork *open_network_impl(ATHandler &at);

private:
bool _active_high;
DigitalOut _pwr_key;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2019, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "TELIT_ME910_CellularNetwork.h"

using namespace mbed;

TELIT_ME910_CellularNetwork::TELIT_ME910_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularNetwork(atHandler, device)
{
}

TELIT_ME910_CellularNetwork::~TELIT_ME910_CellularNetwork()
{
}

nsapi_error_t TELIT_ME910_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opsAct)
{
switch (opsAct) {
case RAT_GSM:
case RAT_CATM1:
case RAT_NB1:
_op_act = opsAct;
return NSAPI_ERROR_OK;

default:
_op_act = RAT_UNKNOWN;
return NSAPI_ERROR_UNSUPPORTED;
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2019, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef TELIT_ME910_CELLULAR_NETWORK_H_
#define TELIT_ME910_CELLULAR_NETWORK_H_

#include "AT_CellularNetwork.h"

namespace mbed {

class TELIT_ME910_CellularNetwork : public AT_CellularNetwork {
public:
TELIT_ME910_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device);
virtual ~ TELIT_ME910_CellularNetwork();

protected:
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opRat);

};

} // namespace mbed

#endif // TELIT_ME910_CELLULAR_NETWORK_H_
1 change: 1 addition & 0 deletions features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
};
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_G3XX)
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
};

UBLOX_N2XX::UBLOX_N2XX(FileHandle *fh): AT_CellularDevice(fh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
};
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_G3XX)
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
Expand Down
4 changes: 4 additions & 0 deletions features/cellular/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"max-cp-data-recv-len" : {
"help": "Max length of the buffer storing data received over control plane",
"value": 1358
},
"plmn-fallback-auto" : {
"help": "If manual PLMN is selected, use mode 4 manual/automatic in AT+COPS to try automatic mode if manual selection fails. Set to null to disable",
"value": null
}
}
}

0 comments on commit 6baa5e4

Please sign in to comment.