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 get_rate_control(CellularNetwork::RateControlExceptionReports &reports, 00078 CellularNetwork::RateControlUplinkTimeUnit &time_unit, int &uplink_rate); 00079 00080 virtual nsapi_error_t get_apn_backoff_timer(int &backoff_timer); 00081 00082 virtual void attach(Callback<void(nsapi_event_t, intptr_t)> status_cb); 00083 00084 virtual nsapi_connection_status_t get_connection_status() const; 00085 00086 virtual nsapi_error_t set_blocking(bool blocking); 00087 00088 virtual const char *get_ip_address(); 00089 00090 virtual nsapi_error_t set_access_technology(RadioAccessTechnology rat); 00091 virtual nsapi_error_t get_access_technology(RadioAccessTechnology& rat); 00092 00093 virtual nsapi_error_t scan_plmn(operList_t &operators, int &ops_count); 00094 00095 virtual nsapi_error_t set_ciot_optimization_config(Supported_UE_Opt supported_opt, 00096 Preferred_UE_Opt preferred_opt); 00097 00098 virtual nsapi_error_t get_ciot_optimization_config(Supported_UE_Opt& supported_opt, 00099 Preferred_UE_Opt& preferred_opt); 00100 00101 virtual nsapi_error_t set_stack_type(nsapi_ip_stack_t stack_type); 00102 00103 virtual nsapi_ip_stack_t get_stack_type(); 00104 00105 virtual nsapi_error_t get_pdpcontext_params(pdpContextList_t& params_list); 00106 00107 virtual nsapi_error_t get_extended_signal_quality(int &rxlev, int &ber, int &rscp, int &ecno, int &rsrq, int &rsrp); 00108 00109 virtual nsapi_error_t get_signal_quality(int &rssi, int &ber); 00110 00111 virtual nsapi_error_t get_cell_id(int &cell_id); 00112 00113 virtual int get_3gpp_error(); 00114 00115 virtual nsapi_error_t get_operator_params(int &format, operator_t &operator_params); 00116 00117 virtual nsapi_error_t set_registration_urc(RegistrationType type, bool on); 00118 00119 protected: 00120 00121 /** Check if modem supports the given stack type. 00122 * 00123 * @return true if supported 00124 */ 00125 virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack); 00126 00127 /** Check if modem supports given registration type. 00128 * 00129 * @param reg_type enum RegistrationType 00130 * @return true if given registration type is supported by modem 00131 */ 00132 virtual bool has_registration(RegistrationType reg_type); 00133 00134 /** Sets access technology to be scanned. Modem specific implementation. 00135 * 00136 * @param op_rat Access technology 00137 * 00138 * @return zero on success 00139 */ 00140 virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat); 00141 00142 private: 00143 // "NO CARRIER" urc 00144 void urc_no_carrier(); 00145 void urc_creg(); 00146 void urc_cereg(); 00147 void urc_cgreg(); 00148 00149 nsapi_error_t set_context_to_be_activated(); 00150 nsapi_ip_stack_t string_to_stack_type(const char* pdp_type); 00151 00152 void free_credentials(); 00153 00154 nsapi_error_t open_data_channel(); 00155 bool get_context(); 00156 bool set_new_context(int cid); 00157 00158 nsapi_error_t delete_current_context(); 00159 00160 void read_reg_params_and_compare(RegistrationType type); 00161 void read_reg_params(RegistrationType type, RegistrationStatus ®_status, int &lac, int &cell_id, int &act); 00162 00163 #if NSAPI_PPP_AVAILABLE 00164 void ppp_status_cb(nsapi_event_t, intptr_t); 00165 #endif 00166 00167 protected: 00168 NetworkStack *_stack; 00169 char *_apn; 00170 char *_uname; 00171 char *_pwd; 00172 nsapi_ip_stack_t _ip_stack_type_requested; 00173 nsapi_ip_stack_t _ip_stack_type; 00174 int _cid; 00175 Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb; 00176 RadioAccessTechnology _op_act; 00177 AuthenticationType _authentication_type; 00178 int _cell_id; 00179 nsapi_connection_status_t _connect_status; 00180 bool _new_context_set; 00181 bool _is_context_active; 00182 RegistrationStatus _reg_status; 00183 RadioAccessTechnology _current_act; 00184 mbed::Callback<void()> _urc_funcs[C_MAX]; 00185 }; 00186 00187 } // namespace mbed 00188 00189 #endif // AT_CELLULAR_NETWORK_H_
Generated on Tue Jul 12 2022 15:17:16 by
1.7.2