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.
AT_CellularNetwork.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 AT_CELLULAR_NETWORK_H_ 00019 #define AT_CELLULAR_NETWORK_H_ 00020 00021 #include "CellularNetwork.h" 00022 #include "AT_CellularBase.h" 00023 #include "NetworkStack.h" 00024 00025 namespace mbed { 00026 00027 #define AT_NETWORK_TRIALS 5 00028 00029 /** 00030 * Class AT_CellularNetwork 00031 * 00032 * Class for connecting to a network and getting information from it. 00033 */ 00034 class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase 00035 { 00036 00037 public: 00038 00039 AT_CellularNetwork(ATHandler &atHandler); 00040 virtual ~AT_CellularNetwork(); 00041 // declare friend so it can access stack 00042 friend class AT_CellularDevice; 00043 00044 public: // NetworkInterface 00045 00046 virtual nsapi_error_t set_credentials(const char *apn, 00047 const char *username = 0, const char *password = 0); 00048 00049 virtual nsapi_error_t set_credentials(const char *apn, AuthenticationType type, 00050 const char *username = 0, const char *password = 0); 00051 00052 virtual nsapi_error_t connect(const char *apn, 00053 const char *username = 0, const char *password = 0); 00054 00055 virtual nsapi_error_t connect(); 00056 00057 virtual nsapi_error_t disconnect(); 00058 00059 protected: 00060 virtual NetworkStack *get_stack(); 00061 00062 public: // CellularNetwork 00063 virtual nsapi_error_t init(); 00064 00065 virtual nsapi_error_t activate_context(); 00066 00067 virtual nsapi_error_t set_registration(const char *plmn = 0); 00068 00069 virtual nsapi_error_t get_network_registering_mode(NWRegisteringMode& mode); 00070 00071 virtual nsapi_error_t get_registration_status(RegistrationType type, RegistrationStatus &status); 00072 00073 virtual nsapi_error_t set_attach(int timeout = 10*1000); 00074 00075 virtual nsapi_error_t get_attach(AttachStatus &status); 00076 00077 virtual nsapi_error_t detach(); 00078 00079 virtual nsapi_error_t get_rate_control(CellularNetwork::RateControlExceptionReports &reports, 00080 CellularNetwork::RateControlUplinkTimeUnit &time_unit, int &uplink_rate); 00081 00082 virtual nsapi_error_t get_apn_backoff_timer(int &backoff_timer); 00083 00084 virtual void attach(Callback<void(nsapi_event_t, intptr_t)> status_cb); 00085 00086 virtual nsapi_connection_status_t get_connection_status() const; 00087 00088 virtual nsapi_error_t set_blocking(bool blocking); 00089 00090 virtual const char *get_ip_address(); 00091 00092 virtual nsapi_error_t set_access_technology(RadioAccessTechnology rat); 00093 virtual nsapi_error_t get_access_technology(RadioAccessTechnology& rat); 00094 00095 virtual nsapi_error_t scan_plmn(operList_t &operators, int &ops_count); 00096 00097 virtual nsapi_error_t set_ciot_optimization_config(Supported_UE_Opt supported_opt, 00098 Preferred_UE_Opt preferred_opt); 00099 00100 virtual nsapi_error_t get_ciot_optimization_config(Supported_UE_Opt& supported_opt, 00101 Preferred_UE_Opt& preferred_opt); 00102 00103 virtual nsapi_error_t set_stack_type(nsapi_ip_stack_t stack_type); 00104 00105 virtual nsapi_ip_stack_t get_stack_type(); 00106 00107 virtual nsapi_error_t get_pdpcontext_params(pdpContextList_t& params_list); 00108 00109 virtual nsapi_error_t get_extended_signal_quality(int &rxlev, int &ber, int &rscp, int &ecno, int &rsrq, int &rsrp); 00110 00111 virtual nsapi_error_t get_signal_quality(int &rssi, int &ber); 00112 00113 virtual nsapi_error_t get_cell_id(int &cell_id); 00114 00115 virtual int get_3gpp_error(); 00116 00117 virtual nsapi_error_t get_operator_params(int &format, operator_t &operator_params); 00118 00119 virtual nsapi_error_t set_registration_urc(RegistrationType type, bool on); 00120 00121 virtual nsapi_error_t get_operator_names(operator_names_list &op_names); 00122 protected: 00123 00124 /** Check if modem supports the given stack type. 00125 * 00126 * @return true if supported 00127 */ 00128 virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack); 00129 00130 /** Check if modem supports given registration type. 00131 * 00132 * @param reg_type enum RegistrationType 00133 * @return true if given registration type is supported by modem 00134 */ 00135 virtual bool has_registration(RegistrationType reg_type); 00136 00137 /** Sets access technology to be scanned. Modem specific implementation. 00138 * 00139 * @param op_rat Access technology 00140 * 00141 * @return zero on success 00142 */ 00143 virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat); 00144 00145 private: 00146 // "NO CARRIER" urc 00147 void urc_no_carrier(); 00148 void urc_creg(); 00149 void urc_cereg(); 00150 void urc_cgreg(); 00151 00152 nsapi_error_t set_context_to_be_activated(); 00153 nsapi_ip_stack_t string_to_stack_type(const char* pdp_type); 00154 00155 void free_credentials(); 00156 00157 nsapi_error_t open_data_channel(); 00158 bool get_context(); 00159 bool set_new_context(int cid); 00160 00161 nsapi_error_t delete_current_context(); 00162 00163 void read_reg_params_and_compare(RegistrationType type); 00164 void read_reg_params(RegistrationType type, RegistrationStatus ®_status, int &lac, int &cell_id, int &act); 00165 00166 #if NSAPI_PPP_AVAILABLE 00167 void ppp_status_cb(nsapi_event_t, intptr_t); 00168 #endif 00169 00170 protected: 00171 NetworkStack *_stack; 00172 char *_apn; 00173 char *_uname; 00174 char *_pwd; 00175 nsapi_ip_stack_t _ip_stack_type_requested; 00176 nsapi_ip_stack_t _ip_stack_type; 00177 int _cid; 00178 Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb; 00179 RadioAccessTechnology _op_act; 00180 AuthenticationType _authentication_type; 00181 int _cell_id; 00182 nsapi_connection_status_t _connect_status; 00183 bool _new_context_set; 00184 bool _is_context_active; 00185 RegistrationStatus _reg_status; 00186 RadioAccessTechnology _current_act; 00187 mbed::Callback<void()> _urc_funcs[C_MAX]; 00188 }; 00189 00190 } // namespace mbed 00191 00192 #endif // AT_CELLULAR_NETWORK_H_
Generated on Tue Jul 12 2022 18:18:27 by
