Skip to content

Commit 6baa5e4

Browse files
authored
Merge pull request #12020 from linlingao/fix_rat
Fix issues in setting radio access technology
2 parents 5f495db + 0bc8f4f commit 6baa5e4

File tree

20 files changed

+146
-23
lines changed

20 files changed

+146
-23
lines changed

features/cellular/framework/API/CellularNetwork.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ class CellularNetwork {
161161
NWModeManualAutomatic // if manual fails, fallback to automatic
162162
};
163163

164+
/// Operator name format
165+
enum OperatorNameFormat {
166+
OperatorNameAlphaLong = 0, // alphanumeric long form
167+
OperatorNameAlphaShort, // alphanumeric short form
168+
OperatorNameNumeric // numeric digits
169+
};
170+
164171
/// Network registration information
165172
struct registration_params_t {
166173
RegistrationType _type;

features/cellular/framework/AT/AT_CellularDevice.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,22 @@ class AT_CellularDevice : public CellularDevice {
4242
* to the end (just before PROPERTY_MAX). Do not modify any of the existing fields.
4343
*/
4444
enum CellularProperty {
45-
PROPERTY_C_EREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
46-
PROPERTY_C_GREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
47-
PROPERTY_C_REG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
48-
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
49-
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
50-
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
51-
PROPERTY_AT_CNMI, // 0 = not supported, 1 = supported. New message (SMS) indication AT command
52-
PROPERTY_AT_CSMP, // 0 = not supported, 1 = supported. Set text mode AT command
53-
PROPERTY_AT_CMGF, // 0 = not supported, 1 = supported. Set preferred message format AT command
54-
PROPERTY_AT_CSDH, // 0 = not supported, 1 = supported. Show text mode AT command
55-
PROPERTY_IPV4_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4?
56-
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
57-
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4 and IPV6 simultaneously?
58-
PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP?
59-
PROPERTY_AT_CGEREP, // 0 = not supported, 1 = supported. Does modem support AT command AT+CGEREP.
45+
PROPERTY_C_EREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
46+
PROPERTY_C_GREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
47+
PROPERTY_C_REG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
48+
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
49+
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
50+
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
51+
PROPERTY_AT_CNMI, // 0 = not supported, 1 = supported. New message (SMS) indication AT command
52+
PROPERTY_AT_CSMP, // 0 = not supported, 1 = supported. Set text mode AT command
53+
PROPERTY_AT_CMGF, // 0 = not supported, 1 = supported. Set preferred message format AT command
54+
PROPERTY_AT_CSDH, // 0 = not supported, 1 = supported. Show text mode AT command
55+
PROPERTY_IPV4_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4?
56+
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
57+
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4 and IPV6 simultaneously?
58+
PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP?
59+
PROPERTY_AT_CGEREP, // 0 = not supported, 1 = supported. Does modem support AT command AT+CGEREP.
60+
PROPERTY_AT_COPS_FALLBACK_AUTO, // 0 = not supported, 1 = supported. Does modem support mode 4 of AT+COPS= ?
6061

6162
PROPERTY_MAX
6263
};

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,10 @@ nsapi_error_t AT_CellularNetwork::get_network_registering_mode(NWRegisteringMode
209209
nsapi_error_t AT_CellularNetwork::set_registration(const char *plmn)
210210
{
211211

212+
NWRegisteringMode mode = NWModeAutomatic;
213+
212214
if (!plmn) {
213215
tr_debug("Automatic network registration");
214-
NWRegisteringMode mode;
215216
if (get_network_registering_mode(mode) != NSAPI_ERROR_OK) {
216217
return NSAPI_ERROR_DEVICE_ERROR;
217218
}
@@ -221,10 +222,17 @@ nsapi_error_t AT_CellularNetwork::set_registration(const char *plmn)
221222
return NSAPI_ERROR_OK;
222223
} else {
223224
tr_debug("Manual network registration to %s", plmn);
225+
mode = NWModeManual;
226+
OperatorNameFormat format = OperatorNameNumeric;
227+
#ifdef MBED_CONF_CELLULAR_PLMN_FALLBACK_AUTO
228+
if (_device.get_property(AT_CellularDevice::PROPERTY_AT_COPS_FALLBACK_AUTO)) {
229+
mode = NWModeManualAutomatic;
230+
}
231+
#endif
224232
if (_op_act != RAT_UNKNOWN) {
225-
return _at.at_cmd_discard("+COPS", "=1,2,", "%s%d", plmn, _op_act);
233+
return _at.at_cmd_discard("+COPS", "=", "%d%d%s%d", mode, format, plmn, _op_act);
226234
} else {
227-
return _at.at_cmd_discard("+COPS", "=1,2,", "%s", plmn);
235+
return _at.at_cmd_discard("+COPS", "=", "%d%d%s", mode, format, plmn);
228236
}
229237
}
230238
}

features/cellular/framework/targets/GENERIC/GENERIC_AT3GPP/GENERIC_AT3GPP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
3737
1, // PROPERTY_IPV4V6_STACK
3838
0, // PROPERTY_NON_IP_PDP_TYPE
3939
1, // PROPERTY_AT_CGEREP
40+
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
4041
};
4142

4243
GENERIC_AT3GPP::GENERIC_AT3GPP(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/MultiTech/DragonflyNano/PPP/SARA4_PPP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
3737
0, // PROPERTY_IPV4V6_STACK
3838
0, // PROPERTY_NON_IP_PDP_TYPE
3939
1, // PROPERTY_AT_CGEREP
40+
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
4041
};
4142

4243
SARA4_PPP::SARA4_PPP(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4343
1, // PROPERTY_IPV6_STACK
4444
0, // PROPERTY_IPV4V6_STACK
4545
0, // PROPERTY_NON_IP_PDP_TYPE
46-
0, // PROPERTY_AT_CGEREP
46+
0, // PROPERTY_AT_CGEREP,
47+
0, // PROPERTY_AT_COPS_FALLBACK_AUTO
4748
};
4849

4950
QUECTEL_BC95::QUECTEL_BC95(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
6060
1, // PROPERTY_IPV6_STACK
6161
0, // PROPERTY_IPV4V6_STACK
6262
1, // PROPERTY_NON_IP_PDP_TYPE
63-
1, // PROPERTY_AT_CGEREP
63+
1, // PROPERTY_AT_CGEREP,
64+
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
6465
};
6566

6667
QUECTEL_BG96::QUECTEL_BG96(FileHandle *fh, PinName pwr, bool active_high, PinName rst)

features/cellular/framework/targets/QUECTEL/EC2X/QUECTEL_EC2X.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
6161
1, // PROPERTY_IPV6_STACK
6262
1, // PROPERTY_IPV4V6_STACK
6363
0, // PROPERTY_NON_IP_PDP_TYPE
64-
1, // PROPERTY_AT_CGEREP
64+
1, // PROPERTY_AT_CGEREP,
65+
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
6566
};
6667

6768
QUECTEL_EC2X::QUECTEL_EC2X(FileHandle *fh, PinName pwr, bool active_high, PinName rst)

features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4040
0, // PROPERTY_IPV4V6_STACK
4141
0, // PROPERTY_NON_IP_PDP_TYPE
4242
1, // PROPERTY_AT_CGEREP
43+
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
4344
};
4445

4546
QUECTEL_M26::QUECTEL_M26(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/QUECTEL/UG96/QUECTEL_UG96.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4141
0, // PROPERTY_IPV6_STACK
4242
0, // PROPERTY_IPV4V6_STACK
4343
0, // PROPERTY_NON_IP_PDP_TYPE
44-
1, // PROPERTY_AT_CGEREP
44+
1, // PROPERTY_AT_CGEREP,
45+
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
4546
};
4647

4748
QUECTEL_UG96::QUECTEL_UG96(FileHandle *fh) : AT_CellularDevice(fh)

0 commit comments

Comments
 (0)