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.
Fork of X_NUCLEO_IDW01M1 by
Spwf_API/utils/ItfTranslator.cpp@6:e7a3fca2df10, 2016-05-09 (annotated)
- Committer:
- mridup
- Date:
- Mon May 09 10:38:22 2016 +0000
- Revision:
- 6:e7a3fca2df10
- Parent:
- 5:c83ffd44f40a
- Child:
- 8:0f302a13e21b
Socket Server support.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mridup | 1:bd9db471d47d | 1 | /* mbed Microcontroller Library |
| mridup | 1:bd9db471d47d | 2 | * Copyright (c) 2006-2013 ARM Limited |
| mridup | 1:bd9db471d47d | 3 | * |
| mridup | 1:bd9db471d47d | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| mridup | 1:bd9db471d47d | 5 | * you may not use this file except in compliance with the License. |
| mridup | 1:bd9db471d47d | 6 | * You may obtain a copy of the License at |
| mridup | 1:bd9db471d47d | 7 | * |
| mridup | 1:bd9db471d47d | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| mridup | 1:bd9db471d47d | 9 | * |
| mridup | 1:bd9db471d47d | 10 | * Unless required by applicable law or agreed to in writing, software |
| mridup | 1:bd9db471d47d | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| mridup | 1:bd9db471d47d | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| mridup | 1:bd9db471d47d | 13 | * See the License for the specific language governing permissions and |
| mridup | 1:bd9db471d47d | 14 | * limitations under the License. |
| mridup | 1:bd9db471d47d | 15 | */ |
| mridup | 1:bd9db471d47d | 16 | |
| mridup | 1:bd9db471d47d | 17 | /** |
| mridup | 1:bd9db471d47d | 18 | ****************************************************************************** |
| mridup | 1:bd9db471d47d | 19 | * @file ItfTranslator.cpp |
| mridup | 1:bd9db471d47d | 20 | * @author STMicroelectronics |
| mridup | 1:bd9db471d47d | 21 | * @brief Wrapper Functions for access to SPWFSADevice class/vice-versa |
| mridup | 1:bd9db471d47d | 22 | ****************************************************************************** |
| mridup | 1:bd9db471d47d | 23 | * @copy |
| mridup | 1:bd9db471d47d | 24 | * |
| mridup | 1:bd9db471d47d | 25 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
| mridup | 1:bd9db471d47d | 26 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
| mridup | 1:bd9db471d47d | 27 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY |
| mridup | 1:bd9db471d47d | 28 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
| mridup | 1:bd9db471d47d | 29 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
| mridup | 1:bd9db471d47d | 30 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
| mridup | 1:bd9db471d47d | 31 | * |
| mridup | 1:bd9db471d47d | 32 | * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2> |
| mridup | 1:bd9db471d47d | 33 | ****************************************************************************** |
| mridup | 1:bd9db471d47d | 34 | */ |
| mridup | 1:bd9db471d47d | 35 | |
| mridup | 1:bd9db471d47d | 36 | #include "SpwfSADevice.h" |
| mridup | 1:bd9db471d47d | 37 | #include "ItfTranslator.h" |
| mridup | 1:bd9db471d47d | 38 | |
| mridup | 1:bd9db471d47d | 39 | SpwfSADevice * device; |
| mridup | 1:bd9db471d47d | 40 | |
| mridup | 1:bd9db471d47d | 41 | void setSpwfSADevice(SpwfSADevice * dev); |
| mridup | 1:bd9db471d47d | 42 | |
| mridup | 1:bd9db471d47d | 43 | void setSpwfSADevice(SpwfSADevice * dev) |
| mridup | 1:bd9db471d47d | 44 | { |
| mridup | 1:bd9db471d47d | 45 | device = dev; |
| mridup | 1:bd9db471d47d | 46 | } |
| mridup | 1:bd9db471d47d | 47 | |
| mridup | 1:bd9db471d47d | 48 | #ifdef __cplusplus |
| mridup | 1:bd9db471d47d | 49 | extern "C" { |
| mridup | 1:bd9db471d47d | 50 | #endif |
| mridup | 1:bd9db471d47d | 51 | |
| mridup | 1:bd9db471d47d | 52 | void callSpwfSADevice_init(void* object) |
| mridup | 1:bd9db471d47d | 53 | { |
| mridup | 1:bd9db471d47d | 54 | //static_cast<SpwfSADevice*>(object)->init(); |
| mridup | 1:bd9db471d47d | 55 | device->init(); |
| mridup | 1:bd9db471d47d | 56 | return; |
| mridup | 1:bd9db471d47d | 57 | } |
| mridup | 1:bd9db471d47d | 58 | |
| mridup | 1:bd9db471d47d | 59 | char callSpwfSADevice_getChar(void* object) |
| mridup | 1:bd9db471d47d | 60 | { |
| mridup | 1:bd9db471d47d | 61 | return(device->spwf_get()); |
| mridup | 1:bd9db471d47d | 62 | } |
| mridup | 1:bd9db471d47d | 63 | |
| mridup | 1:bd9db471d47d | 64 | void callSpwfSADevice_write(void* object, const char * cmd, uint16_t size) |
| mridup | 1:bd9db471d47d | 65 | { |
| mridup | 1:bd9db471d47d | 66 | device->spwf_send(cmd, size); |
| mridup | 1:bd9db471d47d | 67 | } |
| mridup | 1:bd9db471d47d | 68 | |
| mridup | 1:bd9db471d47d | 69 | void callSpwfSADevice_wakeup(void* object, int wake) |
| mridup | 1:bd9db471d47d | 70 | { |
| mridup | 1:bd9db471d47d | 71 | device->spwf_wakeup(wake); |
| mridup | 1:bd9db471d47d | 72 | } |
| mridup | 1:bd9db471d47d | 73 | |
| mridup | 1:bd9db471d47d | 74 | void callSpwfSADevice_reset(void* object, int reset) |
| mridup | 1:bd9db471d47d | 75 | { |
| mridup | 1:bd9db471d47d | 76 | device->spwf_reset(reset); |
| mridup | 1:bd9db471d47d | 77 | } |
| mridup | 1:bd9db471d47d | 78 | |
| mridup | 1:bd9db471d47d | 79 | void callSpwfSADevice_rts(void* object, int rts) |
| mridup | 1:bd9db471d47d | 80 | { |
| mridup | 1:bd9db471d47d | 81 | device->spwf_rts(rts); |
| mridup | 1:bd9db471d47d | 82 | } |
| mridup | 1:bd9db471d47d | 83 | |
| mridup | 1:bd9db471d47d | 84 | int callSpwfSADevice_read_rts(void* object) |
| mridup | 1:bd9db471d47d | 85 | { |
| mridup | 1:bd9db471d47d | 86 | return(device->spwf_read_rts()); |
| mridup | 1:bd9db471d47d | 87 | } |
| mridup | 1:bd9db471d47d | 88 | |
| mridup | 1:bd9db471d47d | 89 | void callSpwfSADevice_attach(wifi_bool attach) |
| mridup | 1:bd9db471d47d | 90 | { |
| mridup | 1:bd9db471d47d | 91 | device->spwf_attach_irq(attach); |
| mridup | 1:bd9db471d47d | 92 | } |
| mridup | 1:bd9db471d47d | 93 | |
| mridup | 1:bd9db471d47d | 94 | void callSpwfSADevice_debug(void* object, const char * string) |
| mridup | 1:bd9db471d47d | 95 | { |
| mridup | 1:bd9db471d47d | 96 | device->debug_print(string); |
| mridup | 1:bd9db471d47d | 97 | } |
| mridup | 1:bd9db471d47d | 98 | |
| mridup | 1:bd9db471d47d | 99 | void destroySpwfSADevice() |
| mridup | 1:bd9db471d47d | 100 | { |
| mridup | 1:bd9db471d47d | 101 | |
| mridup | 1:bd9db471d47d | 102 | } |
| mridup | 1:bd9db471d47d | 103 | |
| mridup | 1:bd9db471d47d | 104 | /*Callbacks implementation*/ |
| mridup | 1:bd9db471d47d | 105 | |
| mridup | 1:bd9db471d47d | 106 | void ind_wifi_on() |
| mridup | 1:bd9db471d47d | 107 | { |
| mridup | 1:bd9db471d47d | 108 | device->signal_synch_wait(WiFi_MODULE_SUCCESS); |
| mridup | 1:bd9db471d47d | 109 | } |
| mridup | 1:bd9db471d47d | 110 | |
| mridup | 1:bd9db471d47d | 111 | void ind_wifi_connected() |
| mridup | 1:bd9db471d47d | 112 | { |
| mridup | 1:bd9db471d47d | 113 | device->signal_synch_wait(WiFi_MODULE_SUCCESS); |
| mridup | 1:bd9db471d47d | 114 | } |
| mridup | 1:bd9db471d47d | 115 | |
| mridup | 1:bd9db471d47d | 116 | void ind_wifi_connection_error(WiFi_Status_t code) |
| mridup | 1:bd9db471d47d | 117 | { |
| mridup | 1:bd9db471d47d | 118 | switch(code) |
| mridup | 1:bd9db471d47d | 119 | { |
| mridup | 1:bd9db471d47d | 120 | case WiFi_DISASSOCIATION: |
| mridup | 1:bd9db471d47d | 121 | device->signal_synch_wait(code); |
| mridup | 1:bd9db471d47d | 122 | break; |
| mridup | 1:bd9db471d47d | 123 | case WiFi_DE_AUTH: |
| mridup | 1:bd9db471d47d | 124 | break; |
| mridup | 1:bd9db471d47d | 125 | default: |
| mridup | 1:bd9db471d47d | 126 | break; |
| mridup | 1:bd9db471d47d | 127 | } |
| mridup | 1:bd9db471d47d | 128 | } |
| mridup | 1:bd9db471d47d | 129 | |
| mridup | 1:bd9db471d47d | 130 | void ind_wifi_socket_data_received(uint8_t socket_id, uint8_t * data_ptr, uint32_t message_size, uint32_t chunk_size) |
| mridup | 1:bd9db471d47d | 131 | { |
| mridup | 1:bd9db471d47d | 132 | device->signal_data_receive(socket_id, data_ptr, message_size, chunk_size); |
| mridup | 1:bd9db471d47d | 133 | } |
| mridup | 1:bd9db471d47d | 134 | |
| mridup | 1:bd9db471d47d | 135 | void ind_wifi_http_data_available(uint8_t * data_ptr, uint32_t message_size) |
| mridup | 1:bd9db471d47d | 136 | { |
| mridup | 6:e7a3fca2df10 | 137 | //spwf->debug("\r\nrx>>\r\n"); |
| mridup | 6:e7a3fca2df10 | 138 | //memcpy(user_buffer, data_ptr, 511); |
| mridup | 1:bd9db471d47d | 139 | } |
| mridup | 1:bd9db471d47d | 140 | |
| mridup | 1:bd9db471d47d | 141 | void ind_wifi_socket_client_remote_server_closed(uint8_t * socket_closed_id) |
| mridup | 1:bd9db471d47d | 142 | { |
| mridup | 5:c83ffd44f40a | 143 | //device->debug_print("\r\nsocket closed!\r\n"); |
| mridup | 5:c83ffd44f40a | 144 | //device->signal_synch_wait(WiFi_MODULE_SUCCESS); |
| mridup | 1:bd9db471d47d | 145 | } |
| mridup | 1:bd9db471d47d | 146 | |
| mridup | 6:e7a3fca2df10 | 147 | void ind_socket_server_client_joined(void) |
| mridup | 6:e7a3fca2df10 | 148 | { |
| mridup | 6:e7a3fca2df10 | 149 | //device->debug_print("\r\nclient connected!\r\n"); |
| mridup | 6:e7a3fca2df10 | 150 | device->set_wait_for_incoming_client(true); |
| mridup | 6:e7a3fca2df10 | 151 | } |
| mridup | 6:e7a3fca2df10 | 152 | |
| mridup | 6:e7a3fca2df10 | 153 | void ind_socket_server_client_left(void) |
| mridup | 6:e7a3fca2df10 | 154 | { |
| mridup | 6:e7a3fca2df10 | 155 | |
| mridup | 6:e7a3fca2df10 | 156 | } |
| mridup | 6:e7a3fca2df10 | 157 | |
| mridup | 6:e7a3fca2df10 | 158 | void ind_wifi_socket_server_data_lost(void) |
| mridup | 6:e7a3fca2df10 | 159 | { |
| mridup | 6:e7a3fca2df10 | 160 | |
| mridup | 6:e7a3fca2df10 | 161 | } |
| mridup | 6:e7a3fca2df10 | 162 | |
| mridup | 1:bd9db471d47d | 163 | #ifdef __cplusplus |
| mridup | 1:bd9db471d47d | 164 | } |
| mridup | 1:bd9db471d47d | 165 | #endif |
| mridup | 1:bd9db471d47d | 166 | |
| mridup | 1:bd9db471d47d | 167 | |
| mridup | 1:bd9db471d47d | 168 |
