Updated to use external spawn.
Fork of simplelink_V2 by
G_functions/fPtr_func.cpp@0:1a07906111ec, 2015-06-06 (annotated)
- Committer:
- dflet
- Date:
- Sat Jun 06 13:31:01 2015 +0000
- Revision:
- 0:1a07906111ec
Changes made to use external spawn Freertos
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dflet | 0:1a07906111ec | 1 | /* |
dflet | 0:1a07906111ec | 2 | * - CC31xx/CC32xx Host Driver Implementation |
dflet | 0:1a07906111ec | 3 | * |
dflet | 0:1a07906111ec | 4 | * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ |
dflet | 0:1a07906111ec | 5 | * |
dflet | 0:1a07906111ec | 6 | * |
dflet | 0:1a07906111ec | 7 | * Redistribution and use in source and binary forms, with or without |
dflet | 0:1a07906111ec | 8 | * modification, are permitted provided that the following conditions |
dflet | 0:1a07906111ec | 9 | * are met: |
dflet | 0:1a07906111ec | 10 | * |
dflet | 0:1a07906111ec | 11 | * Redistributions of source code must retain the above copyright |
dflet | 0:1a07906111ec | 12 | * notice, this list of conditions and the following disclaimer. |
dflet | 0:1a07906111ec | 13 | * |
dflet | 0:1a07906111ec | 14 | * Redistributions in binary form must reproduce the above copyright |
dflet | 0:1a07906111ec | 15 | * notice, this list of conditions and the following disclaimer in the |
dflet | 0:1a07906111ec | 16 | * documentation and/or other materials provided with the |
dflet | 0:1a07906111ec | 17 | * distribution. |
dflet | 0:1a07906111ec | 18 | * |
dflet | 0:1a07906111ec | 19 | * Neither the name of Texas Instruments Incorporated nor the names of |
dflet | 0:1a07906111ec | 20 | * its contributors may be used to endorse or promote products derived |
dflet | 0:1a07906111ec | 21 | * from this software without specific prior written permission. |
dflet | 0:1a07906111ec | 22 | * |
dflet | 0:1a07906111ec | 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
dflet | 0:1a07906111ec | 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
dflet | 0:1a07906111ec | 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
dflet | 0:1a07906111ec | 26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
dflet | 0:1a07906111ec | 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
dflet | 0:1a07906111ec | 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
dflet | 0:1a07906111ec | 29 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
dflet | 0:1a07906111ec | 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
dflet | 0:1a07906111ec | 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
dflet | 0:1a07906111ec | 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
dflet | 0:1a07906111ec | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
dflet | 0:1a07906111ec | 34 | * |
dflet | 0:1a07906111ec | 35 | */ |
dflet | 0:1a07906111ec | 36 | |
dflet | 0:1a07906111ec | 37 | #include "simplelink_V2/cc3100_simplelink.h" |
dflet | 0:1a07906111ec | 38 | |
dflet | 0:1a07906111ec | 39 | #include "simplelink_V2/cc3100.h" |
dflet | 0:1a07906111ec | 40 | #include "simplelink_V2/cc3100_driver.h" |
dflet | 0:1a07906111ec | 41 | #include "simplelink_V2/G_functions/fPtr_func.h" |
dflet | 0:1a07906111ec | 42 | #include "simplelink_V2/cc3100_nonos.h" |
dflet | 0:1a07906111ec | 43 | #include "cli_uart.h" |
dflet | 0:1a07906111ec | 44 | |
dflet | 0:1a07906111ec | 45 | #include "cc3100_trace.h" |
dflet | 0:1a07906111ec | 46 | |
dflet | 0:1a07906111ec | 47 | using namespace mbed_cc3100; |
dflet | 0:1a07906111ec | 48 | |
dflet | 0:1a07906111ec | 49 | cc3100 _cc3100_(p16, p17, p9, p10, p8, SPI(p5, p6, p7));//LPC1768 irq, nHib, cs, mosi, miso, sck |
dflet | 0:1a07906111ec | 50 | |
dflet | 0:1a07906111ec | 51 | #ifdef __cplusplus |
dflet | 0:1a07906111ec | 52 | extern "C" { |
dflet | 0:1a07906111ec | 53 | #endif |
dflet | 0:1a07906111ec | 54 | |
dflet | 0:1a07906111ec | 55 | #define PRINT_BUF_LEN 128 |
dflet | 0:1a07906111ec | 56 | extern int8_t print_buf[PRINT_BUF_LEN]; |
dflet | 0:1a07906111ec | 57 | |
dflet | 0:1a07906111ec | 58 | /* General Events handling*/ |
dflet | 0:1a07906111ec | 59 | #if defined (EXT_LIB_REGISTERED_GENERAL_EVENTS) |
dflet | 0:1a07906111ec | 60 | |
dflet | 0:1a07906111ec | 61 | typedef _SlEventPropogationStatus_e (*general_callback) (SlDeviceEvent_t *); |
dflet | 0:1a07906111ec | 62 | |
dflet | 0:1a07906111ec | 63 | static const general_callback general_callbacks[] = |
dflet | 0:1a07906111ec | 64 | { |
dflet | 0:1a07906111ec | 65 | #ifdef SlExtLib1GeneralEventHandler |
dflet | 0:1a07906111ec | 66 | SlExtLib1GeneralEventHandler, |
dflet | 0:1a07906111ec | 67 | #endif |
dflet | 0:1a07906111ec | 68 | |
dflet | 0:1a07906111ec | 69 | #ifdef SlExtLib2GeneralEventHandler |
dflet | 0:1a07906111ec | 70 | SlExtLib2GeneralEventHandler, |
dflet | 0:1a07906111ec | 71 | #endif |
dflet | 0:1a07906111ec | 72 | |
dflet | 0:1a07906111ec | 73 | #ifdef SlExtLib3GeneralEventHandler |
dflet | 0:1a07906111ec | 74 | SlExtLib3GeneralEventHandler, |
dflet | 0:1a07906111ec | 75 | #endif |
dflet | 0:1a07906111ec | 76 | |
dflet | 0:1a07906111ec | 77 | #ifdef SlExtLib4GeneralEventHandler |
dflet | 0:1a07906111ec | 78 | SlExtLib4GeneralEventHandler, |
dflet | 0:1a07906111ec | 79 | #endif |
dflet | 0:1a07906111ec | 80 | |
dflet | 0:1a07906111ec | 81 | #ifdef SlExtLib5GeneralEventHandler |
dflet | 0:1a07906111ec | 82 | SlExtLib5GeneralEventHandler, |
dflet | 0:1a07906111ec | 83 | #endif |
dflet | 0:1a07906111ec | 84 | }; |
dflet | 0:1a07906111ec | 85 | |
dflet | 0:1a07906111ec | 86 | #undef _SlDrvHandleGeneralEvents |
dflet | 0:1a07906111ec | 87 | |
dflet | 0:1a07906111ec | 88 | /******************************************************************** |
dflet | 0:1a07906111ec | 89 | _SlDrvHandleGeneralEvents |
dflet | 0:1a07906111ec | 90 | Iterates through all the general(device) event handlers which are |
dflet | 0:1a07906111ec | 91 | registered by the external libs/user application. |
dflet | 0:1a07906111ec | 92 | *********************************************************************/ |
dflet | 0:1a07906111ec | 93 | void _SlDrvHandleGeneralEvents(SlDeviceEvent_t *slGeneralEvent) |
dflet | 0:1a07906111ec | 94 | { |
dflet | 0:1a07906111ec | 95 | uint8_t i; |
dflet | 0:1a07906111ec | 96 | |
dflet | 0:1a07906111ec | 97 | /* Iterate over all the extenal libs handlers */ |
dflet | 0:1a07906111ec | 98 | for ( i = 0 ; i < sizeof(general_callbacks)/sizeof(general_callbacks[0]) ; i++ ) |
dflet | 0:1a07906111ec | 99 | { |
dflet | 0:1a07906111ec | 100 | if (EVENT_PROPAGATION_BLOCK == general_callbacks[i](slGeneralEvent) ) |
dflet | 0:1a07906111ec | 101 | { |
dflet | 0:1a07906111ec | 102 | /* exit immediately and do not call the user specific handler as well */ |
dflet | 0:1a07906111ec | 103 | return; |
dflet | 0:1a07906111ec | 104 | } |
dflet | 0:1a07906111ec | 105 | } |
dflet | 0:1a07906111ec | 106 | |
dflet | 0:1a07906111ec | 107 | /* At last call the Application specific handler if registered */ |
dflet | 0:1a07906111ec | 108 | #ifdef sl_GeneralEvtHdlr |
dflet | 0:1a07906111ec | 109 | sl_GeneralEvtHdlr(slGeneralEvent); |
dflet | 0:1a07906111ec | 110 | #endif |
dflet | 0:1a07906111ec | 111 | |
dflet | 0:1a07906111ec | 112 | } |
dflet | 0:1a07906111ec | 113 | #endif |
dflet | 0:1a07906111ec | 114 | |
dflet | 0:1a07906111ec | 115 | |
dflet | 0:1a07906111ec | 116 | |
dflet | 0:1a07906111ec | 117 | /* WLAN Events handling*/ |
dflet | 0:1a07906111ec | 118 | |
dflet | 0:1a07906111ec | 119 | #if defined (EXT_LIB_REGISTERED_WLAN_EVENTS) |
dflet | 0:1a07906111ec | 120 | |
dflet | 0:1a07906111ec | 121 | typedef _SlEventPropogationStatus_e (*wlan_callback) (SlWlanEvent_t *); |
dflet | 0:1a07906111ec | 122 | |
dflet | 0:1a07906111ec | 123 | static wlan_callback wlan_callbacks[] = |
dflet | 0:1a07906111ec | 124 | { |
dflet | 0:1a07906111ec | 125 | #ifdef SlExtLib1WlanEventHandler |
dflet | 0:1a07906111ec | 126 | SlExtLib1WlanEventHandler, |
dflet | 0:1a07906111ec | 127 | #endif |
dflet | 0:1a07906111ec | 128 | |
dflet | 0:1a07906111ec | 129 | #ifdef SlExtLib2WlanEventHandler |
dflet | 0:1a07906111ec | 130 | SlExtLib2WlanEventHandler, |
dflet | 0:1a07906111ec | 131 | #endif |
dflet | 0:1a07906111ec | 132 | |
dflet | 0:1a07906111ec | 133 | #ifdef SlExtLib3WlanEventHandler |
dflet | 0:1a07906111ec | 134 | SlExtLib3WlanEventHandler, |
dflet | 0:1a07906111ec | 135 | #endif |
dflet | 0:1a07906111ec | 136 | |
dflet | 0:1a07906111ec | 137 | #ifdef SlExtLib4WlanEventHandler |
dflet | 0:1a07906111ec | 138 | SlExtLib4WlanEventHandler, |
dflet | 0:1a07906111ec | 139 | #endif |
dflet | 0:1a07906111ec | 140 | |
dflet | 0:1a07906111ec | 141 | #ifdef SlExtLib5WlanEventHandler |
dflet | 0:1a07906111ec | 142 | SlExtLib5WlanEventHandler, |
dflet | 0:1a07906111ec | 143 | #endif |
dflet | 0:1a07906111ec | 144 | }; |
dflet | 0:1a07906111ec | 145 | |
dflet | 0:1a07906111ec | 146 | #undef _SlDrvHandleWlanEvents |
dflet | 0:1a07906111ec | 147 | |
dflet | 0:1a07906111ec | 148 | /*********************************************************** |
dflet | 0:1a07906111ec | 149 | _SlDrvHandleWlanEvents |
dflet | 0:1a07906111ec | 150 | Iterates through all the wlan event handlers which are |
dflet | 0:1a07906111ec | 151 | registered by the external libs/user application. |
dflet | 0:1a07906111ec | 152 | ************************************************************/ |
dflet | 0:1a07906111ec | 153 | void _SlDrvHandleWlanEvents(SlWlanEvent_t *slWlanEvent) |
dflet | 0:1a07906111ec | 154 | { |
dflet | 0:1a07906111ec | 155 | uint8_t i; |
dflet | 0:1a07906111ec | 156 | |
dflet | 0:1a07906111ec | 157 | /* Iterate over all the extenal libs handlers */ |
dflet | 0:1a07906111ec | 158 | for ( i = 0 ; i < sizeof(wlan_callbacks)/sizeof(wlan_callbacks[0]) ; i++ ) |
dflet | 0:1a07906111ec | 159 | { |
dflet | 0:1a07906111ec | 160 | if ( EVENT_PROPAGATION_BLOCK == wlan_callbacks[i](slWlanEvent) ) |
dflet | 0:1a07906111ec | 161 | { |
dflet | 0:1a07906111ec | 162 | /* exit immediately and do not call the user specific handler as well */ |
dflet | 0:1a07906111ec | 163 | return; |
dflet | 0:1a07906111ec | 164 | } |
dflet | 0:1a07906111ec | 165 | } |
dflet | 0:1a07906111ec | 166 | |
dflet | 0:1a07906111ec | 167 | /* At last call the Application specific handler if registered */ |
dflet | 0:1a07906111ec | 168 | #ifdef sl_WlanEvtHdlr |
dflet | 0:1a07906111ec | 169 | sl_WlanEvtHdlr(slWlanEvent); |
dflet | 0:1a07906111ec | 170 | #endif |
dflet | 0:1a07906111ec | 171 | |
dflet | 0:1a07906111ec | 172 | } |
dflet | 0:1a07906111ec | 173 | #endif |
dflet | 0:1a07906111ec | 174 | |
dflet | 0:1a07906111ec | 175 | |
dflet | 0:1a07906111ec | 176 | /* NetApp Events handling */ |
dflet | 0:1a07906111ec | 177 | #if defined (EXT_LIB_REGISTERED_NETAPP_EVENTS) |
dflet | 0:1a07906111ec | 178 | |
dflet | 0:1a07906111ec | 179 | typedef _SlEventPropogationStatus_e (*netApp_callback) (SlNetAppEvent_t *); |
dflet | 0:1a07906111ec | 180 | |
dflet | 0:1a07906111ec | 181 | static const netApp_callback netApp_callbacks[] = |
dflet | 0:1a07906111ec | 182 | { |
dflet | 0:1a07906111ec | 183 | #ifdef SlExtLib1NetAppEventHandler |
dflet | 0:1a07906111ec | 184 | SlExtLib1NetAppEventHandler, |
dflet | 0:1a07906111ec | 185 | #endif |
dflet | 0:1a07906111ec | 186 | |
dflet | 0:1a07906111ec | 187 | #ifdef SlExtLib2NetAppEventHandler |
dflet | 0:1a07906111ec | 188 | SlExtLib2NetAppEventHandler, |
dflet | 0:1a07906111ec | 189 | #endif |
dflet | 0:1a07906111ec | 190 | |
dflet | 0:1a07906111ec | 191 | #ifdef SlExtLib3NetAppEventHandler |
dflet | 0:1a07906111ec | 192 | SlExtLib3NetAppEventHandler, |
dflet | 0:1a07906111ec | 193 | #endif |
dflet | 0:1a07906111ec | 194 | |
dflet | 0:1a07906111ec | 195 | #ifdef SlExtLib4NetAppEventHandler |
dflet | 0:1a07906111ec | 196 | SlExtLib4NetAppEventHandler, |
dflet | 0:1a07906111ec | 197 | #endif |
dflet | 0:1a07906111ec | 198 | |
dflet | 0:1a07906111ec | 199 | #ifdef SlExtLib5NetAppEventHandler |
dflet | 0:1a07906111ec | 200 | SlExtLib5NetAppEventHandler, |
dflet | 0:1a07906111ec | 201 | #endif |
dflet | 0:1a07906111ec | 202 | }; |
dflet | 0:1a07906111ec | 203 | |
dflet | 0:1a07906111ec | 204 | #undef _SlDrvHandleNetAppEvents |
dflet | 0:1a07906111ec | 205 | |
dflet | 0:1a07906111ec | 206 | /************************************************************ |
dflet | 0:1a07906111ec | 207 | _SlDrvHandleNetAppEvents |
dflet | 0:1a07906111ec | 208 | Iterates through all the net app event handlers which are |
dflet | 0:1a07906111ec | 209 | registered by the external libs/user application. |
dflet | 0:1a07906111ec | 210 | ************************************************************/ |
dflet | 0:1a07906111ec | 211 | void _SlDrvHandleNetAppEvents(SlNetAppEvent_t *slNetAppEvent) |
dflet | 0:1a07906111ec | 212 | { |
dflet | 0:1a07906111ec | 213 | uint8_t i; |
dflet | 0:1a07906111ec | 214 | |
dflet | 0:1a07906111ec | 215 | /* Iterate over all the extenal libs handlers */ |
dflet | 0:1a07906111ec | 216 | for ( i = 0 ; i < sizeof(netApp_callbacks)/sizeof(netApp_callbacks[0]) ; i++ ) |
dflet | 0:1a07906111ec | 217 | { |
dflet | 0:1a07906111ec | 218 | if (EVENT_PROPAGATION_BLOCK == netApp_callbacks[i](slNetAppEvent) ) |
dflet | 0:1a07906111ec | 219 | { |
dflet | 0:1a07906111ec | 220 | /* exit immediately and do not call the user specific handler as well */ |
dflet | 0:1a07906111ec | 221 | return; |
dflet | 0:1a07906111ec | 222 | } |
dflet | 0:1a07906111ec | 223 | } |
dflet | 0:1a07906111ec | 224 | |
dflet | 0:1a07906111ec | 225 | /* At last call the Application specific handler if registered */ |
dflet | 0:1a07906111ec | 226 | #ifdef sl_NetAppEvtHdlr |
dflet | 0:1a07906111ec | 227 | sl_NetAppEvtHdlr(slNetAppEvent); |
dflet | 0:1a07906111ec | 228 | #endif |
dflet | 0:1a07906111ec | 229 | |
dflet | 0:1a07906111ec | 230 | } |
dflet | 0:1a07906111ec | 231 | #endif |
dflet | 0:1a07906111ec | 232 | |
dflet | 0:1a07906111ec | 233 | |
dflet | 0:1a07906111ec | 234 | /* Http Server Events handling */ |
dflet | 0:1a07906111ec | 235 | #if defined (EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) |
dflet | 0:1a07906111ec | 236 | |
dflet | 0:1a07906111ec | 237 | typedef _SlEventPropogationStatus_e (*httpServer_callback) (SlHttpServerEvent_t*, SlHttpServerResponse_t*); |
dflet | 0:1a07906111ec | 238 | |
dflet | 0:1a07906111ec | 239 | static const httpServer_callback httpServer_callbacks[] = |
dflet | 0:1a07906111ec | 240 | { |
dflet | 0:1a07906111ec | 241 | #ifdef SlExtLib1HttpServerEventHandler |
dflet | 0:1a07906111ec | 242 | SlExtLib1HttpServerEventHandler, |
dflet | 0:1a07906111ec | 243 | #endif |
dflet | 0:1a07906111ec | 244 | |
dflet | 0:1a07906111ec | 245 | #ifdef SlExtLib2HttpServerEventHandler |
dflet | 0:1a07906111ec | 246 | SlExtLib2HttpServerEventHandler, |
dflet | 0:1a07906111ec | 247 | #endif |
dflet | 0:1a07906111ec | 248 | |
dflet | 0:1a07906111ec | 249 | #ifdef SlExtLib3HttpServerEventHandler |
dflet | 0:1a07906111ec | 250 | SlExtLib3HttpServerEventHandler, |
dflet | 0:1a07906111ec | 251 | #endif |
dflet | 0:1a07906111ec | 252 | |
dflet | 0:1a07906111ec | 253 | #ifdef SlExtLib4HttpServerEventHandler |
dflet | 0:1a07906111ec | 254 | SlExtLib4HttpServerEventHandler, |
dflet | 0:1a07906111ec | 255 | #endif |
dflet | 0:1a07906111ec | 256 | |
dflet | 0:1a07906111ec | 257 | #ifdef SlExtLib5HttpServerEventHandler |
dflet | 0:1a07906111ec | 258 | SlExtLib5HttpServerEventHandler, |
dflet | 0:1a07906111ec | 259 | #endif |
dflet | 0:1a07906111ec | 260 | }; |
dflet | 0:1a07906111ec | 261 | |
dflet | 0:1a07906111ec | 262 | #undef _SlDrvHandleHttpServerEvents |
dflet | 0:1a07906111ec | 263 | |
dflet | 0:1a07906111ec | 264 | /******************************************************************* |
dflet | 0:1a07906111ec | 265 | _SlDrvHandleHttpServerEvents |
dflet | 0:1a07906111ec | 266 | Iterates through all the http server event handlers which are |
dflet | 0:1a07906111ec | 267 | registered by the external libs/user application. |
dflet | 0:1a07906111ec | 268 | ********************************************************************/ |
dflet | 0:1a07906111ec | 269 | void _SlDrvHandleHttpServerEvents(SlHttpServerEvent_t *slHttpServerEvent, SlHttpServerResponse_t *slHttpServerResponse) |
dflet | 0:1a07906111ec | 270 | { |
dflet | 0:1a07906111ec | 271 | _u8 i; |
dflet | 0:1a07906111ec | 272 | |
dflet | 0:1a07906111ec | 273 | /* Iterate over all the external libs handlers */ |
dflet | 0:1a07906111ec | 274 | for ( i = 0 ; i < sizeof(httpServer_callbacks)/sizeof(httpServer_callbacks[0]) ; i++ ) |
dflet | 0:1a07906111ec | 275 | { |
dflet | 0:1a07906111ec | 276 | if ( EVENT_PROPAGATION_BLOCK == httpServer_callbacks[i](slHttpServerEvent, slHttpServerResponse) ) |
dflet | 0:1a07906111ec | 277 | { |
dflet | 0:1a07906111ec | 278 | /* exit immediately and do not call the user specific handler as well */ |
dflet | 0:1a07906111ec | 279 | return; |
dflet | 0:1a07906111ec | 280 | } |
dflet | 0:1a07906111ec | 281 | } |
dflet | 0:1a07906111ec | 282 | |
dflet | 0:1a07906111ec | 283 | /* At last call the Application specific handler if registered */ |
dflet | 0:1a07906111ec | 284 | #ifdef sl_HttpServerCallback |
dflet | 0:1a07906111ec | 285 | sl_HttpServerCallback(slHttpServerEvent, slHttpServerResponse); |
dflet | 0:1a07906111ec | 286 | #endif |
dflet | 0:1a07906111ec | 287 | |
dflet | 0:1a07906111ec | 288 | } |
dflet | 0:1a07906111ec | 289 | #endif |
dflet | 0:1a07906111ec | 290 | |
dflet | 0:1a07906111ec | 291 | |
dflet | 0:1a07906111ec | 292 | /* Socket Events */ |
dflet | 0:1a07906111ec | 293 | #if defined (EXT_LIB_REGISTERED_SOCK_EVENTS) |
dflet | 0:1a07906111ec | 294 | |
dflet | 0:1a07906111ec | 295 | typedef _SlEventPropogationStatus_e (*sock_callback) (SlSockEvent_t *); |
dflet | 0:1a07906111ec | 296 | |
dflet | 0:1a07906111ec | 297 | static const sock_callback sock_callbacks[] = |
dflet | 0:1a07906111ec | 298 | { |
dflet | 0:1a07906111ec | 299 | #ifdef SlExtLib1SockEventHandler |
dflet | 0:1a07906111ec | 300 | SlExtLib1SockEventHandler, |
dflet | 0:1a07906111ec | 301 | #endif |
dflet | 0:1a07906111ec | 302 | |
dflet | 0:1a07906111ec | 303 | #ifdef SlExtLib2SockEventHandler |
dflet | 0:1a07906111ec | 304 | SlExtLib2SockEventHandler, |
dflet | 0:1a07906111ec | 305 | #endif |
dflet | 0:1a07906111ec | 306 | |
dflet | 0:1a07906111ec | 307 | #ifdef SlExtLib3SockEventHandler |
dflet | 0:1a07906111ec | 308 | SlExtLib3SockEventHandler, |
dflet | 0:1a07906111ec | 309 | #endif |
dflet | 0:1a07906111ec | 310 | |
dflet | 0:1a07906111ec | 311 | #ifdef SlExtLib4SockEventHandler |
dflet | 0:1a07906111ec | 312 | SlExtLib4SockEventHandler, |
dflet | 0:1a07906111ec | 313 | #endif |
dflet | 0:1a07906111ec | 314 | |
dflet | 0:1a07906111ec | 315 | #ifdef SlExtLib5SockEventHandler |
dflet | 0:1a07906111ec | 316 | SlExtLib5SockEventHandler, |
dflet | 0:1a07906111ec | 317 | #endif |
dflet | 0:1a07906111ec | 318 | }; |
dflet | 0:1a07906111ec | 319 | |
dflet | 0:1a07906111ec | 320 | /************************************************************* |
dflet | 0:1a07906111ec | 321 | _SlDrvHandleSockEvents |
dflet | 0:1a07906111ec | 322 | Iterates through all the socket event handlers which are |
dflet | 0:1a07906111ec | 323 | registered by the external libs/user application. |
dflet | 0:1a07906111ec | 324 | **************************************************************/ |
dflet | 0:1a07906111ec | 325 | void _SlDrvHandleSockEvents(SlSockEvent_t *slSockEvent) |
dflet | 0:1a07906111ec | 326 | { |
dflet | 0:1a07906111ec | 327 | uint8_t i; |
dflet | 0:1a07906111ec | 328 | |
dflet | 0:1a07906111ec | 329 | /* Iterate over all the external libs handlers */ |
dflet | 0:1a07906111ec | 330 | for ( i = 0 ; i < sizeof(sock_callbacks)/sizeof(sock_callbacks[0]) ; i++ ) |
dflet | 0:1a07906111ec | 331 | { |
dflet | 0:1a07906111ec | 332 | if ( EVENT_PROPAGATION_BLOCK == sock_callbacks[i](slSockEvent) ) |
dflet | 0:1a07906111ec | 333 | { |
dflet | 0:1a07906111ec | 334 | /* exit immediately and do not call the user specific handler as well */ |
dflet | 0:1a07906111ec | 335 | return; |
dflet | 0:1a07906111ec | 336 | } |
dflet | 0:1a07906111ec | 337 | } |
dflet | 0:1a07906111ec | 338 | |
dflet | 0:1a07906111ec | 339 | /* At last call the Application specific handler if registered */ |
dflet | 0:1a07906111ec | 340 | #ifdef sl_SockEvtHdlr |
dflet | 0:1a07906111ec | 341 | sl_SockEvtHdlr(slSockEvent); |
dflet | 0:1a07906111ec | 342 | #endif |
dflet | 0:1a07906111ec | 343 | |
dflet | 0:1a07906111ec | 344 | } |
dflet | 0:1a07906111ec | 345 | |
dflet | 0:1a07906111ec | 346 | #endif |
dflet | 0:1a07906111ec | 347 | |
dflet | 0:1a07906111ec | 348 | /*! |
dflet | 0:1a07906111ec | 349 | \brief This function handles ping report events |
dflet | 0:1a07906111ec | 350 | |
dflet | 0:1a07906111ec | 351 | \param[in] pPingReport holds the ping report statistics |
dflet | 0:1a07906111ec | 352 | |
dflet | 0:1a07906111ec | 353 | \return None |
dflet | 0:1a07906111ec | 354 | |
dflet | 0:1a07906111ec | 355 | \note |
dflet | 0:1a07906111ec | 356 | |
dflet | 0:1a07906111ec | 357 | \warning |
dflet | 0:1a07906111ec | 358 | */ |
dflet | 0:1a07906111ec | 359 | void SimpleLinkPingReport(SlPingReport_t *pPingReport) |
dflet | 0:1a07906111ec | 360 | { |
dflet | 0:1a07906111ec | 361 | _cc3100_.SET_STATUS_BIT(g_Status, STATUS_BIT_PING_DONE); |
dflet | 0:1a07906111ec | 362 | |
dflet | 0:1a07906111ec | 363 | if(pPingReport == NULL) |
dflet | 0:1a07906111ec | 364 | Uart_Write((uint8_t*)" [PING REPORT] NULL Pointer Error\r\n"); |
dflet | 0:1a07906111ec | 365 | |
dflet | 0:1a07906111ec | 366 | g_PingPacketsRecv = pPingReport->PacketsReceived; |
dflet | 0:1a07906111ec | 367 | } |
dflet | 0:1a07906111ec | 368 | |
dflet | 0:1a07906111ec | 369 | |
dflet | 0:1a07906111ec | 370 | /*******************************************************************************/ |
dflet | 0:1a07906111ec | 371 | /* _sl_HandleAsync_Accept */ |
dflet | 0:1a07906111ec | 372 | /*******************************************************************************/ |
dflet | 0:1a07906111ec | 373 | #ifndef SL_TINY_EXT |
dflet | 0:1a07906111ec | 374 | void _sl_HandleAsync_Accept(void *pVoidBuf) |
dflet | 0:1a07906111ec | 375 | { |
dflet | 0:1a07906111ec | 376 | _SocketAddrResponse_u *pMsgArgs = (_SocketAddrResponse_u *)_SL_RESP_ARGS_START(pVoidBuf); |
dflet | 0:1a07906111ec | 377 | |
dflet | 0:1a07906111ec | 378 | _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); |
dflet | 0:1a07906111ec | 379 | |
dflet | 0:1a07906111ec | 380 | VERIFY_PROTOCOL(( pMsgArgs->IpV4.sd & BSD_SOCKET_ID_MASK) <= SL_MAX_SOCKETS); |
dflet | 0:1a07906111ec | 381 | VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); |
dflet | 0:1a07906111ec | 382 | |
dflet | 0:1a07906111ec | 383 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs,sizeof(_SocketAddrResponse_u)); |
dflet | 0:1a07906111ec | 384 | _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); |
dflet | 0:1a07906111ec | 385 | |
dflet | 0:1a07906111ec | 386 | _cc3100_._driver._SlDrvProtectionObjUnLock(); |
dflet | 0:1a07906111ec | 387 | return; |
dflet | 0:1a07906111ec | 388 | } |
dflet | 0:1a07906111ec | 389 | |
dflet | 0:1a07906111ec | 390 | /*******************************************************************************/ |
dflet | 0:1a07906111ec | 391 | /* _sl_HandleAsync_Connect */ |
dflet | 0:1a07906111ec | 392 | /*******************************************************************************/ |
dflet | 0:1a07906111ec | 393 | void _sl_HandleAsync_Connect(void *pVoidBuf) |
dflet | 0:1a07906111ec | 394 | { |
dflet | 0:1a07906111ec | 395 | _SocketResponse_t *pMsgArgs = (_SocketResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
dflet | 0:1a07906111ec | 396 | |
dflet | 0:1a07906111ec | 397 | _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); |
dflet | 0:1a07906111ec | 398 | |
dflet | 0:1a07906111ec | 399 | VERIFY_PROTOCOL((pMsgArgs->sd & BSD_SOCKET_ID_MASK) <= SL_MAX_SOCKETS); |
dflet | 0:1a07906111ec | 400 | VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); |
dflet | 0:1a07906111ec | 401 | |
dflet | 0:1a07906111ec | 402 | ((_SocketResponse_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->sd = pMsgArgs->sd; |
dflet | 0:1a07906111ec | 403 | ((_SocketResponse_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->statusOrLen = pMsgArgs->statusOrLen; |
dflet | 0:1a07906111ec | 404 | |
dflet | 0:1a07906111ec | 405 | _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); |
dflet | 0:1a07906111ec | 406 | _cc3100_._driver._SlDrvProtectionObjUnLock(); |
dflet | 0:1a07906111ec | 407 | return; |
dflet | 0:1a07906111ec | 408 | } |
dflet | 0:1a07906111ec | 409 | |
dflet | 0:1a07906111ec | 410 | /*******************************************************************************/ |
dflet | 0:1a07906111ec | 411 | /* _sl_HandleAsync_Select */ |
dflet | 0:1a07906111ec | 412 | /*******************************************************************************/ |
dflet | 0:1a07906111ec | 413 | void _sl_HandleAsync_Select(void *pVoidBuf) |
dflet | 0:1a07906111ec | 414 | { |
dflet | 0:1a07906111ec | 415 | _SelectAsyncResponse_t *pMsgArgs = (_SelectAsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
dflet | 0:1a07906111ec | 416 | |
dflet | 0:1a07906111ec | 417 | _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); |
dflet | 0:1a07906111ec | 418 | |
dflet | 0:1a07906111ec | 419 | VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); |
dflet | 0:1a07906111ec | 420 | |
dflet | 0:1a07906111ec | 421 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_SelectAsyncResponse_t)); |
dflet | 0:1a07906111ec | 422 | |
dflet | 0:1a07906111ec | 423 | _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); |
dflet | 0:1a07906111ec | 424 | _cc3100_._driver._SlDrvProtectionObjUnLock(); |
dflet | 0:1a07906111ec | 425 | |
dflet | 0:1a07906111ec | 426 | return; |
dflet | 0:1a07906111ec | 427 | } |
dflet | 0:1a07906111ec | 428 | |
dflet | 0:1a07906111ec | 429 | #endif |
dflet | 0:1a07906111ec | 430 | |
dflet | 0:1a07906111ec | 431 | /******************************************************************************/ |
dflet | 0:1a07906111ec | 432 | /* _sl_HandleAsync_DnsGetHostByName */ |
dflet | 0:1a07906111ec | 433 | /******************************************************************************/ |
dflet | 0:1a07906111ec | 434 | void _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf) |
dflet | 0:1a07906111ec | 435 | { |
dflet | 0:1a07906111ec | 436 | _GetHostByNameIPv4AsyncResponse_t *pMsgArgs = (_GetHostByNameIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
dflet | 0:1a07906111ec | 437 | |
dflet | 0:1a07906111ec | 438 | _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); |
dflet | 0:1a07906111ec | 439 | |
dflet | 0:1a07906111ec | 440 | VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); |
dflet | 0:1a07906111ec | 441 | |
dflet | 0:1a07906111ec | 442 | /*IPv6 */ |
dflet | 0:1a07906111ec | 443 | if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK) { |
dflet | 0:1a07906111ec | 444 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv6AsyncResponse_t)); |
dflet | 0:1a07906111ec | 445 | } |
dflet | 0:1a07906111ec | 446 | /*IPv4 */ |
dflet | 0:1a07906111ec | 447 | else |
dflet | 0:1a07906111ec | 448 | { |
dflet | 0:1a07906111ec | 449 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv4AsyncResponse_t)); |
dflet | 0:1a07906111ec | 450 | } |
dflet | 0:1a07906111ec | 451 | |
dflet | 0:1a07906111ec | 452 | _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); |
dflet | 0:1a07906111ec | 453 | _cc3100_._driver._SlDrvProtectionObjUnLock(); |
dflet | 0:1a07906111ec | 454 | |
dflet | 0:1a07906111ec | 455 | return; |
dflet | 0:1a07906111ec | 456 | } |
dflet | 0:1a07906111ec | 457 | |
dflet | 0:1a07906111ec | 458 | /******************************************************************************/ |
dflet | 0:1a07906111ec | 459 | |
dflet | 0:1a07906111ec | 460 | /****************************************************************************** |
dflet | 0:1a07906111ec | 461 | _sl_HandleAsync_DnsGetHostByService |
dflet | 0:1a07906111ec | 462 | |
dflet | 0:1a07906111ec | 463 | CALLER NWP - Async event on sl_DnsGetHostByService with IPv4 Family |
dflet | 0:1a07906111ec | 464 | |
dflet | 0:1a07906111ec | 465 | |
dflet | 0:1a07906111ec | 466 | DESCRIPTION: |
dflet | 0:1a07906111ec | 467 | |
dflet | 0:1a07906111ec | 468 | Async event on sl_DnsGetHostByService command with IPv4 Family. |
dflet | 0:1a07906111ec | 469 | Return service attributes like IP address, port and text according to service name. |
dflet | 0:1a07906111ec | 470 | The user sets a service name Full/Part (see example below), and should get the: |
dflet | 0:1a07906111ec | 471 | 1. IP of the service |
dflet | 0:1a07906111ec | 472 | 2. The port of service. |
dflet | 0:1a07906111ec | 473 | 3. The text of service. |
dflet | 0:1a07906111ec | 474 | |
dflet | 0:1a07906111ec | 475 | Hence it can make a connection to the specific service and use it. |
dflet | 0:1a07906111ec | 476 | It is similar to get host by name method. |
dflet | 0:1a07906111ec | 477 | |
dflet | 0:1a07906111ec | 478 | It is done by a single shot query with PTR type on the service name. |
dflet | 0:1a07906111ec | 479 | |
dflet | 0:1a07906111ec | 480 | |
dflet | 0:1a07906111ec | 481 | |
dflet | 0:1a07906111ec | 482 | Note: |
dflet | 0:1a07906111ec | 483 | 1. The return's attributes are belonged to first service that is found. |
dflet | 0:1a07906111ec | 484 | It can be other services with the same service name will response to |
dflet | 0:1a07906111ec | 485 | the query. The results of these responses are saved in the peer cache of the NWP, and |
dflet | 0:1a07906111ec | 486 | should be read by another API. |
dflet | 0:1a07906111ec | 487 | |
dflet | 0:1a07906111ec | 488 | |
dflet | 0:1a07906111ec | 489 | PARAMETERS: |
dflet | 0:1a07906111ec | 490 | |
dflet | 0:1a07906111ec | 491 | pVoidBuf - is point to opcode of the event. |
dflet | 0:1a07906111ec | 492 | it contains the outputs that are given to the user |
dflet | 0:1a07906111ec | 493 | |
dflet | 0:1a07906111ec | 494 | outputs description: |
dflet | 0:1a07906111ec | 495 | |
dflet | 0:1a07906111ec | 496 | 1.out_pAddr[] - output: Contain the IP address of the service. |
dflet | 0:1a07906111ec | 497 | 2.out_pPort - output: Contain the port of the service. |
dflet | 0:1a07906111ec | 498 | 3.inout_TextLen - Input: Contain the max length of the text that the user wants to get. |
dflet | 0:1a07906111ec | 499 | it means that if the test of service is bigger that its value than |
dflet | 0:1a07906111ec | 500 | the text is cut to inout_TextLen value. |
dflet | 0:1a07906111ec | 501 | Output: Contain the length of the text that is returned. Can be full text or part |
dflet | 0:1a07906111ec | 502 | of the text (see above). |
dflet | 0:1a07906111ec | 503 | |
dflet | 0:1a07906111ec | 504 | 4.out_pText - Contain the text of the service (full or part see above- inout_TextLen description). |
dflet | 0:1a07906111ec | 505 | |
dflet | 0:1a07906111ec | 506 | * |
dflet | 0:1a07906111ec | 507 | |
dflet | 0:1a07906111ec | 508 | |
dflet | 0:1a07906111ec | 509 | RETURNS: success or fail. |
dflet | 0:1a07906111ec | 510 | |
dflet | 0:1a07906111ec | 511 | ******************************************************************************/ |
dflet | 0:1a07906111ec | 512 | #ifndef SL_TINY_EXT |
dflet | 0:1a07906111ec | 513 | void _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf) |
dflet | 0:1a07906111ec | 514 | { |
dflet | 0:1a07906111ec | 515 | _GetHostByServiceAsyncResponse_t* Res; |
dflet | 0:1a07906111ec | 516 | uint16_t TextLen; |
dflet | 0:1a07906111ec | 517 | uint16_t UserTextLen; |
dflet | 0:1a07906111ec | 518 | |
dflet | 0:1a07906111ec | 519 | /*pVoidBuf - is point to opcode of the event.*/ |
dflet | 0:1a07906111ec | 520 | |
dflet | 0:1a07906111ec | 521 | /*set pMsgArgs to point to the attribute of the event.*/ |
dflet | 0:1a07906111ec | 522 | _GetHostByServiceIPv4AsyncResponse_t *pMsgArgs = (_GetHostByServiceIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
dflet | 0:1a07906111ec | 523 | |
dflet | 0:1a07906111ec | 524 | VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); |
dflet | 0:1a07906111ec | 525 | |
dflet | 0:1a07906111ec | 526 | /*IPv6*/ |
dflet | 0:1a07906111ec | 527 | if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK) { |
dflet | 0:1a07906111ec | 528 | return; |
dflet | 0:1a07906111ec | 529 | } |
dflet | 0:1a07906111ec | 530 | /*IPv4*/ |
dflet | 0:1a07906111ec | 531 | else { |
dflet | 0:1a07906111ec | 532 | /************************************************************************************************* |
dflet | 0:1a07906111ec | 533 | |
dflet | 0:1a07906111ec | 534 | 1. Copy the attribute part of the evnt to the attribute part of the response |
dflet | 0:1a07906111ec | 535 | memcpy(g_pCB->GetHostByServiceCB.pAsyncRsp, pMsgArgs, sizeof(_GetHostByServiceIPv4AsyncResponse_t)); |
dflet | 0:1a07906111ec | 536 | |
dflet | 0:1a07906111ec | 537 | set to TextLen the text length of the service.*/ |
dflet | 0:1a07906111ec | 538 | TextLen = pMsgArgs->TextLen; |
dflet | 0:1a07906111ec | 539 | |
dflet | 0:1a07906111ec | 540 | /*Res pointed to mDNS global object struct */ |
dflet | 0:1a07906111ec | 541 | Res = (_GetHostByServiceAsyncResponse_t*)g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs; |
dflet | 0:1a07906111ec | 542 | |
dflet | 0:1a07906111ec | 543 | |
dflet | 0:1a07906111ec | 544 | |
dflet | 0:1a07906111ec | 545 | /*It is 4 bytes so we avoid from memcpy*/ |
dflet | 0:1a07906111ec | 546 | Res->out_pAddr[0] = pMsgArgs->Address; |
dflet | 0:1a07906111ec | 547 | Res->out_pPort[0] = pMsgArgs->Port; |
dflet | 0:1a07906111ec | 548 | Res->Status = pMsgArgs->Status; |
dflet | 0:1a07906111ec | 549 | |
dflet | 0:1a07906111ec | 550 | /*set to TextLen the text length of the user (input fromthe user).*/ |
dflet | 0:1a07906111ec | 551 | UserTextLen = Res->inout_TextLen[0]; |
dflet | 0:1a07906111ec | 552 | |
dflet | 0:1a07906111ec | 553 | /*Cut the service text if the user requested for smaller text.*/ |
dflet | 0:1a07906111ec | 554 | UserTextLen = (TextLen <= UserTextLen) ? TextLen : UserTextLen; |
dflet | 0:1a07906111ec | 555 | Res->inout_TextLen[0] = UserTextLen ; |
dflet | 0:1a07906111ec | 556 | |
dflet | 0:1a07906111ec | 557 | /************************************************************************************************** |
dflet | 0:1a07906111ec | 558 | |
dflet | 0:1a07906111ec | 559 | 2. Copy the payload part of the evnt (the text) to the payload part of the response |
dflet | 0:1a07906111ec | 560 | the lenght of the copy is according to the text length in the attribute part. */ |
dflet | 0:1a07906111ec | 561 | |
dflet | 0:1a07906111ec | 562 | |
dflet | 0:1a07906111ec | 563 | memcpy(Res->out_pText, |
dflet | 0:1a07906111ec | 564 | (int8_t *)(& pMsgArgs[1]), /* & pMsgArgs[1] -> 1st byte after the fixed header = 1st byte of variable text.*/ |
dflet | 0:1a07906111ec | 565 | UserTextLen); |
dflet | 0:1a07906111ec | 566 | |
dflet | 0:1a07906111ec | 567 | |
dflet | 0:1a07906111ec | 568 | /**************************************************************************************************/ |
dflet | 0:1a07906111ec | 569 | _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); |
dflet | 0:1a07906111ec | 570 | return; |
dflet | 0:1a07906111ec | 571 | } |
dflet | 0:1a07906111ec | 572 | } |
dflet | 0:1a07906111ec | 573 | #endif |
dflet | 0:1a07906111ec | 574 | |
dflet | 0:1a07906111ec | 575 | /*****************************************************************************/ |
dflet | 0:1a07906111ec | 576 | /* _sl_HandleAsync_PingResponse */ |
dflet | 0:1a07906111ec | 577 | /*****************************************************************************/ |
dflet | 0:1a07906111ec | 578 | #ifndef SL_TINY_EXT |
dflet | 0:1a07906111ec | 579 | void _sl_HandleAsync_PingResponse(void *pVoidBuf) |
dflet | 0:1a07906111ec | 580 | { |
dflet | 0:1a07906111ec | 581 | _PingReportResponse_t *pMsgArgs = (_PingReportResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
dflet | 0:1a07906111ec | 582 | SlPingReport_t pingReport; |
dflet | 0:1a07906111ec | 583 | |
dflet | 0:1a07906111ec | 584 | if(pPingCallBackFunc) { |
dflet | 0:1a07906111ec | 585 | _cc3100_._netapp.CopyPingResultsToReport(pMsgArgs,&pingReport); |
dflet | 0:1a07906111ec | 586 | pPingCallBackFunc(&pingReport); |
dflet | 0:1a07906111ec | 587 | } else { |
dflet | 0:1a07906111ec | 588 | |
dflet | 0:1a07906111ec | 589 | _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); |
dflet | 0:1a07906111ec | 590 | VERIFY_SOCKET_CB(NULL != g_pCB->PingCB.PingAsync.pAsyncRsp); |
dflet | 0:1a07906111ec | 591 | |
dflet | 0:1a07906111ec | 592 | if (NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs) { |
dflet | 0:1a07906111ec | 593 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_PingReportResponse_t)); |
dflet | 0:1a07906111ec | 594 | _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); |
dflet | 0:1a07906111ec | 595 | } |
dflet | 0:1a07906111ec | 596 | _cc3100_._driver._SlDrvProtectionObjUnLock(); |
dflet | 0:1a07906111ec | 597 | } |
dflet | 0:1a07906111ec | 598 | return; |
dflet | 0:1a07906111ec | 599 | } |
dflet | 0:1a07906111ec | 600 | #endif |
dflet | 0:1a07906111ec | 601 | |
dflet | 0:1a07906111ec | 602 | /* ******************************************************************************/ |
dflet | 0:1a07906111ec | 603 | /* _SlDrvMsgReadSpawnCtx */ |
dflet | 0:1a07906111ec | 604 | /* ******************************************************************************/ |
dflet | 0:1a07906111ec | 605 | |
dflet | 0:1a07906111ec | 606 | _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue) |
dflet | 0:1a07906111ec | 607 | { |
dflet | 0:1a07906111ec | 608 | // Uart_Write((uint8_t*)"\n\r _SlDrvMsgReadSpawnCtx \n\r"); |
dflet | 0:1a07906111ec | 609 | #ifdef SL_POLLING_MODE_USED |
dflet | 0:1a07906111ec | 610 | int16_t retCode = OSI_OK; |
dflet | 0:1a07906111ec | 611 | // for polling based systems |
dflet | 0:1a07906111ec | 612 | do { |
dflet | 0:1a07906111ec | 613 | retCode = _cc3100_->_nonos.sl_LockObjLock(&g_pCB->GlobalLockObj, 0); |
dflet | 0:1a07906111ec | 614 | if ( OSI_OK != retCode ) { |
dflet | 0:1a07906111ec | 615 | if (TRUE == g_pCB->IsCmdRespWaited) { |
dflet | 0:1a07906111ec | 616 | OSI_RET_OK_CHECK( _cc3100_->_nonos.sl_SyncObjSignal(&g_pCB->CmdSyncObj) ); |
dflet | 0:1a07906111ec | 617 | return SL_RET_CODE_OK; |
dflet | 0:1a07906111ec | 618 | } |
dflet | 0:1a07906111ec | 619 | } |
dflet | 0:1a07906111ec | 620 | |
dflet | 0:1a07906111ec | 621 | } while (OSI_OK != retCode); |
dflet | 0:1a07906111ec | 622 | |
dflet | 0:1a07906111ec | 623 | #else |
dflet | 0:1a07906111ec | 624 | |
dflet | 0:1a07906111ec | 625 | // OSI_RET_OK_CHECK(_cc3100_->_nonos.sl_LockObjLock(&g_pCB->GlobalLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE, NON_OS_LOCK_OBJ_LOCK_VALUE, SL_OS_WAIT_FOREVER) ); |
dflet | 0:1a07906111ec | 626 | _cc3100_._driver._SlDrvObjLockWaitForever(&g_pCB->GlobalLockObj); |
dflet | 0:1a07906111ec | 627 | |
dflet | 0:1a07906111ec | 628 | #endif |
dflet | 0:1a07906111ec | 629 | |
dflet | 0:1a07906111ec | 630 | g_pCB->FunctionParams.AsyncExt.pAsyncBuf = NULL;// buffer must be allocated by _SlDrvMsgRead |
dflet | 0:1a07906111ec | 631 | g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler= NULL; |
dflet | 0:1a07906111ec | 632 | g_pCB->FunctionParams.AsyncExt.RxMsgClass = CMD_RESP_CLASS;// init to illegal value and verify it's overwritten with the valid one |
dflet | 0:1a07906111ec | 633 | |
dflet | 0:1a07906111ec | 634 | // Messages might have been read by CmdResp context. Therefore after |
dflet | 0:1a07906111ec | 635 | // getting LockObj, check again where the Pending Rx Msg is still present. |
dflet | 0:1a07906111ec | 636 | if(FALSE == (_cc3100_._driver._SL_PENDING_RX_MSG(g_pCB))) { |
dflet | 0:1a07906111ec | 637 | _cc3100_._driver._SlDrvObjUnLock(&g_pCB->GlobalLockObj); |
dflet | 0:1a07906111ec | 638 | // OSI_RET_OK_CHECK(_cc3100_->_nonos.sl_LockObjUnlock(&g_pCB->GlobalLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); |
dflet | 0:1a07906111ec | 639 | return SL_RET_CODE_OK; |
dflet | 0:1a07906111ec | 640 | } |
dflet | 0:1a07906111ec | 641 | |
dflet | 0:1a07906111ec | 642 | VERIFY_RET_OK(_cc3100_._driver._SlDrvMsgRead()); |
dflet | 0:1a07906111ec | 643 | |
dflet | 0:1a07906111ec | 644 | g_pCB->RxDoneCnt++; |
dflet | 0:1a07906111ec | 645 | |
dflet | 0:1a07906111ec | 646 | switch(g_pCB->FunctionParams.AsyncExt.RxMsgClass) { |
dflet | 0:1a07906111ec | 647 | case ASYNC_EVT_CLASS: |
dflet | 0:1a07906111ec | 648 | // If got here and protected by LockObj a message is waiting |
dflet | 0:1a07906111ec | 649 | // to be read |
dflet | 0:1a07906111ec | 650 | VERIFY_PROTOCOL(NULL != g_pCB->FunctionParams.AsyncExt.pAsyncBuf); |
dflet | 0:1a07906111ec | 651 | |
dflet | 0:1a07906111ec | 652 | _cc3100_._driver._SlAsyncEventGenericHandler(); |
dflet | 0:1a07906111ec | 653 | |
dflet | 0:1a07906111ec | 654 | #if (SL_MEMORY_MGMT == SL_MEMORY_MGMT_STATIC) |
dflet | 0:1a07906111ec | 655 | g_pCB->FunctionParams.AsyncExt.pAsyncBuf = NULL; |
dflet | 0:1a07906111ec | 656 | #else |
dflet | 0:1a07906111ec | 657 | free(g_pCB->FunctionParams.AsyncExt.pAsyncBuf); |
dflet | 0:1a07906111ec | 658 | #endif |
dflet | 0:1a07906111ec | 659 | break; |
dflet | 0:1a07906111ec | 660 | case DUMMY_MSG_CLASS: |
dflet | 0:1a07906111ec | 661 | case RECV_RESP_CLASS: |
dflet | 0:1a07906111ec | 662 | // These types are legal in this context. Do nothing |
dflet | 0:1a07906111ec | 663 | break; |
dflet | 0:1a07906111ec | 664 | case CMD_RESP_CLASS: |
dflet | 0:1a07906111ec | 665 | // Command response is illegal in this context. |
dflet | 0:1a07906111ec | 666 | // No 'break' here: Assert! |
dflet | 0:1a07906111ec | 667 | default: |
dflet | 0:1a07906111ec | 668 | VERIFY_PROTOCOL(0); |
dflet | 0:1a07906111ec | 669 | } |
dflet | 0:1a07906111ec | 670 | |
dflet | 0:1a07906111ec | 671 | _cc3100_._driver._SlDrvObjUnLock(&g_pCB->GlobalLockObj); |
dflet | 0:1a07906111ec | 672 | // OSI_RET_OK_CHECK(_cc3100_->_nonos.sl_LockObjUnlock(&g_pCB->GlobalLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); |
dflet | 0:1a07906111ec | 673 | |
dflet | 0:1a07906111ec | 674 | return(SL_RET_CODE_OK); |
dflet | 0:1a07906111ec | 675 | |
dflet | 0:1a07906111ec | 676 | } |
dflet | 0:1a07906111ec | 677 | |
dflet | 0:1a07906111ec | 678 | /*************************************************************************** |
dflet | 0:1a07906111ec | 679 | _sl_HandleAsync_Stop - handles stop signalling to |
dflet | 0:1a07906111ec | 680 | a waiting object |
dflet | 0:1a07906111ec | 681 | ****************************************************************************/ |
dflet | 0:1a07906111ec | 682 | void _sl_HandleAsync_Stop(void *pVoidBuf) |
dflet | 0:1a07906111ec | 683 | { |
dflet | 0:1a07906111ec | 684 | _BasicResponse_t *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
dflet | 0:1a07906111ec | 685 | |
dflet | 0:1a07906111ec | 686 | VERIFY_SOCKET_CB(NULL != g_pCB->StopCB.pAsyncRsp); |
dflet | 0:1a07906111ec | 687 | |
dflet | 0:1a07906111ec | 688 | _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); |
dflet | 0:1a07906111ec | 689 | |
dflet | 0:1a07906111ec | 690 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_BasicResponse_t)); |
dflet | 0:1a07906111ec | 691 | _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); |
dflet | 0:1a07906111ec | 692 | _cc3100_._driver._SlDrvProtectionObjUnLock(); |
dflet | 0:1a07906111ec | 693 | return; |
dflet | 0:1a07906111ec | 694 | } |
dflet | 0:1a07906111ec | 695 | |
dflet | 0:1a07906111ec | 696 | /****************************************************************************** |
dflet | 0:1a07906111ec | 697 | _SlDrvDeviceEventHandler - handles internally device async events |
dflet | 0:1a07906111ec | 698 | ******************************************************************************/ |
dflet | 0:1a07906111ec | 699 | void _SlDrvDeviceEventHandler(void *pArgs) |
dflet | 0:1a07906111ec | 700 | { |
dflet | 0:1a07906111ec | 701 | _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)pArgs; |
dflet | 0:1a07906111ec | 702 | |
dflet | 0:1a07906111ec | 703 | switch(pHdr->GenHeader.Opcode) { |
dflet | 0:1a07906111ec | 704 | case SL_OPCODE_DEVICE_INITCOMPLETE: |
dflet | 0:1a07906111ec | 705 | _cc3100_._sl_HandleAsync_InitComplete(pHdr); |
dflet | 0:1a07906111ec | 706 | |
dflet | 0:1a07906111ec | 707 | break; |
dflet | 0:1a07906111ec | 708 | case SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE: |
dflet | 0:1a07906111ec | 709 | _sl_HandleAsync_Stop(pHdr); |
dflet | 0:1a07906111ec | 710 | |
dflet | 0:1a07906111ec | 711 | break; |
dflet | 0:1a07906111ec | 712 | |
dflet | 0:1a07906111ec | 713 | |
dflet | 0:1a07906111ec | 714 | case SL_OPCODE_DEVICE_ABORT: |
dflet | 0:1a07906111ec | 715 | { |
dflet | 0:1a07906111ec | 716 | #if defined (sl_GeneralEvtHdlr) || defined(EXT_LIB_REGISTERED_GENERAL_EVENTS) |
dflet | 0:1a07906111ec | 717 | SlDeviceEvent_t devHandler; |
dflet | 0:1a07906111ec | 718 | devHandler.Event = SL_DEVICE_ABORT_ERROR_EVENT; |
dflet | 0:1a07906111ec | 719 | devHandler.EventData.deviceReport.AbortType = *((uint32_t*)pArgs + 2); |
dflet | 0:1a07906111ec | 720 | devHandler.EventData.deviceReport.AbortData = *((uint32_t*)pArgs + 3); |
dflet | 0:1a07906111ec | 721 | _SlDrvHandleGeneralEvents(&devHandler); |
dflet | 0:1a07906111ec | 722 | #endif |
dflet | 0:1a07906111ec | 723 | } |
dflet | 0:1a07906111ec | 724 | break; |
dflet | 0:1a07906111ec | 725 | case SL_OPCODE_DEVICE_DEVICEASYNCFATALERROR: |
dflet | 0:1a07906111ec | 726 | #if defined (sl_GeneralEvtHdlr) || defined(EXT_LIB_REGISTERED_GENERAL_EVENTS) |
dflet | 0:1a07906111ec | 727 | { |
dflet | 0:1a07906111ec | 728 | _BasicResponse_t *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(pHdr); |
dflet | 0:1a07906111ec | 729 | SlDeviceEvent_t devHandler; |
dflet | 0:1a07906111ec | 730 | devHandler.Event = SL_DEVICE_FATAL_ERROR_EVENT; |
dflet | 0:1a07906111ec | 731 | devHandler.EventData.deviceEvent.status = pMsgArgs->status & 0xFF; |
dflet | 0:1a07906111ec | 732 | devHandler.EventData.deviceEvent.sender = (SlErrorSender_e)((pMsgArgs->status >> 8) & 0xFF); |
dflet | 0:1a07906111ec | 733 | _SlDrvHandleGeneralEvents(&devHandler); |
dflet | 0:1a07906111ec | 734 | } |
dflet | 0:1a07906111ec | 735 | #endif |
dflet | 0:1a07906111ec | 736 | break; |
dflet | 0:1a07906111ec | 737 | default: |
dflet | 0:1a07906111ec | 738 | SL_ERROR_TRACE2(MSG_306, "ASSERT: _SlDrvDeviceEventHandler : invalid opcode = 0x%x = %i", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode); |
dflet | 0:1a07906111ec | 739 | //printf("ASSERT: _SlDrvDeviceEventHandler : invalid opcode = 0x%x = %i", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode); |
dflet | 0:1a07906111ec | 740 | |
dflet | 0:1a07906111ec | 741 | } |
dflet | 0:1a07906111ec | 742 | } |
dflet | 0:1a07906111ec | 743 | |
dflet | 0:1a07906111ec | 744 | /*****************************************************************************/ |
dflet | 0:1a07906111ec | 745 | /* _SlDrvNetAppEventHandler */ |
dflet | 0:1a07906111ec | 746 | /*****************************************************************************/ |
dflet | 0:1a07906111ec | 747 | void _SlDrvNetAppEventHandler(void *pArgs) |
dflet | 0:1a07906111ec | 748 | { |
dflet | 0:1a07906111ec | 749 | _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)pArgs; |
dflet | 0:1a07906111ec | 750 | #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) |
dflet | 0:1a07906111ec | 751 | SlHttpServerEvent_t httpServerEvent; |
dflet | 0:1a07906111ec | 752 | SlHttpServerResponse_t httpServerResponse; |
dflet | 0:1a07906111ec | 753 | #endif |
dflet | 0:1a07906111ec | 754 | switch(pHdr->GenHeader.Opcode) { |
dflet | 0:1a07906111ec | 755 | case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE: |
dflet | 0:1a07906111ec | 756 | case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE_V6: |
dflet | 0:1a07906111ec | 757 | _sl_HandleAsync_DnsGetHostByName(pArgs); |
dflet | 0:1a07906111ec | 758 | break; |
dflet | 0:1a07906111ec | 759 | #ifndef SL_TINY_EXT |
dflet | 0:1a07906111ec | 760 | case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE: |
dflet | 0:1a07906111ec | 761 | case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE_V6: |
dflet | 0:1a07906111ec | 762 | _sl_HandleAsync_DnsGetHostByService(pArgs); |
dflet | 0:1a07906111ec | 763 | break; |
dflet | 0:1a07906111ec | 764 | case SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE: |
dflet | 0:1a07906111ec | 765 | _sl_HandleAsync_PingResponse(pArgs); |
dflet | 0:1a07906111ec | 766 | break; |
dflet | 0:1a07906111ec | 767 | #endif |
dflet | 0:1a07906111ec | 768 | |
dflet | 0:1a07906111ec | 769 | #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) |
dflet | 0:1a07906111ec | 770 | case SL_OPCODE_NETAPP_HTTPGETTOKENVALUE: { |
dflet | 0:1a07906111ec | 771 | |
dflet | 0:1a07906111ec | 772 | uint8_t *pTokenName; |
dflet | 0:1a07906111ec | 773 | slHttpServerData_t Token_value; |
dflet | 0:1a07906111ec | 774 | sl_NetAppHttpServerGetToken_t *httpGetToken = (sl_NetAppHttpServerGetToken_t *)_SL_RESP_ARGS_START(pHdr); |
dflet | 0:1a07906111ec | 775 | pTokenName = (uint8_t *)((sl_NetAppHttpServerGetToken_t *)httpGetToken + 1); |
dflet | 0:1a07906111ec | 776 | |
dflet | 0:1a07906111ec | 777 | httpServerResponse.Response = SL_NETAPP_HTTPSETTOKENVALUE; |
dflet | 0:1a07906111ec | 778 | httpServerResponse.ResponseData.token_value.len = MAX_TOKEN_VALUE_LEN; |
dflet | 0:1a07906111ec | 779 | |
dflet | 0:1a07906111ec | 780 | /* Reuse the async buffer for getting the token value response from the user */ |
dflet | 0:1a07906111ec | 781 | httpServerResponse.ResponseData.token_value.data = (uint8_t *)_SL_RESP_ARGS_START(pHdr) + MAX_TOKEN_NAME_LEN; |
dflet | 0:1a07906111ec | 782 | httpServerEvent.Event = SL_NETAPP_HTTPGETTOKENVALUE_EVENT; |
dflet | 0:1a07906111ec | 783 | |
dflet | 0:1a07906111ec | 784 | httpServerEvent.EventData.httpTokenName.len = httpGetToken->token_name_len; |
dflet | 0:1a07906111ec | 785 | httpServerEvent.EventData.httpTokenName.data = pTokenName; |
dflet | 0:1a07906111ec | 786 | |
dflet | 0:1a07906111ec | 787 | Token_value.token_name = pTokenName; |
dflet | 0:1a07906111ec | 788 | |
dflet | 0:1a07906111ec | 789 | _SlDrvHandleHttpServerEvents (&httpServerEvent, &httpServerResponse); |
dflet | 0:1a07906111ec | 790 | |
dflet | 0:1a07906111ec | 791 | Token_value.value_len = httpServerResponse.ResponseData.token_value.len; |
dflet | 0:1a07906111ec | 792 | Token_value.name_len = httpServerEvent.EventData.httpTokenName.len; |
dflet | 0:1a07906111ec | 793 | |
dflet | 0:1a07906111ec | 794 | Token_value.token_value = httpServerResponse.ResponseData.token_value.data; |
dflet | 0:1a07906111ec | 795 | |
dflet | 0:1a07906111ec | 796 | |
dflet | 0:1a07906111ec | 797 | _cc3100_._netapp.sl_NetAppSendTokenValue(&Token_value); |
dflet | 0:1a07906111ec | 798 | #endif |
dflet | 0:1a07906111ec | 799 | } |
dflet | 0:1a07906111ec | 800 | break; |
dflet | 0:1a07906111ec | 801 | |
dflet | 0:1a07906111ec | 802 | case SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE: { |
dflet | 0:1a07906111ec | 803 | #ifdef sl_HttpServerCallback |
dflet | 0:1a07906111ec | 804 | uint8_t *pPostParams; |
dflet | 0:1a07906111ec | 805 | |
dflet | 0:1a07906111ec | 806 | sl_NetAppHttpServerPostToken_t *httpPostTokenArgs = (sl_NetAppHttpServerPostToken_t *)_SL_RESP_ARGS_START(pHdr); |
dflet | 0:1a07906111ec | 807 | pPostParams = (uint8_t *)((sl_NetAppHttpServerPostToken_t *)httpPostTokenArgs + 1); |
dflet | 0:1a07906111ec | 808 | |
dflet | 0:1a07906111ec | 809 | httpServerEvent.Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT; |
dflet | 0:1a07906111ec | 810 | |
dflet | 0:1a07906111ec | 811 | httpServerEvent.EventData.httpPostData.action.len = httpPostTokenArgs->post_action_len; |
dflet | 0:1a07906111ec | 812 | httpServerEvent.EventData.httpPostData.action.data = pPostParams; |
dflet | 0:1a07906111ec | 813 | pPostParams+=httpPostTokenArgs->post_action_len; |
dflet | 0:1a07906111ec | 814 | |
dflet | 0:1a07906111ec | 815 | httpServerEvent.EventData.httpPostData.token_name.len = httpPostTokenArgs->token_name_len; |
dflet | 0:1a07906111ec | 816 | httpServerEvent.EventData.httpPostData.token_name.data = pPostParams; |
dflet | 0:1a07906111ec | 817 | pPostParams+=httpPostTokenArgs->token_name_len; |
dflet | 0:1a07906111ec | 818 | |
dflet | 0:1a07906111ec | 819 | httpServerEvent.EventData.httpPostData.token_value.len = httpPostTokenArgs->token_value_len; |
dflet | 0:1a07906111ec | 820 | httpServerEvent.EventData.httpPostData.token_value.data = pPostParams; |
dflet | 0:1a07906111ec | 821 | |
dflet | 0:1a07906111ec | 822 | httpServerResponse.Response = SL_NETAPP_RESPONSE_NONE; |
dflet | 0:1a07906111ec | 823 | |
dflet | 0:1a07906111ec | 824 | |
dflet | 0:1a07906111ec | 825 | _SlDrvHandleHttpServerEvents (&httpServerEvent, &httpServerResponse); |
dflet | 0:1a07906111ec | 826 | } |
dflet | 0:1a07906111ec | 827 | break; |
dflet | 0:1a07906111ec | 828 | #endif |
dflet | 0:1a07906111ec | 829 | default: |
dflet | 0:1a07906111ec | 830 | SL_ERROR_TRACE2(MSG_305, "ASSERT: _SlDrvNetAppEventHandler : invalid opcode = 0x%x = %i", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode); |
dflet | 0:1a07906111ec | 831 | VERIFY_PROTOCOL(0); |
dflet | 0:1a07906111ec | 832 | } |
dflet | 0:1a07906111ec | 833 | } |
dflet | 0:1a07906111ec | 834 | |
dflet | 0:1a07906111ec | 835 | /* |
dflet | 0:1a07906111ec | 836 | * ASYNCHRONOUS EVENT HANDLERS -- Start |
dflet | 0:1a07906111ec | 837 | */ |
dflet | 0:1a07906111ec | 838 | |
dflet | 0:1a07906111ec | 839 | /*! |
dflet | 0:1a07906111ec | 840 | \brief This function handles WLAN events |
dflet | 0:1a07906111ec | 841 | |
dflet | 0:1a07906111ec | 842 | \param[in] pWlanEvent is the event passed to the handler |
dflet | 0:1a07906111ec | 843 | |
dflet | 0:1a07906111ec | 844 | \return None |
dflet | 0:1a07906111ec | 845 | |
dflet | 0:1a07906111ec | 846 | \note |
dflet | 0:1a07906111ec | 847 | |
dflet | 0:1a07906111ec | 848 | \warning |
dflet | 0:1a07906111ec | 849 | */ |
dflet | 0:1a07906111ec | 850 | #if (defined(sl_WlanEvtHdlr)) |
dflet | 0:1a07906111ec | 851 | void SimpleLinkWlanEventHandler(SlWlanEvent_t *pWlanEvent) |
dflet | 0:1a07906111ec | 852 | { |
dflet | 0:1a07906111ec | 853 | unsigned char g_ucConnectionSSID[32+1]; //Connection SSID |
dflet | 0:1a07906111ec | 854 | unsigned char g_ucConnectionBSSID[6]; //Connection BSSID |
dflet | 0:1a07906111ec | 855 | |
dflet | 0:1a07906111ec | 856 | if(pWlanEvent == NULL) |
dflet | 0:1a07906111ec | 857 | Uart_Write((uint8_t*)" [WLAN EVENT] NULL Pointer Error \n\r"); |
dflet | 0:1a07906111ec | 858 | |
dflet | 0:1a07906111ec | 859 | switch(pWlanEvent->Event) { |
dflet | 0:1a07906111ec | 860 | case SL_WLAN_CONNECT_EVENT: { |
dflet | 0:1a07906111ec | 861 | _cc3100_.SET_STATUS_BIT(g_Status, STATUS_BIT_CONNECTION); |
dflet | 0:1a07906111ec | 862 | |
dflet | 0:1a07906111ec | 863 | // Copy new connection SSID and BSSID to global parameters |
dflet | 0:1a07906111ec | 864 | memcpy(g_ucConnectionSSID,pWlanEvent->EventData. |
dflet | 0:1a07906111ec | 865 | STAandP2PModeWlanConnected.ssid_name, |
dflet | 0:1a07906111ec | 866 | pWlanEvent->EventData.STAandP2PModeWlanConnected.ssid_len); |
dflet | 0:1a07906111ec | 867 | memcpy(g_ucConnectionBSSID, |
dflet | 0:1a07906111ec | 868 | pWlanEvent->EventData.STAandP2PModeWlanConnected.bssid, |
dflet | 0:1a07906111ec | 869 | SL_BSSID_LENGTH); |
dflet | 0:1a07906111ec | 870 | |
dflet | 0:1a07906111ec | 871 | memset(print_buf, 0x00, PRINT_BUF_LEN); |
dflet | 0:1a07906111ec | 872 | sprintf((char*) print_buf, "[WLAN EVENT] STA Connected to the AP: %s ,""BSSID: %x:%x:%x:%x:%x:%x\n\r", |
dflet | 0:1a07906111ec | 873 | g_ucConnectionSSID,g_ucConnectionBSSID[0], |
dflet | 0:1a07906111ec | 874 | g_ucConnectionBSSID[1],g_ucConnectionBSSID[2], |
dflet | 0:1a07906111ec | 875 | g_ucConnectionBSSID[3],g_ucConnectionBSSID[4], |
dflet | 0:1a07906111ec | 876 | g_ucConnectionBSSID[5]); |
dflet | 0:1a07906111ec | 877 | Uart_Write((uint8_t *) print_buf); |
dflet | 0:1a07906111ec | 878 | /* |
dflet | 0:1a07906111ec | 879 | * Information about the connected AP (like name, MAC etc) will be |
dflet | 0:1a07906111ec | 880 | * available in 'slWlanConnectAsyncResponse_t' - Applications |
dflet | 0:1a07906111ec | 881 | * can use it if required |
dflet | 0:1a07906111ec | 882 | * |
dflet | 0:1a07906111ec | 883 | * slWlanConnectAsyncResponse_t *pEventData = NULL; |
dflet | 0:1a07906111ec | 884 | * pEventData = &pWlanEvent->EventData.STAandP2PModeWlanConnected; |
dflet | 0:1a07906111ec | 885 | * |
dflet | 0:1a07906111ec | 886 | */ |
dflet | 0:1a07906111ec | 887 | } |
dflet | 0:1a07906111ec | 888 | break; |
dflet | 0:1a07906111ec | 889 | |
dflet | 0:1a07906111ec | 890 | case SL_WLAN_DISCONNECT_EVENT: { |
dflet | 0:1a07906111ec | 891 | slWlanConnectAsyncResponse_t* pEventData = NULL; |
dflet | 0:1a07906111ec | 892 | |
dflet | 0:1a07906111ec | 893 | _cc3100_.CLR_STATUS_BIT(g_Status, STATUS_BIT_CONNECTION); |
dflet | 0:1a07906111ec | 894 | _cc3100_.CLR_STATUS_BIT(g_Status, STATUS_BIT_IP_ACQUIRED); |
dflet | 0:1a07906111ec | 895 | |
dflet | 0:1a07906111ec | 896 | pEventData = &pWlanEvent->EventData.STAandP2PModeDisconnected; |
dflet | 0:1a07906111ec | 897 | |
dflet | 0:1a07906111ec | 898 | /* If the user has initiated 'Disconnect' request, 'reason_code' is SL_USER_INITIATED_DISCONNECTION */ |
dflet | 0:1a07906111ec | 899 | if(SL_USER_INITIATED_DISCONNECTION == pEventData->reason_code) { |
dflet | 0:1a07906111ec | 900 | memset(print_buf, 0x00, PRINT_BUF_LEN); |
dflet | 0:1a07906111ec | 901 | sprintf((char*) print_buf, "[WLAN EVENT]Device disconnected from the AP: %s," |
dflet | 0:1a07906111ec | 902 | "BSSID: %x:%x:%x:%x:%x:%x on application's request \n\r", |
dflet | 0:1a07906111ec | 903 | g_ucConnectionSSID,g_ucConnectionBSSID[0], |
dflet | 0:1a07906111ec | 904 | g_ucConnectionBSSID[1],g_ucConnectionBSSID[2], |
dflet | 0:1a07906111ec | 905 | g_ucConnectionBSSID[3],g_ucConnectionBSSID[4], |
dflet | 0:1a07906111ec | 906 | g_ucConnectionBSSID[5]); |
dflet | 0:1a07906111ec | 907 | Uart_Write((uint8_t *) print_buf); |
dflet | 0:1a07906111ec | 908 | } else { |
dflet | 0:1a07906111ec | 909 | memset(print_buf, 0x00, PRINT_BUF_LEN); |
dflet | 0:1a07906111ec | 910 | sprintf((char*) print_buf, "[WLAN ERROR]Device disconnected from the AP AP: %s," |
dflet | 0:1a07906111ec | 911 | "BSSID: %x:%x:%x:%x:%x:%x on an ERROR..!! \n\r", |
dflet | 0:1a07906111ec | 912 | g_ucConnectionSSID,g_ucConnectionBSSID[0], |
dflet | 0:1a07906111ec | 913 | g_ucConnectionBSSID[1],g_ucConnectionBSSID[2], |
dflet | 0:1a07906111ec | 914 | g_ucConnectionBSSID[3],g_ucConnectionBSSID[4], |
dflet | 0:1a07906111ec | 915 | g_ucConnectionBSSID[5]); |
dflet | 0:1a07906111ec | 916 | Uart_Write((uint8_t *) print_buf); |
dflet | 0:1a07906111ec | 917 | } |
dflet | 0:1a07906111ec | 918 | memset(g_ucConnectionSSID,0,sizeof(g_ucConnectionSSID)); |
dflet | 0:1a07906111ec | 919 | memset(g_ucConnectionBSSID,0,sizeof(g_ucConnectionBSSID)); |
dflet | 0:1a07906111ec | 920 | } |
dflet | 0:1a07906111ec | 921 | break; |
dflet | 0:1a07906111ec | 922 | |
dflet | 0:1a07906111ec | 923 | case SL_WLAN_STA_CONNECTED_EVENT: { |
dflet | 0:1a07906111ec | 924 | _cc3100_.SET_STATUS_BIT(g_Status, STATUS_BIT_STA_CONNECTED); |
dflet | 0:1a07906111ec | 925 | } |
dflet | 0:1a07906111ec | 926 | break; |
dflet | 0:1a07906111ec | 927 | |
dflet | 0:1a07906111ec | 928 | case SL_WLAN_STA_DISCONNECTED_EVENT: { |
dflet | 0:1a07906111ec | 929 | _cc3100_.CLR_STATUS_BIT(g_Status, STATUS_BIT_STA_CONNECTED); |
dflet | 0:1a07906111ec | 930 | _cc3100_.CLR_STATUS_BIT(g_Status, STATUS_BIT_IP_LEASED); |
dflet | 0:1a07906111ec | 931 | } |
dflet | 0:1a07906111ec | 932 | break; |
dflet | 0:1a07906111ec | 933 | |
dflet | 0:1a07906111ec | 934 | default: { |
dflet | 0:1a07906111ec | 935 | memset(print_buf, 0x00, PRINT_BUF_LEN); |
dflet | 0:1a07906111ec | 936 | sprintf((char*) print_buf, "[WLAN EVENT] Unexpected event [0x%x]\n\r",pWlanEvent->Event); |
dflet | 0:1a07906111ec | 937 | Uart_Write((uint8_t *) print_buf); |
dflet | 0:1a07906111ec | 938 | } |
dflet | 0:1a07906111ec | 939 | break; |
dflet | 0:1a07906111ec | 940 | } |
dflet | 0:1a07906111ec | 941 | } |
dflet | 0:1a07906111ec | 942 | #endif |
dflet | 0:1a07906111ec | 943 | |
dflet | 0:1a07906111ec | 944 | /*! |
dflet | 0:1a07906111ec | 945 | \brief This function handles events for IP address acquisition via DHCP |
dflet | 0:1a07906111ec | 946 | indication |
dflet | 0:1a07906111ec | 947 | |
dflet | 0:1a07906111ec | 948 | \param[in] pNetAppEvent is the event passed to the handler |
dflet | 0:1a07906111ec | 949 | |
dflet | 0:1a07906111ec | 950 | \return None |
dflet | 0:1a07906111ec | 951 | |
dflet | 0:1a07906111ec | 952 | \note |
dflet | 0:1a07906111ec | 953 | |
dflet | 0:1a07906111ec | 954 | \warning |
dflet | 0:1a07906111ec | 955 | */ |
dflet | 0:1a07906111ec | 956 | #if (defined(sl_NetAppEvtHdlr)) |
dflet | 0:1a07906111ec | 957 | void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent) |
dflet | 0:1a07906111ec | 958 | { |
dflet | 0:1a07906111ec | 959 | |
dflet | 0:1a07906111ec | 960 | if(pNetAppEvent == NULL){ |
dflet | 0:1a07906111ec | 961 | Uart_Write((uint8_t *)" [NETAPP EVENT] NULL Pointer Error \n\r"); |
dflet | 0:1a07906111ec | 962 | } |
dflet | 0:1a07906111ec | 963 | |
dflet | 0:1a07906111ec | 964 | switch(pNetAppEvent->Event) { |
dflet | 0:1a07906111ec | 965 | case SL_NETAPP_IPV4_IPACQUIRED_EVENT: { |
dflet | 0:1a07906111ec | 966 | SlIpV4AcquiredAsync_t *pEventData = NULL; |
dflet | 0:1a07906111ec | 967 | _cc3100_.SET_STATUS_BIT(g_Status, STATUS_BIT_IP_ACQUIRED); |
dflet | 0:1a07906111ec | 968 | pEventData = &pNetAppEvent->EventData.ipAcquiredV4; |
dflet | 0:1a07906111ec | 969 | g_GatewayIP = pEventData->gateway; |
dflet | 0:1a07906111ec | 970 | |
dflet | 0:1a07906111ec | 971 | memset(print_buf, 0x00, PRINT_BUF_LEN); |
dflet | 0:1a07906111ec | 972 | sprintf((char*) print_buf, "[NETAPP EVENT] IP Acquired: IP=%d.%d.%d.%d , ""Gateway=%d.%d.%d.%d\n\r", |
dflet | 0:1a07906111ec | 973 | _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,3), |
dflet | 0:1a07906111ec | 974 | _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,2), |
dflet | 0:1a07906111ec | 975 | _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,1), |
dflet | 0:1a07906111ec | 976 | _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,0), |
dflet | 0:1a07906111ec | 977 | _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,3), |
dflet | 0:1a07906111ec | 978 | _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,2), |
dflet | 0:1a07906111ec | 979 | _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,1), |
dflet | 0:1a07906111ec | 980 | _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,0)); |
dflet | 0:1a07906111ec | 981 | Uart_Write((uint8_t *) print_buf); |
dflet | 0:1a07906111ec | 982 | |
dflet | 0:1a07906111ec | 983 | } |
dflet | 0:1a07906111ec | 984 | break; |
dflet | 0:1a07906111ec | 985 | |
dflet | 0:1a07906111ec | 986 | case SL_NETAPP_IP_LEASED_EVENT: { |
dflet | 0:1a07906111ec | 987 | g_StationIP = pNetAppEvent->EventData.ipLeased.ip_address; |
dflet | 0:1a07906111ec | 988 | _cc3100_.SET_STATUS_BIT(g_Status, STATUS_BIT_IP_LEASED); |
dflet | 0:1a07906111ec | 989 | |
dflet | 0:1a07906111ec | 990 | } |
dflet | 0:1a07906111ec | 991 | break; |
dflet | 0:1a07906111ec | 992 | |
dflet | 0:1a07906111ec | 993 | default: { |
dflet | 0:1a07906111ec | 994 | memset(print_buf, 0x00, PRINT_BUF_LEN); |
dflet | 0:1a07906111ec | 995 | sprintf((char*) print_buf, "[NETAPP EVENT] Unexpected event [0x%x] \n\r",pNetAppEvent->Event); |
dflet | 0:1a07906111ec | 996 | Uart_Write((uint8_t *) print_buf); |
dflet | 0:1a07906111ec | 997 | } |
dflet | 0:1a07906111ec | 998 | break; |
dflet | 0:1a07906111ec | 999 | } |
dflet | 0:1a07906111ec | 1000 | } |
dflet | 0:1a07906111ec | 1001 | #endif |
dflet | 0:1a07906111ec | 1002 | |
dflet | 0:1a07906111ec | 1003 | /*! |
dflet | 0:1a07906111ec | 1004 | \brief This function handles socket events indication |
dflet | 0:1a07906111ec | 1005 | |
dflet | 0:1a07906111ec | 1006 | \param[in] pSock is the event passed to the handler |
dflet | 0:1a07906111ec | 1007 | |
dflet | 0:1a07906111ec | 1008 | \return None |
dflet | 0:1a07906111ec | 1009 | */ |
dflet | 0:1a07906111ec | 1010 | #if (defined(sl_SockEvtHdlr)) |
dflet | 0:1a07906111ec | 1011 | void SimpleLinkSockEventHandler(SlSockEvent_t *pSock) |
dflet | 0:1a07906111ec | 1012 | { |
dflet | 0:1a07906111ec | 1013 | if(pSock == NULL) |
dflet | 0:1a07906111ec | 1014 | Uart_Write((uint8_t *)" [SOCK EVENT] NULL Pointer Error \n\r"); |
dflet | 0:1a07906111ec | 1015 | |
dflet | 0:1a07906111ec | 1016 | switch( pSock->Event ) |
dflet | 0:1a07906111ec | 1017 | { |
dflet | 0:1a07906111ec | 1018 | case SL_SOCKET_TX_FAILED_EVENT: |
dflet | 0:1a07906111ec | 1019 | /* |
dflet | 0:1a07906111ec | 1020 | * TX Failed |
dflet | 0:1a07906111ec | 1021 | * |
dflet | 0:1a07906111ec | 1022 | * Information about the socket descriptor and status will be |
dflet | 0:1a07906111ec | 1023 | * available in 'SlSockEventData_t' - Applications can use it if |
dflet | 0:1a07906111ec | 1024 | * required |
dflet | 0:1a07906111ec | 1025 | * |
dflet | 0:1a07906111ec | 1026 | * SlSockEventData_t *pEventData = NULL; |
dflet | 0:1a07906111ec | 1027 | * pEventData = & pSock->EventData; |
dflet | 0:1a07906111ec | 1028 | */ |
dflet | 0:1a07906111ec | 1029 | |
dflet | 0:1a07906111ec | 1030 | switch( pSock->socketAsyncEvent.SockTxFailData.status ) |
dflet | 0:1a07906111ec | 1031 | { |
dflet | 0:1a07906111ec | 1032 | case SL_ECLOSE: |
dflet | 0:1a07906111ec | 1033 | Uart_Write((uint8_t *)" [SOCK EVENT] Close socket operation, failed to transmit all queued packets\n\r"); |
dflet | 0:1a07906111ec | 1034 | break; |
dflet | 0:1a07906111ec | 1035 | default: |
dflet | 0:1a07906111ec | 1036 | memset(print_buf, 0x00, PRINT_BUF_LEN); |
dflet | 0:1a07906111ec | 1037 | sprintf((char*) print_buf, "[SOCK ERROR] - TX FAILED : socket %d , reason""(%d) \n\n", pSock->socketAsyncEvent.SockTxFailData.sd, pSock->socketAsyncEvent.SockTxFailData.status); |
dflet | 0:1a07906111ec | 1038 | Uart_Write((uint8_t *) print_buf); |
dflet | 0:1a07906111ec | 1039 | break; |
dflet | 0:1a07906111ec | 1040 | } |
dflet | 0:1a07906111ec | 1041 | break; |
dflet | 0:1a07906111ec | 1042 | |
dflet | 0:1a07906111ec | 1043 | default: |
dflet | 0:1a07906111ec | 1044 | memset(print_buf, 0x00, PRINT_BUF_LEN); |
dflet | 0:1a07906111ec | 1045 | sprintf((char*) print_buf, "[SOCK EVENT] - Unexpected Event [%x0x]\n\n",pSock->Event); |
dflet | 0:1a07906111ec | 1046 | Uart_Write((uint8_t *) print_buf); |
dflet | 0:1a07906111ec | 1047 | break; |
dflet | 0:1a07906111ec | 1048 | } |
dflet | 0:1a07906111ec | 1049 | } |
dflet | 0:1a07906111ec | 1050 | #endif |
dflet | 0:1a07906111ec | 1051 | |
dflet | 0:1a07906111ec | 1052 | /*! |
dflet | 0:1a07906111ec | 1053 | \brief This function handles callback for the HTTP server events |
dflet | 0:1a07906111ec | 1054 | |
dflet | 0:1a07906111ec | 1055 | \param[in] pHttpEvent - Contains the relevant event information |
dflet | 0:1a07906111ec | 1056 | \param[in] pHttpResponse - Should be filled by the user with the |
dflet | 0:1a07906111ec | 1057 | relevant response information |
dflet | 0:1a07906111ec | 1058 | |
dflet | 0:1a07906111ec | 1059 | \return None |
dflet | 0:1a07906111ec | 1060 | |
dflet | 0:1a07906111ec | 1061 | \note |
dflet | 0:1a07906111ec | 1062 | |
dflet | 0:1a07906111ec | 1063 | \warning |
dflet | 0:1a07906111ec | 1064 | */ |
dflet | 0:1a07906111ec | 1065 | #if (defined(sl_HttpServerCallback)) |
dflet | 0:1a07906111ec | 1066 | void SimpleLinkHttpServerCallback(SlHttpServerEvent_t *pHttpEvent, SlHttpServerResponse_t *pHttpResponse) |
dflet | 0:1a07906111ec | 1067 | { |
dflet | 0:1a07906111ec | 1068 | /* |
dflet | 0:1a07906111ec | 1069 | * This application doesn't work with HTTP server - Hence these |
dflet | 0:1a07906111ec | 1070 | * events are not handled here |
dflet | 0:1a07906111ec | 1071 | */ |
dflet | 0:1a07906111ec | 1072 | Uart_Write((uint8_t *)" [HTTP EVENT] Unexpected event \n\r"); |
dflet | 0:1a07906111ec | 1073 | } |
dflet | 0:1a07906111ec | 1074 | #endif |
dflet | 0:1a07906111ec | 1075 | /*! |
dflet | 0:1a07906111ec | 1076 | \brief This function handles general error events indication |
dflet | 0:1a07906111ec | 1077 | |
dflet | 0:1a07906111ec | 1078 | \param[in] pDevEvent is the event passed to the handler |
dflet | 0:1a07906111ec | 1079 | |
dflet | 0:1a07906111ec | 1080 | \return None |
dflet | 0:1a07906111ec | 1081 | */ |
dflet | 0:1a07906111ec | 1082 | #if (defined(sl_GeneralEvtHdlr)) |
dflet | 0:1a07906111ec | 1083 | void SimpleLinkGeneralEventHandler(SlDeviceEvent_t *pDevEvent) |
dflet | 0:1a07906111ec | 1084 | { |
dflet | 0:1a07906111ec | 1085 | /* |
dflet | 0:1a07906111ec | 1086 | * Most of the general errors are not FATAL are are to be handled |
dflet | 0:1a07906111ec | 1087 | * appropriately by the application |
dflet | 0:1a07906111ec | 1088 | */ |
dflet | 0:1a07906111ec | 1089 | memset(print_buf, 0x00, PRINT_BUF_LEN); |
dflet | 0:1a07906111ec | 1090 | sprintf((char*) print_buf, "[GENERAL EVENT] - ID=[%d] Sender=[%d]\n\n", pDevEvent->EventData.deviceEvent.status, pDevEvent->EventData.deviceEvent.sender); |
dflet | 0:1a07906111ec | 1091 | Uart_Write((uint8_t *) print_buf); |
dflet | 0:1a07906111ec | 1092 | } |
dflet | 0:1a07906111ec | 1093 | #endif |
dflet | 0:1a07906111ec | 1094 | |
dflet | 0:1a07906111ec | 1095 | #ifdef __cplusplus |
dflet | 0:1a07906111ec | 1096 | } |
dflet | 0:1a07906111ec | 1097 | #endif /* __cplusplus */ |
dflet | 0:1a07906111ec | 1098 | |
dflet | 0:1a07906111ec | 1099 | //}//namespace |