Mistake on this page?
Report an issue in GitHub or email us
CellularInformation.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_INFORMATION_H_
19 #define CELLULAR_INFORMATION_H_
20 
21 #include <stddef.h>
22 #include "netsocket/nsapi_types.h"
23 
24 const int MAX_IMSI_LENGTH = 15;
25 const int MAX_ICCID_LENGTH = 20 + 1; // +1 for zero termination
26 
27 namespace mbed {
28 
29 /**
30  * @addtogroup cellular
31  * @{
32  */
33 
34 /**
35  * Class CellularInformation
36  *
37  * An abstract interface that provides information about cellular device.
38  */
40 protected:
41  // friend of CellularDevice so that it's the only way to close/delete this class.
42  friend class CellularDevice;
43 
44  /** virtual Destructor
45  */
46  virtual ~CellularInformation() {};
47 
48 public:
49  /** Request manufacturer identification of cellular device
50  *
51  * @param buf manufacturer identification as zero terminated string
52  * @param buf_size max length of manufacturer identification is 2048 characters
53  * @return NSAPI_ERROR_OK on success
54  * NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
55  * NSAPI_ERROR_DEVICE_ERROR on failure
56  */
57  virtual nsapi_error_t get_manufacturer(char *buf, size_t buf_size) = 0;
58 
59  /** Request model identification of cellular device
60  *
61  * @param buf model identification as zero terminated string
62  * @param buf_size max length of model identification is 2048 characters
63  * @return NSAPI_ERROR_OK on success
64  * NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
65  * NSAPI_ERROR_DEVICE_ERROR on failure
66  */
67  virtual nsapi_error_t get_model(char *buf, size_t buf_size) = 0;
68 
69  /** Request revision identification of cellular device
70  *
71  * @param buf revision identification as zero terminated string
72  * @param buf_size max length of revision identification is 2048 characters
73  * @return NSAPI_ERROR_OK on success
74  * NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
75  * NSAPI_ERROR_DEVICE_ERROR on failure
76  */
77  virtual nsapi_error_t get_revision(char *buf, size_t buf_size) = 0;
78 
79  /** Request serial number identification of cellular device
80  *
81  * @param buf serial number as zero terminated string
82  * @param buf_size max length of serial number is 2048 characters
83  * @param type serial number type to read
84  * @return NSAPI_ERROR_OK on success
85  * NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
86  * NSAPI_ERROR_UNSUPPORTED if the modem does not support SerialNumberType
87  * NSAPI_ERROR_DEVICE_ERROR on other failures
88  */
90  SN = 0, // Serial Number
91  IMEI = 1, // International Mobile station Equipment Identity
92  IMEISV = 2, // IMEI and Software Version number
93  SVN = 3 // Software Version Number
94  };
95  virtual nsapi_size_or_error_t get_serial_number(char *buf, size_t buf_size, SerialNumberType type = SN) = 0;
96 
97  /** Get IMSI from the sim card
98  *
99  * @remark Given imsi buffer length must be 16 or more as imsi max length is 15!
100  *
101  * @param imsi preallocated char* which after successful request contains imsi
102  * @param buf_size size of imsi buffer
103  * @return NSAPI_ERROR_OK on success
104  * NSAPI_ERROR_PARAMETER if imsi is null or buf_size is zero or buf_size is smaller than
105  * MAX_IMSI_LENGTH + 1
106  * NSAPI_ERROR_DEVICE_ERROR on other failures
107  */
108  virtual nsapi_error_t get_imsi(char *imsi, size_t buf_size) = 0;
109 
110  /** Get serial number from the SIM card
111  *
112  * @param buf SIM ICCID as zero terminated string
113  * @param buf_size max length of SIM ICCID is MAX_ICCID_LENGTH
114  * @return NSAPI_ERROR_OK on success
115  * NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
116  * NSAPI_ERROR_DEVICE_ERROR on failure
117  */
118  virtual nsapi_error_t get_iccid(char *buf, size_t buf_size) = 0;
119 };
120 
121 /**
122  * @}
123  */
124 
125 } // namespace mbed
126 
127 #endif // CELLULAR_INFORMATION_H_
virtual nsapi_error_t get_iccid(char *buf, size_t buf_size)=0
Get serial number from the SIM card.
virtual nsapi_error_t get_model(char *buf, size_t buf_size)=0
Request model identification of cellular device.
virtual nsapi_error_t get_revision(char *buf, size_t buf_size)=0
Request revision identification of cellular device.
SerialNumberType
Request serial number identification of cellular device.
Class CellularDevice.
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:142
signed int nsapi_size_or_error_t
Type used to represent either a size or error passed through sockets.
Definition: nsapi_types.h:153
Class CellularInformation.
virtual ~CellularInformation()
virtual Destructor
virtual nsapi_error_t get_manufacturer(char *buf, size_t buf_size)=0
Request manufacturer identification of cellular device.
virtual nsapi_error_t get_imsi(char *imsi, size_t buf_size)=0
Get IMSI from the sim card.
Definition: ATHandler.h:46
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.