Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Committer:
kenjiArai
Date:
Tue Dec 17 23:23:45 2019 +0000
Revision:
0:5b88d5760320
mbed-os5 only for TYBLE16

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 0:5b88d5760320 1 /*
kenjiArai 0:5b88d5760320 2 * Copyright (c) 2018, Arm Limited and affiliates.
kenjiArai 0:5b88d5760320 3 * SPDX-License-Identifier: Apache-2.0
kenjiArai 0:5b88d5760320 4 *
kenjiArai 0:5b88d5760320 5 * Licensed under the Apache License, Version 2.0 (the "License");
kenjiArai 0:5b88d5760320 6 * you may not use this file except in compliance with the License.
kenjiArai 0:5b88d5760320 7 * You may obtain a copy of the License at
kenjiArai 0:5b88d5760320 8 *
kenjiArai 0:5b88d5760320 9 * http://www.apache.org/licenses/LICENSE-2.0
kenjiArai 0:5b88d5760320 10 *
kenjiArai 0:5b88d5760320 11 * Unless required by applicable law or agreed to in writing, software
kenjiArai 0:5b88d5760320 12 * distributed under the License is distributed on an "AS IS" BASIS,
kenjiArai 0:5b88d5760320 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kenjiArai 0:5b88d5760320 14 * See the License for the specific language governing permissions and
kenjiArai 0:5b88d5760320 15 * limitations under the License.
kenjiArai 0:5b88d5760320 16 */
kenjiArai 0:5b88d5760320 17
kenjiArai 0:5b88d5760320 18 #ifndef CELLULAR_COMMON_
kenjiArai 0:5b88d5760320 19 #define CELLULAR_COMMON_
kenjiArai 0:5b88d5760320 20
kenjiArai 0:5b88d5760320 21 #include <stdint.h>
kenjiArai 0:5b88d5760320 22 #include "nsapi_types.h"
kenjiArai 0:5b88d5760320 23
kenjiArai 0:5b88d5760320 24 const int CELLULAR_RETRY_ARRAY_SIZE = 10;
kenjiArai 0:5b88d5760320 25
kenjiArai 0:5b88d5760320 26 struct cell_callback_data_t {
kenjiArai 0:5b88d5760320 27 nsapi_error_t error; /* possible error code */
kenjiArai 0:5b88d5760320 28 int status_data; /* cellular_event_status related enum or other info in int format. Check cellular_event_status comments.*/
kenjiArai 0:5b88d5760320 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. */
kenjiArai 0:5b88d5760320 30 const void *data; /* possible extra data in any form. Format specified in cellular_connection_status_t per event if any. */
kenjiArai 0:5b88d5760320 31 cell_callback_data_t()
kenjiArai 0:5b88d5760320 32 {
kenjiArai 0:5b88d5760320 33 error = NSAPI_ERROR_OK;
kenjiArai 0:5b88d5760320 34 status_data = -1;
kenjiArai 0:5b88d5760320 35 final_try = false;
kenjiArai 0:5b88d5760320 36 data = NULL;
kenjiArai 0:5b88d5760320 37 }
kenjiArai 0:5b88d5760320 38 };
kenjiArai 0:5b88d5760320 39
kenjiArai 0:5b88d5760320 40 struct cell_signal_quality_t {
kenjiArai 0:5b88d5760320 41 int rssi; /* received signal strength */
kenjiArai 0:5b88d5760320 42 int ber; /* channel bit error rate */
kenjiArai 0:5b88d5760320 43 cell_signal_quality_t()
kenjiArai 0:5b88d5760320 44 {
kenjiArai 0:5b88d5760320 45 rssi = -1;
kenjiArai 0:5b88d5760320 46 ber = -1;
kenjiArai 0:5b88d5760320 47 }
kenjiArai 0:5b88d5760320 48 };
kenjiArai 0:5b88d5760320 49
kenjiArai 0:5b88d5760320 50 /**
kenjiArai 0:5b88d5760320 51 * Cellular specific event changes.
kenjiArai 0:5b88d5760320 52 * Connect and disconnect are handled via NSAPI_EVENT_CONNECTION_STATUS_CHANGE
kenjiArai 0:5b88d5760320 53 * All enum types have struct *cell_callback_data_t in intptr_t with possible error code in cell_callback_data_t.error.
kenjiArai 0:5b88d5760320 54 * Most enum values also have some enum in cell_callback_data_t.enumeration, check comments below.
kenjiArai 0:5b88d5760320 55 */
kenjiArai 0:5b88d5760320 56 typedef enum cellular_event_status {
kenjiArai 0:5b88d5760320 57 CellularDeviceReady = NSAPI_EVENT_CELLULAR_STATUS_BASE, /* Modem is powered and ready to receive commands. cell_callback_data_t.status_data will be -1 */
kenjiArai 0:5b88d5760320 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*/
kenjiArai 0:5b88d5760320 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*/
kenjiArai 0:5b88d5760320 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*/
kenjiArai 0:5b88d5760320 61 CellularCellIDChanged = NSAPI_EVENT_CELLULAR_STATUS_BASE + 4, /* Network Cell ID have changed. cell_callback_data_t.status_data will be int cellid*/
kenjiArai 0:5b88d5760320 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*/
kenjiArai 0:5b88d5760320 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 */
kenjiArai 0:5b88d5760320 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 */
kenjiArai 0:5b88d5760320 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*/
kenjiArai 0:5b88d5760320 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.
kenjiArai 0:5b88d5760320 67 cellular_event_status.data contains current retrycount */
kenjiArai 0:5b88d5760320 68 CellularDeviceTimeout = NSAPI_EVENT_CELLULAR_STATUS_BASE + 10,/* cell_callback_data_t.error contain an error or NSAPI_ERROR_OK,
kenjiArai 0:5b88d5760320 69 cell_callback_data_t.status_data contains the current cellular_connection_status_t,
kenjiArai 0:5b88d5760320 70 cellular_event_status.data contains new timeout value in milliseconds */
kenjiArai 0:5b88d5760320 71 } cellular_connection_status_t;
kenjiArai 0:5b88d5760320 72
kenjiArai 0:5b88d5760320 73 #endif // CELLULAR_COMMON_