Extending the X_NUCLEO_IDW01M1 to allow configuration of the board as an access point
Dependents: X_NUCLEO_IDW01M1_AP_Test
Fork of X_NUCLEO_IDW01M1 by
Spwf/utils/event_buffer.h@22:a1276b7d3b2d, 2016-07-07 (annotated)
- Committer:
- scsims
- Date:
- Thu Jul 07 13:54:06 2016 +0000
- Revision:
- 22:a1276b7d3b2d
- Parent:
- 1:bd9db471d47d
Added wifi_connected_to_ap extern to indicate when BSSS beacons have been lost/picked up. Also added some debugging to get a better idea as to what's going to and from the SPWF01SA.11 over the UART
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mridup | 0:dc55f40eb04f | 1 | /** |
mridup | 0:dc55f40eb04f | 2 | ****************************************************************************** |
mridup | 0:dc55f40eb04f | 3 | * @file event_buffer.h |
mridup | 0:dc55f40eb04f | 4 | * @author Central LAB |
mridup | 0:dc55f40eb04f | 5 | * @version V2.0.0 |
mridup | 0:dc55f40eb04f | 6 | * @date 10-February-2016 |
mridup | 0:dc55f40eb04f | 7 | * @brief Header File for Event Buffer management of the Wi-Fi module |
mridup | 0:dc55f40eb04f | 8 | ****************************************************************************** |
mridup | 0:dc55f40eb04f | 9 | * @attention |
mridup | 0:dc55f40eb04f | 10 | * |
mridup | 0:dc55f40eb04f | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
mridup | 0:dc55f40eb04f | 12 | * |
mridup | 0:dc55f40eb04f | 13 | * Redistribution and use in source and binary forms, with or without modification, |
mridup | 0:dc55f40eb04f | 14 | * are permitted provided that the following conditions are met: |
mridup | 0:dc55f40eb04f | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
mridup | 0:dc55f40eb04f | 16 | * this list of conditions and the following disclaimer. |
mridup | 0:dc55f40eb04f | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mridup | 0:dc55f40eb04f | 18 | * this list of conditions and the following disclaimer in the documentation |
mridup | 0:dc55f40eb04f | 19 | * and/or other materials provided with the distribution. |
mridup | 0:dc55f40eb04f | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mridup | 0:dc55f40eb04f | 21 | * may be used to endorse or promote products derived from this software |
mridup | 0:dc55f40eb04f | 22 | * without specific prior written permission. |
mridup | 0:dc55f40eb04f | 23 | * |
mridup | 0:dc55f40eb04f | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mridup | 0:dc55f40eb04f | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mridup | 0:dc55f40eb04f | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mridup | 0:dc55f40eb04f | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mridup | 0:dc55f40eb04f | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mridup | 0:dc55f40eb04f | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mridup | 0:dc55f40eb04f | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mridup | 0:dc55f40eb04f | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mridup | 0:dc55f40eb04f | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mridup | 0:dc55f40eb04f | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mridup | 0:dc55f40eb04f | 34 | * |
mridup | 0:dc55f40eb04f | 35 | ****************************************************************************** |
mridup | 0:dc55f40eb04f | 36 | */ |
mridup | 0:dc55f40eb04f | 37 | |
mridup | 0:dc55f40eb04f | 38 | /* Includes ------------------------------------------------------------------*/ |
mridup | 0:dc55f40eb04f | 39 | #include <stdio.h> |
mridup | 0:dc55f40eb04f | 40 | #include <string.h> |
mridup | 0:dc55f40eb04f | 41 | #include <stdint.h> |
mridup | 0:dc55f40eb04f | 42 | #include <stdlib.h> |
mridup | 0:dc55f40eb04f | 43 | #include "wifi_module.h" |
mridup | 0:dc55f40eb04f | 44 | #ifndef __EVENT_BUFFER_H |
mridup | 0:dc55f40eb04f | 45 | #define __EVENT_BUFFER_H |
mridup | 0:dc55f40eb04f | 46 | |
mridup | 0:dc55f40eb04f | 47 | /** @addtogroup BSP |
mridup | 0:dc55f40eb04f | 48 | * @{ |
mridup | 0:dc55f40eb04f | 49 | */ |
mridup | 0:dc55f40eb04f | 50 | |
mridup | 0:dc55f40eb04f | 51 | |
mridup | 0:dc55f40eb04f | 52 | /** @defgroup NUCLEO_WIFI_BUFFER_MGMT |
mridup | 0:dc55f40eb04f | 53 | * @brief Wi-Fi_driver modules |
mridup | 0:dc55f40eb04f | 54 | * @{ |
mridup | 0:dc55f40eb04f | 55 | */ |
mridup | 0:dc55f40eb04f | 56 | |
mridup | 0:dc55f40eb04f | 57 | |
mridup | 0:dc55f40eb04f | 58 | /** @defgroup NUCLEO_WIFI_BUFFER_MGMT_Private_TypesDefinitions |
mridup | 0:dc55f40eb04f | 59 | * @{ |
mridup | 0:dc55f40eb04f | 60 | */ |
mridup | 0:dc55f40eb04f | 61 | |
mridup | 0:dc55f40eb04f | 62 | /** |
mridup | 0:dc55f40eb04f | 63 | * @} |
mridup | 0:dc55f40eb04f | 64 | */ |
mridup | 0:dc55f40eb04f | 65 | |
mridup | 0:dc55f40eb04f | 66 | /** @defgroup NUCLEO_WIFI_BUFFER_MGMT_Private_Defines |
mridup | 0:dc55f40eb04f | 67 | * @{ |
mridup | 0:dc55f40eb04f | 68 | */ |
mridup | 0:dc55f40eb04f | 69 | |
mridup | 0:dc55f40eb04f | 70 | /** |
mridup | 0:dc55f40eb04f | 71 | * @} |
mridup | 0:dc55f40eb04f | 72 | */ |
mridup | 0:dc55f40eb04f | 73 | |
mridup | 0:dc55f40eb04f | 74 | /** @defgroup NUCLEO_WIFI_BUFFER_MGMT_Private_Macros |
mridup | 0:dc55f40eb04f | 75 | * @{ |
mridup | 0:dc55f40eb04f | 76 | */ |
mridup | 0:dc55f40eb04f | 77 | |
mridup | 0:dc55f40eb04f | 78 | |
mridup | 0:dc55f40eb04f | 79 | |
mridup | 0:dc55f40eb04f | 80 | /** |
mridup | 0:dc55f40eb04f | 81 | * @} |
mridup | 0:dc55f40eb04f | 82 | */ |
mridup | 0:dc55f40eb04f | 83 | |
mridup | 0:dc55f40eb04f | 84 | /** @defgroup NUCLEO_WIFI_BUFFER_MGMT_Private_Variables |
mridup | 0:dc55f40eb04f | 85 | * @{ |
mridup | 0:dc55f40eb04f | 86 | */ |
mridup | 0:dc55f40eb04f | 87 | |
mridup | 0:dc55f40eb04f | 88 | typedef enum |
mridup | 0:dc55f40eb04f | 89 | { |
mridup | 0:dc55f40eb04f | 90 | WIFI_NO_EVENT, |
mridup | 0:dc55f40eb04f | 91 | WIFI_WIND_EVENT = 0x0001, |
mridup | 0:dc55f40eb04f | 92 | WIFI_SOCK_ID_EVENT, |
mridup | 0:dc55f40eb04f | 93 | WIFI_GCFG_EVENT, |
mridup | 0:dc55f40eb04f | 94 | WIFI_GPIO_EVENT, |
mridup | 0:dc55f40eb04f | 95 | WIFI_OK_EVENT, |
mridup | 0:dc55f40eb04f | 96 | WIFI_ERROR_EVENT, |
mridup | 0:dc55f40eb04f | 97 | WIFI_STANDBY_CONFIG_EVENT, |
mridup | 0:dc55f40eb04f | 98 | WIFI_RESUME_CONFIG_EVENT, |
mridup | 0:dc55f40eb04f | 99 | WIFI_HTTP_EVENT, |
mridup | 0:dc55f40eb04f | 100 | WIFI_CLIENT_SOCKET_WRITE_EVENT, |
mridup | 0:dc55f40eb04f | 101 | WIFI_FILE_EVENT, |
mridup | 0:dc55f40eb04f | 102 | WIFI_CLIENT_SOCKET_OPEN_EVENT, |
mridup | 0:dc55f40eb04f | 103 | WIFI_CLIENT_SOCKET_CLOSE_EVENT, |
mridup | 0:dc55f40eb04f | 104 | WIFI_FW_UPDATE_EVENT, |
mridup | 0:dc55f40eb04f | 105 | } event_e; |
mridup | 0:dc55f40eb04f | 106 | |
mridup | 0:dc55f40eb04f | 107 | |
mridup | 0:dc55f40eb04f | 108 | typedef struct |
mridup | 0:dc55f40eb04f | 109 | { |
mridup | 0:dc55f40eb04f | 110 | uint32_t wind; |
mridup | 0:dc55f40eb04f | 111 | uint32_t data_length; |
mridup | 0:dc55f40eb04f | 112 | uint16_t socket_id; |
mridup | 0:dc55f40eb04f | 113 | uint8_t wind64_pending_packet_no; |
mridup | 0:dc55f40eb04f | 114 | wifi_bool enc; |
mridup | 0:dc55f40eb04f | 115 | wifi_bool ok_eval; |
mridup | 0:dc55f40eb04f | 116 | wifi_bool event_pop; |
mridup | 0:dc55f40eb04f | 117 | event_e event; |
mridup | 0:dc55f40eb04f | 118 | } event_s_TypeDef; |
mridup | 0:dc55f40eb04f | 119 | |
mridup | 0:dc55f40eb04f | 120 | struct event_buffer { |
mridup | 0:dc55f40eb04f | 121 | volatile int start; // position of first data from USART |
mridup | 0:dc55f40eb04f | 122 | volatile int end; // position of last data from USART |
mridup | 0:dc55f40eb04f | 123 | volatile int size; //Max size in terms of number of data packets (Total Bytes/size of each packet (8 bytes)) |
mridup | 0:dc55f40eb04f | 124 | volatile int count; // number of currently filled data packets (=size if full & =0 if empty) |
mridup | 0:dc55f40eb04f | 125 | |
mridup | 0:dc55f40eb04f | 126 | /*unsigned main buffer pointer*/ |
mridup | 0:dc55f40eb04f | 127 | event_s_TypeDef *element; |
mridup | 0:dc55f40eb04f | 128 | }; |
mridup | 0:dc55f40eb04f | 129 | |
mridup | 0:dc55f40eb04f | 130 | typedef struct event_buffer buffer_e; |
mridup | 0:dc55f40eb04f | 131 | |
mridup | 0:dc55f40eb04f | 132 | void event_init(buffer_e *buffer, int size); |
mridup | 0:dc55f40eb04f | 133 | int event_full(buffer_e *buffer); |
mridup | 0:dc55f40eb04f | 134 | int event_empty(buffer_e *buffer); |
mridup | 0:dc55f40eb04f | 135 | void push_eventbuffer(buffer_e *buffer, event_s_TypeDef data); |
mridup | 0:dc55f40eb04f | 136 | event_s_TypeDef * pop_eventbuffer_queue(buffer_e *buffer); |
mridup | 0:dc55f40eb04f | 137 | void reset_event(event_s_TypeDef *r_event); |
mridup | 0:dc55f40eb04f | 138 | |
mridup | 0:dc55f40eb04f | 139 | /** |
mridup | 0:dc55f40eb04f | 140 | * @} |
mridup | 0:dc55f40eb04f | 141 | */ |
mridup | 0:dc55f40eb04f | 142 | |
mridup | 0:dc55f40eb04f | 143 | /** |
mridup | 0:dc55f40eb04f | 144 | * @} |
mridup | 0:dc55f40eb04f | 145 | */ |
mridup | 0:dc55f40eb04f | 146 | |
mridup | 0:dc55f40eb04f | 147 | /** |
mridup | 0:dc55f40eb04f | 148 | * @} |
mridup | 0:dc55f40eb04f | 149 | */ |
mridup | 0:dc55f40eb04f | 150 | |
mridup | 0:dc55f40eb04f | 151 | /** |
mridup | 0:dc55f40eb04f | 152 | * @} |
mridup | 0:dc55f40eb04f | 153 | */ |
mridup | 0:dc55f40eb04f | 154 | |
mridup | 0:dc55f40eb04f | 155 | |
mridup | 0:dc55f40eb04f | 156 | |
mridup | 0:dc55f40eb04f | 157 | #endif |