Mbed OS Reference
Loading...
Searching...
No Matches
CellularCommon.h
1/*
2 * Copyright (c) 2018, Arm Limited and affiliates.
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef CELLULAR_COMMON_
19#define CELLULAR_COMMON_
20
21#include <stdint.h>
22#include "netsocket/nsapi_types.h"
23
24const int CELLULAR_RETRY_ARRAY_SIZE = 10;
25
27 nsapi_error_t error; /* possible error code */
28 int status_data; /* cellular_event_status related enum or other info in int format. Check cellular_event_status comments.*/
29 bool final_try; /* This flag is true if state machine is used and this was the last try. State machine does goes to idle. */
30 const void *data; /* possible extra data in any form. Format specified in cellular_connection_status_t per event if any. */
32 {
34 status_data = -1;
35 final_try = false;
36 data = NULL;
37 }
38};
39
41 int rssi; /* received signal strength */
42 int ber; /* channel bit error rate */
44 {
45 rssi = -1;
46 ber = -1;
47 }
48};
49
50/**
51 * Cellular specific event changes.
52 * Connect and disconnect are handled via NSAPI_EVENT_CONNECTION_STATUS_CHANGE
53 * All enum types have struct *cell_callback_data_t in intptr_t with possible error code in cell_callback_data_t.error.
54 * Most enum values also have some enum in cell_callback_data_t.enumeration, check comments below.
55 */
56typedef enum cellular_event_status {
57 CellularDeviceReady = NSAPI_EVENT_CELLULAR_STATUS_BASE, /* Modem is powered and ready to receive commands. cell_callback_data_t.status_data will be -1 */
58 CellularSIMStatusChanged = NSAPI_EVENT_CELLULAR_STATUS_BASE + 1, /* SIM state changed. cell_callback_data_t.status_data will be enum SimState. See enum SimState in ../API/CellularSIM.h*/
59 CellularRegistrationStatusChanged = NSAPI_EVENT_CELLULAR_STATUS_BASE + 2, /* Registering status changed. cell_callback_data_t.status_data will be enum RegistrationStatus. See enum RegistrationStatus in ../API/CellularNetwork.h*/
60 CellularRegistrationTypeChanged = NSAPI_EVENT_CELLULAR_STATUS_BASE + 3, /* Registration type changed. cell_callback_data_t.status_data will be enum RegistrationType. See enum RegistrationType in ../API/CellularNetwork.h*/
61 CellularCellIDChanged = NSAPI_EVENT_CELLULAR_STATUS_BASE + 4, /* Network Cell ID have changed. cell_callback_data_t.status_data will be int cellid*/
62 CellularRadioAccessTechnologyChanged = NSAPI_EVENT_CELLULAR_STATUS_BASE + 5, /* Network roaming status have changed. cell_callback_data_t.status_data will be enum RadioAccessTechnology See enum RadioAccessTechnology in ../API/CellularNetwork.h*/
63 CellularAttachNetwork = NSAPI_EVENT_CELLULAR_STATUS_BASE + 6, /* cell_callback_data_t.status_data will be enum AttachStatus. See enum AttachStatus in ../API/CellularNetwork.h */
64 CellularActivatePDPContext = NSAPI_EVENT_CELLULAR_STATUS_BASE + 7, /* NSAPI_ERROR_OK in cell_callback_data_t.error on successfully PDP Context activated or negative error */
65 CellularSignalQuality = NSAPI_EVENT_CELLULAR_STATUS_BASE + 8, /* cell_callback_data_t.error will contains return value when signal quality was queried. data will hold the pointer to cell_signal_quality struct. See possible values from ../API/CellularNetwork.h*/
66 CellularStateRetryEvent = NSAPI_EVENT_CELLULAR_STATUS_BASE + 9, /* cell_callback_data_t.error contain an error if any. cell_callback_data_t.status_data contains cellular_event_status and it specifies the operation which is retried.
67 cellular_event_status.data contains current retrycount */
68 CellularDeviceTimeout = NSAPI_EVENT_CELLULAR_STATUS_BASE + 10,/* cell_callback_data_t.error contain an error or NSAPI_ERROR_OK,
69 cell_callback_data_t.status_data contains the current cellular_connection_status_t,
70 cellular_event_status.data contains new timeout value in milliseconds */
71} cellular_connection_status_t;
72
73#endif // CELLULAR_COMMON_
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:142
@ NSAPI_EVENT_CELLULAR_STATUS_BASE
Definition: nsapi_types.h:132
@ NSAPI_ERROR_OK
Definition: nsapi_types.h:85
MBED_NORETURN void error(const char *format,...) MBED_PRINTF(1
To generate a fatal compile-time error, you can use the pre-processor error directive.