Skip to content

Commit 13106fb

Browse files
author
Ari Parkkila
committed
Cellular: Disable AT+CGAUTH on HE910 and BC95
1 parent 4698cd2 commit 13106fb

File tree

7 files changed

+22
-2
lines changed

7 files changed

+22
-2
lines changed

features/cellular/TESTS/socket/udp/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static void udp_network_stack()
162162
cellular.set_sim_pin(MBED_CONF_APP_CELLULAR_SIM_PIN);
163163
#ifdef MBED_CONF_APP_APN
164164
CellularNetwork *network = cellular.get_network();
165-
TEST_ASSERT(network->set_credentials(MBED_CONF_APP_APN) == NSAPI_ERROR_OK);
165+
TEST_ASSERT(network->set_credentials(MBED_CONF_APP_APN, MBED_CONF_APP_USERNAME, MBED_CONF_APP_PASSWORD) == NSAPI_ERROR_OK);
166166
#endif
167167
cellular_target_state = CellularConnectionFSM::STATE_CONNECTED;
168168
TEST_ASSERT(cellular.continue_to_state(cellular_target_state) == NSAPI_ERROR_OK);

features/cellular/framework/API/CellularNetwork.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class CellularNetwork : public NetworkInterface {
390390
*
391391
* @return NSAPI_ERROR_OK on success
392392
* NSAPI_ERROR_NO_CONNECTION if fails to find suitable context to activate or activation failed (if not already activated)
393-
* NSAPI_ERROR_UNSUPPORTED if NetworkStack was not found
393+
* NSAPI_ERROR_UNSUPPORTED if NetworkStack was not found or cellular device does not support authentication
394394
* NSAPI_ERROR_AUTH_FAILURE if password and username were provided and authentication to network failed
395395
* Also if PPP mode
396396
* NSAPI_ERROR_DEVICE_ERROR on failure and check more error from nsapi_ppp_connect(...)

features/cellular/framework/AT/AT_CellularBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class AT_CellularBase {
5151
enum SupportedFeature {
5252
AT_CGSN_WITH_TYPE, // AT+CGSN without type is likely always supported similar to AT+GSN
5353
AT_CGDATA, // alternative is to support only ATD*99***<cid>#
54+
AT_CGAUTH, // APN authentication AT commands supported
5455
SUPPORTED_FEATURE_END_MARK // must be last element in the array of features
5556
};
5657
static void set_unsupported_features(const SupportedFeature *unsupported_features);

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
210210
}
211211

212212
if (username && (len = strlen(username)) > 0) {
213+
if (!is_supported(AT_CGAUTH)) { // APN authentication is needed with username/password
214+
return NSAPI_ERROR_UNSUPPORTED;
215+
}
213216
_uname = (char *)malloc(len * sizeof(char) + 1);
214217
if (_uname) {
215218
memcpy(_uname, username, len + 1);
@@ -512,6 +515,9 @@ nsapi_error_t AT_CellularNetwork::do_user_authentication()
512515
{
513516
// if user has defined user name and password we need to call CGAUTH before activating or modifying context
514517
if (_pwd && _uname) {
518+
if (!is_supported(AT_CGAUTH)) {
519+
return NSAPI_ERROR_UNSUPPORTED;
520+
}
515521
_at.cmd_start("AT+CGAUTH=");
516522
_at.write_int(_cid);
517523
_at.write_int(_authentication_type);

features/cellular/framework/AT/AT_CellularNetwork.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase {
146146
*/
147147
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat);
148148

149+
/** APN user authentication
150+
*
151+
* @return NSAPI_ERROR_OK on success
152+
* NSAPI_ERROR_UNSUPPORTED on authentication not supported by cellular device
153+
* NSAPI_ERROR_AUTH_FAILURE on authentication to network failed
154+
*/
149155
virtual nsapi_error_t do_user_authentication();
150156
private:
151157
// "NO CARRIER" urc

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@
3131
using namespace events;
3232
using namespace mbed;
3333

34+
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
35+
AT_CellularBase::AT_CGAUTH, // BC95_AT_Commands_Manual_V1.9
36+
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
37+
};
38+
3439
QUECTEL_BC95::QUECTEL_BC95(EventQueue &queue) : AT_CellularDevice(queue)
3540
{
41+
AT_CellularBase::set_unsupported_features(unsupported_features);
3642
}
3743

3844
QUECTEL_BC95::~QUECTEL_BC95()

features/cellular/framework/targets/TELIT/HE910/TELIT_HE910.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ using namespace events;
2424

2525
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
2626
AT_CellularBase::AT_CGSN_WITH_TYPE, // HE910/UE910/UL865/UE866 AT Commands Reference Guide Rev. 11-2006-10-14
27+
AT_CellularBase::AT_CGAUTH, // HE910/UE910/UL865/UE866 AT Commands Reference Guide Rev. 11-2006-10-14
2728
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
2829
};
2930

0 commit comments

Comments
 (0)