Skip to content

Commit cd0126a

Browse files
author
Cruz Monrreal
authored
Merge pull request #7768 from jarvte/document_all_cellular_errcodes
Cellular: Document all possible error codes for cellular API.
2 parents 08afaf2 + 9f5a71a commit cd0126a

File tree

5 files changed

+180
-99
lines changed

5 files changed

+180
-99
lines changed

features/cellular/framework/API/CellularInformation.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,26 @@ class CellularInformation {
4242
*
4343
* @param buf manufacturer identification as zero terminated string
4444
* @param buf_size max length of manufacturer identification is 2048 characters
45-
* @return zero on success, on failure negative error code
45+
* @return NSAPI_ERROR_OK on success
46+
* NSAPI_ERROR_DEVICE_ERROR on failure
4647
*/
4748
virtual nsapi_error_t get_manufacturer(char *buf, size_t buf_size) = 0;
4849

4950
/** Request model identification of cellular device
5051
*
5152
* @param buf model identification as zero terminated string
5253
* @param buf_size max length of model identification is 2048 characters
53-
* @return zero on success, on failure negative error code
54+
* @return NSAPI_ERROR_OK on success
55+
* NSAPI_ERROR_DEVICE_ERROR on failure
5456
*/
5557
virtual nsapi_error_t get_model(char *buf, size_t buf_size) = 0;
5658

5759
/** Request revision identification of cellular device
5860
*
5961
* @param buf revision identification as zero terminated string
6062
* @param buf_size max length of revision identification is 2048 characters
61-
* @return zero on success, on failure negative error code
63+
* @return NSAPI_ERROR_OK on success
64+
* NSAPI_ERROR_DEVICE_ERROR on failure
6265
*/
6366
virtual nsapi_error_t get_revision(char *buf, size_t buf_size) = 0;
6467

@@ -67,7 +70,9 @@ class CellularInformation {
6770
* @param buf serial number as zero terminated string
6871
* @param buf_size max length of serial number is 2048 characters
6972
* @param type serial number type to read
70-
* @return zero on success, on failure negative error code
73+
* @return NSAPI_ERROR_OK on success
74+
* NSAPI_ERROR_UNSUPPORTED if the modem does not support SerialNumberType
75+
* NSAPI_ERROR_DEVICE_ERROR on other failures
7176
*/
7277
enum SerialNumberType {
7378
SN = 0, // Serial Number

features/cellular/framework/API/CellularNetwork.h

Lines changed: 97 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -226,21 +226,24 @@ class CellularNetwork : public NetworkInterface {
226226
/** Does all the needed initializations that can fail
227227
*
228228
* @remark must be called immediately after constructor.
229-
* @return zero on success
229+
* @return NSAPI_ERROR_OK on success
230+
* NSAPI_ERROR_NO_MEMORY on memory failure
230231
*/
231232
virtual nsapi_error_t init() = 0;
232233

233234
/** Request registering to network.
234235
*
235236
* @param plmn format is in numeric format or 0 for automatic network registration
236-
* @return zero on success
237+
* @return NSAPI_ERROR_OK on success
238+
* NSAPI_ERROR_DEVICE_ERROR on failure
237239
*/
238240
virtual nsapi_error_t set_registration(const char *plmn = 0) = 0;
239241

240242
/** Get the current network registering mode
241243
*
242-
* @param mode on successful return contains the current network registering mode
243-
* @return zero on success
244+
* @param mode on successful return contains the current network registering mode
245+
* @return NSAPI_ERROR_OK on success
246+
* NSAPI_ERROR_DEVICE_ERROR on failure
244247
*/
245248
virtual nsapi_error_t get_network_registering_mode(NWRegisteringMode &mode) = 0;
246249

@@ -249,17 +252,21 @@ class CellularNetwork : public NetworkInterface {
249252
* After successful call network class starts to get information about network changes like
250253
* registration statue, access technology, cell id...
251254
*
252-
* @param type RegistrationType to set urc on/off
253-
* @param on Controls are urc' active or not
254-
* @return zero on success
255+
* @param type RegistrationType to set urc on/off
256+
* @param on Controls are urc active or not
257+
* @return NSAPI_ERROR_OK on success
258+
* NSAPI_ERROR_UNSUPPORTED if the modem does not support RegistrationType
259+
* NSAPI_ERROR_DEVICE_ERROR on failure
255260
*/
256261
virtual nsapi_error_t set_registration_urc(RegistrationType type, bool on) = 0;
257262

258263
/** Gets the network registration status.
259264
*
260-
* @param type see RegistrationType values
261-
* @param status see RegistrationStatus values
262-
* @return zero on success
265+
* @param type see RegistrationType values
266+
* @param status see RegistrationStatus values
267+
* @return NSAPI_ERROR_OK on success
268+
* NSAPI_ERROR_UNSUPPORTED if the modem does not support RegistrationType
269+
* NSAPI_ERROR_DEVICE_ERROR on failure
263270
*/
264271
virtual nsapi_error_t get_registration_status(RegistrationType type, RegistrationStatus &status) = 0;
265272

@@ -268,7 +275,8 @@ class CellularNetwork : public NetworkInterface {
268275
* @param apn Optional name of the network to connect to
269276
* @param username Optional username for the APN
270277
* @param password Optional password fot the APN
271-
* @return 0 on success, negative error code on failure
278+
* @return NSAPI_ERROR_OK on success
279+
* NSAPI_ERROR_NO_MEMORY on memory failure
272280
*/
273281
virtual nsapi_error_t set_credentials(const char *apn,
274282
const char *username = 0, const char *password = 0) = 0;
@@ -279,30 +287,34 @@ class CellularNetwork : public NetworkInterface {
279287
* @param type Authentication type to use
280288
* @param username Optional username for the APN
281289
* @param password Optional password fot the APN
282-
* @return 0 on success, negative error code on failure
290+
* @return NSAPI_ERROR_OK on success
291+
* NSAPI_ERROR_NO_MEMORY on memory failure
283292
*/
284293
virtual nsapi_error_t set_credentials(const char *apn, AuthenticationType type,
285294
const char *username = 0, const char *password = 0) = 0;
286295

287296
/** Request attach to network.
288297
*
289298
* @deprecated Parameter timeout will be deprecated. Use mbed-os/features/cellular/framework/API/CellularDevice.h set_timeout instead.
290-
* @param timeout milliseconds to wait for attach response
291-
* @return zero on success
299+
* @param timeout milliseconds to wait for attach response
300+
* @return NSAPI_ERROR_OK on success
301+
* NSAPI_ERROR_DEVICE_ERROR on failure
292302
*/
293303
MBED_DEPRECATED_SINCE("mbed-os-5.9", "Parameter timeout will be deprecated. Use mbed-os/features/cellular/framework/API/CellularDevice.h set_timeout instead.")
294304
virtual nsapi_error_t set_attach(int timeout = 10 * 1000) = 0;
295305

296306
/** Request attach status from network.
297307
*
298-
* @param status see AttachStatus values
299-
* @return zero on success
308+
* @param status see AttachStatus values
309+
* @return NSAPI_ERROR_OK on success
310+
* NSAPI_ERROR_DEVICE_ERROR on failure
300311
*/
301312
virtual nsapi_error_t get_attach(AttachStatus &status) = 0;
302313

303314
/** Request detach from a network.
304315
*
305-
* @return zero on success
316+
* @return NSAPI_ERROR_OK on success
317+
* NSAPI_ERROR_DEVICE_ERROR on failure
306318
*/
307319
virtual nsapi_error_t detach() = 0;
308320

@@ -312,45 +324,54 @@ class CellularNetwork : public NetworkInterface {
312324
* @param reports Additional exception reports at maximum rate reached are allowed to be sent [optional]
313325
* @param time_unit Uplink time unit with values 0=unrestricted, 1=minute, 2=hour, 3=day, 4=week [optional]
314326
* @param uplink_rate Maximum number of messages per timeUnit [optional]
315-
* @return zero on success
327+
* @return NSAPI_ERROR_OK on success
328+
* NSAPI_ERROR_DEVICE_ERROR on case of failure
316329
*/
317330
virtual nsapi_error_t get_rate_control(CellularNetwork::RateControlExceptionReports &reports,
318331
CellularNetwork::RateControlUplinkTimeUnit &time_unit, int &uplink_rate) = 0;
319332

320333
/** Get backoff timer value
321334
*
322335
* @param backoff_timer Backoff timer value associated with PDP APN in seconds
323-
* @return zero on success
336+
* @return NSAPI_ERROR_OK on success
337+
* NSAPI_ERROR_PARAMETER if no access point is set or found when activating context
338+
* NSAPI_ERROR_DEVICE_ERROR on failure
324339
*/
325340
virtual nsapi_error_t get_apn_backoff_timer(int &backoff_timer) = 0;
326341

327342
/** Sets radio access technology.
328343
*
329-
* @param rat Radio access technology
330-
* @return zero on success
344+
* @param rat Radio access technology
345+
* @return NSAPI_ERROR_OK on success
346+
* NSAPI_ERROR_UNSUPPORTED if the given rat is RAT_UNKNOWN or inheriting target class
347+
* has not implemented method set_access_technology_impl(...)
348+
* OR return value of the inheriting target class set_access_technology_impl(...)
331349
*/
332350
virtual nsapi_error_t set_access_technology(RadioAccessTechnology rat) = 0;
333351

334352
/** Get current radio access technology.
335353
*
336-
* @param rat Radio access technology
337-
* @return zero on success
354+
* @param rat Radio access technology
355+
* @return NSAPI_ERROR_OK
338356
*/
339357
virtual nsapi_error_t get_access_technology(RadioAccessTechnology &rat) = 0;
340358

341359
/** Scans for operators module can reach.
342360
*
343-
* @param operators Container of reachable operators and their access technologies
344-
* @param ops_count Number of found operators
345-
* @return zero on success
361+
* @param operators Container of reachable operators and their access technologies
362+
* @param ops_count Number of found operators
363+
* @return NSAPI_ERROR_OK on success
364+
* NSAPI_ERROR_NO_MEMORY on memory failure
365+
* NSAPI_ERROR_DEVICE_ERROR on other failures
346366
*/
347367
virtual nsapi_error_t scan_plmn(operList_t &operators, int &ops_count) = 0;
348368

349369
/** Set CIoT optimizations.
350370
*
351371
* @param supported_opt Supported CIoT EPS optimizations.
352372
* @param preferred_opt Preferred CIoT EPS optimizations.
353-
* @return zero on success
373+
* @return NSAPI_ERROR_OK on success
374+
* NSAPI_ERROR_DEVICE_ERROR on failure
354375
*/
355376
virtual nsapi_error_t set_ciot_optimization_config(Supported_UE_Opt supported_opt,
356377
Preferred_UE_Opt preferred_opt) = 0;
@@ -359,14 +380,20 @@ class CellularNetwork : public NetworkInterface {
359380
*
360381
* @param supported_opt Supported CIoT EPS optimizations.
361382
* @param preferred_opt Preferred CIoT EPS optimizations.
362-
* @return zero on success
383+
* @return NSAPI_ERROR_OK on success
384+
* NSAPI_ERROR_DEVICE_ERROR on failure
363385
*/
364386
virtual nsapi_error_t get_ciot_optimization_config(Supported_UE_Opt &supported_opt,
365387
Preferred_UE_Opt &preferred_opt) = 0;
366388

367389
/** Start the interface. Attempts to connect to a cellular network.
368390
*
369-
* @return 0 on success, negative error code on failure
391+
* @return NSAPI_ERROR_OK on success
392+
* 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
394+
* NSAPI_ERROR_AUTH_FAILURE if password and username were provided and authentication to network failed
395+
* Also if PPP mode
396+
* NSAPI_ERROR_DEVICE_ERROR on failure and check more error from nsapi_ppp_connect(...)
370397
*/
371398
virtual nsapi_error_t connect() = 0;
372399

@@ -375,15 +402,24 @@ class CellularNetwork : public NetworkInterface {
375402
* @param apn Optional name of the network to connect to
376403
* @param username Optional username for your APN
377404
* @param password Optional password for your APN
378-
* @return 0 on success, negative error code on failure
405+
* @return NSAPI_ERROR_OK on success
406+
* NSAPI_ERROR_NO_CONNECTION if fails to find suitable context to activate or activation failed (if not already activated)
407+
* NSAPI_ERROR_UNSUPPORTED if NetworkStack was not found
408+
* NSAPI_ERROR_AUTH_FAILURE if password and username were provided and authentication to network failed
409+
* NSAPI_ERROR_NO_MEMORY on memory failure
410+
* Also if PPP mode
411+
* NSAPI_ERROR_DEVICE_ERROR on failure and check more error from nsapi_ppp_connect(...)
379412
*/
380413
virtual nsapi_error_t connect(const char *apn,
381414
const char *username = 0, const char *password = 0) = 0;
382415

383416
/** Finds the correct PDP context and activates it. If correct PDP context is not found, one is created.
384417
* Given APN (or not given) and stack type (IPv4/IPv6/dual) are influencing when finding the PDP context.
385418
*
386-
* @return zero on success
419+
* @return NSAPI_ERROR_OK on success
420+
* NSAPI_ERROR_NO_CONNECTION if fails to find suitable context to activate or activation failed (if not already activated)
421+
* NSAPI_ERROR_UNSUPPORTED if NetworkStack was not found
422+
* NSAPI_ERROR_AUTH_FAILURE if password and username were provided and authentication to network failed
387423
*/
388424
virtual nsapi_error_t activate_context() = 0;
389425

@@ -392,7 +428,8 @@ class CellularNetwork : public NetworkInterface {
392428
*
393429
* @param stack_type the stack type to be used.
394430
*
395-
* @return NSAPI_ERROR_OK on success
431+
* @return NSAPI_ERROR_OK on success
432+
* NSAPI_ERROR_PARAMETER if modem does not support the given stack_type
396433
*/
397434
virtual nsapi_error_t set_stack_type(nsapi_ip_stack_t stack_type) = 0;
398435

@@ -406,35 +443,39 @@ class CellularNetwork : public NetworkInterface {
406443
/** Get the relevant information for an active non secondary PDP context.
407444
*
408445
* @remark optional params are not updated if not received from network.
409-
* @param params_list reference to linked list which is filled on successful call
410-
* @return 0 on success, negative error code on failure
446+
* @param params_list reference to linked list, which is filled on successful call
447+
* @return NSAPI_ERROR_OK on success
448+
* NSAPI_ERROR_NO_MEMORY on memory failure
449+
* NSAPI_ERROR_DEVICE_ERROR on other failures
411450
*/
412451
virtual nsapi_error_t get_pdpcontext_params(pdpContextList_t &params_list) = 0;
413452

414453
/** Get extended signal quality parameters.
415454
*
416-
* @param rxlev signal strength level
417-
* @param ber bit error rate
418-
* @param rscp signal code power
419-
* @param ecno ratio of the received energy per PN chip to the total received power spectral density
420-
* @param rsrq signal received quality
421-
* @param rsrp signal received power
422-
* @return NSAPI_ERROR_OK on success, negative error code on failure
455+
* @param rxlev signal strength level
456+
* @param ber bit error rate
457+
* @param rscp signal code power
458+
* @param ecno ratio of the received energy per PN chip to the total received power spectral density
459+
* @param rsrq signal received quality
460+
* @param rsrp signal received power
461+
* @return NSAPI_ERROR_OK on success
462+
* NSAPI_ERROR_DEVICE_ERROR on other failures
423463
*/
424464
virtual nsapi_error_t get_extended_signal_quality(int &rxlev, int &ber, int &rscp, int &ecno, int &rsrq, int &rsrp) = 0;
425465

426466
/** Get signal quality parameters.
427467
*
428-
* @param rssi signal strength level
429-
* @param ber bit error rate
430-
* @return NSAPI_ERROR_OK on success, negative error code on failure
468+
* @param rssi signal strength level
469+
* @param ber bit error rate
470+
* @return NSAPI_ERROR_OK on success
471+
* NSAPI_ERROR_DEVICE_ERROR on other failures
431472
*/
432473
virtual nsapi_error_t get_signal_quality(int &rssi, int &ber) = 0;
433474

434475
/** Get cell id.
435476
*
436-
* @param cell_id cell id
437-
* @return NSAPI_ERROR_OK on success, negative error code on failure
477+
* @param cell_id cell ID
478+
* @return NSAPI_ERROR_OK
438479
*/
439480
virtual nsapi_error_t get_cell_id(int &cell_id) = 0;
440481

@@ -445,9 +486,10 @@ class CellularNetwork : public NetworkInterface {
445486

446487
/** Get the operator parameters.
447488
*
448-
* @param format format of the operator field
449-
* @param operator_params applicable operator param fields filled
450-
* @return NSAPI_ERROR_OK on success, negative error code on failure
489+
* @param format format of the operator field
490+
* @param operator_params applicable operator param fields filled
491+
* @return NSAPI_ERROR_OK on success
492+
* NSAPI_ERROR_DEVICE_ERROR on case of other failures
451493
*/
452494
virtual nsapi_error_t get_operator_params(int &format, operator_t &operator_params) = 0;
453495

@@ -470,14 +512,17 @@ class CellularNetwork : public NetworkInterface {
470512
/** Set blocking status of connect() which by default should be blocking
471513
*
472514
* @param blocking true if connect is blocking
473-
* @return 0 on success, negative error code on failure
515+
* @return NSAPI_ERROR_OK
516+
* if PPP mode check errors from nsapi_ppp_set_blocking(...)
474517
*/
475518
virtual nsapi_error_t set_blocking(bool blocking) = 0;
476519

477520
/** Read operator names
478521
*
479-
* @param op_names on successful return will contain linked list of operator names.
480-
* @return zero on success
522+
* @param op_names on successful return contains linked list of operator names.
523+
* @return NSAPI_ERROR_OK on success
524+
* NSAPI_ERROR_NO_MEMORY on memory failure
525+
* NSAPI_ERROR_DEVICE_ERROR on other failures
481526
*/
482527
virtual nsapi_error_t get_operator_names(operator_names_list &op_names) = 0;
483528
};

0 commit comments

Comments
 (0)