WORKS
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
common_stub.cpp
00001 /* 00002 * Copyright (c) 2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #include "common_stub.h" 00017 #include "sn_grs.h" 00018 #include <sys/socket.h> 00019 00020 socket_error_t common_stub::error; 00021 socket_event_t * common_stub::event; 00022 socket_addr * common_stub::addr; 00023 void * common_stub::void_value; 00024 bool common_stub::visited; 00025 bool common_stub::bool_value; 00026 int common_stub::int_value; 00027 int common_stub::int2_value; 00028 addrinfo* common_stub::addrinfo; 00029 uint16_t common_stub::uint_value; 00030 omalw_certificate_list_t *common_stub::cert; 00031 sn_coap_hdr_s *common_stub::coap_header; 00032 sn_nsdl_resource_info_s *common_stub::resource; 00033 pthread_t common_stub::thread; 00034 const char* common_stub::char_value; 00035 00036 using namespace mbed; 00037 using namespace mbed::Sockets::v0; 00038 00039 void common_stub::clear() 00040 { 00041 int_value = -1; 00042 int2_value = -1; 00043 uint_value = 0; 00044 error = SOCKET_ERROR_NONE; 00045 event = NULL; 00046 addr = NULL; 00047 void_value = NULL; 00048 cert = NULL; 00049 visited = false; 00050 bool_value= false; 00051 coap_header = NULL; 00052 resource = NULL; 00053 addrinfo = NULL; 00054 char_value = NULL; 00055 } 00056 00057 UDPSocket::UDPSocket(socket_stack_t stack) :Socket(stack) 00058 { 00059 } 00060 00061 UDPSocket::~UDPSocket() 00062 { 00063 } 00064 00065 socket_error_t UDPSocket::connect(const SocketAddr *, const uint16_t ) 00066 { 00067 return common_stub::error; 00068 } 00069 00070 //SocketAddr 00071 00072 void SocketAddr::setAddr(const struct socket_addr *) 00073 { 00074 } 00075 00076 void SocketAddr::setAddr(const SocketAddr *) 00077 { 00078 } 00079 00080 bool SocketAddr::SocketAddr::is_v4() 00081 { 00082 return common_stub::bool_value; 00083 } 00084 00085 void mbed::Ticker::detach() 00086 { 00087 common_stub::visited = true; 00088 } 00089 00090 00091 // SN_NSDL_LIB 00092 00093 struct nsdl_s *sn_nsdl_init (uint8_t (*sn_nsdl_tx_cb)(struct nsdl_s *, sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *), 00094 uint8_t (*sn_nsdl_rx_cb)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *), 00095 void *(*sn_nsdl_alloc)(uint16_t),void (*sn_nsdl_free)(void *)) 00096 { 00097 return NULL; 00098 } 00099 00100 uint16_t sn_nsdl_register_endpoint(struct nsdl_s *, sn_nsdl_ep_parameters_s *) 00101 { 00102 return common_stub::uint_value; 00103 } 00104 00105 uint16_t sn_nsdl_unregister_endpoint(struct nsdl_s *) 00106 { 00107 return common_stub::uint_value; 00108 } 00109 00110 uint16_t sn_nsdl_update_registration(struct nsdl_s *,uint8_t *, uint8_t) 00111 { 00112 return common_stub::uint_value; 00113 } 00114 00115 uint16_t sn_nsdl_send_observation_notification(struct nsdl_s *, uint8_t *, uint8_t, 00116 uint8_t *, uint16_t, 00117 uint8_t *, uint8_t, 00118 sn_coap_msg_type_e , uint8_t) 00119 { 00120 return common_stub::uint_value; 00121 } 00122 00123 int8_t sn_nsdl_destroy(struct nsdl_s *handle) 00124 { 00125 return common_stub::int_value; 00126 } 00127 00128 sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *, sn_coap_hdr_s *, uint8_t ) 00129 { 00130 return common_stub::coap_header; 00131 } 00132 00133 sn_nsdl_resource_info_s *sn_nsdl_get_resource(struct nsdl_s *, uint16_t, uint8_t *) 00134 { 00135 return common_stub::resource; 00136 } 00137 00138 int8_t sn_nsdl_process_coap(struct nsdl_s *, uint8_t *, uint16_t , sn_nsdl_addr_s *) 00139 { 00140 return common_stub::int_value; 00141 } 00142 00143 int8_t sn_nsdl_exec(struct nsdl_s *, uint32_t) 00144 { 00145 return common_stub::int_value; 00146 } 00147 00148 void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *, sn_coap_hdr_s *header) 00149 { 00150 if(header && header != common_stub::coap_header){ 00151 if( header->content_type_ptr ){ 00152 free(header->content_type_ptr); 00153 header->content_type_ptr = NULL; 00154 } 00155 if( header->options_list_ptr){ 00156 free(header->options_list_ptr); 00157 header->options_list_ptr = NULL; 00158 } 00159 free(header); 00160 header = NULL; 00161 } 00162 } 00163 00164 int8_t sn_nsdl_create_resource(struct nsdl_s *, sn_nsdl_resource_info_s *) 00165 { 00166 return common_stub::int_value; 00167 } 00168 00169 int8_t sn_nsdl_delete_resource(struct nsdl_s *, uint16_t , uint8_t *) 00170 { 00171 return common_stub::int_value; 00172 } 00173 00174 int8_t sn_nsdl_send_coap_message(struct nsdl_s *, sn_nsdl_addr_s *, sn_coap_hdr_s *) 00175 { 00176 return common_stub::int_value; 00177 } 00178 00179 int8_t sn_nsdl_update_resource(struct nsdl_s *, sn_nsdl_resource_info_s *) 00180 { 00181 return common_stub::int_value; 00182 } 00183 00184 int8_t set_NSP_address(struct nsdl_s *, uint8_t *, uint16_t, sn_nsdl_addr_type_e) 00185 { 00186 return common_stub::int_value; 00187 } 00188 00189 uint16_t sn_nsdl_oma_bootstrap(struct nsdl_s *, sn_nsdl_addr_s *, 00190 sn_nsdl_ep_parameters_s *, 00191 sn_nsdl_bs_ep_info_t *) 00192 { 00193 return common_stub::uint_value; 00194 } 00195 00196 omalw_certificate_list_t *sn_nsdl_get_certificates(struct nsdl_s *) 00197 { 00198 return common_stub::cert; 00199 } 00200 00201 int8_t sn_nsdl_update_certificates(struct nsdl_s *, omalw_certificate_list_t*, uint8_t) 00202 { 00203 return common_stub::int_value; 00204 } 00205 00206 int8_t sn_nsdl_create_oma_device_object(struct nsdl_s *, sn_nsdl_oma_device_t *) 00207 { 00208 return common_stub::int_value; 00209 } 00210 00211 //Coap Headers 00212 00213 sn_coap_hdr_s *sn_coap_build_response(struct coap_s *, sn_coap_hdr_s *, uint8_t ) 00214 { 00215 return common_stub::coap_header; 00216 } 00217 00218 void sn_coap_parser_release_allocated_coap_msg_mem(struct coap_s *, sn_coap_hdr_s *) 00219 { 00220 } 00221 00222 int8_t sn_coap_protocol_set_retransmission_parameters(uint8_t, uint8_t) 00223 { 00224 return common_stub::int_value; 00225 } 00226 00227 // IP6String.h 00228 uint_fast8_t ip6tos(const void *, char *) 00229 { 00230 } 00231 00232 //Socket 00233 Socket::Socket(const socket_stack_t ) : _irq(this) 00234 { 00235 _socket.api = NULL; 00236 } 00237 00238 Socket::~Socket() 00239 { 00240 } 00241 00242 socket_error_t Socket::open(const socket_address_family_t , const socket_proto_family_t ) 00243 { 00244 return common_stub::error; 00245 } 00246 00247 bool Socket::error_check(socket_error_t ) 00248 { 00249 return common_stub::bool_value; 00250 } 00251 00252 void Socket::_eventHandler(struct socket_event *) 00253 { 00254 } 00255 00256 void Socket::setOnError(const ErrorHandler_t &) 00257 { 00258 } 00259 00260 void Socket::setOnReadable(const ReadableHandler_t &) 00261 { 00262 } 00263 00264 void Socket::setOnSent(const SentHandler_t & ) 00265 { 00266 } 00267 00268 void Socket::_nvEventHandler(void * ) 00269 { 00270 } 00271 00272 socket_error_t Socket::getLocalAddr(SocketAddr *) const 00273 { 00274 return common_stub::error; 00275 } 00276 00277 socket_error_t Socket::getLocalPort(uint16_t *) const 00278 { 00279 return common_stub::error; 00280 } 00281 00282 socket_error_t Socket::getRemoteAddr(SocketAddr *) const 00283 { 00284 return common_stub::error; 00285 } 00286 00287 socket_error_t Socket::getRemotePort(uint16_t *) const 00288 { 00289 return common_stub::error; 00290 } 00291 00292 socket_error_t Socket::resolve(const char* , const DNSHandler_t & ) 00293 { 00294 return common_stub::error; 00295 } 00296 00297 socket_error_t Socket::bind(const char * , const uint16_t ) 00298 { 00299 return common_stub::error; 00300 } 00301 socket_error_t Socket::bind(const SocketAddr * , const uint16_t ) 00302 { 00303 return common_stub::error; 00304 } 00305 00306 socket_error_t Socket::close() 00307 { 00308 return common_stub::error; 00309 } 00310 00311 socket_error_t Socket::recv(void * , size_t *) 00312 { 00313 return common_stub::error; 00314 } 00315 socket_error_t Socket::recv_from(void * , size_t *, SocketAddr *, uint16_t *) 00316 { 00317 return common_stub::error; 00318 } 00319 00320 socket_error_t Socket::send(const void * , const size_t ) 00321 { 00322 return common_stub::error; 00323 } 00324 socket_error_t Socket::send_to(const void * , const size_t , const SocketAddr *, uint16_t ) 00325 { 00326 return common_stub::error; 00327 } 00328 00329 bool Socket::isConnected() const { 00330 return common_stub::error; 00331 } 00332 00333 // pthread 00334 int pthread_equal (pthread_t , pthread_t ) __THROW 00335 { 00336 return common_stub::int2_value; 00337 } 00338 00339 pthread_t pthread_self (void) __THROW 00340 { 00341 return common_stub::thread; 00342 } 00343 00344 int pthread_detach (pthread_t) __THROW 00345 { 00346 return common_stub::int_value; 00347 } 00348 00349 int pthread_create (pthread_t * , 00350 const pthread_attr_t *, 00351 void *(*__start_routine) (void *), 00352 void *) __THROWNL 00353 { 00354 __start_routine(NULL); 00355 return common_stub::int_value; 00356 } 00357 00358 int pthread_cancel (pthread_t) 00359 { 00360 return common_stub::int_value; 00361 } 00362 00363 int pthread_join (pthread_t , void **) 00364 { 00365 return common_stub::int_value; 00366 } 00367 00368 void pthread_exit (void *__retval)/* __attribute__ ((__noreturn__))*/ 00369 { 00370 00371 } 00372 00373 // sys/socket 00374 #ifndef __SOCKADDR_ARG 00375 # define __SOCKADDR_ARG struct sockaddr *__restrict 00376 #endif 00377 00378 #ifndef __CONST_SOCKADDR_ARG 00379 # define __CONST_SOCKADDR_ARG const struct sockaddr * 00380 #endif 00381 00382 #ifndef __socklen_t_defined 00383 typedef __socklen_t socklen_t; 00384 # define __socklen_t_defined 00385 #endif 00386 00387 int bind (int , __CONST_SOCKADDR_ARG , socklen_t ) 00388 __THROW 00389 { 00390 return common_stub::int_value; 00391 } 00392 00393 ssize_t sendto (int , const void *, size_t , 00394 int , __CONST_SOCKADDR_ARG , 00395 socklen_t ) 00396 { 00397 return common_stub::int_value; 00398 } 00399 00400 ssize_t recvfrom (int , void * , size_t , 00401 int , __SOCKADDR_ARG , 00402 socklen_t * ) 00403 { 00404 return common_stub::int_value; 00405 } 00406 00407 int getaddrinfo (const char *__restrict, 00408 const char *__restrict, 00409 const struct addrinfo *__restrict, 00410 struct addrinfo **__restrict addr) 00411 { 00412 //*addr = (addrinfo*)malloc(sizeof(addrinfo)); 00413 //(*addr)->ai_addr = (sockaddr*)malloc(sizeof(sockaddr)); 00414 *addr = common_stub::addrinfo; 00415 return common_stub::int_value; 00416 } 00417 00418 void freeaddrinfo (struct addrinfo * addr) 00419 __THROW 00420 { 00421 // free(addr->ai_addr); 00422 // free(addr); 00423 } 00424 00425 const char *inet_ntop (int, const void *__restrict, 00426 char *__restrict, socklen_t) 00427 __THROW 00428 { 00429 return common_stub::char_value; 00430 } 00431 00432 int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len) 00433 { 00434 return common_stub::int_value; 00435 } 00436
Generated on Tue Jul 12 2022 12:28:28 by
1.7.2
