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.
Dependents: SpwfInterface_NSAPI_Tests HelloWorld_IDW01M1
Fork of X_NUCLEO_IDW01M1 by
ItfTranslator.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may 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, 00012 * WITHOUT 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 00017 /** 00018 ****************************************************************************** 00019 * @file ItfTranslator.cpp 00020 * @author STMicroelectronics 00021 * @brief Wrapper Functions for access to SPWFSADevice class/vice-versa 00022 ****************************************************************************** 00023 * @copy 00024 * 00025 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00026 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 00027 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 00028 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 00029 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 00030 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00031 * 00032 * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2> 00033 ****************************************************************************** 00034 */ 00035 00036 #include "SpwfSADevice.h" 00037 #include "ItfTranslator.h" 00038 00039 SpwfSADevice * device; 00040 00041 void setSpwfSADevice(SpwfSADevice * dev); 00042 00043 void setSpwfSADevice(SpwfSADevice * dev) 00044 { 00045 device = dev; 00046 } 00047 00048 #ifdef __cplusplus 00049 extern "C" { 00050 #endif 00051 00052 /** 00053 * @brief Wrapper function to CPP 00054 * Calls SpwfSADevice init 00055 * @param void* not used 00056 * @retval None 00057 */ 00058 void callSpwfSADevice_init(void* object) 00059 { 00060 //static_cast<SpwfSADevice*>(object)->init(); 00061 device->init(); 00062 return; 00063 } 00064 00065 /** 00066 * @brief Wrapper function to CPP 00067 * Calls SpwfSADevice getChar 00068 * @param void* not used 00069 * @retval None 00070 */ 00071 char callSpwfSADevice_getChar(void* object) 00072 { 00073 return(device->spwf_get()); 00074 } 00075 00076 /** 00077 * @brief Wrapper function to CPP 00078 * Calls SpwfSADevice write 00079 * @param void* not used 00080 * cmd: data to write 00081 * size: size of data 00082 * @retval None 00083 */ 00084 int callSpwfSADevice_write(void* object, const char * cmd, uint16_t size) 00085 { 00086 return (device->spwf_send(cmd, size)); 00087 } 00088 00089 /** 00090 * @brief Wrapper function to CPP 00091 * Calls SpwfSADevice wakeup 00092 * @param void* not used 00093 * wake: (re)set wakeup pin value 00094 * @retval None 00095 */ 00096 void callSpwfSADevice_wakeup(void* object, int wake) 00097 { 00098 device->spwf_wakeup(wake); 00099 } 00100 00101 /** 00102 * @brief Wrapper function to CPP 00103 * Calls SpwfSADevice reset 00104 * @param void* not used 00105 * reset: (re)set reset pin value 00106 * @retval None 00107 */ 00108 void callSpwfSADevice_reset(void* object, int reset) 00109 { 00110 device->spwf_reset(reset); 00111 } 00112 00113 /** 00114 * @brief Wrapper function to CPP 00115 * Calls SpwfSADevice read_rts 00116 * @param void* not used 00117 * rts: (re)set RTS pin value 00118 * @retval None 00119 */ 00120 void callSpwfSADevice_rts(void* object, int rts) 00121 { 00122 device->spwf_rts(rts); 00123 } 00124 00125 /** 00126 * @brief Wrapper function to CPP 00127 * Calls SpwfSADevice read_rts 00128 * @param void* not used 00129 * @retval RTS value 00130 */ 00131 int callSpwfSADevice_read_rts(void* object) 00132 { 00133 return(device->spwf_read_rts()); 00134 } 00135 00136 /** 00137 * @brief Wrapper function to CPP 00138 * Calls SpwfSADevice attach 00139 * @param attach boolean 00140 * @retval None 00141 */ 00142 void callSpwfSADevice_attach(wifi_bool attach) 00143 { 00144 device->spwf_attach_irq(attach); 00145 } 00146 00147 /** 00148 * @brief Wrapper function to CPP 00149 * Calls SpwfSADevice debug 00150 * @param void* not used 00151 * string: data string to debug print 00152 * @retval None 00153 */ 00154 void callSpwfSADevice_debug(void* object, const char * string) 00155 { 00156 device->debug_print(string); 00157 } 00158 00159 /** 00160 * @brief Wrapper function to CPP 00161 * not used 00162 * @param void* not used 00163 * @retval None 00164 */ 00165 void destroySpwfSADevice() 00166 { 00167 00168 } 00169 00170 /*Callbacks implementation*/ 00171 00172 void ind_wifi_on() 00173 { 00174 device->signal_synch_wait(WiFi_MODULE_SUCCESS); 00175 } 00176 00177 void ind_wifi_connected() 00178 { 00179 device->signal_synch_wait(WiFi_MODULE_SUCCESS); 00180 } 00181 00182 void ind_wifi_connection_error(WiFi_Status_t code) 00183 { 00184 switch(code) 00185 { 00186 case WiFi_DISASSOCIATION: 00187 device->signal_synch_wait(code); 00188 break; 00189 case WiFi_DE_AUTH: 00190 break; 00191 default: 00192 break; 00193 } 00194 } 00195 00196 void ind_wifi_socket_data_received(uint8_t socket_id, uint8_t * data_ptr, uint32_t message_size, uint32_t chunk_size) 00197 { 00198 device->signal_data_receive(socket_id, data_ptr, message_size, chunk_size); 00199 } 00200 00201 void ind_wifi_http_data_available(uint8_t * data_ptr, uint32_t message_size) 00202 { 00203 //spwf->debug("\r\nrx>>\r\n"); 00204 //memcpy(user_buffer, data_ptr, 511); 00205 } 00206 00207 void ind_wifi_socket_client_remote_server_closed(uint8_t * socket_closed_id) 00208 { 00209 //device->debug_print("\r\nsocket closed!\r\n"); 00210 //device->signal_synch_wait(WiFi_MODULE_SUCCESS); 00211 } 00212 00213 void ind_socket_server_client_joined(void) 00214 { 00215 //device->debug_print("\r\nclient connected!\r\n"); 00216 device->set_wait_for_incoming_client(true); 00217 } 00218 00219 void ind_socket_server_client_left(void) 00220 { 00221 00222 } 00223 00224 void ind_wifi_socket_server_data_lost(void) 00225 { 00226 00227 } 00228 00229 #ifdef __cplusplus 00230 } 00231 #endif 00232 00233 00234
Generated on Tue Jul 12 2022 16:20:36 by
1.7.2

X-NUCLEO-IDW01M1 Wi-Fi expansion board