libwebsockets
Lightweight C library for HTML5 websockets
lws-freertos.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2020 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  *
24  * This is included from libwebsockets.h if LWS_PLAT_FREERTOS
25  */
26 
27 typedef int lws_sockfd_type;
28 typedef int lws_filefd_type;
29 
30 #if defined(LWS_AMAZON_RTOS)
31 #include <FreeRTOS.h>
32 #include <event_groups.h>
33 #include <string.h>
34 #include "timers.h"
35 #include <lwip/sockets.h>
36 
37 /*
38  * Later lwip (at least 2.1.12) already defines these in its own headers
39  * protected by the same test as used here... if POLLIN / POLLOUT already exist
40  * then assume no need to declare those and struct pollfd.
41  *
42  * Older lwip needs these declarations done here.
43  */
44 
45 #if !defined(POLLIN) && !defined(POLLOUT)
46 
47 struct pollfd {
48  lws_sockfd_type fd;
49  short events;
50  short revents;
51 };
52 #define POLLIN 0x0001
53 #define POLLPRI 0x0002
54 #define POLLOUT 0x0004
55 #define POLLERR 0x0008
56 #define POLLHUP 0x0010
57 #define POLLNVAL 0x0020
58 
59 #endif
60 
61 #else /* LWS_AMAZON_RTOS */
62 #include <freertos/FreeRTOS.h>
63 #include <freertos/event_groups.h>
64 #include <string.h>
65 #include "esp_wifi.h"
66 #include "esp_system.h"
67 #include "esp_event.h"
68 //#include "esp_event_loop.h"
69 #include "nvs.h"
70 #include "driver/gpio.h"
71 #include "esp_spi_flash.h"
72 #include "freertos/timers.h"
73 
74 #if defined(LWS_ESP_PLATFORM)
75 #include "lwip/sockets.h"
76 #include "lwip/netdb.h"
77 #if defined(LWS_WITH_DRIVERS)
78 #include "libwebsockets/lws-gpio.h"
79 extern const lws_gpio_ops_t lws_gpio_plat;
80 #endif
81 #endif
82 
83 #endif /* LWS_AMAZON_RTOS */
84 
85 #if !defined(CONFIG_FREERTOS_HZ)
86 #define CONFIG_FREERTOS_HZ 100
87 #endif
Definition: lws-gpio.h:52