Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
CellularSIM.h
00001 /* 00002 * Copyright (c) 2017, 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_SIM_H_ 00019 #define CELLULAR_SIM_H_ 00020 00021 #include <stddef.h> 00022 00023 #include "nsapi_types.h" 00024 00025 namespace mbed { 00026 00027 const int MAX_SIM_READY_WAITING_TIME = 30; 00028 const int MAX_IMSI_LENGTH = 15; 00029 const int MAX_ICCID_LENGTH = 20 + 1; // +1 for zero termination 00030 /** 00031 * Class CellularSIM 00032 * 00033 * An abstract interface for SIM card handling. 00034 */ 00035 class CellularSIM { 00036 protected: 00037 // friend of CellularDevice so that it's the only way to close/delete this class. 00038 friend class CellularDevice; 00039 00040 /** 00041 * virtual Destructor 00042 */ 00043 virtual ~CellularSIM() {}; 00044 00045 public: 00046 /* enumeration for possible SIM states */ 00047 enum SimState { 00048 SimStateReady = 0, 00049 SimStatePinNeeded, 00050 SimStatePukNeeded, 00051 SimStateUnknown 00052 }; 00053 00054 /** Open the SIM card by setting the pin code for SIM. 00055 * 00056 * @param sim_pin PIN for the SIM card 00057 * @return zero on success 00058 */ 00059 virtual nsapi_error_t set_pin(const char *sim_pin) = 0; 00060 00061 /** Change sim pin code. 00062 * 00063 * @param sim_pin Current PIN for sim 00064 * @param new_pin New PIN for sim 00065 * @return zero on success 00066 */ 00067 virtual nsapi_error_t change_pin(const char *sim_pin, const char *new_pin) = 0; 00068 00069 /** Change is pin query needed after boot 00070 * 00071 * @param sim_pin Valid PIN for SIM card 00072 * @param query_pin False is PIN query not needed, True if PIN query needed after boot. 00073 * @return zero on success 00074 */ 00075 virtual nsapi_error_t set_pin_query(const char *sim_pin, bool query_pin) = 0; 00076 00077 /** Get sim card's state 00078 * 00079 * @param state current state of SIM 00080 * @return zero on success 00081 */ 00082 virtual nsapi_error_t get_sim_state(SimState &state) = 0; 00083 00084 /** Get IMSI from the sim card 00085 * @remark Given imsi buffer length must be 16 or more as imsi max length is 15! 00086 * 00087 * @param imsi preallocated char* which after successful request contains imsi 00088 * @return zero on success 00089 */ 00090 virtual nsapi_error_t get_imsi(char *imsi) = 0; 00091 00092 /** Get serial number from the SIM card 00093 * 00094 * @param buf SIM ICCID as zero terminated string 00095 * @param buf_size max length of SIM ICCID is MAX_ICCID_LENGTH 00096 * @return zero on success, on failure negative error code 00097 */ 00098 virtual nsapi_error_t get_iccid(char *buf, size_t buf_size) = 0; 00099 }; 00100 00101 } // namespace mbed 00102 00103 #endif // CELLULAR_SIM_H_
Generated on Tue Jul 12 2022 12:43:38 by
