Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CellularCommon.h Source File

CellularCommon.h

00001 /*
00002  * Copyright (c) 2018, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef CELLULAR_COMMON_
00019 #define CELLULAR_COMMON_
00020 
00021 #include <stdint.h>
00022 #include "nsapi_types.h"
00023 
00024 const int CELLULAR_RETRY_ARRAY_SIZE = 10;
00025 
00026 struct cell_callback_data_t {
00027     nsapi_error_t error; /* possible error code */
00028     int status_data;     /* cellular_event_status related enum or other info in int format. Check cellular_event_status comments.*/
00029     bool final_try;      /* This flag is true if state machine is used and this was the last try. State machine does goes to idle. */
00030     const void *data;    /* possible extra data in any form. Format specified in cellular_connection_status_t per event if any. */
00031     cell_callback_data_t()
00032     {
00033         error = NSAPI_ERROR_OK ;
00034         status_data = -1;
00035         final_try = false;
00036         data = NULL;
00037     }
00038 };
00039 
00040 struct cell_signal_quality_t {
00041     int rssi;           /* received signal strength */
00042     int ber;            /* channel bit error rate */
00043     cell_signal_quality_t()
00044     {
00045         rssi = -1;
00046         ber = -1;
00047     }
00048 };
00049 
00050 /**
00051  * Cellular specific event changes.
00052  * Connect and disconnect are handled via NSAPI_EVENT_CONNECTION_STATUS_CHANGE
00053  * All enum types have struct *cell_callback_data_t in intptr_t with possible error code in cell_callback_data_t.error.
00054  * Most enum values also have some enum in cell_callback_data_t.enumeration, check comments below.
00055  */
00056 typedef enum cellular_event_status {
00057     CellularDeviceReady                     = NSAPI_EVENT_CELLULAR_STATUS_BASE ,     /* Modem is powered and ready to receive commands. cell_callback_data_t.status_data will be -1 */
00058     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*/
00059     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*/
00060     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*/
00061     CellularCellIDChanged                   = NSAPI_EVENT_CELLULAR_STATUS_BASE  + 4, /* Network Cell ID have changed. cell_callback_data_t.status_data will be int cellid*/
00062     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*/
00063     CellularAttachNetwork                   = NSAPI_EVENT_CELLULAR_STATUS_BASE  + 6, /* cell_callback_data_t.status_data will be enum AttachStatus. See enum AttachStatus in ../API/CellularNetwork.h */
00064     CellularActivatePDPContext              = NSAPI_EVENT_CELLULAR_STATUS_BASE  + 7, /* NSAPI_ERROR_OK in cell_callback_data_t.error on successfully PDP Context activated or negative error */
00065     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*/
00066     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.
00067                                                                                        cellular_event_status.data contains current retrycount */
00068     CellularDeviceTimeout                   = NSAPI_EVENT_CELLULAR_STATUS_BASE  + 10,/* cell_callback_data_t.error contain an error or NSAPI_ERROR_OK,
00069                                                                                        cell_callback_data_t.status_data contains the current cellular_connection_status_t,
00070                                                                                        cellular_event_status.data contains new timeout value in milliseconds */
00071 } cellular_connection_status_t;
00072 
00073 #endif // CELLULAR_COMMON_