Skip to content

Commit b3ebb52

Browse files
ytsuboiadbridge
authored andcommitted
Changed suggested points
Changed accessibility cellular features member functions, fixed minor target issues
1 parent 4b1d087 commit b3ebb52

File tree

6 files changed

+45
-43
lines changed

6 files changed

+45
-43
lines changed

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,16 @@ nsapi_error_t AT_CellularNetwork::activate_context()
243243
{
244244
_at.lock();
245245

246-
nsapi_error_t err = set_context_to_be_activated();
246+
nsapi_error_t err = NSAPI_ERROR_OK;
247+
248+
// try to find or create context with suitable stack
249+
if(get_context()) {
250+
// try to authenticate user before activating or modifying context
251+
err = do_user_authentication();
252+
} else {
253+
err = NSAPI_ERROR_NO_CONNECTION;
254+
}
255+
247256
if (err != NSAPI_ERROR_OK) {
248257
_at.unlock();
249258
tr_error("Failed to activate network context! (%d)", err);
@@ -426,7 +435,7 @@ void AT_CellularNetwork::ppp_status_cb(nsapi_event_t event, intptr_t parameter)
426435
}
427436
#endif
428437

429-
nsapi_error_t AT_CellularNetwork::set_context_to_be_activated()
438+
nsapi_error_t AT_CellularNetwork::do_user_authentication()
430439
{
431440
// try to find or create context with suitable stack
432441
if (!get_context()) {
@@ -435,21 +444,11 @@ nsapi_error_t AT_CellularNetwork::set_context_to_be_activated()
435444

436445
// if user has defined user name and password we need to call CGAUTH before activating or modifying context
437446
if (_pwd && _uname) {
438-
#if defined(TARGET_WIO_3G)
439-
_at.cmd_start("AT+QICSGP=");
440-
_at.write_int(_cid);
441-
_at.write_int(1); // context type 1=IPv4
442-
_at.write_string(_apn);
443-
_at.write_string(_uname);
444-
_at.write_string(_pwd);
445-
_at.write_int(_authentication_type);
446-
#else
447447
_at.cmd_start("AT+CGAUTH=");
448448
_at.write_int(_cid);
449449
_at.write_int(_authentication_type);
450450
_at.write_string(_uname);
451451
_at.write_string(_pwd);
452-
#endif
453452
_at.cmd_stop();
454453
_at.resp_start();
455454
_at.resp_stop();
@@ -458,7 +457,7 @@ nsapi_error_t AT_CellularNetwork::set_context_to_be_activated()
458457
}
459458
}
460459

461-
return _at.get_last_error();
460+
return NSAPI_ERROR_OK;
462461
}
463462

464463
bool AT_CellularNetwork::set_new_context(int cid)

features/cellular/framework/AT/AT_CellularNetwork.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,11 @@ class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase
149149
void urc_cereg();
150150
void urc_cgreg();
151151

152-
nsapi_error_t set_context_to_be_activated();
153152
nsapi_ip_stack_t string_to_stack_type(const char* pdp_type);
154153

155154
void free_credentials();
156155

157156
nsapi_error_t open_data_channel();
158-
bool get_context();
159157
bool set_new_context(int cid);
160158

161159
nsapi_error_t delete_current_context();
@@ -180,6 +178,8 @@ class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase
180178
AuthenticationType _authentication_type;
181179
int _cell_id;
182180
nsapi_connection_status_t _connect_status;
181+
virtual nsapi_error_t do_user_authentication();
182+
bool get_context();
183183
bool _new_context_set;
184184
bool _is_context_active;
185185
RegistrationStatus _reg_status;

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,29 @@ nsapi_error_t QUECTEL_UG96_CellularNetwork::set_access_technology_impl(RadioAcce
4242
_op_act = RAT_UNKNOWN;
4343
return NSAPI_ERROR_UNSUPPORTED;
4444
}
45+
46+
nsapi_error_t QUECTEL_UG96_CellularNetwork::do_user_authentication()
47+
{
48+
// try to find or create context with suitable stack
49+
if (!get_context()) {
50+
return NSAPI_ERROR_NO_CONNECTION;
51+
}
52+
53+
if (_pwd && _uname) {
54+
_at.cmd_start("AT+QICSGP=");
55+
_at.write_int(_cid);
56+
_at.write_int(1); // context type 1=IPv4
57+
_at.write_string(_apn);
58+
_at.write_string(_uname);
59+
_at.write_string(_pwd);
60+
_at.write_int(_authentication_type);
61+
_at.cmd_stop();
62+
_at.resp_start();
63+
_at.resp_stop();
64+
if (_at.get_last_error() != NSAPI_ERROR_OK) {
65+
return NSAPI_ERROR_AUTH_FAILURE;
66+
}
67+
}
68+
69+
return NSAPI_ERROR_OK;
70+
}

features/cellular/framework/targets/QUECTEL/UG96/QUECTEL_UG96_CellularNetwork.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class QUECTEL_UG96_CellularNetwork : public AT_CellularNetwork
3434
virtual bool has_registration(RegistrationType rat);
3535

3636
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opRat);
37+
38+
virtual nsapi_error_t do_user_authentication();
3739
};
3840

3941
} // namespace mbed

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/PinNames.h

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ typedef enum {
220220
LED_RED = LED2,
221221
USER_BUTTON = PC_13,
222222
// Standardized button names
223-
// BUTTON1 = USER_BUTTON,
223+
BUTTON1 = PC_13,
224224
SERIAL_TX = STDIO_UART_TX, // Virtual Com Port
225225
SERIAL_RX = STDIO_UART_RX, // Virtual Com Port
226226
USBTX = STDIO_UART_TX, // Virtual Com Port
@@ -229,33 +229,8 @@ typedef enum {
229229
SPI_MISO = PC_11,
230230
SPI_SCK = PC_10,
231231
SPI_CS = PD_0,
232-
// PWM_OUT = D9,
232+
PWM_OUT = D39,
233233

234-
/*
235-
//USB pins
236-
USB_OTG_HS_ULPI_D0 = PA_3,
237-
USB_OTG_HS_SOF = PA_4,
238-
USB_OTG_HS_ULPI_CK = PA_5,
239-
USB_OTG_FS_SOF = PA_8,
240-
USB_OTG_FS_VBUS = PA_9,
241-
USB_OTG_FS_ID = PA_10,
242-
USB_OTG_FS_DM = PA_11,
243-
USB_OTG_FS_DP = PA_12,
244-
USB_OTG_HS_ULPI_D1 = PB_0,
245-
USB_OTG_HS_ULPI_D2 = PB_1,
246-
USB_OTG_HS_ULPI_D7 = PB_5,
247-
USB_OTG_HS_ULPI_D3 = PB_10,
248-
USB_OTG_HS_ULPI_D4 = PB_11,
249-
USB_OTG_HS_ID = PB_12,
250-
USB_OTG_HS_ULPI_D5 = PB_12,
251-
USB_OTG_HS_ULPI_D6 = PB_13,
252-
USB_OTG_HS_VBUS = PB_13,
253-
USB_OTG_HS_DM = PB_14,
254-
USB_OTG_HS_DP = PB_15,
255-
USB_OTG_HS_ULPI_STP = PC_0,
256-
USB_OTG_HS_ULPI_DIR = PC_2,
257-
USB_OTG_HS_ULPI_NXT = PC_3,
258-
*/
259234

260235
// Not connected
261236
NC = (int)0xFFFFFFFF

targets/targets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,7 @@
17361736
"core": "Cortex-M4F",
17371737
"config": {
17381738
"clock_source": {
1739-
"help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
1739+
"help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL | USE_PLL_HSI",
17401740
"value": "USE_PLL_HSE_XTAL|USE_PLL_HSI",
17411741
"macro_name": "CLOCK_SOURCE"
17421742
},

0 commit comments

Comments
 (0)