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.
ATHandler_stub.cpp
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 #include <ctype.h> 00019 #include "nsapi_types.h" 00020 #include "ATHandler.h" 00021 #include "EventQueue.h" 00022 #include "ATHandler_stub.h" 00023 00024 using namespace mbed; 00025 using namespace events; 00026 00027 #include "CellularLog.h" 00028 00029 const int DEFAULT_AT_TIMEOUT = 1000; // at default timeout in milliseconds 00030 00031 nsapi_error_t ATHandler_stub::nsapi_error_value = 0; 00032 uint8_t ATHandler_stub::nsapi_error_ok_counter = 0; 00033 int ATHandler_stub::int_value = -1; 00034 int ATHandler_stub::ref_count = 0; 00035 int ATHandler_stub::timeout = 0; 00036 bool ATHandler_stub::default_timeout = 0; 00037 bool ATHandler_stub::debug_on = 0; 00038 ssize_t ATHandler_stub::ssize_value = 0; 00039 char* ATHandler_stub::read_string_value = NULL; 00040 size_t ATHandler_stub::size_value = 0; 00041 size_t ATHandler_stub::return_given_size = false; 00042 bool ATHandler_stub::bool_value = false; 00043 uint8_t ATHandler_stub::uint8_value = 0; 00044 FileHandle_stub *ATHandler_stub::fh_value = NULL; 00045 device_err_t ATHandler_stub::device_err_value; 00046 Callback<void()> ATHandler_stub::callback = NULL; 00047 uint8_t ATHandler_stub::resp_info_true_counter = false; 00048 00049 ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char *output_delimiter, uint16_t send_delay) : 00050 _nextATHandler(0), 00051 _fileHandle(fh), 00052 _queue(queue) 00053 { 00054 ATHandler_stub::ref_count = 1; 00055 } 00056 00057 void ATHandler::set_debug(bool debug_on) 00058 { 00059 ATHandler_stub::debug_on = debug_on; 00060 } 00061 00062 ATHandler::~ATHandler() 00063 { 00064 ATHandler_stub::ref_count = -909; 00065 } 00066 00067 void ATHandler::inc_ref_count() 00068 { 00069 ATHandler_stub::ref_count++; 00070 } 00071 00072 void ATHandler::dec_ref_count() 00073 { 00074 ATHandler_stub::ref_count--; 00075 } 00076 00077 int ATHandler::get_ref_count() 00078 { 00079 return ATHandler_stub::ref_count; 00080 } 00081 00082 FileHandle *ATHandler::get_file_handle() 00083 { 00084 return ATHandler_stub::fh_value; 00085 } 00086 00087 void ATHandler::set_file_handle(FileHandle *fh) 00088 { 00089 } 00090 00091 nsapi_error_t ATHandler::set_urc_handler(const char *urc, mbed::Callback<void()> cb) 00092 { 00093 ATHandler_stub::callback = cb; 00094 return NSAPI_ERROR_OK ; 00095 } 00096 00097 void ATHandler::remove_urc_handler(const char *prefix, mbed::Callback<void()> callback) 00098 { 00099 } 00100 00101 nsapi_error_t ATHandler::get_last_error() const 00102 { 00103 if (ATHandler_stub::nsapi_error_ok_counter) { 00104 ATHandler_stub::nsapi_error_ok_counter--; 00105 return NSAPI_ERROR_OK ; 00106 } 00107 return ATHandler_stub::nsapi_error_value; 00108 } 00109 00110 void ATHandler::lock() 00111 { 00112 } 00113 00114 void ATHandler::unlock() 00115 { 00116 } 00117 00118 nsapi_error_t ATHandler::unlock_return_error() 00119 { 00120 return ATHandler_stub::nsapi_error_value; 00121 } 00122 00123 void ATHandler::set_at_timeout(uint32_t timeout_milliseconds, bool default_timeout) 00124 { 00125 ATHandler_stub::timeout = timeout_milliseconds; 00126 ATHandler_stub::default_timeout = default_timeout; 00127 } 00128 00129 void ATHandler::restore_at_timeout() 00130 { 00131 } 00132 00133 void ATHandler::process_oob() 00134 { 00135 } 00136 00137 void ATHandler::clear_error() 00138 { 00139 } 00140 00141 void ATHandler::skip_param(uint32_t count) { 00142 00143 } 00144 00145 void ATHandler::skip_param(ssize_t len, uint32_t count) 00146 { 00147 } 00148 00149 ssize_t ATHandler::read_bytes(uint8_t *buf, size_t len) 00150 { 00151 return ATHandler_stub::ssize_value; 00152 } 00153 00154 ssize_t ATHandler::read_string(char *buf, size_t size, bool read_even_stop_tag) 00155 { 00156 if (ATHandler_stub::read_string_value && ATHandler_stub::ssize_value >= 0) { 00157 memcpy(buf, ATHandler_stub::read_string_value, ATHandler_stub::ssize_value); 00158 } 00159 return ATHandler_stub::ssize_value; 00160 } 00161 00162 int ATHandler::read_int() 00163 { 00164 return ATHandler_stub::int_value; 00165 } 00166 00167 void ATHandler::set_delimiter(char delimiter) 00168 { 00169 } 00170 00171 void ATHandler::set_default_delimiter() 00172 { 00173 } 00174 00175 void ATHandler::set_stop_tag(const char *stop_tag_seq) 00176 { 00177 } 00178 00179 int ATHandler::get_3gpp_error() 00180 { 00181 return ATHandler_stub::int_value; 00182 } 00183 00184 void ATHandler::resp_start(const char *prefix, bool stop) 00185 { 00186 } 00187 00188 bool ATHandler::info_resp() 00189 { 00190 if (ATHandler_stub::resp_info_true_counter) { 00191 ATHandler_stub::resp_info_true_counter--; 00192 return true; 00193 } 00194 return ATHandler_stub::bool_value; 00195 } 00196 00197 bool ATHandler::info_elem(char start_tag) 00198 { 00199 return ATHandler_stub::bool_value; 00200 } 00201 00202 bool ATHandler::consume_to_stop_tag() 00203 { 00204 return ATHandler_stub::bool_value; 00205 } 00206 00207 void ATHandler::resp_stop() 00208 { 00209 } 00210 00211 void ATHandler::cmd_start(const char* cmd) 00212 { 00213 } 00214 00215 void ATHandler::write_int(int param) 00216 { 00217 } 00218 00219 void ATHandler::write_string(const char* param, bool useQuotations) 00220 { 00221 } 00222 00223 size_t ATHandler::write_bytes(const uint8_t* param, size_t len) 00224 { 00225 if (ATHandler_stub::return_given_size) { 00226 return len; 00227 } 00228 return ATHandler_stub::size_value; 00229 } 00230 00231 void ATHandler::cmd_stop() 00232 { 00233 } 00234 00235 device_err_t ATHandler::get_last_device_error() const 00236 { 00237 return ATHandler_stub::device_err_value; 00238 } 00239 00240 void ATHandler::flush() 00241 { 00242 00243 }
Generated on Tue Jul 12 2022 12:43:34 by
1.7.2