Mbed OS Reference
Loading...
Searching...
No Matches
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
24const int MAX_IMSI_LENGTH = 15;
25const int MAX_ICCID_LENGTH = 20 + 1; // +1 for zero termination
26
27namespace 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 */
40protected:
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 */
47
48public:
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 enum SerialNumberType {
80 SN = 0, // Serial Number
81 IMEI = 1, // International Mobile station Equipment Identity
82 IMEISV = 2, // IMEI and Software Version number
83 SVN = 3 // Software Version Number
84 };
85
86 /** Request serial number identification of cellular device
87 *
88 * @param buf serial number as zero terminated string
89 * @param buf_size max length of serial number is 2048 characters
90 * @param type serial number type to read
91 * @return NSAPI_ERROR_OK on success
92 * NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
93 * NSAPI_ERROR_UNSUPPORTED if the modem does not support SerialNumberType
94 * NSAPI_ERROR_DEVICE_ERROR on other failures
95 */
96 virtual nsapi_size_or_error_t get_serial_number(char *buf, size_t buf_size, SerialNumberType type = SN) = 0;
97
98 /** Get IMSI from the sim card
99 *
100 * @remark Given imsi buffer length must be 16 or more as imsi max length is 15!
101 *
102 * @param imsi preallocated char* which after successful request contains imsi
103 * @param buf_size size of imsi buffer
104 * @return NSAPI_ERROR_OK on success
105 * NSAPI_ERROR_PARAMETER if imsi is null or buf_size is zero or buf_size is smaller than
106 * MAX_IMSI_LENGTH + 1
107 * NSAPI_ERROR_DEVICE_ERROR on other failures
108 */
109 virtual nsapi_error_t get_imsi(char *imsi, size_t buf_size) = 0;
110
111 /** Get serial number from the SIM card
112 *
113 * @param buf SIM ICCID as zero terminated string
114 * @param buf_size max length of SIM ICCID is MAX_ICCID_LENGTH
115 * @return NSAPI_ERROR_OK on success
116 * NSAPI_ERROR_PARAMETER if buf is null or buf_size is zero
117 * NSAPI_ERROR_DEVICE_ERROR on failure
118 */
119 virtual nsapi_error_t get_iccid(char *buf, size_t buf_size) = 0;
120};
121
122/**
123 * @}
124 */
125
126} // namespace mbed
127
128#endif // CELLULAR_INFORMATION_H_
Class CellularDevice.
Class CellularInformation.
virtual ~CellularInformation()
virtual Destructor
virtual nsapi_error_t get_imsi(char *imsi, size_t buf_size)=0
Get IMSI from the sim card.
virtual nsapi_size_or_error_t get_serial_number(char *buf, size_t buf_size, SerialNumberType type=SN)=0
Request serial number identification of cellular device.
virtual nsapi_error_t get_revision(char *buf, size_t buf_size)=0
Request revision identification of cellular device.
virtual nsapi_error_t get_manufacturer(char *buf, size_t buf_size)=0
Request manufacturer identification of cellular device.
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.
signed int nsapi_size_or_error_t
Type used to represent either a size or error passed through sockets.
Definition: nsapi_types.h:153
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:142