Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CellularInformation.h Source File

CellularInformation.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_INFORMATION_H_
00019 #define CELLULAR_INFORMATION_H_
00020 
00021 #include <stddef.h>
00022 #include "nsapi_types.h"
00023 
00024 const int MAX_IMSI_LENGTH = 15;
00025 const int MAX_ICCID_LENGTH = 20 + 1; // +1 for zero termination
00026 
00027 namespace mbed {
00028 
00029 /**
00030  * @addtogroup cellular
00031  * @{
00032  */
00033 
00034 /**
00035  *  Class CellularInformation
00036  *
00037  *  An abstract interface that provides information about cellular device.
00038  */
00039 class CellularInformation {
00040 protected:
00041     // friend of CellularDevice so that it's the only way to close/delete this class.
00042     friend class CellularDevice;
00043 
00044     /** virtual Destructor
00045      */
00046     virtual ~CellularInformation() {};
00047 
00048 public:
00049     /** Request manufacturer identification of cellular device
00050      *
00051      *  @param buf      manufacturer identification as zero terminated string
00052      *  @param buf_size max length of manufacturer identification is 2048 characters
00053      *  @return         NSAPI_ERROR_OK on success
00054      *                  NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
00055      *                  NSAPI_ERROR_DEVICE_ERROR on failure
00056      */
00057     virtual nsapi_error_t get_manufacturer(char *buf, size_t buf_size) = 0;
00058 
00059     /** Request model identification of cellular device
00060      *
00061      *  @param buf      model identification as zero terminated string
00062      *  @param buf_size max length of model identification is 2048 characters
00063      *  @return         NSAPI_ERROR_OK on success
00064      *                  NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
00065      *                  NSAPI_ERROR_DEVICE_ERROR on failure
00066      */
00067     virtual nsapi_error_t get_model(char *buf, size_t buf_size) = 0;
00068 
00069     /** Request revision identification of cellular device
00070      *
00071      *  @param buf      revision identification as zero terminated string
00072      *  @param buf_size max length of revision identification is 2048 characters
00073      *  @return         NSAPI_ERROR_OK on success
00074      *                  NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
00075      *                  NSAPI_ERROR_DEVICE_ERROR on failure
00076      */
00077     virtual nsapi_error_t get_revision(char *buf, size_t buf_size) = 0;
00078 
00079     /** Request serial number identification of cellular device
00080      *
00081      *  @param buf      serial number as zero terminated string
00082      *  @param buf_size max length of serial number is 2048 characters
00083      *  @param type     serial number type to read
00084      *  @return         NSAPI_ERROR_OK on success
00085      *                  NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
00086      *                  NSAPI_ERROR_UNSUPPORTED if the modem does not support SerialNumberType
00087      *                  NSAPI_ERROR_DEVICE_ERROR on other failures
00088      */
00089     enum SerialNumberType {
00090         SN = 0, // Serial Number
00091         IMEI = 1, // International Mobile station Equipment Identity
00092         IMEISV = 2, // IMEI and Software Version number
00093         SVN  = 3 // Software Version Number
00094     };
00095     virtual nsapi_size_or_error_t get_serial_number(char *buf, size_t buf_size, SerialNumberType type = SN) = 0;
00096 
00097     /** Get IMSI from the sim card
00098      *
00099      *  @remark         Given imsi buffer length must be 16 or more as imsi max length is 15!
00100      *
00101      *  @param imsi     preallocated char* which after successful request contains imsi
00102      *  @param buf_size size of imsi buffer
00103      *  @return         NSAPI_ERROR_OK on success
00104      *                  NSAPI_ERROR_PARAMETER if imsi is null or buf_size is zero or buf_size is smaller than
00105      *                  MAX_IMSI_LENGTH + 1
00106      *                  NSAPI_ERROR_DEVICE_ERROR on other failures
00107      */
00108     virtual nsapi_error_t get_imsi(char *imsi, size_t buf_size) = 0;
00109 
00110     /** Get serial number from the SIM card
00111      *
00112      *  @param buf      SIM ICCID as zero terminated string
00113      *  @param buf_size max length of SIM ICCID is MAX_ICCID_LENGTH
00114      *  @return         NSAPI_ERROR_OK on success
00115      *                  NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
00116      *                  NSAPI_ERROR_DEVICE_ERROR on failure
00117      */
00118     virtual nsapi_error_t get_iccid(char *buf, size_t buf_size) = 0;
00119 };
00120 
00121 /**
00122  * @}
00123  */
00124 
00125 } // namespace mbed
00126 
00127 #endif // CELLULAR_INFORMATION_H_