From e9faf132b46d29e4a2ceb5042d4cd8e68882264a Mon Sep 17 00:00:00 2001 From: Alexey Gerenkov Date: Wed, 17 Jul 2019 15:53:23 +0300 Subject: [PATCH 01/36] tools: Update recommended OpenOCD version to v0.10.0-esp32-20190708 --- tools/tools.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/tools.json b/tools/tools.json index 5bbed7e8b..17ee68efe 100644 --- a/tools/tools.json +++ b/tools/tools.json @@ -190,26 +190,26 @@ "versions": [ { "linux-amd64": { - "sha256": "e5b5579edffde090e426b4995b346e281843bf84394f8e68c8e41bd1e4c576bd", - "size": 1681596, - "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190313/openocd-esp32-linux64-0.10.0-esp32-20190313.tar.gz" + "sha256": "038affba6cb2874098f6b70e61ce139afdf056f926ea6aefcf4d90a6ccf05bc3", + "size": 1675213, + "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190708/openocd-esp32-linux64-0.10.0-esp32-20190708.tar.gz" }, "macos": { - "sha256": "09504eea5aa92646a117f16573c95b34e04b4010791a2f8fefcd2bd8c430f081", - "size": 1760536, - "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190313/openocd-esp32-macos-0.10.0-esp32-20190313.tar.gz" + "sha256": "840c94ce6208c5b21d0ba6c3113a06405daf6b27085a287cfbb6c9d21e80bd70", + "size": 1760060, + "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190708/openocd-esp32-macos-0.10.0-esp32-20190708.tar.gz" }, - "name": "v0.10.0-esp32-20190313", + "name": "v0.10.0-esp32-20190708", "status": "recommended", "win32": { - "sha256": "b86a7f9f39dfc4d8e289fc819375bbb7a5e9fcb8895805ba2b5faf67b8b25ce2", - "size": 2098513, - "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190313/openocd-esp32-win32-0.10.0-esp32-20190313.zip" + "sha256": "a3a6f288a501c2992d2950c1b2c502e479e16aedda21b626602933c75f027a13", + "size": 2098530, + "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190708/openocd-esp32-win32-0.10.0-esp32-20190708.zip" }, "win64": { - "sha256": "b86a7f9f39dfc4d8e289fc819375bbb7a5e9fcb8895805ba2b5faf67b8b25ce2", - "size": 2098513, - "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190313/openocd-esp32-win32-0.10.0-esp32-20190313.zip" + "sha256": "a3a6f288a501c2992d2950c1b2c502e479e16aedda21b626602933c75f027a13", + "size": 2098530, + "url": "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20190708/openocd-esp32-win32-0.10.0-esp32-20190708.zip" } } ] From 8d35744a3366efec2087164afb2888424e89da44 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Sun, 28 Jul 2019 10:14:04 +0200 Subject: [PATCH 02/36] examples: ext_flash_fatfs: use DIO mode by default DIO works with the same connections as Fast Read, so use it by default. Also correct the note in README.md which says that DIO requires additional pins. --- examples/storage/ext_flash_fatfs/README.md | 4 ++-- .../ext_flash_fatfs/main/ext_flash_fatfs_example_main.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/storage/ext_flash_fatfs/README.md b/examples/storage/ext_flash_fatfs/README.md index 787ec690a..fcc54e76f 100644 --- a/examples/storage/ext_flash_fatfs/README.md +++ b/examples/storage/ext_flash_fatfs/README.md @@ -8,7 +8,7 @@ The flow of the example is as follows: 1. Initialize the SPI bus and configure the pins. In this example, VSPI peripheral is used. The pins chosen in this example correspond to IOMUX pins for the VSPI peripheral. If the pin assignment is changed, SPI driver will instead connect the peripheral to the pins using the GPIO Matrix. -2. Initialize the SPI flash chip. This involves creating a run-time object which describes the flash chip (`esp_flash_t`), probing the flash chip, and configuring it for the selected read mode. By default this example uses "Fast Read" mode, which only requires 4 pins (MOSI, MISO, SCLK, CS). For modes such as DIO, QIO, additional pins must be connected. +2. Initialize the SPI flash chip. This involves creating a run-time object which describes the flash chip (`esp_flash_t`), probing the flash chip, and configuring it for the selected read mode. By default this example uses DIO mode, which only requires 4 pins (MOSI, MISO, SCLK, CS). For modes such as QIO and QOUT, additional pins must be connected. 3. Register the entire area of the Flash chip as a *partition* (`esp_partition_t`). This allows other components (FATFS, SPIFFS, NVS, etc) to use the storage provided by the external flash chip. @@ -56,7 +56,7 @@ I (328) example: Initializing external SPI Flash I (338) example: Pin assignments: I (338) example: MOSI: 23 MISO: 19 SCLK: 18 CS: 5 I (348) spi_flash: detected chip: generic -I (348) spi_flash: flash io: fastrd +I (348) spi_flash: flash io: dio I (348) example: Initialized external Flash, size=4096 KB, ID=0xef4016 I (358) example: Adding external Flash as a partition, label="storage", size=4096 KB I (368) example: Mounting FAT filesystem diff --git a/examples/storage/ext_flash_fatfs/main/ext_flash_fatfs_example_main.c b/examples/storage/ext_flash_fatfs/main/ext_flash_fatfs_example_main.c index c64fb76ad..4a930bf8a 100644 --- a/examples/storage/ext_flash_fatfs/main/ext_flash_fatfs_example_main.c +++ b/examples/storage/ext_flash_fatfs/main/ext_flash_fatfs_example_main.c @@ -98,7 +98,7 @@ static esp_flash_t* example_init_ext_flash() .host_id = VSPI_HOST, .cs_id = 0, .cs_io_num = VSPI_IOMUX_PIN_NUM_CS, - .io_mode = SPI_FLASH_FASTRD, + .io_mode = SPI_FLASH_DIO, .speed = ESP_FLASH_40MHZ }; From 15e0a327865ddd732f2ec4dd83a9de2781916a2a Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Tue, 30 Jul 2019 16:49:53 +0530 Subject: [PATCH 03/36] lwip: remove duplicate (and stale) changelog and version files --- components/lwip/CHANGELOG | 4044 ------------------------------------- components/lwip/VERSION | 1 - 2 files changed, 4045 deletions(-) delete mode 100644 components/lwip/CHANGELOG delete mode 100644 components/lwip/VERSION diff --git a/components/lwip/CHANGELOG b/components/lwip/CHANGELOG deleted file mode 100644 index 21a85c94c..000000000 --- a/components/lwip/CHANGELOG +++ /dev/null @@ -1,4044 +0,0 @@ -HISTORY - -(git master) - - * [Enter new changes just after this line - do not remove this line] - - ++ New features: - - 2016-02-22: Ivan Delamer: - * Initial 6LoWPAN support - - 2015-12-26: Martin Hentschel and Dirk Ziegelmeier - * Rewrite SNMP agent - - 2015-11-12: Dirk Ziegelmeier - * Decouple SNMP stack from lwIP core and move stack to apps/ directory. - Breaking change: Users have to call snmp_init() now! - - 2015-11-12: Dirk Ziegelmeier - * Implement possibility to declare private memory pools. This is useful to - decouple some apps from the core (SNMP stack) or make contrib app useage - simpler (httpserver_raw) - - 2015-10-09: Simon Goldschmidt - * started to move "private" header files containing implementation details to - "lwip/priv/" include directory to seperate the API from the implementation. - - 2015-10-07: Simon Goldschmidt - * added sntp client as first "supported" application layer protocol implementation - added 'apps' folder - - 2015-09-30: Dirk Ziegelmeier - * snmp_structs.h, mib_structs.c, mib2.c: snmp: fixed ugly inheritance - implementation by aggregating the "base class" (struct mib_node) in all - derived node classes to get more type-safe code - - 2015-09-23: Simon Goldschmidt - * netif.h/.c, nd6.c: task #13729: Convert netif addresses (IPv4 & IPv6) to - ip_addr_t (so they can be used without conversion/temporary storage) - - 2015-09-08: Dirk Ziegelmeier - * snmp: Separate mib2 counter/table callbacks from snmp agent. This both cleans - up the code and should allow integration of a 3rd party agent/mib2. Simple - counters are kept in MIB2_STATS, tree/table change function prototypes moved to - snmp_mib2.h. - - 2015-09-03: Simon Goldschmidt - * opt.h, dns.h/.c: DNS/IPv6: added support for AAAA records - - 2015-09-01: Simon Goldschmidt - * task #12178: hardware checksum capabilities can be configured per netif - (use NETIF_SET_CHECKSUM_CTRL() in your netif's init function) - - 2015-08-30: Simon Goldschmidt - * PBUF_REF with "custom" pbufs is now supported for RX pbufs (see pcapif in - contrib for an example, LWIP_SUPPORT_CUSTOM_PBUF is required) - - 2015-08-30: Simon Goldschmidt - * support IPv4 source based routing: define LWIP_HOOK_IP4_ROUTE_SRC to point - to a routing function - - 2015-08-05: Simon Goldschmidt - * many files: allow multicast socket options IP_MULTICAST_TTL, IP_MULTICAST_IF - and IP_MULTICAST_LOOP to be used without IGMP - - 2015-04-24: Simon Goldschmidt - * dhcp.h/c, autoip.h/.c: added functions dhcp/autoip_supplied_address() to - check for the source of address assignment (replacement for NETIF_FLAG_DHCP) - - 2015-04-10: Simon Goldschmidt - * many files: task #13480: added LWIP_IPV4 define - IPv4 can be disabled, - leaving an IPv6-only stack - - 2015-04-09: Simon Goldschmidt - * nearly all files: task #12722 (improve IPv4/v6 address handling): renamed - ip_addr_t to ip4_addr_t, renamed ipX_addr_t to ip_addr_t and added IP - version; ip_addr_t is used for all generic IP addresses for the API, - ip(4/6)_addr_t are only used internally or when initializing netifs or when - calling version-related functions - - 2015-03-24: Simon Goldschmidt - * opt.h, ip4_addr.h, ip4.c, ip6.c: loopif is not required for loopback traffic - any more but passed through any netif (ENABLE_LOOPBACK has to be enabled) - - 2015-03-23: Simon Goldschmidt - * opt.h, etharp.c: with ETHARP_TABLE_MATCH_NETIF== 1, duplicate (Auto)-IP - addresses on multiple netifs should now be working correctly (if correctly - addressed by routing, that is) - - 2015-03-23: Simon Goldschmidt - * etharp.c: Stable etharp entries that are about to expire are now refreshed - using unicast to prevent unnecessary broadcast. Only if no answer is received - after 15 seconds, broadcast is used. - - 2015-03-06: Philip Gladstone - * netif.h/.c: patch #8359 (Provide utility function to add an IPv6 address to - an interface) - - 2015-03-05: Simon Goldschmidt - * netif.c, ip4.c, dhcp.c, autoip.c: fixed bug #37068 (netif up/down handling - is unclear): correclty separated administrative status of a netif (up/down) - from 'valid address' status - ATTENTION: netif_set_up() now always has to be called, even when dhcp/autoip - is used! - - 2015-02-26: patch by TabascoEye - * netif.c, udp.h/.c: fixed bug #40753 (re-bind UDP pcbs on change of IP address) - - 2015-02-22: chrysn, Simon Goldschmidt - * *.*: Changed nearly all functions taking 'ip(X)_addr_t' pointer to take - const pointers (changed user callbacks: raw_recv_fn, udp_recv_fn; changed - port callbacks: netif_output_fn, netif_igmp_mac_filter_fn) - - 2015-02-19: Ivan Delamer - * netif.h, dhcp.c: Removed unused netif flag for DHCP. The preferred way to evaluate - if DHCP is active is through netif->dhcp field. - - 2015-02-19: Ivan Delamer - * netif.h, slipif.c, ppp.c: Removed unused netif flag for point to point connections - - 2015-02-18: Simon Goldschmidt - * api_lib.c: fixed bug #37958 "netconn API doesn't handle correctly - connections half-closed by peer" - - 2015-02-18: Simon Goldschmidt - * tcp.c: tcp_alloc() prefers killing CLOSING/LAST_ACK over active connections - (see bug #39565) - - 2015-02-16: Claudius Zingerli, Sergio Caprile - * opt.h, dhcp.h/.c: patch #8361 "Add support for NTP option in DHCP" - - 2015-02-14: Simon Goldschmidt - * opt.h, snmp*: added support for write-access community and dedicated - community for sending traps - - 2015-02-13: Simon Goldschmidt - * opt.h, memp.c: added hook LWIP_HOOK_MEMP_AVAILABLE() to get informed when - a memp pool was empty and an item is now available - - 2015-02-13: Simon Goldschmidt - * opt.h, pbuf.h/.c, etharp.c: Added the option PBUF_LINK_ENCAPSULATION_HLEN to - allocate additional header space for TX on netifs requiring additional headers - - 2015-02-12: chrysn - * timers.h/.c: introduce sys_timeouts_sleeptime (returns the time left before - the next timeout is due, for NO_SYS==1) - - 2015-02-11: Nick van Ijzendoorn - * opt.h, sockets.h/c: patch #7702 "Include ability to increase the socket number - with defined offset" - - 2015-02-11: Frederick Baksik - * opt.h, def.h, others: patch #8423 "arch/perf.h" should be made an optional item - - 2015-02-11: Simon Goldschmidt - * api_msg.c, opt.h: started to implement fullduplex sockets/netconns - (note that this is highly unstable yet!) - - 2015-01-17: Simon Goldschmidt - * api: allow enabling socket API without (public) netconn API - netconn API is - still used by sockets, but keeping it private (static) should allow better - compiler optimizations - - 2015-01-16: Simon Goldschmidt - * tcp_in.c: fixed bug #20506 "Initial congestion window is very small" again - by implementing the calculation formula from RFC3390 - - 2014-12-10: Simon Goldschmidt - * api: added option LWIP_NETCONN_SEM_PER_THREAD to use a semaphore per thread - instead of using one per netconn and per select call - - 2014-12-08: Simon Goldschmidt - * ip6.h: fixed bug #43778: IPv6 header version not set on 16-bit platform - (macro IP6H_VTCFL_SET()) - - 2014-12-08: Simon Goldschmidt - * icmp.c, ip4.c, pbuf.c, udp.c, pbuf.h: task #11472 Support PBUF_REF for RX - (IPv6 and IPv4/v6 reassembly might not work yet) - - 2014-11-06: Simon Goldschmidt - * sockets.c/.h, init.c: lwip_socket_init() is not needed any more - -> compatibility define - - 2014-09-16: Simon Goldschmidt - * dns.c, opt.h: reduced ram usage by parsing DNS responses in place - - 2014-09-16: Simon Goldschmidt - * pbuf.h/.c: added pbuf_take_at() and pbuf_put_at() - - 2014-09-15: Simon Goldschmidt - * dns.c: added source port randomization to make the DNS client more robust - (see bug #43144) - - 2013-09-02: Simon Goldschmidt - * arch.h and many other files: added optional macros PACK_STRUCT_FLD_8() and - PACK_STRUCT_FLD_S() to prevent gcc 4 from warning about struct members that - do not need packing - - 2013-08-19: Simon Goldschmidt - * netif.h: bug #42998: made NETIF_MAX_HWADDR_LEN overridable for some special - networks - - 2013-03-17: Simon Goldschmidt (patch by Ghobad Emadi) - * opt.h, etharp.c: Added LWIP_HOOK_ETHARP_GET_GW to implement IPv4 routing with - multiple gateways - - 2013-04-20: Fatih Asici - * opt.h, etharp.h/.c: patch #7993: Added support for transmitting packets - with VLAN headers via hook function LWIP_HOOK_VLAN_SET and to check them - via hook function LWIP_HOOK_VLAN_CHECK - - 2014-02-20: Simon Goldschmidt (based on patch by Artem Pisarenko) - * patch #7885: modification of api modules to support FreeRTOS-MPU - (don't pass stack-pointers to other threads) - - 2014-02-05: Simon Goldschmidt (patch by "xtian" and "alex_ab") - * patch #6537/#7858: TCP window scaling support - - 2014-01-17: Jiri Engelthaler - * icmp, icmp6, opt.h: patch #8027: Completed HW checksuming for IPv4 and - IPv6 ICMP's - - 2012-08-22: Sylvain Rochet - * New PPP stack for lwIP, developed in ppp-new branch. - Based from pppd 2.4.5, released 2009-11-17, with huge changes to match - code size and memory requirements for embedded devices, including: - - Gluing together the previous low-level PPP code in lwIP to pppd 2.4.5, which - is more or less what pppd sys-* files are, so that we get something working - using the unix port. - - Merged some patchs from lwIP Git repository which add interesting features - or fix bugs. - - Merged some patchs from Debian pppd package which add interesting features - or fix bugs. - - Ported PPP timeout handling to the lwIP timers system - - Disabled all the PPP code using filesystem access, replaced in necessary cases - to configuration variables. - - Disabled all the PPP code forking processes. - - Removed IPX support, lwIP does not support IPX. - - Ported and improved random module from the previous PPP port. - - Removed samba TDB (file-driven database) usage, because it needs a filesystem. - - MS-CHAP required a DES implementation, we added the latest PolarSSL DES - implementation which is under a BSD-ish license. - - Also switched to PolarSSL MD4,MD5,SHA1 implementations, which are meant to be - used in embedded devices with reduced memory footprint. - - Removed PPP configuration file parsing support. - - Added macro definition EAP_SUPPORT to make EAP support optional. - - Added macro definition CHAP_SUPPORT to make CHAP support optional. - - Added macro definition MSCHAP_SUPPORT to make MSCHAP support optional. - - Added macro definition PAP_SUPPORT to make PAP support optional. - - Cleared all Linux syscall calls. - - Disabled demand support using a macro, so that it can be ported later. - - Disabled ECP support using a macro, so that it can be ported later. - - Disabled CCP support using a macro, so that it can be ported later. - - Disabled CBCP support using a macro, so that it can be ported later. - - Disabled LQR support using a macro, so that it can be ported later. - - Print packet debug feature optional, through PRINTPKT_SUPPORT - - Removed POSIX signal usage. - - Fully ported PPPoS code from the previous port. - - Fully ported PPPoE code from the previous port. - - Fully ported VJ compression protocol code from the previous port. - - Removed all malloc()/free() use from PPP, replaced by stack usage or PBUF. - - Disabled PPP server support using a macro, so that it can be ported later. - - Switched all PPP debug to lwIP debug system. - - Created PPP Control Block (PPP PCB), removed PPP unit integer everywhere, - removed all global variables everywhere, did everything necessary for - the PPP stack to support more than one PPP session (pppd only support - one session per process). - - Removed the statically allocated output buffer, now using PBUF. - - Improved structure size of all PPP modules, deep analyze of code to reduce - variables size to the bare minimum. Switched all boolean type (char type in - most architecture) to compiler generated bitfields. - - Added PPP IPv6 support, glued lwIP IPv6 support to PPP. - - Now using a persistent netif interface which can then be used in lwIP - functions requiring a netif. - - Now initializing PPP in lwip_init() function. - - Reworked completely the PPP state machine, so that we don't end up in - anymore in inconsistent state, especially with PPPoE. - - Improved the way we handle PPP reconnection after disconnect, cleaning - everything required so that we start the PPP connection again from a - clean state. - - Added PPP holdoff support, allow the lwIP user to wait a little bit before - reconnecting, prevents connection flood, especially when using PPPoL2TP. - - Added PPPoL2TP LAC support (a.k.a. UDP tunnels), adding a VPN client - feature to lwIP, L2TP being a widely used tunnel protocol. - - Switched all used PPP types to lwIP types (u8t, u16t, u32t, ...) - - Added PPP API "sequential" thread-safe API, based from NETIFAPI. - - 2011-07-21: Simon Goldschmidt - * sockets.c, opt.h: (bug #30185): added LWIP_FIONREAD_LINUXMODE that makes - ioctl/FIONREAD return the size of the next pending datagram. - - 2011-05-25: Simon Goldschmidt - * again nearly the whole stack, renamed ip.c to ip4.c, ip_addr.c to ip4_addr.c, - combined ipv4/ipv6 inet_chksum.c, added ip.h, ip_addr.h: Combined IPv4 - and IPv6 code where possible, added defines to access IPv4/IPv6 in non-IP - code so that the code is more readable. - - 2011-05-17: Patch by Ivan Delamer (only checked in by Simon Goldschmidt) - * nearly the whole stack: Finally, we got decent IPv6 support, big thanks to - Ivan! (this is work in progress: we're just post release anyway :-) - - - ++ Bugfixes: - - 2016-03-05: Simon Goldschmidt - * err.h/.c, sockets.c: ERR_IF is not necessarily a fatal error - - 2015-11-19: fix by Kerem Hadimli - * sockets.c: fixed bug #46471: lwip_accept() leaks socket descriptors if new - netconn was already closed because of peer behavior - - 2015-11-12: fix by Valery Ushakov - * tcp_in.c: fixed bug #46365 tcp_accept_null() should call tcp_abort() - - 2015-10-02: Dirk Ziegelmeier/Simon Goldschmidt - * snmp: cleaned up snmp structs API (fixed race conditions from bug #46089, - reduce ram/rom usage of tables): incompatible change for private MIBs - - 2015-09-30: Simon Goldschmidt - * ip4_addr.c: fixed bug #46072: ip4addr_aton() does not check the number range - of all address parts - - 2015-08-28: Simon Goldschmidt - * tcp.c, tcp_in.c: fixed bug #44023: TCP ssthresh value is unclear: ssthresh - is set to the full send window for active open, too, and is updated once - after SYN to ensure the correct send window is used - - 2015-08-28: Simon Goldschmidt - * tcp: fixed bug #45559: Window scaling casts u32_t to u16_t without checks - - 2015-08-26: Simon Goldschmidt - * ip6_frag.h/.c: fixed bug bug #41009: IPv6 reassembly broken on 64-bit platforms: - define IPV6_FRAG_COPYHEADER==1 on these platforms to copy the IPv6 header - instead of referencing it, which gives more room for struct ip6_reass_helper - - 2015-08-25: Simon Goldschmidt - * sockets.c: fixed bug #45827: recvfrom: TCP window is updated with MSG_PEEK - - 2015-08-20: Manoj Kumar - * snmp_msg.h, msg_in.c: fixed bug #43790: Sending octet string of Length >255 - from SNMP agent - - 2015-08-19: Jens Nielsen - * icmp.c, ip4.c, tcp_in.c, udp.c, raw.c: fixed bug #45120: Broadcast & multiple - interfaces handling - - 2015-08-19: Simon Goldschmidt (patch by "Sandra") - * dns.c: fixed bug #45004: dns response without answer might be discarded - - 2015-08-18: Chrysn - * timers.c: patch #8704 fix sys_timeouts_sleeptime function - - 2015-07-01: Erik Ekman - * puf.c: fixed bug #45454 (pbuf_take_at() skips write and returns OK if offset - is at start of pbuf in chain) - - 2015-05-19: Simon Goldschmidt - * dhcp.h/.c: fixed bugs #45140 and #45141 (dhcp was not stopped correctly after - fixing bug #38204) - - 2015-03-21: Simon Goldschmidt (patch by Homyak) - * tcp_in.c: fixed bug #44766 (LWIP_WND_SCALE: tcphdr->wnd was not scaled in - two places) - - 2015-03-21: Simon Goldschmidt - * tcp_impl.h, tcp.c, tcp_in.c: fixed bug #41318 (Bad memory ref in tcp_input() - after tcp_close()) - - 2015-03-21: Simon Goldschmidt - * tcp_in.c: fixed bug #38468 (tcp_sent() not called on half-open connection for - data ACKed with the same ack as FIN) - - 2015-03-21: Simon Goldschmidt (patch by Christoffer Lind) - * dhcp.h/.c: fixed bug #38204 (DHCP lease time not handled correctly) - - 2015-03-20: Simon Goldschmidt - * dhcp.c: fixed bug #38714 (Missing option and client address in DHCPRELEASE message) - - 2015-03-19: Simon Goldschmidt - * api.h, tcpip.h, api_lib.c, api_msg.c: fixed race conditions in assigning - netconn->last_err (fixed bugs #38121 and #37676) - - 2015-03-09: Simon Goldschmidt - * ip4.c: fixed the IPv4 part of bug #43904 (ip_route() must detect linkup status) - - 2015-03-04: Simon Goldschmidt - * nd6.c: fixed bug #43784 (a host should send at least one Router Solicitation) - - 2015-03-04: Valery Ushakov - * ip6.c: fixed bug #41094 (Byte-order bug in IPv6 fragmentation header test) - - 2015-03-04: Zach Smith - * nd6.c: fixed bug #38153 (nd6_input() byte order issues) - - 2015-02-26: Simon Goldschmidt - * netif.c, tcp.h/.c: fixed bug #44378 (TCP connections are not aborted on netif - remove) - - 2015-02-25: Simon Goldschmidt - * ip4.c, etharp.c: fixed bug #40177 (System hangs when dealing with corrupted - packets), implemented task #12357 (Ensure that malicious packets don't - assert-fail): improved some pbuf_header calls to not assert-fail. - - 2015-02-25: patch by Joel Cunningham - * udp.h/.c, sockets.c: fixed bug #43028 (IP_MULTICAST_TTL affects unicast - datagrams) - - 2015-02-25: patch by Greg Renda - * ip4_frag.c: fixed bug #38210 (ip reassembly while remove oldest datagram) - - 2015-02-25: Simon Goldschmidt - * sockets.c: fixed bug #38165 (socket with mulicast): ensure igmp membership - are dropped when socket (not netconn!) is closed. - - 2015-02-25: Simon Goldschmidt - * ip4.h/.c, udp.c: fixed bug #38061 (wrong multicast routing in IPv4) by - adding an optional default netif for multicast routing - - 2015-02-25: Simon Goldschmidt - * netconn API: fixed that netconn_connect still used message passing for - LWIP_TCPIP_CORE_LOCKING==1 - - 2015-02-22: patch by Jens Nielsen - * icmp.c: fixed bug #38803 (Source address in broadcast ping reply) - - 2015-02-22: Simon Goldschmidt - * udp.h, sockets.c: added proper accessor functions for pcb->multicast_ip - (previously used by get/setsockopt only) - - 2015-02-18: Simon Goldschmidt - * sockets.c: Fixed select not reporting received FIN as 'readable' in certain - rare cases (bug #43779: select(), close(), and TCP retransmission error) - - 2015-02-17: Simon Goldschmidt - * err.h, sockets.c, api_msg.c: fixed bug #38853 "connect() use a wrong errno": - return ERR_ALREADY/EALRADY during connect, ERR_ISCONN/EISCONN when already - connected - - 2015-02-17: Simon Goldschmidt - * tcp_impl.h, tcp_out.c, tcp.c, api_msg.c: fixed bug #37614 "Errors from - ipX_output are not processed". Now tcp_output(_segment) checks for the return - value of ipX_output and does not try to send more on error. A netif driver - can call tcp_txnow() (from tcpip_thread!) to try to send again if TX buffers - are available again. - - 2015-02-14: patches by Freddie Chopin - * snmp*: made community writable, fixed some const pointers - - 2015-02-13: Simon Goldschmidt - * msg_in.c: fixed bug #22070 "MIB_OBJECT_WRITE_ONLY not implemented in SNMP" - - 2015-02-12: Simon Goldschmidt - * ip.h, ip4.c, ip6.c: fixed bug #36403 "ip4_input() and ip6_input() always pass - inp to higher layers": now the accepting netif is passed up, but the input - netif is available through ip_current_input_netif() if required. - - 2015-02-11: patch by hichard - * tcpip.c: fixed bug #43094 "The function tcpip_input() forget to handle IPv6" - - 2015-02-10: Simon Goldschmidt - * netconn API: fixed that netconn_close/netconn_delete still used message passing - for LWIP_TCPIP_CORE_LOCKING==1 - - 2015-02-10: Simon Goldschmidt - * netconn/socket api: fixed bug #44225 "closing TCP socket should time out - eventually", implemented task #6930 "Implement SO_LINGER": closing TCP sockets - times out after 20 seconds or after the configured SND_TIMEOUT or depending - on the linger settings. - - 2015-01-27: Simon Goldschmidt - * api_msg.c: fixed that SHUT_RD followed by SHUT_WR was different to SHUT_RDWR, - fixed return value of lwip_netconn_do_close on unconnected netconns - - 2015-01-17: Simon Goldschmidt - * sockets.c: fixed bug #43361 select() crashes with stale FDs - - 2015-01-17: Simon Goldschmidt - * sockets.c/.h, memp_std.h: fixed bug #40788 "lwip_setsockopt_internal() crashes" - by rewriting set/getsockopt functions to combine checks with the actual code - and add more NULL checks; this also fixes that CORE_LOCKING used message - passing for set/getsockopt. - - 2014-12-19: Simon Goldschmidt - * opt.h, dhcp.h/.c: prevent dhcp from starting when netif link is down (only - when LWIP_DHCP_CHECK_LINK_UP==1, which is disabled by default for - compatibility reasons) - - 2014-12-17: Simon Goldschmidt - * tcp_out.c: fixed bug #43840 Checksum error for TCP_CHECKSUM_ON_COPY==1 for - no-copy data with odd length - - 2014-12-10: Simon Goldschmidt - * sockets.c, tcp.c, others: fixed bug #43797 set/getsockopt: SO_SNDTIMEO/SO_RCVTIMEO - take int as option but should take timeval (LWIP_SO_SNDRCVTIMEO_STANDARD==0 can - be used to revert to the old 'winsock' style behaviour) - Fixed implementation of SO_ACCEPTCONN to just look at the pcb state - - 2014-12-09: Simon Goldschmidt - * ip4.c: fixed bug #43596 IGMP queries from 0.0.0.0 are discarded - - 2014-10-21: Simon Goldschmidt (patch by Joel Cunningham and Albert Huitsing) - * sockts.c: fixed bugs #41495 Possible threading issue in select() and #43278 - event_callback() handle context switch when calling sys_sem_signal() - - 2014-10-21: Simon Goldschmidt - * api_msg.c: fixed bug #38219 Assert on TCP netconn_write with sndtimeout set - - 2014-09-16: Kevin Cernekee - * dns.c: patch #8480 Fix handling of dns_seqno wraparound - - 2014-09-16: Simon Goldschmidt - * tcp_out.c: fixed bug #43192 tcp_enqueue_flags() should not check TCP_SND_QUEUELEN - when sending FIN - - 2014-09-03: Simon Goldschmidt - * msg_in.c: fixed bug #39355 SNMP Memory Leak in case of error - - 2014-09-02: Simon Goldschmidt - * err.h/.c, sockets.c, api_msg.c: fixed bug #43110 call getpeername() before - listen() will cause a error - - 2014-09-02: Simon Goldschmidt - * sockets.c: fixed bug #42117 lwip_fcntl does not set errno - - 2014-09-02: Simon Goldschmidt - * tcp.c: fixed bug #42299 tcp_abort() leaves freed pcb on tcp_bound_pcbs list - - 2014-08-20: Simon Goldschmidt - * dns.c: fixed bug #42987 lwIP is vulnerable to DNS cache poisoning due to - non-randomized TXIDs - - 2014-06-03: Simon Goldschmidt - * tcp_impl.h, tcp_in.c: fixed bug #37969 SYN packet dropped as short packet in - tcp_input function - - 2014-05-20: Simon Goldschmidt - * tcp_out.c: fixed bug #37184 tcp_write problem for pcbs in the SYN_SENT state - - 2014-05-19: Simon Goldschmidt - * *.h: Fixed bug #35874 reserved identifier violation (removed leading underscores - from header include guards) - - 2014-04-08: Simon Goldschmidt - * tcp.c: Fixed bug #36167 tcp server crash when client closes (maximum window) - - 2014-04-06: Simon Goldschmidt - * tcp_in.c: Fixed bug #36210 lwIP does not elicit an empty ACK when received - unacceptable ACK - - 2014-04-06: Simon Goldschmidt - * dhcp.c, ip4.c/.h, ip6.c/.h, udp.c/.h, ip.h: Fixed bug #41787 DHCP Discovery - is invalid when an IP is set to thet netif. - - 2014-03-14: Simon Goldschmidt - * tcp_out.c: Fixed bug #36153 TCP Cheksum error if LWIP_CHECKSUM_ON_COPY=1 - - 2014-03-11: Simon Goldschmidt (patch by Mason) - * opt.h, sockets.c: fixed bug #35928 BSD sockets functions must set errno for - POSIX-compliance - - 2014-02-27: Simon Goldschmidt - * dhcp.c: fixed bug #40303 DHCP xid renewed when sending a DHCPREQUEST - - 2014-02-27: Simon Goldschmidt - * raw.c: fixed bug #41680 raw socket can not receive IPv6 packet when - IP_SOF_BROADCAST_RECV==1 - - 2014-02-27: Simon Goldschmidt - * api_msg.c, sockets.c: fixed bug #38404 getpeeraddr returns success on - unconnected/listening TCP sockets - - 2014-02-27: Simon Goldschmidt - * sockets.c: fixed bug #41729 Some socket functions return Exyz instead of -1 - - 2014-02-25: Simon Goldschmidt - * ip4.c: fixed bug #39514 ip_route() may return an IPv6-only interface - - 2014-02-25: Simon Goldschmidt, patch by Fatih Asici - * pbuf.c: fixed bug #39356 Wrong increment in pbuf_memfind() - - 2014-02-25: Simon Goldschmidt - * netif.c/.h, udp.c: fixed bug #39225 udp.c uses netif_matches_ip6_addr() incorrectly; - renamed function netif_matches_ip6_addr() to netif_get_ip6_addr_match() - - 2014-02-25: Simon Goldschmidt - * igmp.c: fixed bug #39145 IGMP membership report for 224.0.0.1 - - 2014-02-22: Simon Goldschmidt (patch by Amir Shalem) - * etharp.c, opt.h: fixed bug #34681 Limit ARP queue length by ARP_QUEUE_LEN (=3) - - 2014-02-22: Simon Goldschmidt (patch by Amir Shalem) - * etharp.h/.c: fixed bug #34682 Limit ARP request flood for unresolved entry - - 2014-02-20: Simon Goldschmidt - * tcp_out.c: fixed bug #39683 Assertion "seg->tcphdr not aligned" failed with - MEM_ALIGNMENT = 8 - - 2014-02-20: Simon Goldschmidt - * sockets.c: fixed bug #39882 No function shall set errno to 0 - - 2014-02-20: Simon Goldschmidt - * mib_structs.c: fixed bug #40050 SNMP problem with MIB arrays > 255 - - 2014-02-20: Simon Goldschmidt - * api.h, sockets.c: fixed bug #41499 netconn::recv_avail can overflow - - 2014-01-08: Stathis Voukelatos - * memp_std.h: patch #7928 Fixed size calculation in MALLOC memory pool - creation macro - - 2014-01-18: Brian Fahs - * tcp_out.c: patch #8237: tcp_rexmit_rto fails to update pcb->unsent_oversize - when necessary - - 2014-01-17: Grant Erickson, Jay Logue, Simon Goldschmidt - * ipv6.c, netif.c: patch #7913 Enable Support for IPv6 Loopback - - 2014-01-16: Stathis Voukelatos - * netif.c: patch #7902 Fixed netif_poll() operation when LWIP_LOOPBACK_MAX_PBUFS > 0 - - 2014-01-14: "Freddie Chopin" - * snmp.h, mib2.c: fixed constness and spelling of sysdescr - - 2014-01-14: Simon Goldschmidt (patch by Thomas Faber) - * tcpip.c: patch #8241: Fix implicit declaration of ip_input with - LWIP_TCPIP_CORE_LOCKING_INPUT disabled - - 2014-01-14: chrysn - * timers.c: patch #8244 make timeouts usable reliably from outside of the - timeout routine - - 2014-01-10: Simon Goldschmidt - * ip_frag.c, ip6_frag.c: fixed bug #41041 Potential use-after-free in IPv6 reassembly - - 2014-01-10: Simon Goldschmidt - * memp.c: fixed bug #41188 Alignment error in memp_init() when MEMP_SEPARATE_POOLS==1 - - 2014-01-10: Simon Goldschmidt - * tcp.c: fixed bug #39898 tcp_fasttmr() possible lock due to infinte queue process loop - - 2013-06-29: Simon Goldschmidt - * inet.h, sockets.h: partially fixed bug #37585: IPv6 compatibility (in socket structs) - - 2013-06-29: Simon Goldschmidt - * inet6.h: bug #37585/task #12600: fixed struct in6_addr.s6_addr to conform to spec - - 2013-04-24: patch by Liam - * api_msg.c: patch #8008 Fix a potential null pointer dereference in assert - - 2013-04-24: Simon Goldschmidt - * igmp.c: fixed possible division by zero - - 2013-04-24: Simon Goldschmidt - * ip6.h, some ipv6 C files: fixed bug #38526 Coverity: Recursive Header Inclusion in ip6.h - - 2013-04-24: Simon Goldschmidt (patch by Emil Ljungdahl): - * netif.c: fixed bug #38586 netif_loop_output() "deadlocks" - - 2013-01-15: Simon Goldschmidt - * ip4.c: fixed bug #37665 ip_canforward operates on address in wrong byte order - - 2013-01-15: Simon Goldschmidt - * pbuf.h: fixed bug #38097 pbuf_free_ooseq() warning - - 2013-01-14: Simon Goldschmidt - * dns.c: fixed bug #37705 Possible memory corruption in DNS query - - 2013-01-11: Simon Goldschmidt - * raw.c: fixed bug #38066 Raw pcbs can alter packet without eating it - - 2012-08-22: Simon Goldschmidt - * memp.c: fixed bug #37166: memp_sanity check loops itself - - 2012-08-13: Simon Goldschmidt - * dhcp.c: fixed bug #36645: Calling dhcp_release before dhcp_start - dereferences NULL - - 2012-08-13: Simon Goldschmidt - * msg_out.c: fixed bug #36840 snmp_send_trap() NULL de-reference if traps - configured but no interfaces available - - 2012-08-13: Simon Goldschmidt - * dns.c: fixed bug #36899 DNS TTL 0 is cached for a long time - - 2012-05-11: Simon Goldschmidt (patch by Marty) - * memp.c: fixed bug #36412: memp.c does not compile when - MEMP_OVERFLOW_CHECK > zero and MEMP_SEPARATE_POOLS == 1 - - 2012-05-03: Simon Goldschmidt (patch by Sylvain Rochet) - * ppp.c: fixed bug #36283 (PPP struct used on header size computation and - not packed) - - 2012-05-03: Simon Goldschmidt (patch by David Empson) - * ppp.c: fixed bug #36388 (PPP: checksum-only in last pbuf leads to pbuf with - zero length) - - 2012-03-25: Simon Goldschmidt - * api_msg.c: Fixed bug #35817: do_connect() invalidly signals op_completed - for UDP/RAW with LWIP_TCPIP_CORE_LOCKING==1 - - 2012-03-25: Simon Goldschmidt - * api_msg.h, api_lib.c, api_msg.c, netifapi.c: fixed bug #35931: Name space - pollution in api_msg.c and netifapi.c - - 2011-08-24: Simon Goldschmidt - * inet6.h: fixed bug #34124 struct in6_addr does not conform to the standard - - - -(STABLE-1.4.1) - - ++ New features: - - 2012-03-25: Simon Goldschmidt (idea by Mason) - * posix/*: added posix-compatibility include files posix/netdb.h and posix/sys/socket.h - which are a simple wrapper to the correct lwIP include files. - - 2012-01-16: Simon Goldschmidt - * opt.h, icmp.c: Added option CHECKSUM_GEN_ICMP - - 2011-12-17: Simon Goldschmidt - * ip.h: implemented API functions to access so_options of IP pcbs (UDP, TCP, RAW) - (fixes bug #35061) - - 2011-09-27: Simon Goldschmidt - * opt.h, tcp.c, tcp_in.c: Implemented limiting data on ooseq queue (task #9989) - (define TCP_OOSEQ_MAX_BYTES / TCP_OOSEQ_MAX_PBUFS in lwipopts.h) - - 2011-09-21: Simon Goldschmidt - * opt.h, api.h, api_lib.c, api_msg.h/.c, sockets.c: Implemented timeout on - send (TCP only, bug #33820) - - 2011-09-21: Simon Goldschmidt - * init.c: Converted runtime-sanity-checks into compile-time checks that can - be disabled (since runtime checks can often not be seen on embedded targets) - - 2011-09-11: Simon Goldschmidt - * ppp.h, ppp_impl.h: splitted ppp.h to an internal and external header file - to get a clear separation of which functions an application or port may use - (task #11281) - - 2011-09-11: Simon Goldschmidt - * opt.h, tcp_impl.h, tcp.c, udp.h/.c: Added a config option to randomize - initial local TCP/UDP ports (so that different port ranges are used after - a reboot; bug #33818; this one added tcp_init/udp_init functions again) - - 2011-09-03: Simon Goldschmidt - * dhcp.c: DHCP uses LWIP_RAND() for xid's (bug #30302) - - 2011-08-24: Simon Goldschmidt - * opt.h, netif.h/.c: added netif remove callback (bug #32397) - - 2011-07-26: Simon Goldschmidt - * etharp.c: ETHARP_SUPPORT_VLAN: add support for an external VLAN filter - function instead of only checking for one VLAN (define ETHARP_VLAN_CHECK_FN) - - 2011-07-21: Simon Goldschmidt (patch by hanhui) - * ip4.c, etharp.c, pbuf.h: bug #33634 ip_forward() have a faulty behaviour: - Added pbuf flags to mark incoming packets as link-layer broadcast/multicast. - Also added code to allow ip_forward() to forward non-broadcast packets to - the input netif (set IP_FORWARD_ALLOW_TX_ON_RX_NETIF==1). - - 2011-06-26: Simon Goldschmidt (patch by Cameron Gutman) - * tcp.c, tcp_out.c: bug #33604: added some more asserts to check that - pcb->state != LISTEN - - 2011-05-14: Simon Goldschmidt (patch by Stéphane Lesage) - * tcpip.c/.h: patch #7449 allow tcpip callback from interrupt with static - memory message - - - ++ Bugfixes: - - 2012-09-26: Simon Goldschmidt - * api_msg.c: fixed bug #37405 'err_tcp()' uses already freed 'netconn' object - - 2012-09-26: patch by Henrik Persson - * dhcp.c: patch #7843 Fix corner case with dhcp timeouts - - 2012-09-26: patch by Henrik Persson - * dhcp.c: patch #7840 Segfault in dhcp_parse_reply if no end marker in dhcp packet - - 2012-08-22: Simon Goldschmidt - * memp.c: fixed bug #37166: memp_sanity check loops itself - - 2012-05-08: Simon Goldschmidt - * tcp_out.c: fixed bug: #36380 unsent_oversize mismatch in 1.4.1RC1 (this was - a debug-check issue only) - - 2012-03-27: Simon Goldschmidt - * vj.c: fixed bug #35756 header length calculation problem in ppp/vj.c - - 2012-03-27: Simon Goldschmidt (patch by Mason) - * tcp_out.c: fixed bug #35945: SYN packet should provide the recv MSS not the - send MSS - - 2012-03-22: Simon Goldschmidt - * ip4.c: fixed bug #35927: missing refragmentaion in ip_forward - - 2012-03-20: Simon Goldschmidt (patch by Mason) - * netdb.c: fixed bug #35907: lwip_gethostbyname_r returns an invalid h_addr_list - - 2012-03-12: Simon Goldschmidt (patch by Bostjan Meglic) - * ppp.c: fixed bug #35809: PPP GetMask(): Compiler warning on big endian, - possible bug on little endian system - - 2012-02-23: Simon Goldschmidt - * etharp.c: fixed bug #35595: Impossible to send broadcast without a gateway - (introduced when fixing bug# 33551) - - 2012-02-16: Simon Goldschmidt - * ppp.c: fixed pbuf leak when PPP session is aborted through pppSigHUP() - (bug #35541: PPP Memory Leak) - - 2012-02-16: Simon Goldschmidt - * etharp.c: fixed bug #35531: Impossible to send multicast without a gateway - (introduced when fixing bug# 33551) - - 2012-02-16: Simon Goldschmidt (patch by Stéphane Lesage) - * msg_in.c, msg_out.c: fixed bug #35536 SNMP: error too big response is malformed - - 2012-02-15: Simon Goldschmidt - * init.c: fixed bug #35537: MEMP_NUM_* sanity checks should be disabled with - MEMP_MEM_MALLOC==1 - - 2012-02-12: Simon Goldschmidt - * tcp.h, tcp_in.c, tcp_out.c: partly fixed bug #25882: TCP hangs on - MSS > pcb->snd_wnd (by not creating segments bigger than half the window) - - 2012-02-11: Simon Goldschmidt - * tcp.c: fixed bug #35435: No pcb state check before adding it to time-wait - queue while closing - - 2012-01-22: Simon Goldschmidt - * tcp.c, tcp_in.c: fixed bug #35305: pcb may be freed too early on shutdown(WR) - - 2012-01-21: Simon Goldschmidt - * tcp.c: fixed bug #34636: FIN_WAIT_2 - Incorrect shutdown of TCP pcb - - 2012-01-20: Simon Goldschmidt - * dhcp.c: fixed bug #35151: DHCP asserts on incoming option lengths - - 2012-01-20: Simon Goldschmidt - * pbuf.c: fixed bug #35291: NULL pointer in pbuf_copy - - 2011-11-25: Simon Goldschmidt - * tcp.h/.c, tcp_impl.h, tcp_in.c: fixed bug #31177: tcp timers can corrupt - tcp_active_pcbs in some cases - - 2011-11-23: Simon Goldschmidt - * sys.c: fixed bug #34884: sys_msleep() body needs to be surrounded with - '#ifndef sys_msleep' - - 2011-11-22: Simon Goldschmidt - * netif.c, etharp.h/.c: fixed bug #34684: Clear the arp table cache when - netif is brought down - - 2011-10-28: Simon Goldschmidt - * tcp_in.c: fixed bug #34638: Dead code in tcp_receive - pcb->dupacks - - 2011-10-23: Simon Goldschmidt - * mem.c: fixed bug #34429: possible memory corruption with - LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT set to 1 - - 2011-10-18: Simon Goldschmidt - * arch.h, netdb.c: fixed bug #34592: lwip_gethostbyname_r uses nonstandard - error value - - 2011-10-18: Simon Goldschmidt - * opt.h: fixed default values of TCP_SNDLOWAT and TCP_SNDQUEUELOWAT for small - windows (bug #34176 select after non-blocking send times out) - - 2011-10-18: Simon Goldschmidt - * tcp_impl.h, tcp_out.c: fixed bug #34587: TCP_BUILD_MSS_OPTION doesn't - consider netif->mtu, causes slow network - - 2011-10-18: Simon Goldschmidt - * sockets.c: fixed bug #34581 missing parentheses in udplite sockets code - - 2011-10-18: Simon Goldschmidt - * sockets.h: fixed bug #34580 fcntl() is missing in LWIP_COMPAT_SOCKETS - - 2011-10-17: Simon Goldschmidt - * api_msg.c: fixed bug #34569: shutdown(SHUT_WR) crashes netconn/socket api - - 2011-10-13: Simon Goldschmidt - * tcp_in.c, tcp_out.c: fixed bug #34517 (persist timer is started although no - zero window is received) by starting the persist timer when a zero window is - received, not when we have more data queued for sending than fits into the - window - - 2011-10-13: Simon Goldschmidt - * def.h, timers.c: fixed bug #34541: LWIP_U32_DIFF is unnecessarily complex - - 2011-10-13: Simon Goldschmidt - * sockets.c, api_lib.c: fixed bug #34540: compiler error when CORE_LOCKING is - used and not all protocols are enabled - - 2011-10-12: Simon Goldschmidt - * pbuf.c: fixed bug #34534: Error in sending fragmented IP if MEM_ALIGNMENT > 4 - - 2011-10-09: Simon Goldschmidt - * tcp_out.c: fixed bug #34426: tcp_zero_window_probe() transmits incorrect - byte value when pcb->unacked != NULL - - 2011-10-09: Simon Goldschmidt - * ip4.c: fixed bug #34447 LWIP_IP_ACCEPT_UDP_PORT(dst_port) wrong - - 2011-09-27: Simon Goldschmidt - * tcp_in.c, tcp_out.c: Reset pcb->unsent_oversize in 2 more places... - - 2011-09-27: Simon Goldschmidt - * tcp_in.c: fixed bug #28288: Data after FIN in oos queue - - 2011-09-27: Simon Goldschmidt - * dhcp.c: fixed bug #34406 dhcp_option_hostname() can overflow the pbuf - - 2011-09-24: Simon Goldschmidt - * mem.h: fixed bug #34377 MEM_SIZE_F is not defined if MEM_LIBC_MALLOC==1 - - 2011-09-23: Simon Goldschmidt - * pbuf.h, tcp.c, tcp_in.c: fixed bug #33871: rejecting TCP_EVENT_RECV() for - the last packet including FIN can lose data - - 2011-09-22: Simon Goldschmidt - * tcp_impl.h: fixed bug #34355: nagle does not take snd_buf/snd_queuelen into - account - - 2011-09-21: Simon Goldschmidt - * opt.h: fixed default value of TCP_SND_BUF to not violate the sanity checks - in init.c - - 2011-09-20: Simon Goldschmidt - * timers.c: fixed bug #34337 (possible NULL pointer in sys_check_timeouts) - - 2011-09-11: Simon Goldschmidt - * tcp_out.c: use pcb->mss instead of TCP_MSS for preallocate mss-sized pbufs - (bug #34019) - - 2011-09-09: Simon Goldschmidt - * udp.c: fixed bug #34072: UDP broadcast is received from wrong UDP pcb if - udp port matches - - 2011-09-03: Simon Goldschmidt - * tcp_in.c: fixed bug #33952 PUSH flag in incoming packet is lost when packet - is aggregated and sent to application - - 2011-09-01: Simon Goldschmidt - * opt.h: fixed bug #31809 LWIP_EVENT_API in opts.h is inconsistent compared - to other options - - 2011-09-01: Simon Goldschmidt - * tcp_in.c: fixed bug #34111 RST for ACK to listening pcb has wrong seqno - - 2011-08-24: Simon Goldschmidt - * api_msg.c, sockets.c: fixed bug #33956 Wrong error returned when calling - accept() on UDP connections - - 2011-08-24: Simon Goldschmidt - * sockets.h: fixed bug #34057 socklen_t should be a typedef - - 2011-08-24: Simon Goldschmidt - * pbuf.c: fixed bug #34112 Odd check in pbuf_alloced_custom (typo) - - 2011-08-24: Simon Goldschmidt - * dhcp.c: fixed bug #34122 dhcp: hostname can overflow - - 2011-08-24: Simon Goldschmidt - * netif.c: fixed bug #34121 netif_add/netif_set_ipaddr fail on NULL ipaddr - - 2011-08-22: Simon Goldschmidt - * tcp_out.c: fixed bug #33962 TF_FIN not always set after FIN is sent. (This - merely prevents nagle from not transmitting fast after closing.) - - 2011-07-22: Simon Goldschmidt - * api_lib.c, api_msg.c, sockets.c, api.h: fixed bug #31084 (socket API returns - always EMSGSIZE on non-blocking sockets if data size > send buffers) -> now - lwip_send() sends as much as possible for non-blocking sockets - - 2011-07-22: Simon Goldschmidt - * pbuf.c/.h, timers.c: freeing ooseq pbufs when the pbuf pool is empty implemented - for NO_SYS==1: when not using sys_check_timeouts(), call PBUF_CHECK_FREE_OOSEQ() - at regular intervals from main level. - - 2011-07-21: Simon Goldschmidt - * etharp.c: fixed bug #33551 (ARP entries may time out although in use) by - sending an ARP request when an ARP entry is used in the last minute before - it would time out. - - 2011-07-04: Simon Goldschmidt - * sys_arch.txt: Fixed documentation after changing sys arch prototypes for 1.4.0. - - 2011-06-26: Simon Goldschmidt - * tcp.c: fixed bug #31723 (tcp_kill_prio() kills pcbs with the same prio) by - updating its documentation only. - - 2011-06-26: Simon Goldschmidt - * mem.c: fixed bug #33545: With MEM_USE_POOLS==1, mem_malloc can return an - unaligned pointer. - - 2011-06-26: Simon Goldschmidt - * mem.c: fixed bug #33544 "warning in mem.c in lwip 1.4.0 with NO_SYS=1" - - 2011-05-25: Simon Goldschmidt - * tcp.c: fixed bug #33398 (pointless conversion when checking TCP port range) - - - -(STABLE-1.4.0) - - ++ New features: - - 2011-03-27: Simon Goldschmidt - * tcp_impl.h, tcp_in.c, tcp_out.c: Removed 'dataptr' from 'struct tcp_seg' and - calculate it in tcp_zero_window_probe (the only place where it was used). - - 2010-11-21: Simon Goldschmidt - * dhcp.c/.h: Added a function to deallocate the struct dhcp from a netif - (fixes bug #31525). - - 2010-07-12: Simon Goldschmidt (patch by Stephane Lesage) - * ip.c, udp.c/.h, pbuf.h, sockets.c: task #10495: Added support for - IP_MULTICAST_LOOP at socket- and raw-API level. - - 2010-06-16: Simon Goldschmidt - * ip.c: Added an optional define (LWIP_IP_ACCEPT_UDP_PORT) that can allow - link-layer-addressed UDP traffic to be received while a netif is down (just - like DHCP during configuration) - - 2010-05-22: Simon Goldschmidt - * many many files: bug #27352: removed packing from ip_addr_t, the packed - version is now only used in protocol headers. Added global storage for - current src/dest IP address while in input functions. - - 2010-05-16: Simon Goldschmidt - * def.h: task #10391: Add preprocessor-macros for compile-time htonl - calculation (and use them throughout the stack where applicable) - - 2010-05-16: Simon Goldschmidt - * opt.h, memp_std.h, memp.c, ppp_oe.h/.c: PPPoE now uses its own MEMP pool - instead of the heap (moved struct pppoe_softc from ppp_oe.c to ppp_oe.h) - - 2010-05-16: Simon Goldschmidt - * opt.h, memp_std.h, dns.h/.c: DNS_LOCAL_HOSTLIST_IS_DYNAMIC uses its own - MEMP pool instead of the heap - - 2010-05-13: Simon Goldschmidt - * tcp.c, udp.c: task #6995: Implement SO_REUSEADDR (correctly), added - new option SO_REUSE_RXTOALL to pass received UDP broadcast/multicast - packets to more than one pcb. - - 2010-05-02: Simon Goldschmidt - * netbuf.h/.c, sockets.c, api_msg.c: use checksum-on-copy for sending - UDP data for LWIP_NETIF_TX_SINGLE_PBUF==1 - - 2010-04-30: Simon Goldschmidt - * udp.h/.c, pbuf.h/.c: task #6849: added udp_send(_to/_if) functions that - take a precalculated checksum, added pbuf_fill_chksum() to copy data - into a pbuf and at the same time calculating the checksum for that data - - 2010-04-29: Simon Goldschmidt - * ip_addr.h, etharp.h/.c, autoip.c: Create overridable macros for copying - 2-byte-aligned IP addresses and MAC addresses - - 2010-04-28: Patch by Bill Auerbach - * ip.c: Inline generating IP checksum to save a function call - - 2010-04-14: Simon Goldschmidt - * tcpip.h/.c, timers.c: Added an overridable define to get informed when the - tcpip_thread processes messages or timeouts to implement a watchdog. - - 2010-03-28: Simon Goldschmidt - * ip_frag.c: create a new (contiguous) PBUF_RAM for every outgoing - fragment if LWIP_NETIF_TX_SINGLE_PBUF==1 - - 2010-03-27: Simon Goldschmidt - * etharp.c: Speedup TX by moving code from find_entry to etharp_output/ - etharp_query to prevent unnecessary function calls (inspired by - patch #7135). - - 2010-03-20: Simon Goldschmidt - * opt.h, tcpip.c/.h: Added an option to disable tcpip_(un)timeout code - since the linker cannot do this automatically to save space. - - 2010-03-20: Simon Goldschmidt - * opt.h, etharp.c/.h: Added support for static ARP table entries - - 2010-03-14: Simon Goldschmidt - * tcp_impl.h, tcp_out.c, inet_chksum.h/.c: task #6849: Calculate checksum - when creating TCP segments, not when (re-)transmitting them. - - 2010-03-07: Simon Goldschmidt - * sockets.c: bug #28775 (select/event_callback: only check select_cb_list - on change) plus use SYS_LIGHTWEIGHT_PROT to protect the select code. - This should speed up receiving data on sockets as the select code in - event_callback is only executed when select is waiting. - - 2010-03-06: Simon Goldschmidt - * tcp_out.c: task #7013 (Create option to have all packets delivered to - netif->output in one piece): Always copy to try to create single pbufs - in tcp_write. - - 2010-03-06: Simon Goldschmidt - * api.h, api_lib.c, sockets.c: task #10167 (sockets: speed up TCP recv - by not allocating a netbuf): added function netconn_recv_tcp_pbuf() - for tcp netconns to receive pbufs, not netbufs; use that function - for tcp sockets. - - 2010-03-05: Jakob Ole Stoklundsen / Simon Goldschmidt - * opt.h, tcp.h, tcp_impl.h, tcp.c, tcp_in.c, tcp_out.c: task #7040: - Work on tcp_enqueue: Don't waste memory when chaining segments, - added option TCP_OVERSIZE to prevent creating many small pbufs when - calling tcp_write with many small blocks of data. Instead, pbufs are - allocated larger than needed and the space is used for later calls to - tcp_write. - - 2010-02-21: Simon Goldschmidt - * stats.c/.h: Added const char* name to mem- and memp-stats for easier - debugging. - - 2010-02-21: Simon Goldschmidt - * tcp.h (and usages), added tcp_impl.h: Splitted API and internal - implementation of tcp to make API usage cleare to application programmers - - 2010-02-14: Simon Goldschmidt/Stephane Lesage - * ip_addr.h: Improved some defines working on ip addresses, added faster - macro to copy addresses that cannot be NULL - - 2010-02-13: Simon Goldschmidt - * api.h, api_lib.c, api_msg.c, sockets.c: task #7865 (implement non- - blocking send operation) - - 2010-02-12: Simon Goldschmidt - * sockets.c/.h: Added a minimal version of posix fctl() to have a - standardised way to set O_NONBLOCK for nonblocking sockets. - - 2010-02-12: Simon Goldschmidt - * dhcp.c/.h, autoip.c/.h: task #10139 (Prefer statically allocated - memory): added autoip_set_struct() and dhcp_set_struct() to let autoip - and dhcp work with user-allocated structs instead of callin mem_malloc - - 2010-02-12: Simon Goldschmidt/Jeff Barber - * tcp.c/h: patch #6865 (SO_REUSEADDR for TCP): if pcb.so_options has - SOF_REUSEADDR set, allow binding to endpoint in TIME_WAIT - - 2010-02-12: Simon Goldschmidt - * sys layer: task #10139 (Prefer statically allocated memory): converted - mbox and semaphore functions to take pointers to sys_mbox_t/sys_sem_t; - converted sys_mbox_new/sys_sem_new to take pointers and return err_t; - task #7212: Add Mutex concept in sys_arch (define LWIP_COMPAT_MUTEX - to let sys.h use binary semaphores instead of mutexes - as before) - - 2010-02-09: Simon Goldschmidt (Simon Kallweit) - * timers.c/.h: Added function sys_restart_timeouts() from patch #7085 - (Restart system timeout handling) - - 2010-02-09: Simon Goldschmidt - * netif.c/.h, removed loopif.c/.h: task #10153 (Integrate loopif into - netif.c) - loopif does not have to be created by the port any more, - just define LWIP_HAVE_LOOPIF to 1. - - 2010-02-08: Simon Goldschmidt - * inet.h, ip_addr.c/.h: Added reentrant versions of inet_ntoa/ipaddr_ntoa - inet_ntoa_r/ipaddr_ntoa_r - - 2010-02-08: Simon Goldschmidt - * netif.h: Added netif_s/get_igmp_mac_filter() macros - - 2010-02-05: Simon Goldschmidt - * netif.h: Added function-like macros to get/set the hostname on a netif - - 2010-02-04: Simon Goldschmidt - * nearly every file: Replaced struct ip_addr by typedef ip_addr_t to - make changing the actual implementation behind the typedef easier. - - 2010-02-01: Simon Goldschmidt - * opt.h, memp_std.h, dns.h, netdb.c, memp.c: Let netdb use a memp pool - for allocating memory when getaddrinfo() is called. - - 2010-01-31: Simon Goldschmidt - * dhcp.h, dhcp.c: Reworked the code that parses DHCP options: parse - them once instead of parsing for every option. This also removes - the need for mem_malloc from dhcp_recv and makes it possible to - correctly retrieve the BOOTP file. - - 2010-01-30: simon Goldschmidt - * sockets.c: Use SYS_LIGHTWEIGHT_PROT instead of a semaphore to protect - the sockets array. - - 2010-01-29: Simon Goldschmidt (patch by Laura Garrett) - * api.h, api_msg.c, sockets.c: Added except set support in select - (patch #6860) - - 2010-01-29: Simon Goldschmidt (patch by Laura Garrett) - * api.h, sockets.h, err.h, api_lib.c, api_msg.c, sockets.c, err.c: - Add non-blocking support for connect (partly from patch #6860), - plus many cleanups in socket & netconn API. - - 2010-01-27: Simon Goldschmidt - * opt.h, tcp.h, init.c, api_msg.c: Added TCP_SNDQUEUELOWAT corresponding - to TCP_SNDLOWAT and added tcp_sndqueuelen() - this fixes bug #28605 - - 2010-01-26: Simon Goldschmidt - * snmp: Use memp pools for snmp instead of the heap; added 4 new pools. - - 2010-01-14: Simon Goldschmidt - * ppp.c/.h: Fixed bug #27856: PPP: Set netif link- and status-callback - by adding ppp_set_netif_statuscallback()/ppp_set_netif_linkcallback() - - 2010-01-13: Simon Goldschmidt - * mem.c: The heap now may be moved to user-defined memory by defining - LWIP_RAM_HEAP_POINTER as a void pointer to that memory's address - (patch #6966 and bug #26133) - - 2010-01-10: Simon Goldschmidt (Bill Auerbach) - * opt.h, memp.c: patch #6822 (Add option to place memory pools in - separate arrays) - - 2010-01-10: Simon Goldschmidt - * init.c, igmp.c: patch #6463 (IGMP - Adding Random Delay): added define - LWIP_RAND() for lwip-wide randomization (to be defined in cc.h) - - 2009-12-31: Simon Goldschmidt - * tcpip.c, init.c, memp.c, sys.c, memp_std.h, sys.h, tcpip.h - added timers.c/.h: Separated timer implementation from semaphore/mbox - implementation, moved timer implementation to timers.c/.h, timers are - now only called from tcpip_thread or by explicitly checking them. - (TASK#7235) - - 2009-12-27: Simon Goldschmidt - * opt.h, etharp.h/.c, init.c, tcpip.c: Added an additional option - LWIP_ETHERNET to support ethernet without ARP (necessary for pure PPPoE) - - - ++ Bugfixes: - - 2011-04-20: Simon Goldschmidt - * sys_arch.txt: sys_arch_timeouts() is not needed any more. - - 2011-04-13: Simon Goldschmidt - * tcp.c, udp.c: Fixed bug #33048 (Bad range for IP source port numbers) by - using ports in the IANA private/dynamic range (49152 through 65535). - - 2011-03-29: Simon Goldschmidt, patch by Emil Lhungdahl: - * etharp.h/.c: Fixed broken VLAN support. - - 2011-03-27: Simon Goldschmidt - * tcp.c: Fixed bug #32926 (TCP_RMV(&tcp_bound_pcbs) is called on unbound tcp - pcbs) by checking if the pcb was bound (local_port != 0). - - 2011-03-27: Simon Goldschmidt - * ppp.c: Fixed bug #32280 (ppp: a pbuf is freed twice) - - 2011-03-27: Simon Goldschmidt - * sockets.c: Fixed bug #32906: lwip_connect+lwip_send did not work for udp and - raw pcbs with LWIP_TCPIP_CORE_LOCKING==1. - - 2011-03-27: Simon Goldschmidt - * tcp_out.c: Fixed bug #32820 (Outgoing TCP connections created before route - is present never times out) by starting retransmission timer before checking - route. - - 2011-03-22: Simon Goldschmidt - * ppp.c: Fixed bug #32648 (PPP code crashes when terminating a link) by only - calling sio_read_abort() if the file descriptor is valid. - - 2011-03-14: Simon Goldschmidt - * err.h/.c, sockets.c, api_msg.c: fixed bug #31748 (Calling non-blocking connect - more than once can render a socket useless) since it mainly involves changing - "FATAL" classification of error codes: ERR_USE and ERR_ISCONN just aren't fatal. - - 2011-03-13: Simon Goldschmidt - * sockets.c: fixed bug #32769 (ESHUTDOWN is linux-specific) by fixing - err_to_errno_table (ERR_CLSD: ENOTCONN instead of ESHUTDOWN), ERR_ISCONN: - use EALRADY instead of -1 - - 2011-03-13: Simon Goldschmidt - * api_lib.c: netconn_accept: return ERR_ABRT instead of ERR_CLSD if the - connection has been aborted by err_tcp (since this is not a normal closing - procedure). - - 2011-03-13: Simon Goldschmidt - * tcp.c: tcp_bind: return ERR_VAL instead of ERR_ISCONN when trying to bind - with pcb->state != CLOSED - - 2011-02-17: Simon Goldschmidt - * rawapi.txt: Fixed bug #32561 tcp_poll argument definition out-of-order in - documentation - - 2011-02-17: Simon Goldschmidt - * many files: Added missing U/UL modifiers to fix 16-bit-arch portability. - - 2011-01-24: Simon Goldschmidt - * sockets.c: Fixed bug #31741: lwip_select seems to have threading problems - - 2010-12-02: Simon Goldschmidt - * err.h: Fixed ERR_IS_FATAL so that ERR_WOULDBLOCK is not fatal. - - 2010-11-23: Simon Goldschmidt - * api.h, api_lib.c, api_msg.c, sockets.c: netconn.recv_avail is only used for - LWIP_SO_RCVBUF and ioctl/FIONREAD. - - 2010-11-23: Simon Goldschmidt - * etharp.c: Fixed bug #31720: ARP-queueing: RFC 1122 recommends to queue at - least 1 packet -> ARP_QUEUEING==0 now queues the most recent packet. - - 2010-11-23: Simon Goldschmidt - * tcp_in.c: Fixed bug #30577: tcp_input: don't discard ACK-only packets after - refusing 'refused_data' again. - - 2010-11-22: Simon Goldschmidt - * sockets.c: Fixed bug #31590: getsockopt(... SO_ERROR ...) gives EINPROGRESS - after a successful nonblocking connection. - - 2010-11-22: Simon Goldschmidt - * etharp.c: Fixed bug #31722: IP packets sent with an AutoIP source addr - must be sent link-local - - 2010-11-22: Simon Goldschmidt - * timers.c: patch #7329: tcp_timer_needed prototype was ifdef'ed out for - LWIP_TIMERS==0 - - 2010-11-20: Simon Goldschmidt - * sockets.c: Fixed bug #31170: lwip_setsockopt() does not set socket number - - 2010-11-20: Simon Goldschmidt - * sockets.h: Fixed bug #31304: Changed SHUT_RD, SHUT_WR and SHUT_RDWR to - resemble other stacks. - - 2010-11-20: Simon Goldschmidt - * dns.c: Fixed bug #31535: TCP_SND_QUEUELEN must be at least 2 or else - no-copy TCP writes will never succeed. - - 2010-11-20: Simon Goldschmidt - * dns.c: Fixed bug #31701: Error return value from dns_gethostbyname() does - not match documentation: return ERR_ARG instead of ERR_VAL if not - initialized or wrong argument. - - 2010-10-20: Simon Goldschmidt - * sockets.h: Fixed bug #31385: sizeof(struct sockaddr) is 30 but should be 16 - - 2010-10-05: Simon Goldschmidt - * dhcp.c: Once again fixed #30038: DHCP/AutoIP cooperation failed when - replugging the network cable after an AutoIP address was assigned. - - 2010-08-10: Simon Goldschmidt - * tcp.c: Fixed bug #30728: tcp_new_port() did not check listen pcbs - - 2010-08-03: Simon Goldschmidt - * udp.c, raw.c: Don't chain empty pbufs when sending them (fixes bug #30625) - - 2010-08-01: Simon Goldschmidt (patch by Greg Renda) - * ppp.c: Applied patch #7264 (PPP protocols are rejected incorrectly on big - endian architectures) - - 2010-07-28: Simon Goldschmidt - * api_lib.c, api_msg.c, sockets.c, mib2.c: Fixed compilation with TCP or UDP - disabled. - - 2010-07-27: Simon Goldschmidt - * tcp.c: Fixed bug #30565 (tcp_connect() check bound list): that check did no - harm but never did anything - - 2010-07-21: Simon Goldschmidt - * ip.c: Fixed invalid fix for bug #30402 (CHECKSUM_GEN_IP_INLINE does not - add IP options) - - 2010-07-16: Kieran Mansley - * msg_in.c: Fixed SNMP ASN constant defines to not use ! operator - - 2010-07-10: Simon Goldschmidt - * ip.c: Fixed bug #30402: CHECKSUM_GEN_IP_INLINE does not add IP options - - 2010-06-30: Simon Goldschmidt - * api_msg.c: fixed bug #30300 (shutdown parameter was not initialized in - netconn_delete) - - 2010-06-28: Kieran Mansley - * timers.c remove unportable printing of C function pointers - - 2010-06-24: Simon Goldschmidt - * init.c, timers.c/.h, opt.h, memp_std.h: From patch #7221: added flag - NO_SYS_NO_TIMERS to drop timer support for NO_SYS==1 for easier upgrading - - 2010-06-24: Simon Goldschmidt - * api(_lib).c/.h, api_msg.c/.h, sockets.c/.h: Fixed bug #10088: Correctly - implemented shutdown at socket level. - - 2010-06-21: Simon Goldschmidt - * pbuf.c/.h, ip_frag.c/.h, opt.h, memp_std.h: Fixed bug #29361 (ip_frag has - problems with zero-copy DMA MACs) by adding custom pbufs and implementing - custom pbufs that reference other (original) pbufs. Additionally set - IP_FRAG_USES_STATIC_BUF=0 as default to be on the safe side. - - 2010-06-15: Simon Goldschmidt - * dhcp.c: Fixed bug #29970: DHCP endian issue parsing option responses - - 2010-06-14: Simon Goldschmidt - * autoip.c: Fixed bug #30039: AutoIP does not reuse previous addresses - - 2010-06-12: Simon Goldschmidt - * dhcp.c: Fixed bug #30038: dhcp_network_changed doesn't reset AUTOIP coop - state - - 2010-05-17: Simon Goldschmidt - * netdb.c: Correctly NULL-terminate h_addr_list - - 2010-05-16: Simon Goldschmidt - * def.h/.c: changed the semantics of LWIP_PREFIX_BYTEORDER_FUNCS to prevent - "symbol already defined" i.e. when linking to winsock - - 2010-05-05: Simon Goldschmidt - * def.h, timers.c: Fixed bug #29769 (sys_check_timeouts: sys_now() may - overflow) - - 2010-04-21: Simon Goldschmidt - * api_msg.c: Fixed bug #29617 (sometime cause stall on delete listening - connection) - - 2010-03-28: Luca Ceresoli - * ip_addr.c/.h: patch #7143: Add a few missing const qualifiers - - 2010-03-27: Luca Ceresoli - * mib2.c: patch #7130: remove meaningless const qualifiers - - 2010-03-26: Simon Goldschmidt - * tcp_out.c: Make LWIP_NETIF_TX_SINGLE_PBUF work for TCP, too - - 2010-03-26: Simon Goldschmidt - * various files: Fixed compiling with different options disabled (TCP/UDP), - triggered by bug #29345; don't allocate acceptmbox if LWIP_TCP is disabled - - 2010-03-25: Simon Goldschmidt - * sockets.c: Fixed bug #29332: lwip_select() processes readset incorrectly - - 2010-03-25: Simon Goldschmidt - * tcp_in.c, test_tcp_oos.c: Fixed bug #29080: Correctly handle remote side - overrunning our rcv_wnd in ooseq case. - - 2010-03-22: Simon Goldschmidt - * tcp.c: tcp_listen() did not copy the pcb's prio. - - 2010-03-19: Simon Goldschmidt - * snmp_msg.c: Fixed bug #29256: SNMP Trap address was not correctly set - - 2010-03-14: Simon Goldschmidt - * opt.h, etharp.h: Fixed bug #29148 (Incorrect PBUF_POOL_BUFSIZE for ports - where ETH_PAD_SIZE > 0) by moving definition of ETH_PAD_SIZE to opt.h - and basing PBUF_LINK_HLEN on it. - - 2010-03-08: Simon Goldschmidt - * netif.c, ipv4/ip.c: task #10241 (AutoIP: don't break existing connections - when assiging routable address): when checking incoming packets and - aborting existing connection on address change, filter out link-local - addresses. - - 2010-03-06: Simon Goldschmidt - * sockets.c: Fixed LWIP_NETIF_TX_SINGLE_PBUF for LWIP_TCPIP_CORE_LOCKING - - 2010-03-06: Simon Goldschmidt - * ipv4/ip.c: Don't try to forward link-local addresses - - 2010-03-06: Simon Goldschmidt - * etharp.c: Fixed bug #29087: etharp: don't send packets for LinkLocal- - addresses to gw - - 2010-03-05: Simon Goldschmidt - * dhcp.c: Fixed bug #29072: Correctly set ciaddr based on message-type - and state. - - 2010-03-05: Simon Goldschmidt - * api_msg.c: Correctly set TCP_WRITE_FLAG_MORE when netconn_write is split - into multiple calls to tcp_write. - - 2010-02-21: Simon Goldschmidt - * opt.h, mem.h, dns.c: task #10140: Remove DNS_USES_STATIC_BUF (keep - the implementation of DNS_USES_STATIC_BUF==1) - - 2010-02-20: Simon Goldschmidt - * tcp.h, tcp.c, tcp_in.c, tcp_out.c: Task #10088: Correctly implement - close() vs. shutdown(). Now the application does not get any more - recv callbacks after calling tcp_close(). Added tcp_shutdown(). - - 2010-02-19: Simon Goldschmidt - * mem.c/.h, pbuf.c: Renamed mem_realloc() to mem_trim() to prevent - confusion with realloc() - - 2010-02-15: Simon Goldschmidt/Stephane Lesage - * netif.c/.h: Link status does not depend on LWIP_NETIF_LINK_CALLBACK - (fixes bug #28899) - - 2010-02-14: Simon Goldschmidt - * netif.c: Fixed bug #28877 (Duplicate ARP gratuitous packet with - LWIP_NETIF_LINK_CALLBACK set on) by only sending if both link- and - admin-status of a netif are up - - 2010-02-14: Simon Goldschmidt - * opt.h: Disable ETHARP_TRUST_IP_MAC by default since it slows down packet - reception and is not really necessary - - 2010-02-14: Simon Goldschmidt - * etharp.c/.h: Fixed ARP input processing: only add a new entry if a - request was directed as us (RFC 826, Packet Reception), otherwise - only update existing entries; internalized some functions - - 2010-02-14: Simon Goldschmidt - * netif.h, etharp.c, tcpip.c: Fixed bug #28183 (ARP and TCP/IP cannot be - disabled on netif used for PPPoE) by adding a new netif flag - (NETIF_FLAG_ETHERNET) that tells the stack the device is an ethernet - device but prevents usage of ARP (so that ethernet_input can be used - for PPPoE). - - 2010-02-12: Simon Goldschmidt - * netif.c: netif_set_link_up/down: only do something if the link state - actually changes - - 2010-02-12: Simon Goldschmidt/Stephane Lesage - * api_msg.c: Fixed bug #28865 (Cannot close socket/netconn in non-blocking - connect) - - 2010-02-12: Simon Goldschmidt - * mem.h: Fixed bug #28866 (mem_realloc function defined in mem.h) - - 2010-02-09: Simon Goldschmidt - * api_lib.c, api_msg.c, sockets.c, api.h, api_msg.h: Fixed bug #22110 - (recv() makes receive window update for data that wasn't received by - application) - - 2010-02-09: Simon Goldschmidt/Stephane Lesage - * sockets.c: Fixed bug #28853 (lwip_recvfrom() returns 0 on receive time-out - or any netconn_recv() error) - - 2010-02-09: Simon Goldschmidt - * ppp.c: task #10154 (PPP: Update snmp in/out counters for tx/rx packets) - - 2010-02-09: Simon Goldschmidt - * netif.c: For loopback packets, adjust the stats- and snmp-counters - for the loopback netif. - - 2010-02-08: Simon Goldschmidt - * igmp.c/.h, ip.h: Moved most defines from igmp.h to igmp.c for clarity - since they are not used anywhere else. - - 2010-02-08: Simon Goldschmidt (Stéphane Lesage) - * igmp.c, igmp.h, stats.c, stats.h: Improved IGMP stats - (patch from bug #28798) - - 2010-02-08: Simon Goldschmidt (Stéphane Lesage) - * igmp.c: Fixed bug #28798 (Error in "Max Response Time" processing) and - another bug when LWIP_RAND() returns zero. - - 2010-02-04: Simon Goldschmidt - * nearly every file: Use macros defined in ip_addr.h (some of them new) - to work with IP addresses (preparation for bug #27352 - Change ip_addr - from struct to typedef (u32_t) - and better code). - - 2010-01-31: Simon Goldschmidt - * netif.c: Don't call the link-callback from netif_set_up/down() since - this invalidly retriggers DHCP. - - 2010-01-29: Simon Goldschmidt - * ip_addr.h, inet.h, def.h, inet.c, def.c, more: Cleanly separate the - portability file inet.h and its contents from the stack: moved htonX- - functions to def.h (and the new def.c - they are not ipv4 dependent), - let inet.h depend on ip_addr.h and not the other way round. - This fixes bug #28732. - - 2010-01-28: Kieran Mansley - * tcp.c: Ensure ssthresh >= 2*MSS - - 2010-01-27: Simon Goldschmidt - * tcp.h, tcp.c, tcp_in.c: Fixed bug #27871: Calling tcp_abort() in recv - callback can lead to accessing unallocated memory. As a consequence, - ERR_ABRT means the application has called tcp_abort()! - - 2010-01-25: Simon Goldschmidt - * snmp_structs.h, msg_in.c: Partly fixed bug #22070 (MIB_OBJECT_WRITE_ONLY - not implemented in SNMP): write-only or not-accessible are still - returned by getnext (though not by get) - - 2010-01-24: Simon Goldschmidt - * snmp: Renamed the private mib node from 'private' to 'mib_private' to - not use reserved C/C++ keywords - - 2010-01-23: Simon Goldschmidt - * sockets.c: Fixed bug #28716: select() returns 0 after waiting for less - than 1 ms - - 2010-01-21: Simon Goldschmidt - * tcp.c, api_msg.c: Fixed bug #28651 (tcp_connect: no callbacks called - if tcp_enqueue fails) both in raw- and netconn-API - - 2010-01-19: Simon Goldschmidt - * api_msg.c: Fixed bug #27316: netconn: Possible deadlock in err_tcp - - 2010-01-18: Iordan Neshev/Simon Goldschmidt - * src/netif/ppp: reorganised PPP sourcecode to 2.3.11 including some - bugfix backports from 2.4.x. - - 2010-01-18: Simon Goldschmidt - * mem.c: Fixed bug #28679: mem_realloc calculates mem_stats wrong - - 2010-01-17: Simon Goldschmidt - * api_lib.c, api_msg.c, (api_msg.h, api.h, sockets.c, tcpip.c): - task #10102: "netconn: clean up conn->err threading issues" by adding - error return value to struct api_msg_msg - - 2010-01-17: Simon Goldschmidt - * api.h, api_lib.c, sockets.c: Changed netconn_recv() and netconn_accept() - to return err_t (bugs #27709 and #28087) - - 2010-01-14: Simon Goldschmidt - * ...: Use typedef for function prototypes throughout the stack. - - 2010-01-13: Simon Goldschmidt - * api_msg.h/.c, api_lib.c: Fixed bug #26672 (close connection when receive - window = 0) by correctly draining recvmbox/acceptmbox - - 2010-01-11: Simon Goldschmidt - * pap.c: Fixed bug #13315 (PPP PAP authentication can result in - erroneous callbacks) by copying the code from recent pppd - - 2010-01-10: Simon Goldschmidt - * raw.c: Fixed bug #28506 (raw_bind should filter received packets) - - 2010-01-10: Simon Goldschmidt - * tcp.h/.c: bug #28127 (remove call to tcp_output() from tcp_ack(_now)()) - - 2010-01-08: Simon Goldschmidt - * sockets.c: Fixed bug #28519 (lwip_recvfrom bug with len > 65535) - - 2010-01-08: Simon Goldschmidt - * dns.c: Copy hostname for DNS_LOCAL_HOSTLIST_IS_DYNAMIC==1 since string - passed to dns_local_addhost() might be volatile - - 2010-01-07: Simon Goldschmidt - * timers.c, tcp.h: Call tcp_timer_needed() with NO_SYS==1, too - - 2010-01-06: Simon Goldschmidt - * netdb.h: Fixed bug #28496: missing include guards in netdb.h - - 2009-12-31: Simon Goldschmidt - * many ppp files: Reorganised PPP source code from ucip structure to pppd - structure to easily compare our code against the pppd code (around v2.3.1) - - 2009-12-27: Simon Goldschmidt - * tcp_in.c: Another fix for bug #28241 (ooseq processing) and adapted - unit test - - -(STABLE-1.3.2) - - ++ New features: - - 2009-10-27 Simon Goldschmidt/Stephan Lesage - * netifapi.c/.h: Added netifapi_netif_set_addr() - - 2009-10-07 Simon Goldschmidt/Fabian Koch - * api_msg.c, netbuf.c/.h, opt.h: patch #6888: Patch for UDP Netbufs to - support dest-addr and dest-port (optional: LWIP_NETBUF_RECVINFO) - - 2009-08-26 Simon Goldschmidt/Simon Kallweit - * slipif.c/.h: bug #26397: SLIP polling support - - 2009-08-25 Simon Goldschmidt - * opt.h, etharp.h/.c: task #9033: Support IEEE 802.1q tagged frame (VLAN), - New configuration options ETHARP_SUPPORT_VLAN and ETHARP_VLAN_CHECK. - - 2009-08-25 Simon Goldschmidt - * ip_addr.h, netdb.c: patch #6900: added define ip_ntoa(struct ip_addr*) - - 2009-08-24 Jakob Stoklund Olesen - * autoip.c, dhcp.c, netif.c: patch #6725: Teach AutoIP and DHCP to respond - to netif_set_link_up(). - - 2009-08-23 Simon Goldschmidt - * tcp.h/.c: Added function tcp_debug_state_str() to convert a tcp state - to a human-readable string. - - ++ Bugfixes: - - 2009-12-24: Kieran Mansley - * tcp_in.c Apply patches from Oleg Tyshev to improve OOS processing - (BUG#28241) - - 2009-12-06: Simon Goldschmidt - * ppp.h/.c: Fixed bug #27079 (Yet another leak in PPP): outpacket_buf can - be statically allocated (like in ucip) - - 2009-12-04: Simon Goldschmidt (patch by Ioardan Neshev) - * pap.c: patch #6969: PPP: missing PAP authentication UNTIMEOUT - - 2009-12-03: Simon Goldschmidt - * tcp.h, tcp_in.c, tcp_out.c: Fixed bug #28106: dup ack for fast retransmit - could have non-zero length - - 2009-12-02: Simon Goldschmidt - * tcp_in.c: Fixed bug #27904: TCP sends too many ACKs: delay resetting - tcp_input_pcb until after calling the pcb's callbacks - - 2009-11-29: Simon Goldschmidt - * tcp_in.c: Fixed bug #28054: Two segments with FIN flag on the out-of- - sequence queue, also fixed PBUF_POOL leak in the out-of-sequence code - - 2009-11-29: Simon Goldschmidt - * pbuf.c: Fixed bug #28064: pbuf_alloc(PBUF_POOL) is not thread-safe by - queueing a call into tcpip_thread to free ooseq-bufs if the pool is empty - - 2009-11-26: Simon Goldschmidt - * tcp.h: Fixed bug #28098: Nagle can prevent fast retransmit from sending - segment - - 2009-11-26: Simon Goldschmidt - * tcp.h, sockets.c: Fixed bug #28099: API required to disable Nagle - algorithm at PCB level - - 2009-11-22: Simon Goldschmidt - * tcp_out.c: Fixed bug #27905: FIN isn't combined with data on unsent - - 2009-11-22: Simon Goldschmidt (suggested by Bill Auerbach) - * tcp.c: tcp_alloc: prevent increasing stats.err for MEMP_TCP_PCB when - reusing time-wait pcb - - 2009-11-20: Simon Goldschmidt (patch by Albert Bartel) - * sockets.c: Fixed bug #28062: Data received directly after accepting - does not wake up select - - 2009-11-11: Simon Goldschmidt - * netdb.h: Fixed bug #27994: incorrect define for freeaddrinfo(addrinfo) - - 2009-10-30: Simon Goldschmidt - * opt.h: Increased default value for TCP_MSS to 536, updated default - value for TCP_WND to 4*TCP_MSS to keep delayed ACK working. - - 2009-10-28: Kieran Mansley - * tcp_in.c, tcp_out.c, tcp.h: re-work the fast retransmission code - to follow algorithm from TCP/IP Illustrated - - 2009-10-27: Kieran Mansley - * tcp_in.c: fix BUG#27445: grow cwnd with every duplicate ACK - - 2009-10-25: Simon Goldschmidt - * tcp.h: bug-fix in the TCP_EVENT_RECV macro (has to call tcp_recved if - pcb->recv is NULL to keep rcv_wnd correct) - - 2009-10-25: Simon Goldschmidt - * tcp_in.c: Fixed bug #26251: RST process in TIME_WAIT TCP state - - 2009-10-23: Simon Goldschmidt (David Empson) - * tcp.c: Fixed bug #27783: Silly window avoidance for small window sizes - - 2009-10-21: Simon Goldschmidt - * tcp_in.c: Fixed bug #27215: TCP sent() callback gives leading and - trailing 1 byte len (SYN/FIN) - - 2009-10-21: Simon Goldschmidt - * tcp_out.c: Fixed bug #27315: zero window probe and FIN - - 2009-10-19: Simon Goldschmidt - * dhcp.c/.h: Minor code simplification (don't store received pbuf, change - conditional code to assert where applicable), check pbuf length before - testing for valid reply - - 2009-10-19: Simon Goldschmidt - * dhcp.c: Removed most calls to udp_connect since they aren't necessary - when using udp_sendto_if() - always stay connected to IP_ADDR_ANY. - - 2009-10-16: Simon Goldschmidt - * ip.c: Fixed bug #27390: Source IP check in ip_input() causes it to drop - valid DHCP packets -> allow 0.0.0.0 as source address when LWIP_DHCP is - enabled - - 2009-10-15: Simon Goldschmidt (Oleg Tyshev) - * tcp_in.c: Fixed bug #27329: dupacks by unidirectional data transmit - - 2009-10-15: Simon Goldschmidt - * api_lib.c: Fixed bug #27709: conn->err race condition on netconn_recv() - timeout - - 2009-10-15: Simon Goldschmidt - * autoip.c: Fixed bug #27704: autoip starts with wrong address - LWIP_AUTOIP_CREATE_SEED_ADDR() returned address in host byte order instead - of network byte order - - 2009-10-11 Simon Goldschmidt (Jörg Kesten) - * tcp_out.c: Fixed bug #27504: tcp_enqueue wrongly concatenates segments - which are not consecutive when retransmitting unacked segments - - 2009-10-09 Simon Goldschmidt - * opt.h: Fixed default values of some stats to only be enabled if used - Fixes bug #27338: sys_stats is defined when NO_SYS = 1 - - 2009-08-30 Simon Goldschmidt - * ip.c: Fixed bug bug #27345: "ip_frag() does not use the LWIP_NETIF_LOOPBACK - function" by checking for loopback before calling ip_frag - - 2009-08-25 Simon Goldschmidt - * dhcp.c: fixed invalid dependency to etharp_query if DHCP_DOES_ARP_CHECK==0 - - 2009-08-23 Simon Goldschmidt - * ppp.c: bug #27078: Possible memory leak in pppInit() - - 2009-08-23 Simon Goldschmidt - * netdb.c, dns.c: bug #26657: DNS, if host name is "localhost", result - is error. - - 2009-08-23 Simon Goldschmidt - * opt.h, init.c: bug #26649: TCP fails when TCP_MSS > TCP_SND_BUF - Fixed wrong parenthesis, added check in init.c - - 2009-08-23 Simon Goldschmidt - * ppp.c: bug #27266: wait-state debug message in pppMain occurs every ms - - 2009-08-23 Simon Goldschmidt - * many ppp files: bug #27267: Added include to string.h where needed - - 2009-08-23 Simon Goldschmidt - * tcp.h: patch #6843: tcp.h macro optimization patch (for little endian) - - -(STABLE-1.3.1) - - ++ New features: - - 2009-05-10 Simon Goldschmidt - * opt.h, sockets.c, pbuf.c, netbuf.h, pbuf.h: task #7013: Added option - LWIP_NETIF_TX_SINGLE_PBUF to try to create transmit packets from only - one pbuf to help MACs that don't support scatter-gather DMA. - - 2009-05-09 Simon Goldschmidt - * icmp.h, icmp.c: Shrinked ICMP code, added option to NOT check icoming - ECHO pbuf for size (just use it): LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN - - 2009-05-05 Simon Goldschmidt, Jakob Stoklund Olesen - * ip.h, ip.c: Added ip_current_netif() & ip_current_header() to receive - extended info about the currently received packet. - - 2009-04-27 Simon Goldschmidt - * sys.h: Made SYS_LIGHTWEIGHT_PROT and sys_now() work with NO_SYS=1 - - 2009-04-25 Simon Goldschmidt - * mem.c, opt.h: Added option MEM_USE_POOLS_TRY_BIGGER_POOL to try the next - bigger malloc pool if one is empty (only usable with MEM_USE_POOLS). - - 2009-04-21 Simon Goldschmidt - * dns.c, init.c, dns.h, opt.h: task #7507, patch #6786: DNS supports static - hosts table. New configuration options DNS_LOCAL_HOSTLIST and - DNS_LOCAL_HOSTLIST_IS_DYNAMIC. Also, DNS_LOOKUP_LOCAL_EXTERN() can be defined - as an external function for lookup. - - 2009-04-15 Simon Goldschmidt - * dhcp.c: patch #6763: Global DHCP XID can be redefined to something more unique - - 2009-03-31 Kieran Mansley - * tcp.c, tcp_out.c, tcp_in.c, sys.h, tcp.h, opts.h: add support for - TCP timestamp options, off by default. Rework tcp_enqueue() to - take option flags rather than specified option data - - 2009-02-18 Simon Goldschmidt - * cc.h: Added printf formatter for size_t: SZT_F - - 2009-02-16 Simon Goldschmidt (patch by Rishi Khan) - * icmp.c, opt.h: patch #6539: (configurable) response to broadcast- and multicast - pings - - 2009-02-12 Simon Goldschmidt - * init.h: Added LWIP_VERSION to get the current version of the stack - - 2009-02-11 Simon Goldschmidt (suggested by Gottfried Spitaler) - * opt.h, memp.h/.c: added MEMP_MEM_MALLOC to use mem_malloc/mem_free instead - of the pool allocator (can save code size with MEM_LIBC_MALLOC if libc-malloc - is otherwise used) - - 2009-01-28 Jonathan Larmour (suggested by Bill Bauerbach) - * ipv4/inet_chksum.c, ipv4/lwip/inet_chksum.h: inet_chksum_pseudo_partial() - is only used by UDPLITE at present, so conditionalise it. - - 2008-12-03 Simon Goldschmidt (base on patch from Luca Ceresoli) - * autoip.c: checked in (slightly modified) patch #6683: Customizable AUTOIP - "seed" address. This should reduce AUTOIP conflicts if - LWIP_AUTOIP_CREATE_SEED_ADDR is overridden. - - 2008-10-02 Jonathan Larmour and Rishi Khan - * sockets.c (lwip_accept): Return EWOULDBLOCK if would block on non-blocking - socket. - - 2008-06-30 Simon Goldschmidt - * mem.c, opt.h, stats.h: fixed bug #21433: Calling mem_free/pbuf_free from - interrupt context isn't safe: LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT allows - mem_free to run between mem_malloc iterations. Added illegal counter for - mem stats. - - 2008-06-27 Simon Goldschmidt - * stats.h/.c, some other files: patch #6483: stats module improvement: - Added defines to display each module's statistic individually, added stats - defines for MEM, MEMP and SYS modules, removed (unused) rexmit counter. - - 2008-06-17 Simon Goldschmidt - * err.h: patch #6459: Made err_t overridable to use a more efficient type - (define LWIP_ERR_T in cc.h) - - 2008-06-17 Simon Goldschmidt - * slipif.c: patch #6480: Added a configuration option for slipif for symmetry - to loopif - - 2008-06-17 Simon Goldschmidt (patch by Luca Ceresoli) - * netif.c, loopif.c, ip.c, netif.h, loopif.h, opt.h: Checked in slightly - modified version of patch # 6370: Moved loopif code to netif.c so that - loopback traffic is supported on all netifs (all local IPs). - Added option to limit loopback packets for each netifs. - - - ++ Bugfixes: - 2009-08-12 Kieran Mansley - * tcp_in.c, tcp.c: Fix bug #27209: handle trimming of segments when - out of window or out of order properly - - 2009-08-12 Kieran Mansley - * tcp_in.c: Fix bug #27199: use snd_wl2 instead of snd_wl1 - - 2009-07-28 Simon Goldschmidt - * mem.h: Fixed bug #27105: "realloc() cannot replace mem_realloc()"s - - 2009-07-27 Kieran Mansley - * api.h api_msg.h netdb.h sockets.h: add missing #include directives - - 2009-07-09 Kieran Mansley - * api_msg.c, sockets.c, api.h: BUG23240 use signed counters for - recv_avail and don't increment counters until message successfully - sent to mbox - - 2009-06-25 Kieran Mansley - * api_msg.c api.h: BUG26722: initialise netconn write variables - in netconn_alloc - - 2009-06-25 Kieran Mansley - * tcp.h: BUG26879: set ret value in TCP_EVENT macros when function is not set - - 2009-06-25 Kieran Mansley - * tcp.c, tcp_in.c, tcp_out.c, tcp.h: BUG26301 and BUG26267: correct - simultaneous close behaviour, and make snd_nxt have the same meaning - as in the RFCs. - - 2009-05-12 Simon Goldschmidt - * etharp.h, etharp.c, netif.c: fixed bug #26507: "Gratuitous ARP depends on - arp_table / uses etharp_query" by adding etharp_gratuitous() - - 2009-05-12 Simon Goldschmidt - * ip.h, ip.c, igmp.c: bug #26487: Added ip_output_if_opt that can add IP options - to the IP header (used by igmp_ip_output_if) - - 2009-05-06 Simon Goldschmidt - * inet_chksum.c: On little endian architectures, use LWIP_PLATFORM_HTONS (if - defined) for SWAP_BYTES_IN_WORD to speed up checksumming. - - 2009-05-05 Simon Goldschmidt - * sockets.c: bug #26405: Prematurely released semaphore causes lwip_select() - to crash - - 2009-05-04 Simon Goldschmidt - * init.c: snmp was not initialized in lwip_init() - - 2009-05-04 Frédéric Bernon - * dhcp.c, netbios.c: Changes if IP_SOF_BROADCAST is enabled. - - 2009-05-03 Simon Goldschmidt - * tcp.h: bug #26349: Nagle algorithm doesn't send although segment is full - (and unsent->next == NULL) - - 2009-05-02 Simon Goldschmidt - * tcpip.h, tcpip.c: fixed tcpip_untimeout (does not need the time, broken after - 1.3.0 in CVS only) - fixes compilation of ppp_oe.c - - 2009-05-02 Simon Goldschmidt - * msg_in.c: fixed bug #25636: SNMPSET value is ignored for integer fields - - 2009-05-01 Simon Goldschmidt - * pap.c: bug #21680: PPP upap_rauthnak() drops legal NAK packets - - 2009-05-01 Simon Goldschmidt - * ppp.c: bug #24228: Memory corruption with PPP and DHCP - - 2009-04-29 Frédéric Bernon - * raw.c, udp.c, init.c, opt.h, ip.h, sockets.h: bug #26309: Implement the - SO(F)_BROADCAST filter for all API layers. Avoid the unindented reception - of broadcast packets even when this option wasn't set. Port maintainers - which want to enable this filter have to set IP_SOF_BROADCAST=1 in opt.h. - If you want this option also filter broadcast on recv operations, you also - have to set IP_SOF_BROADCAST_RECV=1 in opt.h. - - 2009-04-28 Simon Goldschmidt, Jakob Stoklund Olesen - * dhcp.c: patch #6721, bugs #25575, #25576: Some small fixes to DHCP and - DHCP/AUTOIP cooperation - - 2009-04-25 Simon Goldschmidt, Oleg Tyshev - * tcp_out.c: bug #24212: Deadlocked tcp_retransmit due to exceeded pcb->cwnd - Fixed by sorting the unsent and unacked queues (segments are inserted at the - right place in tcp_output and tcp_rexmit). - - 2009-04-25 Simon Goldschmidt - * memp.c, mem.c, memp.h, mem_std.h: bug #26213 "Problem with memory allocation - when debugging": memp_sizes contained the wrong sizes (including sanity - regions); memp pools for MEM_USE_POOLS were too small - - 2009-04-24 Simon Goldschmidt, Frédéric Bernon - * inet.c: patch #6765: Fix a small problem with the last changes (incorrect - behavior, with with ip address string not ended by a '\0', a space or a - end of line) - - 2009-04-19 Simon Goldschmidt - * rawapi.txt: Fixed bug #26069: Corrected documentation: if tcp_connect fails, - pcb->err is called, not pcb->connected (with an error code). - - 2009-04-19 Simon Goldschmidt - * tcp_out.c: Fixed bug #26236: "TCP options (timestamp) don't work with - no-copy-tcpwrite": deallocate option data, only concat segments with same flags - - 2009-04-19 Simon Goldschmidt - * tcp_out.c: Fixed bug #25094: "Zero-length pbuf" (options are now allocated - in the header pbuf, not the data pbuf) - - 2009-04-18 Simon Goldschmidt - * api_msg.c: fixed bug #25695: Segmentation fault in do_writemore() - - 2009-04-15 Simon Goldschmidt - * sockets.c: tried to fix bug #23559: lwip_recvfrom problem with tcp - - 2009-04-15 Simon Goldschmidt - * dhcp.c: task #9192: mem_free of dhcp->options_in and dhcp->msg_in - - 2009-04-15 Simon Goldschmidt - * ip.c, ip6.c, tcp_out.c, ip.h: patch #6808: Add a utility function - ip_hinted_output() (for smaller code mainly) - - 2009-04-15 Simon Goldschmidt - * inet.c: patch #6765: Supporting new line characters in inet_aton() - - 2009-04-15 Simon Goldschmidt - * dhcp.c: patch #6764: DHCP rebind and renew did not send hostnam option; - Converted constant OPTION_MAX_MSG_SIZE to netif->mtu, check if netif->mtu - is big enough in dhcp_start - - 2009-04-15 Simon Goldschmidt - * netbuf.c: bug #26027: netbuf_chain resulted in pbuf memory leak - - 2009-04-15 Simon Goldschmidt - * sockets.c, ppp.c: bug #25763: corrected 4 occurrences of SMEMCPY to MEMCPY - - 2009-04-15 Simon Goldschmidt - * sockets.c: bug #26121: set_errno can be overridden - - 2009-04-09 Kieran Mansley (patch from Luca Ceresoli ) - * init.c, opt.h: Patch#6774 TCP_QUEUE_OOSEQ breaks compilation when - LWIP_TCP==0 - - 2009-04-09 Kieran Mansley (patch from Roy Lee ) - * tcp.h: Patch#6802 Add do-while-clauses to those function like - macros in tcp.h - - 2009-03-31 Kieran Mansley - * tcp.c, tcp_in.c, tcp_out.c, tcp.h, opt.h: Rework the way window - updates are calculated and sent (BUG20515) - - * tcp_in.c: cope with SYN packets received during established states, - and retransmission of initial SYN. - - * tcp_out.c: set push bit correctly when tcp segments are merged - - 2009-03-27 Kieran Mansley - * tcp_out.c set window correctly on probes (correcting change made - yesterday) - - 2009-03-26 Kieran Mansley - * tcp.c, tcp_in.c, tcp.h: add tcp_abandon() to cope with dropping - connections where no reset required (bug #25622) - - * tcp_out.c: set TCP_ACK flag on keepalive and zero window probes - (bug #20779) - - 2009-02-18 Simon Goldschmidt (Jonathan Larmour and Bill Auerbach) - * ip_frag.c: patch #6528: the buffer used for IP_FRAG_USES_STATIC_BUF could be - too small depending on MEM_ALIGNMENT - - 2009-02-16 Simon Goldschmidt - * sockets.h/.c, api_*.h/.c: fixed arguments of socket functions to match the standard; - converted size argument of netconn_write to 'size_t' - - 2009-02-16 Simon Goldschmidt - * tcp.h, tcp.c: fixed bug #24440: TCP connection close problem on 64-bit host - by moving accept callback function pointer to TCP_PCB_COMMON - - 2009-02-12 Simon Goldschmidt - * dhcp.c: fixed bug #25345 (DHCPDECLINE is sent with "Maximum message size" - option) - - 2009-02-11 Simon Goldschmidt - * dhcp.c: fixed bug #24480 (releasing old udp_pdb and pbuf in dhcp_start) - - 2009-02-11 Simon Goldschmidt - * opt.h, api_msg.c: added configurable default valud for netconn->recv_bufsize: - RECV_BUFSIZE_DEFAULT (fixes bug #23726: pbuf pool exhaustion on slow recv()) - - 2009-02-10 Simon Goldschmidt - * tcp.c: fixed bug #25467: Listen backlog is not reset on timeout in SYN_RCVD: - Accepts_pending is decrease on a corresponding listen pcb when a connection - in state SYN_RCVD is close. - - 2009-01-28 Jonathan Larmour - * pbuf.c: reclaim pbufs from TCP out-of-sequence segments if we run - out of pool pbufs. - - 2008-12-19 Simon Goldschmidt - * many files: patch #6699: fixed some warnings on platform where sizeof(int) == 2 - - 2008-12-10 Tamas Somogyi, Frédéric Bernon - * sockets.c: fixed bug #25051: lwip_recvfrom problem with udp: fromaddr and - port uses deleted netbuf. - - 2008-10-18 Simon Goldschmidt - * tcp_in.c: fixed bug ##24596: Vulnerability on faulty TCP options length - in tcp_parseopt - - 2008-10-15 Simon Goldschmidt - * ip_frag.c: fixed bug #24517: IP reassembly crashes on unaligned IP headers - by packing the struct ip_reass_helper. - - 2008-10-03 David Woodhouse, Jonathan Larmour - * etharp.c (etharp_arp_input): Fix type aliasing problem copying ip address. - - 2008-10-02 Jonathan Larmour - * dns.c: Hard-code structure sizes, to avoid issues on some compilers where - padding is included. - - 2008-09-30 Jonathan Larmour - * sockets.c (lwip_accept): check addr isn't NULL. If it's valid, do an - assertion check that addrlen isn't NULL. - - 2008-09-30 Jonathan Larmour - * tcp.c: Fix bug #24227, wrong error message in tcp_bind. - - 2008-08-26 Simon Goldschmidt - * inet.h, ip_addr.h: fixed bug #24132: Cross-dependency between ip_addr.h and - inet.h -> moved declaration of struct in_addr from ip_addr.h to inet.h - - 2008-08-14 Simon Goldschmidt - * api_msg.c: fixed bug #23847: do_close_internal references freed memory (when - tcp_close returns != ERR_OK) - - 2008-07-08 Frédéric Bernon - * stats.h: Fix some build bugs introduced with patch #6483 (missing some parameters - in macros, mainly if MEM_STATS=0 and MEMP_STATS=0). - - 2008-06-24 Jonathan Larmour - * tcp_in.c: Fix for bug #23693 as suggested by Art R. Ensure cseg is unused - if tcp_seg_copy fails. - - 2008-06-17 Simon Goldschmidt - * inet_chksum.c: Checked in some ideas of patch #6460 (loop optimizations) - and created defines for swapping bytes and folding u32 to u16. - - 2008-05-30 Kieran Mansley - * tcp_in.c Remove redundant "if" statement, and use real rcv_wnd - rather than rcv_ann_wnd when deciding if packets are in-window. - Contributed by - - 2008-05-30 Kieran Mansley - * mem.h: Fix BUG#23254. Change macro definition of mem_* to allow - passing as function pointers when MEM_LIBC_MALLOC is defined. - - 2008-05-09 Jonathan Larmour - * err.h, err.c, sockets.c: Fix bug #23119: Reorder timeout error code to - stop it being treated as a fatal error. - - 2008-04-15 Simon Goldschmidt - * dhcp.c: fixed bug #22804: dhcp_stop doesn't clear NETIF_FLAG_DHCP - (flag now cleared) - - 2008-03-27 Simon Goldschmidt - * mem.c, tcpip.c, tcpip.h, opt.h: fixed bug #21433 (Calling mem_free/pbuf_free - from interrupt context isn't safe): set LWIP_USE_HEAP_FROM_INTERRUPT to 1 - in lwipopts.h or use pbuf_free_callback(p)/mem_free_callback(m) to free pbufs - or heap memory from interrupt context - - 2008-03-26 Simon Goldschmidt - * tcp_in.c, tcp.c: fixed bug #22249: division by zero could occur if a remote - host sent a zero mss as TCP option. - - -(STABLE-1.3.0) - - ++ New features: - - 2008-03-10 Jonathan Larmour - * inet_chksum.c: Allow choice of one of the sample algorithms to be - made from lwipopts.h. Fix comment on how to override LWIP_CHKSUM. - - 2008-01-22 Frédéric Bernon - * tcp.c, tcp_in.c, tcp.h, opt.h: Rename LWIP_CALCULATE_EFF_SEND_MSS in - TCP_CALCULATE_EFF_SEND_MSS to have coherent TCP options names. - - 2008-01-14 Frédéric Bernon - * rawapi.txt, api_msg.c, tcp.c, tcp_in.c, tcp.h: changes for task #7675 "Enable - to refuse data on a TCP_EVENT_RECV call". Important, behavior changes for the - tcp_recv callback (see rawapi.txt). - - 2008-01-14 Frédéric Bernon, Marc Chaland - * ip.c: Integrate patch #6369" ip_input : checking before realloc". - - 2008-01-12 Frédéric Bernon - * tcpip.h, tcpip.c, api.h, api_lib.c, api_msg.c, sockets.c: replace the field - netconn::sem per netconn::op_completed like suggested for the task #7490 - "Add return value to sys_mbox_post". - - 2008-01-12 Frédéric Bernon - * api_msg.c, opt.h: replace DEFAULT_RECVMBOX_SIZE per DEFAULT_TCP_RECVMBOX_SIZE, - DEFAULT_UDP_RECVMBOX_SIZE and DEFAULT_RAW_RECVMBOX_SIZE (to optimize queues - sizes), like suggested for the task #7490 "Add return value to sys_mbox_post". - - 2008-01-10 Frédéric Bernon - * tcpip.h, tcpip.c: add tcpip_callback_with_block function for the task #7490 - "Add return value to sys_mbox_post". tcpip_callback is always defined as - "blocking" ("block" parameter = 1). - - 2008-01-10 Frédéric Bernon - * tcpip.h, tcpip.c, api.h, api_lib.c, api_msg.c, sockets.c: replace the field - netconn::mbox (sys_mbox_t) per netconn::sem (sys_sem_t) for the task #7490 - "Add return value to sys_mbox_post". - - 2008-01-05 Frédéric Bernon - * sys_arch.txt, api.h, api_lib.c, api_msg.h, api_msg.c, tcpip.c, sys.h, opt.h: - Introduce changes for task #7490 "Add return value to sys_mbox_post" with some - modifications in the sys_mbox api: sys_mbox_new take a "size" parameters which - indicate the number of pointers query by the mailbox. There is three defines - in opt.h to indicate sizes for tcpip::mbox, netconn::recvmbox, and for the - netconn::acceptmbox. Port maintainers, you can decide to just add this new - parameter in your implementation, but to ignore it to keep the previous behavior. - The new sys_mbox_trypost function return a value to know if the mailbox is - full or if the message is posted. Take a look to sys_arch.txt for more details. - This new function is used in tcpip_input (so, can be called in an interrupt - context since the function is not blocking), and in recv_udp and recv_raw. - - 2008-01-04 Frédéric Bernon, Simon Goldschmidt, Jonathan Larmour - * rawapi.txt, api.h, api_lib.c, api_msg.h, api_msg.c, sockets.c, tcp.h, tcp.c, - tcp_in.c, init.c, opt.h: rename backlog options with TCP_ prefix, limit the - "backlog" parameter in an u8_t, 0 is interpreted as "smallest queue", add - documentation in the rawapi.txt file. - - 2007-12-31 Kieran Mansley (based on patch from Per-Henrik Lundbolm) - * tcp.c, tcp_in.c, tcp_out.c, tcp.h: Add TCP persist timer - - 2007-12-31 Frédéric Bernon, Luca Ceresoli - * autoip.c, etharp.c: ip_addr.h: Integrate patch #6348: "Broadcast ARP packets - in autoip". The change in etharp_raw could be removed, since all calls to - etharp_raw use ethbroadcast for the "ethdst_addr" parameter. But it could be - wrong in the future. - - 2007-12-30 Frédéric Bernon, Tom Evans - * ip.c: Fix bug #21846 "LwIP doesn't appear to perform any IP Source Address - Filtering" reported by Tom Evans. - - 2007-12-21 Frédéric Bernon, Simon Goldschmidt, Jonathan Larmour - * tcp.h, opt.h, api.h, api_msg.h, tcp.c, tcp_in.c, api_lib.c, api_msg.c, - sockets.c, init.c: task #7252: Implement TCP listen backlog: Warning: raw API - applications have to call 'tcp_accepted(pcb)' in their accept callback to - keep accepting new connections. - - 2007-12-13 Frédéric Bernon - * api_msg.c, err.h, err.c, sockets.c, dns.c, dns.h: replace "enum dns_result" - by err_t type. Add a new err_t code "ERR_INPROGRESS". - - 2007-12-12 Frédéric Bernon - * dns.h, dns.c, opt.h: move DNS options to the "right" place. Most visibles - are the one which have ram usage. - - 2007-12-05 Frédéric Bernon - * netdb.c: add a LWIP_DNS_API_HOSTENT_STORAGE option to decide to use a static - set of variables (=0) or a local one (=1). In this last case, your port should - provide a function "struct hostent* sys_thread_hostent( struct hostent* h)" - which have to do a copy of "h" and return a pointer ont the "per-thread" copy. - - 2007-12-03 Simon Goldschmidt - * ip.c: ip_input: check if a packet is for inp first before checking all other - netifs on netif_list (speeds up packet receiving in most cases) - - 2007-11-30 Simon Goldschmidt - * udp.c, raw.c: task #7497: Sort lists (pcb, netif, ...) for faster access - UDP: move a (connected) pcb selected for input to the front of the list of - pcbs so that it is found faster next time. Same for RAW pcbs that have eaten - a packet. - - 2007-11-28 Simon Goldschmidt - * etharp.c, stats.c, stats.h, opt.h: Introduced ETHARP_STATS - - 2007-11-25 Simon Goldschmidt - * dhcp.c: dhcp_unfold_reply() uses pbuf_copy_partial instead of its own copy - algorithm. - - 2007-11-24 Simon Goldschmidt - * netdb.h, netdb.c, sockets.h/.c: Moved lwip_gethostbyname from sockets.c - to the new file netdb.c; included lwip_getaddrinfo. - - 2007-11-21 Simon Goldschmidt - * tcp.h, opt.h, tcp.c, tcp_in.c: implemented calculating the effective send-mss - based on the MTU of the netif used to send. Enabled by default. Disable by - setting LWIP_CALCULATE_EFF_SEND_MSS to 0. This fixes bug #21492. - - 2007-11-19 Frédéric Bernon - * api_msg.c, dns.h, dns.c: Implement DNS_DOES_NAME_CHECK option (check if name - received match the name query), implement DNS_USES_STATIC_BUF (the place where - copy dns payload to parse the response), return an error if there is no place - for a new query, and fix some minor problems. - - 2007-11-16 Simon Goldschmidt - * new files: ipv4/inet.c, ipv4/inet_chksum.c, ipv6/inet6.c - removed files: core/inet.c, core/inet6.c - Moved inet files into ipv4/ipv6 directory; splitted inet.c/inet.h into - inet and chksum part; changed includes in all lwIP files as appropriate - - 2007-11-16 Simon Goldschmidt - * api.h, api_msg.h, api_lib.c, api_msg.c, socket.h, socket.c: Added sequential - dns resolver function for netconn api (netconn_gethostbyname) and socket api - (gethostbyname/gethostbyname_r). - - 2007-11-15 Jim Pettinato, Frédéric Bernon - * opt.h, init.c, tcpip.c, dhcp.c, dns.h, dns.c: add DNS client for simple name - requests with RAW api interface. Initialization is done in lwip_init() with - build time options. DNS timer is added in tcpip_thread context. DHCP can set - DNS server ip addresses when options are received. You need to set LWIP_DNS=1 - in your lwipopts.h file (LWIP_DNS=0 in opt.h). DNS_DEBUG can be set to get - some traces with LWIP_DEBUGF. Sanity check have been added. There is a "todo" - list with points to improve. - - 2007-11-06 Simon Goldschmidt - * opt.h, mib2.c: Patch #6215: added ifAdminStatus write support (if explicitly - enabled by defining SNMP_SAFE_REQUESTS to 0); added code to check link status - for ifOperStatus if LWIP_NETIF_LINK_CALLBACK is defined. - - 2007-11-06 Simon Goldschmidt - * api.h, api_msg.h and dependent files: Task #7410: Removed the need to include - core header files in api.h (ip/tcp/udp/raw.h) to hide the internal - implementation from netconn api applications. - - 2007-11-03 Frédéric Bernon - * api.h, api_lib.c, api_msg.c, sockets.c, opt.h: add SO_RCVBUF option for UDP & - RAW netconn. You need to set LWIP_SO_RCVBUF=1 in your lwipopts.h (it's disabled - by default). Netconn API users can use the netconn_recv_bufsize macro to access - it. This is a first release which have to be improve for TCP. Note it used the - netconn::recv_avail which need to be more "thread-safe" (note there is already - the problem for FIONREAD with lwip_ioctl/ioctlsocket). - - 2007-11-01 Frédéric Bernon, Marc Chaland - * sockets.h, sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c, tcp.h, tcp_out.c: - Integrate "patch #6250 : MSG_MORE flag for send". MSG_MORE is used at socket api - layer, NETCONN_MORE at netconn api layer, and TCP_WRITE_FLAG_MORE at raw api - layer. This option enable to delayed TCP PUSH flag on multiple "write" calls. - Note that previous "copy" parameter for "write" APIs is now called "apiflags". - - 2007-10-24 Frédéric Bernon - * api.h, api_lib.c, api_msg.c: Add macro API_EVENT in the same spirit than - TCP_EVENT_xxx macros to get a code more readable. It could also help to remove - some code (like we have talk in "patch #5919 : Create compile switch to remove - select code"), but it could be done later. - - 2007-10-08 Simon Goldschmidt - * many files: Changed initialization: many init functions are not needed any - more since we now rely on the compiler initializing global and static - variables to zero! - - 2007-10-06 Simon Goldschmidt - * ip_frag.c, memp.c, mib2.c, ip_frag.h, memp_std.h, opt.h: Changed IP_REASSEMBLY - to enqueue the received pbufs so that multiple packets can be reassembled - simultaneously and no static reassembly buffer is needed. - - 2007-10-05 Simon Goldschmidt - * tcpip.c, etharp.h, etharp.c: moved ethernet_input from tcpip.c to etharp.c so - all netifs (or ports) can use it. - - 2007-10-05 Frédéric Bernon - * netifapi.h, netifapi.c: add function netifapi_netif_set_default. Change the - common function to reduce a little bit the footprint (for all functions using - only the "netif" parameter). - - 2007-10-03 Frédéric Bernon - * netifapi.h, netifapi.c: add functions netifapi_netif_set_up, netifapi_netif_set_down, - netifapi_autoip_start and netifapi_autoip_stop. Use a common function to reduce - a little bit the footprint (for all functions using only the "netif" parameter). - - 2007-09-15 Frédéric Bernon - * udp.h, udp.c, sockets.c: Changes for "#20503 IGMP Improvement". Add IP_MULTICAST_IF - option in socket API, and a new field "multicast_ip" in "struct udp_pcb" (for - netconn and raw API users), only if LWIP_IGMP=1. Add getsockopt processing for - IP_MULTICAST_TTL and IP_MULTICAST_IF. - - 2007-09-10 Frédéric Bernon - * snmp.h, mib2.c: enable to remove SNMP timer (which consumne several cycles - even when it's not necessary). snmp_agent.txt tell to call snmp_inc_sysuptime() - each 10ms (but, it's intrusive if you use sys_timeout feature). Now, you can - decide to call snmp_add_sysuptime(100) each 1000ms (which is bigger "step", but - call to a lower frequency). Or, you can decide to not call snmp_inc_sysuptime() - or snmp_add_sysuptime(), and to define the SNMP_GET_SYSUPTIME(sysuptime) macro. - This one is undefined by default in mib2.c. SNMP_GET_SYSUPTIME is called inside - snmp_get_sysuptime(u32_t *value), and enable to change "sysuptime" value only - when it's queried (any direct call to "sysuptime" is changed by a call to - snmp_get_sysuptime). - - 2007-09-09 Frédéric Bernon, Bill Florac - * igmp.h, igmp.c, netif.h, netif.c, ip.c: To enable to have interfaces with IGMP, - and others without it, there is a new NETIF_FLAG_IGMP flag to set in netif->flags - if you want IGMP on an interface. igmp_stop() is now called inside netif_remove(). - igmp_report_groups() is now called inside netif_set_link_up() (need to have - LWIP_NETIF_LINK_CALLBACK=1) to resend reports once the link is up (avoid to wait - the next query message to receive the matching multicast streams). - - 2007-09-08 Frédéric Bernon - * sockets.c, ip.h, api.h, tcp.h: declare a "struct ip_pcb" which only contains - IP_PCB. Add in the netconn's "pcb" union a "struct ip_pcb *ip;" (no size change). - Use this new field to access to common pcb fields (ttl, tos, so_options, etc...). - Enable to access to these fields with LWIP_TCP=0. - - 2007-09-05 Frédéric Bernon - * udp.c, ipv4/icmp.c, ipv4/ip.c, ipv6/icmp.c, ipv6/ip6.c, ipv4/icmp.h, - ipv6/icmp.h, opt.h: Integrate "task #7272 : LWIP_ICMP option". The new option - LWIP_ICMP enable/disable ICMP module inside the IP stack (enable per default). - Be careful, disabling ICMP make your product non-compliant to RFC1122, but - help to reduce footprint, and to reduce "visibility" on the Internet. - - 2007-09-05 Frédéric Bernon, Bill Florac - * opt.h, sys.h, tcpip.c, slipif.c, ppp.c, sys_arch.txt: Change parameters list - for sys_thread_new (see "task #7252 : Create sys_thread_new_ex()"). Two new - parameters have to be provided: a task name, and a task stack size. For this - one, since it's platform dependant, you could define the best one for you in - your lwipopts.h. For port maintainers, you can just add these new parameters - in your sys_arch.c file, and but it's not mandatory, use them in your OS - specific functions. - - 2007-09-05 Frédéric Bernon - * inet.c, autoip.c, msg_in.c, msg_out.c, init.c: Move some build time checkings - inside init.c for task #7142 "Sanity check user-configurable values". - - 2007-09-04 Frédéric Bernon, Bill Florac - * igmp.h, igmp.c, memp_std.h, memp.c, init.c, opt.h: Replace mem_malloc call by - memp_malloc, and use a new MEMP_NUM_IGMP_GROUP option (see opt.h to define the - value). It will avoid potential fragmentation problems, use a counter to know - how many times a group is used on an netif, and free it when all applications - leave it. MEMP_NUM_IGMP_GROUP got 8 as default value (and init.c got a sanity - check if LWIP_IGMP!=0). - - 2007-09-03 Frédéric Bernon - * igmp.h, igmp.c, sockets.c, api_msg.c: Changes for "#20503 IGMP Improvement". - Initialize igmp_mac_filter to NULL in netif_add (this field should be set in - the netif's "init" function). Use the "imr_interface" field (for socket layer) - and/or the "interface" field (for netconn layer), for join/leave operations. - The igmp_join/leavegroup first parameter change from a netif to an ipaddr. - This field could be a netif's ipaddr, or "any" (same meaning than ip_addr_isany). - - 2007-08-30 Frédéric Bernon - * Add netbuf.h, netbuf.c, Change api.h, api_lib.c: #7249 "Split netbuf functions - from api/api_lib". Now netbuf API is independant of netconn, and can be used - with other API (application based on raw API, or future "socket2" API). Ports - maintainers just have to add src/api/netbuf.c in their makefile/projects. - - 2007-08-30 Frédéric Bernon, Jonathan Larmour - * init.c: Add first version of lwip_sanity_check for task #7142 "Sanity check - user-configurable values". - - 2007-08-29 Frédéric Bernon - * igmp.h, igmp.c, tcpip.c, init.c, netif.c: change igmp_init and add igmp_start. - igmp_start is call inside netif_add. Now, igmp initialization is in the same - spirit than the others modules. Modify some IGMP debug traces. - - 2007-08-29 Frédéric Bernon - * Add init.h, init.c, Change opt.h, tcpip.c: Task #7213 "Add a lwip_init function" - Add lwip_init function to regroup all modules initializations, and to provide - a place to add code for task #7142 "Sanity check user-configurable values". - Ports maintainers should remove direct initializations calls from their code, - and add init.c in their makefiles. Note that lwip_init() function is called - inside tcpip_init, but can also be used by raw api users since all calls are - disabled when matching options are disabled. Also note that their is new options - in opt.h, you should configure in your lwipopts.h (they are enabled per default). - - 2007-08-26 Marc Boucher - * api_msg.c: do_close_internal(): Reset the callbacks and arg (conn) to NULL - since they can under certain circumstances be called with an invalid conn - pointer after the connection has been closed (and conn has been freed). - - 2007-08-25 Frédéric Bernon (Artem Migaev's Patch) - * netif.h, netif.c: Integrate "patch #6163 : Function to check if link layer is up". - Add a netif_is_link_up() function if LWIP_NETIF_LINK_CALLBACK option is set. - - 2007-08-22 Frédéric Bernon - * netif.h, netif.c, opt.h: Rename LWIP_NETIF_CALLBACK in LWIP_NETIF_STATUS_CALLBACK - to be coherent with new LWIP_NETIF_LINK_CALLBACK option before next release. - - 2007-08-22 Frédéric Bernon - * tcpip.h, tcpip.c, ethernetif.c, opt.h: remove options ETHARP_TCPIP_INPUT & - ETHARP_TCPIP_ETHINPUT, now, only "ethinput" code is supported, even if the - name is tcpip_input (we keep the name of 1.2.0 function). - - 2007-08-17 Jared Grubb - * memp_std.h, memp.h, memp.c, mem.c, stats.c: (Task #7136) Centralize mempool - settings into new memp_std.h and optional user file lwippools.h. This adds - more dynamic mempools, and allows the user to create an arbitrary number of - mempools for mem_malloc. - - 2007-08-16 Marc Boucher - * api_msg.c: Initialize newconn->state to NETCONN_NONE in accept_function; - otherwise it was left to NETCONN_CLOSE and sent_tcp() could prematurely - close the connection. - - 2007-08-16 Marc Boucher - * sockets.c: lwip_accept(): check netconn_peer() error return. - - 2007-08-16 Marc Boucher - * mem.c, mem.h: Added mem_calloc(). - - 2007-08-16 Marc Boucher - * tcpip.c, tcpip.h memp.c, memp.h: Added distinct memp (MEMP_TCPIP_MSG_INPKT) - for input packets to prevent floods from consuming all of MEMP_TCPIP_MSG - and starving other message types. - Renamed MEMP_TCPIP_MSG to MEMP_TCPIP_MSG_API - - 2007-08-16 Marc Boucher - * pbuf.c, pbuf.h, etharp.c, tcp_in.c, sockets.c: Split pbuf flags in pbuf - type and flgs (later renamed to flags). - Use enum pbuf_flag as pbuf_type. Renumber PBUF_FLAG_*. - Improved lwip_recvfrom(). TCP push now propagated. - - 2007-08-16 Marc Boucher - * ethernetif.c, contrib/ports/various: ethbroadcast now a shared global - provided by etharp. - - 2007-08-16 Marc Boucher - * ppp_oe.c ppp_oe.h, auth.c chap.c fsm.c lcp.c ppp.c ppp.h, - etharp.c ethernetif.c, etharp.h, opt.h tcpip.h, tcpip.c: - Added PPPoE support and various PPP improvements. - - 2007-07-25 Simon Goldschmidt - * api_lib.c, ip_frag.c, pbuf.c, api.h, pbuf.h: Introduced pbuf_copy_partial, - making netbuf_copy_partial use this function. - - 2007-07-25 Simon Goldschmidt - * tcp_in.c: Fix bug #20506: Slow start / initial congestion window starts with - 2 * mss (instead of 1 * mss previously) to comply with some newer RFCs and - other stacks. - - 2007-07-13 Jared Grubb (integrated by Frédéric Bernon) - * opt.h, netif.h, netif.c, ethernetif.c: Add new configuration option to add - a link callback in the netif struct, and functions to handle it. Be carefull - for port maintainers to add the NETIF_FLAG_LINK_UP flag (like in ethernetif.c) - if you want to be sure to be compatible with future changes... - - 2007-06-30 Frédéric Bernon - * sockets.h, sockets.c: Implement MSG_PEEK flag for recv/recvfrom functions. - - 2007-06-21 Simon Goldschmidt - * etharp.h, etharp.c: Combined etharp_request with etharp_raw for both - LWIP_AUTOIP =0 and =1 to remove redundant code. - - 2007-06-21 Simon Goldschmidt - * mem.c, memp.c, mem.h, memp.h, opt.h: task #6863: Introduced the option - MEM_USE_POOLS to use 4 pools with different sized elements instead of a - heap. This both prevents memory fragmentation and gives a higher speed - at the cost of more memory consumption. Turned off by default. - - 2007-06-21 Simon Goldschmidt - * api_lib.c, api_msg.c, api.h, api_msg.h: Converted the length argument of - netconn_write (and therefore also api_msg_msg.msg.w.len) from u16_t into - int to be able to send a bigger buffer than 64K with one time (mainly - used from lwip_send). - - 2007-06-21 Simon Goldschmidt - * tcp.h, api_msg.c: Moved the nagle algorithm from netconn_write/do_write - into a define (tcp_output_nagle) in tcp.h to provide it to raw api users, too. - - 2007-06-21 Simon Goldschmidt - * api.h, api_lib.c, api_msg.c: Fixed bug #20021: Moved sendbuf-processing in - netconn_write from api_lib.c to api_msg.c to also prevent multiple context- - changes on low memory or empty send-buffer. - - 2007-06-18 Simon Goldschmidt - * etharp.c, etharp.h: Changed etharp to use a defined hardware address length - of 6 to avoid loading netif->hwaddr_len every time (since this file is only - used for ethernet and struct eth_addr already had a defined length of 6). - - 2007-06-17 Simon Goldschmidt - * sockets.c, sockets.h: Implemented socket options SO_NO_CHECK for UDP sockets - to disable UDP checksum generation on transmit. - - 2007-06-13 Frédéric Bernon, Simon Goldschmidt - * debug.h, api_msg.c: change LWIP_ERROR to use it to check errors like invalid - pointers or parameters, and let the possibility to redefined it in cc.h. Use - this macro to check "conn" parameter in api_msg.c functions. - - 2007-06-11 Simon Goldschmidt - * sockets.c, sockets.h: Added UDP lite support for sockets - - 2007-06-10 Simon Goldschmidt - * udp.h, opt.h, api_msg.c, ip.c, udp.c: Included switch LWIP_UDPLITE (enabled - by default) to switch off UDP-Lite support if not needed (reduces udp.c code - size) - - 2007-06-09 Dominik Spies (integrated by Frédéric Bernon) - * autoip.h, autoip.c, dhcp.h, dhcp.c, netif.h, netif.c, etharp.h, etharp.c, opt.h: - AutoIP implementation available for IPv4, with new options LWIP_AUTOIP and - LWIP_DHCP_AUTOIP_COOP if you want to cooperate with DHCP. Some tips to adapt - (see TODO mark in the source code). - - 2007-06-09 Simon Goldschmidt - * etharp.h, etharp.c, ethernetif.c: Modified order of parameters for - etharp_output() to match netif->output so etharp_output() can be used - directly as netif->output to save one function call. - - 2007-06-08 Simon Goldschmidt - * netif.h, ethernetif.c, slipif.c, loopif.c: Added define - NETIF_INIT_SNMP(netif, type, speed) to initialize per-netif snmp variables, - added initialization of those to ethernetif, slipif and loopif. - - 2007-05-18 Simon Goldschmidt - * opt.h, ip_frag.c, ip_frag.h, ip.c: Added option IP_FRAG_USES_STATIC_BUF - (defaulting to off for now) that can be set to 0 to send fragmented - packets by passing PBUF_REFs down the stack. - - 2007-05-23 Frédéric Bernon - * api_lib.c: Implement SO_RCVTIMEO for accept and recv on TCP - connections, such present in patch #5959. - - 2007-05-23 Frédéric Bernon - * api.h, api_lib.c, api_msg.c, sockets.c: group the different NETCONN_UDPxxx - code in only one part... - - 2007-05-18 Simon Goldschmidt - * opt.h, memp.h, memp.c: Added option MEMP_OVERFLOW_CHECK to check for memp - elements to overflow. This is achieved by adding some bytes before and after - each pool element (increasing their size, of course), filling them with a - prominent value and checking them on freeing the element. - Set it to 2 to also check every element in every pool each time memp_malloc() - or memp_free() is called (slower but more helpful). - - 2007-05-10 Simon Goldschmidt - * opt.h, memp.h, memp.c, pbuf.c (see task #6831): use a new memp pool for - PBUF_POOL pbufs instead of the old pool implementation in pbuf.c to reduce - code size. - - 2007-05-11 Frédéric Bernon - * sockets.c, api_lib.c, api_msg.h, api_msg.c, netifapi.h, netifapi.c, tcpip.c: - Include a function pointer instead of a table index in the message to reduce - footprint. Disable some part of lwip_send and lwip_sendto if some options are - not set (LWIP_TCP, LWIP_UDP, LWIP_RAW). - - 2007-05-10 Simon Goldschmidt - * *.h (except netif/ppp/*.h): Included patch #5448: include '#ifdef __cplusplus - \ extern "C" {' in all header files. Now you can write your application using - the lwIP stack in C++ and simply #include the core files. Note I have left - out the netif/ppp/*h header files for now, since I don't know which files are - included by applications and which are for internal use only. - - 2007-05-09 Simon Goldschmidt - * opt.h, *.c/*.h: Included patch #5920: Create define to override C-library - memcpy. 2 Defines are created: MEMCPY() for normal memcpy, SMEMCPY() for - situations where some compilers might inline the copy and save a function - call. Also replaced all calls to memcpy() with calls to (S)MEMCPY(). - - 2007-05-08 Simon Goldschmidt - * mem.h: If MEM_LIBC_MALLOC==1, allow the defines (e.g. mem_malloc() -> malloc()) - to be overriden in case the C-library malloc implementation is not protected - against concurrent access. - - 2007-05-04 Simon Goldschmidt (Atte Kojo) - * etharp.c: Introduced fast one-entry-cache to speed up ARP lookup when sending - multiple packets to the same host. - - 2007-05-04 Frédéric Bernon, Jonathan Larmour - * sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c: Fix bug #19162 "lwip_sento: a possible - to corrupt remote addr/port connection state". Reduce problems "not enought memory" with - netbuf (if we receive lot of datagrams). Improve lwip_sendto (only one exchange between - sockets api and api_msg which run in tcpip_thread context). Add netconn_sento function. - Warning, if you directly access to "fromaddr" & "fromport" field from netbuf struct, - these fields are now renamed "addr" & "port". - - 2007-04-11 Jonathan Larmour - * sys.h, api_lib.c: Provide new sys_mbox_tryfetch function. Require ports to provide new - sys_arch_mbox_tryfetch function to get a message if one is there, otherwise return - with SYS_MBOX_EMPTY. sys_arch_mbox_tryfetch can be implemented as a function-like macro - by the port in sys_arch.h if desired. - - 2007-04-06 Frédéric Bernon, Simon Goldschmidt - * opt.h, tcpip.h, tcpip.c, netifapi.h, netifapi.c: New configuration option LWIP_NETIF_API - allow to use thread-safe functions to add/remove netif in list, and to start/stop dhcp - clients, using new functions from netifapi.h. Disable as default (no port change to do). - - 2007-04-05 Frédéric Bernon - * sockets.c: remplace ENOBUFS errors on alloc_socket by ENFILE to be more BSD compliant. - - 2007-04-04 Simon Goldschmidt - * arch.h, api_msg.c, dhcp.c, msg_in.c, sockets.c: Introduced #define LWIP_UNUSED_ARG(x) - use this for and architecture-independent form to tell the compiler you intentionally - are not using this variable. Can be overriden in cc.h. - - 2007-03-28 Frédéric Bernon - * opt.h, netif.h, dhcp.h, dhcp.c: New configuration option LWIP_NETIF_HOSTNAME allow to - define a hostname in netif struct (this is just a pointer, so, you can use a hardcoded - string, point on one of your's ethernetif field, or alloc a string you will free yourself). - It will be used by DHCP to register a client hostname, but can also be use when you call - snmp_set_sysname. - - 2007-03-28 Frédéric Bernon - * netif.h, netif.c: A new NETIF_FLAG_ETHARP flag is defined in netif.h, to allow to - initialize a network interface's flag with. It tell this interface is an ethernet - device, and we can use ARP with it to do a "gratuitous ARP" (RFC 3220 "IP Mobility - Support for IPv4" section 4.6) when interface is "up" with netif_set_up(). - - 2007-03-26 Frédéric Bernon, Jonathan Larmour - * opt.h, tcpip.c: New configuration option LWIP_ARP allow to disable ARP init at build - time if you only use PPP or SLIP. The default is enable. Note we don't have to call - etharp_init in your port's initilization sequence if you use tcpip.c, because this call - is done in tcpip_init function. - - 2007-03-22 Frédéric Bernon - * stats.h, stats.c, msg_in.c: Stats counters can be change to u32_t if necessary with the - new option LWIP_STATS_LARGE. If you need this option, define LWIP_STATS_LARGE to 1 in - your lwipopts.h. More, unused counters are not defined in the stats structs, and not - display by stats_display(). Note that some options (SYS_STATS and RAW_STATS) are defined - but never used. Fix msg_in.c with the correct #if test for a stat display. - - 2007-03-21 Kieran Mansley - * netif.c, netif.h: Apply patch#4197 with some changes (originator: rireland@hmgsl.com). - Provides callback on netif up/down state change. - - 2007-03-11 Frédéric Bernon, Mace Gael, Steve Reynolds - * sockets.h, sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c, igmp.h, igmp.c, - ip.c, netif.h, tcpip.c, opt.h: - New configuration option LWIP_IGMP to enable IGMP processing. Based on only one - filter per all network interfaces. Declare a new function in netif to enable to - control the MAC filter (to reduce lwIP traffic processing). - - 2007-03-11 Frédéric Bernon - * tcp.h, tcp.c, sockets.c, tcp_out.c, tcp_in.c, opt.h: Keepalive values can - be configured at run time with LWIP_TCP_KEEPALIVE, but don't change this - unless you know what you're doing (default are RFC1122 compliant). Note - that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set in seconds. - - 2007-03-08 Frédéric Bernon - * tcp.h: Keepalive values can be configured at compile time, but don't change - this unless you know what you're doing (default are RFC1122 compliant). - - 2007-03-08 Frédéric Bernon - * sockets.c, api.h, api_lib.c, tcpip.c, sys.h, sys.c, err.c, opt.h: - Implement LWIP_SO_RCVTIMEO configuration option to enable/disable SO_RCVTIMEO - on UDP sockets/netconn. - - 2007-03-08 Simon Goldschmidt - * snmp_msg.h, msg_in.c: SNMP UDP ports can be configured at compile time. - - 2007-03-06 Frédéric Bernon - * api.h, api_lib.c, sockets.h, sockets.c, tcpip.c, sys.h, sys.c, err.h: - Implement SO_RCVTIMEO on UDP sockets/netconn. - - 2007-02-28 Kieran Mansley (based on patch from Simon Goldschmidt) - * api_lib.c, tcpip.c, memp.c, memp.h: make API msg structs allocated - on the stack and remove the API msg type from memp - - 2007-02-26 Jonathan Larmour (based on patch from Simon Goldschmidt) - * sockets.h, sockets.c: Move socket initialization to new - lwip_socket_init() function. - NOTE: this changes the API with ports. Ports will have to be - updated to call lwip_socket_init() now. - - 2007-02-26 Jonathan Larmour (based on patch from Simon Goldschmidt) - * api_lib.c: Use memcpy in netbuf_copy_partial. - - - ++ Bug fixes: - - 2008-03-17 Frédéric Bernon, Ed Kerekes - * igmp.h, igmp.c: Fix bug #22613 "IGMP iphdr problem" (could have - some problems to fill the IP header on some targets, use now the - ip.h macros to do it). - - 2008-03-13 Frédéric Bernon - * sockets.c: Fix bug #22435 "lwip_recvfrom with TCP break;". Using - (lwip_)recvfrom with valid "from" and "fromlen" parameters, on a - TCP connection caused a crash. Note that using (lwip_)recvfrom - like this is a bit slow and that using (lwip)getpeername is the - good lwip way to do it (so, using recv is faster on tcp sockets). - - 2008-03-12 Frédéric Bernon, Jonathan Larmour - * api_msg.c, contrib/apps/ping.c: Fix bug #22530 "api_msg.c's - recv_raw() does not consume data", and the ping sample (with - LWIP_SOCKET=1, the code did the wrong supposition that lwip_recvfrom - returned the IP payload, without the IP header). - - 2008-03-04 Jonathan Larmour - * mem.c, stats.c, mem.h: apply patch #6414 to avoid compiler errors - and/or warnings on some systems where mem_size_t and size_t differ. - * pbuf.c, ppp.c: Fix warnings on some systems with mem_malloc. - - 2008-03-04 Kieran Mansley (contributions by others) - * Numerous small compiler error/warning fixes from contributions to - mailing list after 1.3.0 release candidate made. - - 2008-01-25 Cui hengbin (integrated by Frédéric Bernon) - * dns.c: Fix bug #22108 "DNS problem" caused by unaligned structures. - - 2008-01-15 Kieran Mansley - * tcp_out.c: BUG20511. Modify persist timer to start when we are - prevented from sending by a small send window, not just a zero - send window. - - 2008-01-09 Jonathan Larmour - * opt.h, ip.c: Rename IP_OPTIONS define to IP_OPTIONS_ALLOWED to avoid - conflict with Linux system headers. - - 2008-01-06 Jonathan Larmour - * dhcp.c: fix bug #19927: "DHCP NACK problem" by clearing any existing set IP - address entirely on receiving a DHCPNAK, and restarting discovery. - - 2007-12-21 Simon Goldschmidt - * sys.h, api_lib.c, api_msg.c, sockets.c: fix bug #21698: "netconn->recv_avail - is not protected" by using new macros for interlocked access to modify/test - netconn->recv_avail. - - 2007-12-20 Kieran Mansley (based on patch from Oleg Tyshev) - * tcp_in.c: fix bug# 21535 (nrtx not reset correctly in SYN_SENT state) - - 2007-12-20 Kieran Mansley (based on patch from Per-Henrik Lundbolm) - * tcp.c, tcp_in.c, tcp_out.c, tcp.h: fix bug #20199 (better handling - of silly window avoidance and prevent lwIP from shrinking the window) - - 2007-12-04 Simon Goldschmidt - * tcp.c, tcp_in.c: fix bug #21699 (segment leak in ooseq processing when last - data packet was lost): add assert that all segment lists are empty in - tcp_pcb_remove before setting pcb to CLOSED state; don't directly set CLOSED - state from LAST_ACK in tcp_process - - 2007-12-02 Simon Goldschmidt - * sockets.h: fix bug #21654: exclude definition of struct timeval from #ifndef FD_SET - If including for system-struct timeval, LWIP_TIMEVAL_PRIVATE now - has to be set to 0 in lwipopts.h - - 2007-12-02 Simon Goldschmidt - * api_msg.c, api_lib.c: fix bug #21656 (recvmbox problem in netconn API): always - allocate a recvmbox in netconn_new_with_proto_and_callback. For a tcp-listen - netconn, this recvmbox is later freed and a new mbox is allocated for acceptmbox. - This is a fix for thread-safety and allocates all items needed for a netconn - when the netconn is created. - - 2007-11-30 Simon Goldschmidt - * udp.c: first attempt to fix bug #21655 (DHCP doesn't work reliably with multiple - netifs): if LWIP_DHCP is enabled, UDP packets to DHCP_CLIENT_PORT are passed - to netif->dhcp->pcb only (if that exists) and not to any other pcb for the same - port (only solution to let UDP pcbs 'bind' to a netif instead of an IP address) - - 2007-11-27 Simon Goldschmidt - * ip.c: fixed bug #21643 (udp_send/raw_send don't fail if netif is down) by - letting ip_route only use netifs that are up. - - 2007-11-27 Simon Goldschmidt - * err.h, api_lib.c, api_msg.c, sockets.c: Changed error handling: ERR_MEM, ERR_BUF - and ERR_RTE are seen as non-fatal, all other errors are fatal. netconns and - sockets block most operations once they have seen a fatal error. - - 2007-11-27 Simon Goldschmidt - * udp.h, udp.c, dhcp.c: Implemented new function udp_sendto_if which takes the - netif to send as an argument (to be able to send on netifs that are down). - - 2007-11-26 Simon Goldschmidt - * tcp_in.c: Fixed bug #21582: pcb->acked accounting can be wrong when ACKs - arrive out-of-order - - 2007-11-21 Simon Goldschmidt - * tcp.h, tcp_out.c, api_msg.c: Fixed bug #20287: tcp_output_nagle sends too early - Fixed the nagle algorithm; nagle now also works for all raw API applications - and has to be explicitly disabled with 'tcp_pcb->flags |= TF_NODELAY' - - 2007-11-12 Frédéric Bernon - * sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c: Fixed bug #20900. Now, most - of the netconn_peer and netconn_addr processing is done inside tcpip_thread - context in do_getaddr. - - 2007-11-10 Simon Goldschmidt - * etharp.c: Fixed bug: assert fired when MEMP_ARP_QUEUE was empty (which can - happen any time). Now the packet simply isn't enqueued when out of memory. - - 2007-11-01 Simon Goldschmidt - * tcp.c, tcp_in.c: Fixed bug #21494: The send mss (pcb->mss) is set to 536 (or - TCP_MSS if that is smaller) as long as no MSS option is received from the - remote host. - - 2007-11-01 Simon Goldschmidt - * tcp.h, tcp.c, tcp_in.c: Fixed bug #21491: The MSS option sent (with SYN) - is now based on TCP_MSS instead of pcb->mss (on passive open now effectively - sending our configured TCP_MSS instead of the one received). - - 2007-11-01 Simon Goldschmidt - * tcp_in.c: Fixed bug #21181: On active open, the initial congestion window was - calculated based on the configured TCP_MSS, not on the MSS option received - with SYN+ACK. - - 2007-10-09 Simon Goldschmidt - * udp.c, inet.c, inet.h: Fixed UDPLite: send: Checksum was always generated too - short and also was generated wrong if checksum coverage != tot_len; - receive: checksum was calculated wrong if checksum coverage != tot_len - - 2007-10-08 Simon Goldschmidt - * mem.c: lfree was not updated in mem_realloc! - - 2007-10-07 Frédéric Bernon - * sockets.c, api.h, api_lib.c: First step to fix "bug #20900 : Potential - crash error problem with netconn_peer & netconn_addr". VERY IMPORTANT: - this change cause an API breakage for netconn_addr, since a parameter - type change. Any compiler should cause an error without any changes in - yours netconn_peer calls (so, it can't be a "silent change"). It also - reduce a little bit the footprint for socket layer (lwip_getpeername & - lwip_getsockname use now a common lwip_getaddrname function since - netconn_peer & netconn_addr have the same parameters). - - 2007-09-20 Simon Goldschmidt - * tcp.c: Fixed bug #21080 (tcp_bind without check pcbs in TIME_WAIT state) - by checking tcp_tw_pcbs also - - 2007-09-19 Simon Goldschmidt - * icmp.c: Fixed bug #21107 (didn't reset IP TTL in ICMP echo replies) - - 2007-09-15 Mike Kleshov - * mem.c: Fixed bug #21077 (inaccuracy in calculation of lwip_stat.mem.used) - - 2007-09-06 Frédéric Bernon - * several-files: replace some #include "arch/cc.h" by "lwip/arch.h", or simply remove - it as long as "lwip/opt.h" is included before (this one include "lwip/debug.h" which - already include "lwip/arch.h"). Like that, default defines are provided by "lwip/arch.h" - if they are not defined in cc.h, in the same spirit than "lwip/opt.h" for lwipopts.h. - - 2007-08-30 Frédéric Bernon - * igmp.h, igmp.c: Some changes to remove some redundant code, add some traces, - and fix some coding style. - - 2007-08-28 Frédéric Bernon - * tcpip.c: Fix TCPIP_MSG_INPKT processing: now, tcpip_input can be used for any - kind of packets. These packets are considered like Ethernet packets (payload - pointing to ethhdr) if the netif got the NETIF_FLAG_ETHARP flag. Else, packets - are considered like IP packets (payload pointing to iphdr). - - 2007-08-27 Frédéric Bernon - * api.h, api_lib.c, api_msg.c: First fix for "bug #20900 : Potential crash error - problem with netconn_peer & netconn_addr". Introduce NETCONN_LISTEN netconn_state - and remove obsolete ones (NETCONN_RECV & NETCONN_ACCEPT). - - 2007-08-24 Kieran Mansley - * inet.c Modify (acc >> 16) test to ((acc >> 16) != 0) to help buggy - compiler (Paradigm C++) - - 2007-08-09 Frédéric Bernon, Bill Florac - * stats.h, stats.c, igmp.h, igmp.c, opt.h: Fix for bug #20503 : IGMP Improvement. - Introduce IGMP_STATS to centralize statistics management. - - 2007-08-09 Frédéric Bernon, Bill Florac - * udp.c: Fix for bug #20503 : IGMP Improvement. Enable to receive a multicast - packet on a udp pcb binded on an netif's IP address, and not on "any". - - 2007-08-09 Frédéric Bernon, Bill Florac - * igmp.h, igmp.c, ip.c: Fix minor changes from bug #20503 : IGMP Improvement. - This is mainly on using lookup/lookfor, and some coding styles... - - 2007-07-26 Frédéric Bernon (and "thedoctor") - * igmp.c: Fix bug #20595 to accept IGMPv3 "Query" messages. - - 2007-07-25 Simon Goldschmidt - * api_msg.c, tcp.c: Another fix for bug #20021: by not returning an error if - tcp_output fails in tcp_close, the code in do_close_internal gets simpler - (tcp_output is called again later from tcp timers). - - 2007-07-25 Simon Goldschmidt - * ip_frag.c: Fixed bug #20429: use the new pbuf_copy_partial instead of the old - copy_from_pbuf, which illegally modified the given pbuf. - - 2007-07-25 Simon Goldschmidt - * tcp_out.c: tcp_enqueue: pcb->snd_queuelen didn't work for chaine PBUF_RAMs: - changed snd_queuelen++ to snd_queuelen += pbuf_clen(p). - - 2007-07-24 Simon Goldschmidt - * api_msg.c, tcp.c: Fix bug #20480: Check the pcb passed to tcp_listen() for the - correct state (must be CLOSED). - - 2007-07-13 Thomas Taranowski (commited by Jared Grubb) - * memp.c: Fix bug #20478: memp_malloc returned NULL+MEMP_SIZE on failed - allocation. It now returns NULL. - - 2007-07-13 Frédéric Bernon - * api_msg.c: Fix bug #20318: api_msg "recv" callbacks don't call pbuf_free in - all error cases. - - 2007-07-13 Frédéric Bernon - * api_msg.c: Fix bug #20315: possible memory leak problem if tcp_listen failed, - because current code doesn't follow rawapi.txt documentation. - - 2007-07-13 Kieran Mansley - * src/core/tcp_in.c Apply patch#5741 from Oleg Tyshev to fix bug in - out of sequence processing of received packets - - 2007-07-03 Simon Goldschmidt - * nearly-all-files: Added assertions where PBUF_RAM pbufs are used and an - assumption is made that this pbuf is in one piece (i.e. not chained). These - assumptions clash with the possibility of converting to fully pool-based - pbuf implementations, where PBUF_RAM pbufs might be chained. - - 2007-07-03 Simon Goldschmidt - * api.h, api_lib.c, api_msg.c: Final fix for bug #20021 and some other problems - when closing tcp netconns: removed conn->sem, less context switches when - closing, both netconn_close and netconn_delete should safely close tcp - connections. - - 2007-07-02 Simon Goldschmidt - * ipv4/ip.h, ipv6/ip.h, opt.h, netif.h, etharp.h, ipv4/ip.c, netif.c, raw.c, - tcp_out.c, udp.c, etharp.c: Added option LWIP_NETIF_HWADDRHINT (default=off) - to cache ARP table indices with each pcb instead of single-entry cache for - the complete stack. - - 2007-07-02 Simon Goldschmidt - * tcp.h, tcp.c, tcp_in.c, tcp_out.c: Added some ASSERTS and casts to prevent - warnings when assigning to smaller types. - - 2007-06-28 Simon Goldschmidt - * tcp_out.c: Added check to prevent tcp_pcb->snd_queuelen from overflowing. - - 2007-06-28 Simon Goldschmidt - * tcp.h: Fixed bug #20287: Fixed nagle algorithm (sending was done too early if - a segment contained chained pbufs) - - 2007-06-28 Frédéric Bernon - * autoip.c: replace most of rand() calls by a macro LWIP_AUTOIP_RAND which compute - a "pseudo-random" value based on netif's MAC and some autoip fields. It's always - possible to define this macro in your own lwipopts.h to always use C library's - rand(). Note that autoip_create_rand_addr doesn't use this macro. - - 2007-06-28 Frédéric Bernon - * netifapi.h, netifapi.c, tcpip.h, tcpip.c: Update code to handle the option - LWIP_TCPIP_CORE_LOCKING, and do some changes to be coherent with last modifications - in api_lib/api_msg (use pointers and not type with table, etc...) - - 2007-06-26 Simon Goldschmidt - * udp.h: Fixed bug #20259: struct udp_hdr was lacking the packin defines. - - 2007-06-25 Simon Goldschmidt - * udp.c: Fixed bug #20253: icmp_dest_unreach was called with a wrong p->payload - for udp packets with no matching pcb. - - 2007-06-25 Simon Goldschmidt - * udp.c: Fixed bug #20220: UDP PCB search in udp_input(): a non-local match - could get udp input packets if the remote side matched. - - 2007-06-13 Simon Goldschmidt - * netif.c: Fixed bug #20180 (TCP pcbs listening on IP_ADDR_ANY could get - changed in netif_set_ipaddr if previous netif->ip_addr.addr was 0. - - 2007-06-13 Simon Goldschmidt - * api_msg.c: pcb_new sets conn->err if protocol is not implemented - -> netconn_new_..() does not allocate a new connection for unsupported - protocols. - - 2007-06-13 Frédéric Bernon, Simon Goldschmidt - * api_lib.c: change return expression in netconn_addr and netconn_peer, because - conn->err was reset to ERR_OK without any reasons (and error was lost)... - - 2007-06-13 Frédéric Bernon, Matthias Weisser - * opt.h, mem.h, mem.c, memp.c, pbuf.c, ip_frag.c, vj.c: Fix bug #20162. Rename - MEM_ALIGN in LWIP_MEM_ALIGN and MEM_ALIGN_SIZE in LWIP_MEM_ALIGN_SIZE to avoid - some macro names collision with some OS macros. - - 2007-06-11 Simon Goldschmidt - * udp.c: UDP Lite: corrected the use of chksum_len (based on RFC3828: if it's 0, - create checksum over the complete packet. On RX, if it's < 8 (and not 0), - discard the packet. Also removed the duplicate 'udphdr->chksum = 0' for both - UDP & UDP Lite. - - 2007-06-11 Srinivas Gollakota & Oleg Tyshev - * tcp_out.c: Fix for bug #20075 : "A problem with keep-alive timer and TCP flags" - where TCP flags wasn't initialized in tcp_keepalive. - - 2007-06-03 Simon Goldschmidt - * udp.c: udp_input(): Input pbuf was not freed if pcb had no recv function - registered, p->payload was modified without modifying p->len if sending - icmp_dest_unreach() (had no negative effect but was definitively wrong). - - 2007-06-03 Simon Goldschmidt - * icmp.c: Corrected bug #19937: For responding to an icmp echo request, icmp - re-used the input pbuf even if that didn't have enough space to include the - link headers. Now the space is tested and a new pbuf is allocated for the - echo response packet if the echo request pbuf isn't big enough. - - 2007-06-01 Simon Goldschmidt - * sockets.c: Checked in patch #5914: Moved sockopt processing into tcpip_thread. - - 2007-05-23 Frédéric Bernon - * api_lib.c, sockets.c: Fixed bug #5958 for netconn_listen (acceptmbox only - allocated by do_listen if success) and netconn_accept errors handling. In - most of api_lib functions, we replace some errors checkings like "if (conn==NULL)" - by ASSERT, except for netconn_delete. - - 2007-05-23 Frédéric Bernon - * api_lib.c: Fixed bug #5957 "Safe-thread problem inside netconn_recv" to return - an error code if it's impossible to fetch a pbuf on a TCP connection (and not - directly close the recvmbox). - - 2007-05-22 Simon Goldschmidt - * tcp.c: Fixed bug #1895 (tcp_bind not correct) by introducing a list of - bound but unconnected (and non-listening) tcp_pcbs. - - 2007-05-22 Frédéric Bernon - * sys.h, sys.c, api_lib.c, tcpip.c: remove sys_mbox_fetch_timeout() (was only - used for LWIP_SO_RCVTIMEO option) and use sys_arch_mbox_fetch() instead of - sys_mbox_fetch() in api files. Now, users SHOULD NOT use internal lwIP features - like "sys_timeout" in their application threads. - - 2007-05-22 Frédéric Bernon - * api.h, api_lib.c, api_msg.h, api_msg.c: change the struct api_msg_msg to see - which parameters are used by which do_xxx function, and to avoid "misusing" - parameters (patch #5938). - - 2007-05-22 Simon Goldschmidt - * api_lib.c, api_msg.c, raw.c, api.h, api_msg.h, raw.h: Included patch #5938: - changed raw_pcb.protocol from u16_t to u8_t since for IPv4 and IPv6, proto - is only 8 bits wide. This affects the api, as there, the protocol was - u16_t, too. - - 2007-05-18 Simon Goldschmidt - * memp.c: addition to patch #5913: smaller pointer was returned but - memp_memory was the same size -> did not save memory. - - 2007-05-16 Simon Goldschmidt - * loopif.c, slipif.c: Fix bug #19729: free pbuf if netif->input() returns - != ERR_OK. - - 2007-05-16 Simon Goldschmidt - * api_msg.c, udp.c: If a udp_pcb has a local_ip set, check if it is the same - as the one of the netif used for sending to prevent sending from old - addresses after a netif address gets changed (partly fixes bug #3168). - - 2007-05-16 Frédéric Bernon - * tcpip.c, igmp.h, igmp.c: Fixed bug "#19800 : IGMP: igmp_tick() will not work - with NO_SYS=1". Note that igmp_init is always in tcpip_thread (and not in - tcpip_init) because we have to be sure that network interfaces are already - added (mac filter is updated only in igmp_init for the moment). - - 2007-05-16 Simon Goldschmidt - * mem.c, memp.c: Removed semaphores from memp, changed sys_sem_wait calls - into sys_arch_sem_wait calls to prevent timers from running while waiting - for the heap. This fixes bug #19167. - - 2007-05-13 Simon Goldschmidt - * tcp.h, sockets.h, sockets.c: Fixed bug from patch #5865 by moving the defines - for socket options (lwip_set/-getsockopt) used with level IPPROTO_TCP from - tcp.h to sockets.h. - - 2007-05-07 Simon Goldschmidt - * mem.c: Another attempt to fix bug #17922. - - 2007-05-04 Simon Goldschmidt - * pbuf.c, pbuf.h, etharp.c: Further update to ARP queueing: Changed pbuf_copy() - implementation so that it can be reused (don't allocate the target - pbuf inside pbuf_copy()). - - 2007-05-04 Simon Goldschmidt - * memp.c: checked in patch #5913: in memp_malloc() we can return memp as mem - to save a little RAM (next pointer of memp is not used while not in pool). - - 2007-05-03 "maq" - * sockets.c: Fix ioctl FIONREAD when some data remains from last recv. - (patch #3574). - - 2007-04-23 Simon Goldschmidt - * loopif.c, loopif.h, opt.h, src/netif/FILES: fix bug #2595: "loopif results - in NULL reference for incoming TCP packets". Loopif has to be configured - (using LWIP_LOOPIF_MULTITHREADING) to directly call netif->input() - (multithreading environments, e.g. netif->input() = tcpip_input()) or - putting packets on a list that is fed to the stack by calling loopif_poll() - (single-thread / NO_SYS / polling environment where e.g. - netif->input() = ip_input). - - 2007-04-17 Jonathan Larmour - * pbuf.c: Use s32_t in pbuf_realloc(), as an s16_t can't reliably hold - the difference between two u16_t's. - * sockets.h: FD_SETSIZE needs to match number of sockets, which is - MEMP_NUM_NETCONN in sockets.c right now. - - 2007-04-12 Jonathan Larmour - * icmp.c: Reset IP header TTL in ICMP ECHO responses (bug #19580). - - 2007-04-12 Kieran Mansley - * tcp.c, tcp_in.c, tcp_out.c, tcp.h: Modify way the retransmission - timer is reset to fix bug#19434, with help from Oleg Tyshev. - - 2007-04-11 Simon Goldschmidt - * etharp.c, pbuf.c, pbuf.h: 3rd fix for bug #11400 (arp-queuing): More pbufs than - previously thought need to be copied (everything but PBUF_ROM!). Cleaned up - pbuf.c: removed functions no needed any more (by etharp). - - 2007-04-11 Kieran Mansley - * inet.c, ip_addr.h, sockets.h, sys.h, tcp.h: Apply patch #5745: Fix - "Constant is long" warnings with 16bit compilers. Contributed by - avatar@mmlab.cse.yzu.edu.tw - - 2007-04-05 Frédéric Bernon, Jonathan Larmour - * api_msg.c: Fix bug #16830: "err_tcp() posts to connection mailbox when no pend on - the mailbox is active". Now, the post is only done during a connect, and do_send, - do_write and do_join_leave_group don't do anything if a previous error was signaled. - - 2007-04-03 Frédéric Bernon - * ip.c: Don't set the IP_DF ("Don't fragment") flag in the IP header in IP output - packets. See patch #5834. - - 2007-03-30 Frédéric Bernon - * api_msg.c: add a "pcb_new" helper function to avoid redundant code, and to add - missing pcb allocations checking (in do_bind, and for each raw_new). Fix style. - - 2007-03-30 Frédéric Bernon - * most of files: prefix all debug.h define with "LWIP_" to avoid any conflict with - others environment defines (these were too "generic"). - - 2007-03-28 Frédéric Bernon - * api.h, api_lib.c, sockets.c: netbuf_ref doesn't check its internal pbuf_alloc call - result and can cause a crash. lwip_send now check netbuf_ref result. - - 2007-03-28 Simon Goldschmidt - * sockets.c Remove "#include " from sockets.c to avoid multiple - definition of macros (in errno.h and lwip/arch.h) if LWIP_PROVIDE_ERRNO is - defined. This is the way it should have been already (looking at - doc/sys_arch.txt) - - 2007-03-28 Kieran Mansley - * opt.h Change default PBUF_POOL_BUFSIZE (again) to accomodate default MSS + - IP and TCP headers *and* physical link headers - - 2007-03-26 Frédéric Bernon (based on patch from Dmitry Potapov) - * api_lib.c: patch for netconn_write(), fixes a possible race condition which cause - to send some garbage. It is not a definitive solution, but the patch does solve - the problem for most cases. - - 2007-03-22 Frédéric Bernon - * api_msg.h, api_msg.c: Remove obsolete API_MSG_ACCEPT and do_accept (never used). - - 2007-03-22 Frédéric Bernon - * api_lib.c: somes resources couldn't be freed if there was errors during - netconn_new_with_proto_and_callback. - - 2007-03-22 Frédéric Bernon - * ethernetif.c: update netif->input calls to check return value. In older ports, - it's a good idea to upgrade them, even if before, there could be another problem - (access to an uninitialized mailbox). - - 2007-03-21 Simon Goldschmidt - * sockets.c: fixed bug #5067 (essentialy a signed/unsigned warning fixed - by casting to unsigned). - - 2007-03-21 Frédéric Bernon - * api_lib.c, api_msg.c, tcpip.c: integrate sys_mbox_fetch(conn->mbox, NULL) calls from - api_lib.c to tcpip.c's tcpip_apimsg(). Now, use a local variable and not a - dynamic one from memp to send tcpip_msg to tcpip_thread in a synchrone call. - Free tcpip_msg from tcpip_apimsg is not done in tcpip_thread. This give a - faster and more reliable communication between api_lib and tcpip. - - 2007-03-21 Frédéric Bernon - * opt.h: Add LWIP_NETIF_CALLBACK (to avoid compiler warning) and set it to 0. - - 2007-03-21 Frédéric Bernon - * api_msg.c, igmp.c, igmp.h: Fix C++ style comments - - 2007-03-21 Kieran Mansley - * opt.h Change default PBUF_POOL_BUFSIZE to accomodate default MSS + - IP and TCP headers - - 2007-03-21 Kieran Mansley - * Fix all uses of pbuf_header to check the return value. In some - cases just assert if it fails as I'm not sure how to fix them, but - this is no worse than before when they would carry on regardless - of the failure. - - 2007-03-21 Kieran Mansley - * sockets.c, igmp.c, igmp.h, memp.h: Fix C++ style comments and - comment out missing header include in icmp.c - - 2007-03-20 Frédéric Bernon - * memp.h, stats.c: Fix stats_display function where memp_names table wasn't - synchronized with memp.h. - - 2007-03-20 Frédéric Bernon - * tcpip.c: Initialize tcpip's mbox, and verify if initialized in tcpip_input, - tcpip_ethinput, tcpip_callback, tcpip_apimsg, to fix a init problem with - network interfaces. Also fix a compiler warning. - - 2007-03-20 Kieran Mansley - * udp.c: Only try and use pbuf_header() to make space for headers if - not a ROM or REF pbuf. - - 2007-03-19 Frédéric Bernon - * api_msg.h, api_msg.c, tcpip.h, tcpip.c: Add return types to tcpip_apimsg() - and api_msg_post(). - - 2007-03-19 Frédéric Bernon - * Remove unimplemented "memp_realloc" function from memp.h. - - 2007-03-11 Simon Goldschmidt - * pbuf.c: checked in patch #5796: pbuf_alloc: len field claculation caused - memory corruption. - - 2007-03-11 Simon Goldschmidt (based on patch from Dmitry Potapov) - * api_lib.c, sockets.c, api.h, api_msg.h, sockets.h: Fixed bug #19251 - (missing `const' qualifier in socket functions), to get more compatible to - standard POSIX sockets. - - 2007-03-11 Frédéric Bernon (based on patch from Dmitry Potapov) - * sockets.c: Add asserts inside bind, connect and sendto to check input - parameters. Remove excessive set_errno() calls after get_socket(), because - errno is set inside of get_socket(). Move last sock_set_errno() inside - lwip_close. - - 2007-03-09 Simon Goldschmidt - * memp.c: Fixed bug #11400: New etharp queueing introduced bug: memp_memory - was allocated too small. - - 2007-03-06 Simon Goldschmidt - * tcpip.c: Initialize dhcp timers in tcpip_thread (if LWIP_DHCP) to protect - the stack from concurrent access. - - 2007-03-06 Frédéric Bernon, Dmitry Potapov - * tcpip.c, ip_frag.c, ethernetif.c: Fix some build problems, and a redundancy - call to "lwip_stats.link.recv++;" in low_level_input() & ethernetif_input(). - - 2007-03-06 Simon Goldschmidt - * ip_frag.c, ip_frag.h: Reduce code size: don't include code in those files - if IP_FRAG == 0 and IP_REASSEMBLY == 0 - - 2007-03-06 Frédéric Bernon, Simon Goldschmidt - * opt.h, ip_frag.h, tcpip.h, tcpip.c, ethernetif.c: add new configuration - option named ETHARP_TCPIP_ETHINPUT, which enable the new tcpip_ethinput. - Allow to do ARP processing for incoming packets inside tcpip_thread - (protecting ARP layer against concurrent access). You can also disable - old code using tcp_input with new define ETHARP_TCPIP_INPUT set to 0. - Older ports have to use tcpip_ethinput. - - 2007-03-06 Simon Goldschmidt (based on patch from Dmitry Potapov) - * err.h, err.c: fixed compiler warning "initialization dircards qualifiers - from pointer target type" - - 2007-03-05 Frédéric Bernon - * opt.h, sockets.h: add new configuration options (LWIP_POSIX_SOCKETS_IO_NAMES, - ETHARP_TRUST_IP_MAC, review SO_REUSE) - - 2007-03-04 Frédéric Bernon - * api_msg.c: Remove some compiler warnings : parameter "pcb" was never - referenced. - - 2007-03-04 Frédéric Bernon - * api_lib.c: Fix "[patch #5764] api_lib.c cleanup: after patch #5687" (from - Dmitry Potapov). - The api_msg struct stay on the stack (not moved to netconn struct). - - 2007-03-04 Simon Goldschmidt (based on patch from Dmitry Potapov) - * pbuf.c: Fix BUG#19168 - pbuf_free can cause deadlock (if - SYS_LIGHTWEIGHT_PROT=1 & freeing PBUF_RAM when mem_sem is not available) - Also fixed cast warning in pbuf_alloc() - - 2007-03-04 Simon Goldschmidt - * etharp.c, etharp.h, memp.c, memp.h, opt.h: Fix BUG#11400 - don't corrupt - existing pbuf chain when enqueuing multiple pbufs to a pending ARP request - - 2007-03-03 Frédéric Bernon - * udp.c: remove obsolete line "static struct udp_pcb *pcb_cache = NULL;" - It is static, and never used in udp.c except udp_init(). - - 2007-03-02 Simon Goldschmidt - * tcpip.c: Moved call to ip_init(), udp_init() and tcp_init() from - tcpip_thread() to tcpip_init(). This way, raw API connections can be - initialized before tcpip_thread is running (e.g. before OS is started) - - 2007-03-02 Frédéric Bernon - * rawapi.txt: Fix documentation mismatch with etharp.h about etharp_tmr's call - interval. - - 2007-02-28 Kieran Mansley - * pbuf.c: Fix BUG#17645 - ensure pbuf payload pointer is not moved - outside the region of the pbuf by pbuf_header() - - 2007-02-28 Kieran Mansley - * sockets.c: Fix BUG#19161 - ensure milliseconds timeout is non-zero - when supplied timeout is also non-zero - -(STABLE-1.2.0) - - 2006-12-05 Leon Woestenberg - * CHANGELOG: Mention STABLE-1.2.0 release. - - ++ New features: - - 2006-12-01 Christiaan Simons - * mem.h, opt.h: Added MEM_LIBC_MALLOC option. - Note this is a workaround. Currently I have no other options left. - - 2006-10-26 Christiaan Simons (accepted patch by Jonathan Larmour) - * ipv4/ip_frag.c: rename MAX_MTU to IP_FRAG_MAX_MTU and move define - to include/lwip/opt.h. - * ipv4/lwip/ip_frag.h: Remove unused IP_REASS_INTERVAL. - Move IP_REASS_MAXAGE and IP_REASS_BUFSIZE to include/lwip/opt.h. - * opt.h: Add above new options. - - 2006-08-18 Christiaan Simons - * tcp_{in,out}.c: added SNMP counters. - * ipv4/ip.c: added SNMP counters. - * ipv4/ip_frag.c: added SNMP counters. - - 2006-08-08 Christiaan Simons - * etharp.{c,h}: added etharp_find_addr() to read - (stable) ethernet/IP address pair from ARP table - - 2006-07-14 Christiaan Simons - * mib_structs.c: added - * include/lwip/snmp_structs.h: added - * netif.{c,h}, netif/ethernetif.c: added SNMP statistics to netif struct - - 2006-07-06 Christiaan Simons - * snmp/asn1_{enc,dec}.c added - * snmp/mib2.c added - * snmp/msg_{in,out}.c added - * include/lwip/snmp_asn1.h added - * include/lwip/snmp_msg.h added - * doc/snmp_agent.txt added - - 2006-03-29 Christiaan Simons - * inet.c, inet.h: Added platform byteswap support. - Added LWIP_PLATFORM_BYTESWAP define (defaults to 0) and - optional LWIP_PLATFORM_HTONS(), LWIP_PLATFORM_HTONL() macros. - - ++ Bug fixes: - - 2006-11-30 Christiaan Simons - * dhcp.c: Fixed false triggers of request_timeout. - - 2006-11-28 Christiaan Simons - * netif.c: In netif_add() fixed missing clear of ip_addr, netmask, gw and flags. - - 2006-10-11 Christiaan Simons - * api_lib.c etharp.c, ip.c, memp.c, stats.c, sys.{c,h} tcp.h: - Partially accepted patch #5449 for ANSI C compatibility / build fixes. - * ipv4/lwip/ip.h ipv6/lwip/ip.h: Corrected UDP-Lite protocol - identifier from 170 to 136 (bug #17574). - - 2006-10-10 Christiaan Simons - * api_msg.c: Fixed Nagle algorithm as reported by Bob Grice. - - 2006-08-17 Christiaan Simons - * udp.c: Fixed bug #17200, added check for broadcast - destinations for PCBs bound to a unicast address. - - 2006-08-07 Christiaan Simons - * api_msg.c: Flushing TCP output in do_close() (bug #15926). - - 2006-06-27 Christiaan Simons - * api_msg.c: Applied patch for cold case (bug #11135). - In accept_function() ensure newconn->callback is always initialized. - - 2006-06-15 Christiaan Simons - * mem.h: added MEM_SIZE_F alias to fix an ancient cold case (bug #1748), - facilitate printing of mem_size_t and u16_t statistics. - - 2006-06-14 Christiaan Simons - * api_msg.c: Applied patch #5146 to handle allocation failures - in accept() by Kevin Lawson. - - 2006-05-26 Christiaan Simons - * api_lib.c: Removed conn->sem creation and destruction - from netconn_write() and added sys_sem_new to netconn_new_*. - -(STABLE-1_1_1) - - 2006-03-03 Christiaan Simons - * ipv4/ip_frag.c: Added bound-checking assertions on ip_reassbitmap - access and added pbuf_alloc() return value checks. - - 2006-01-01 Leon Woestenberg - * tcp_{in,out}.c, tcp_out.c: Removed 'even sndbuf' fix in TCP, which is - now handled by the checksum routine properly. - - 2006-02-27 Leon Woestenberg - * pbuf.c: Fix alignment; pbuf_init() would not work unless - pbuf_pool_memory[] was properly aligned. (Patch by Curt McDowell.) - - 2005-12-20 Leon Woestenberg - * tcp.c: Remove PCBs which stay in LAST_ACK state too long. Patch - submitted by Mitrani Hiroshi. - - 2005-12-15 Christiaan Simons - * inet.c: Disabled the added summing routine to preserve code space. - - 2005-12-14 Leon Woestenberg - * tcp_in.c: Duplicate FIN ACK race condition fix by Kelvin Lawson. - Added Curt McDowell's optimized checksumming routine for future - inclusion. Need to create test case for unaliged, aligned, odd, - even length combination of cases on various endianess machines. - - 2005-12-09 Christiaan Simons - * inet.c: Rewrote standard checksum routine in proper portable C. - - 2005-11-25 Christiaan Simons - * udp.c tcp.c: Removed SO_REUSE hack. Should reside in socket code only. - * *.c: introduced cc.h LWIP_DEBUG formatters matching the u16_t, s16_t, - u32_t, s32_t typedefs. This solves most debug word-length assumes. - - 2005-07-17 Leon Woestenberg - * inet.c: Fixed unaligned 16-bit access in the standard checksum - routine by Peter Jolasson. - * slipif.c: Fixed implementation assumption of single-pbuf datagrams. - - 2005-02-04 Leon Woestenberg - * tcp_out.c: Fixed uninitialized 'queue' referenced in memerr branch. - * tcp_{out|in}.c: Applied patch fixing unaligned access. - - 2005-01-04 Leon Woestenberg - * pbuf.c: Fixed missing semicolon after LWIP_DEBUG statement. - - 2005-01-03 Leon Woestenberg - * udp.c: UDP pcb->recv() was called even when it was NULL. - -(STABLE-1_1_0) - - 2004-12-28 Leon Woestenberg - * etharp.*: Disabled multiple packets on the ARP queue. - This clashes with TCP queueing. - - 2004-11-28 Leon Woestenberg - * etharp.*: Fixed race condition from ARP request to ARP timeout. - Halved the ARP period, doubled the period counts. - ETHARP_MAX_PENDING now should be at least 2. This prevents - the counter from reaching 0 right away (which would allow - too little time for ARP responses to be received). - - 2004-11-25 Leon Woestenberg - * dhcp.c: Decline messages were not multicast but unicast. - * etharp.c: ETHARP_CREATE is renamed to ETHARP_TRY_HARD. - Do not try hard to insert arbitrary packet's source address, - etharp_ip_input() now calls etharp_update() without ETHARP_TRY_HARD. - etharp_query() now always DOES call ETHARP_TRY_HARD so that users - querying an address will see it appear in the cache (DHCP could - suffer from this when a server invalidly gave an in-use address.) - * ipv4/ip_addr.h: Renamed ip_addr_maskcmp() to _netcmp() as we are - comparing network addresses (identifiers), not the network masks - themselves. - * ipv4/ip_addr.c: ip_addr_isbroadcast() now checks that the given - IP address actually belongs to the network of the given interface. - - 2004-11-24 Kieran Mansley - * tcp.c: Increment pcb->snd_buf when ACK is received in SYN_SENT state. - -(STABLE-1_1_0-RC1) - - 2004-10-16 Kieran Mansley - * tcp.c: Add code to tcp_recved() to send an ACK (window update) immediately, - even if one is already pending, if the rcv_wnd is above a threshold - (currently TCP_WND/2). This avoids waiting for a timer to expire to send a - delayed ACK in order to open the window if the stack is only receiving data. - - 2004-09-12 Kieran Mansley - * tcp*.*: Retransmit time-out handling improvement by Sam Jansen. - - 2004-08-20 Tony Mountifield - * etharp.c: Make sure the first pbuf queued on an ARP entry - is properly ref counted. - - 2004-07-27 Tony Mountifield - * debug.h: Added (int) cast in LWIP_DEBUGF() to avoid compiler - warnings about comparison. - * pbuf.c: Stopped compiler complaining of empty if statement - when LWIP_DEBUGF() empty. Closed an unclosed comment. - * tcp.c: Stopped compiler complaining of empty if statement - when LWIP_DEBUGF() empty. - * ip.h Corrected IPH_TOS() macro: returns a byte, so doesn't need htons(). - * inet.c: Added a couple of casts to quiet the compiler. - No need to test isascii(c) before isdigit(c) or isxdigit(c). - - 2004-07-22 Tony Mountifield - * inet.c: Made data types consistent in inet_ntoa(). - Added casts for return values of checksum routines, to pacify compiler. - * ip_frag.c, tcp_out.c, sockets.c, pbuf.c - Small corrections to some debugging statements, to pacify compiler. - - 2004-07-21 Tony Mountifield - * etharp.c: Removed spurious semicolon and added missing end-of-comment. - * ethernetif.c Updated low_level_output() to match prototype for - netif->linkoutput and changed low_level_input() similarly for consistency. - * api_msg.c: Changed recv_raw() from int to u8_t, to match prototype - of raw_recv() in raw.h and so avoid compiler error. - * sockets.c: Added trivial (int) cast to keep compiler happier. - * ip.c, netif.c Changed debug statements to use the tidier ip4_addrN() macros. - -(STABLE-1_0_0) - - ++ Changes: - - 2004-07-05 Leon Woestenberg - * sockets.*: Restructured LWIP_PRIVATE_TIMEVAL. Make sure - your cc.h file defines this either 1 or 0. If non-defined, - defaults to 1. - * .c: Added and includes where used. - * etharp.c: Made some array indices unsigned. - - 2004-06-27 Leon Woestenberg - * netif.*: Added netif_set_up()/down(). - * dhcp.c: Changes to restart program flow. - - 2004-05-07 Leon Woestenberg - * etharp.c: In find_entry(), instead of a list traversal per candidate, do a - single-pass lookup for different candidates. Should exploit locality. - - 2004-04-29 Leon Woestenberg - * tcp*.c: Cleaned up source comment documentation for Doxygen processing. - * opt.h: ETHARP_ALWAYS_INSERT option removed to comply with ARP RFC. - * etharp.c: update_arp_entry() only adds new ARP entries when adviced to by - the caller. This deprecates the ETHARP_ALWAYS_INSERT overrule option. - - ++ Bug fixes: - - 2004-04-27 Leon Woestenberg - * etharp.c: Applied patch of bug #8708 by Toni Mountifield with a solution - suggested by Timmy Brolin. Fix for 32-bit processors that cannot access - non-aligned 32-bit words, such as soms 32-bit TCP/IP header fields. Fix - is to prefix the 14-bit Ethernet headers with two padding bytes. - - 2004-04-23 Leon Woestenberg - * ip_addr.c: Fix in the ip_addr_isbroadcast() check. - * etharp.c: Fixed the case where the packet that initiates the ARP request - is not queued, and gets lost. Fixed the case where the packets destination - address is already known; we now always queue the packet and perform an ARP - request. - -(STABLE-0_7_0) - - ++ Bug fixes: - - * Fixed TCP bug for SYN_SENT to ESTABLISHED state transition. - * Fixed TCP bug in dequeueing of FIN from out of order segment queue. - * Fixed two possible NULL references in rare cases. - -(STABLE-0_6_6) - - ++ Bug fixes: - - * Fixed DHCP which did not include the IP address in DECLINE messages. - - ++ Changes: - - * etharp.c has been hauled over a bit. - -(STABLE-0_6_5) - - ++ Bug fixes: - - * Fixed TCP bug induced by bad window resizing with unidirectional TCP traffic. - * Packets sent from ARP queue had invalid source hardware address. - - ++ Changes: - - * Pass-by ARP requests do now update the cache. - - ++ New features: - - * No longer dependent on ctype.h. - * New socket options. - * Raw IP pcb support. - -(STABLE-0_6_4) - - ++ Bug fixes: - - * Some debug formatters and casts fixed. - * Numereous fixes in PPP. - - ++ Changes: - - * DEBUGF now is LWIP_DEBUGF - * pbuf_dechain() has been re-enabled. - * Mentioned the changed use of CVS branches in README. - -(STABLE-0_6_3) - - ++ Bug fixes: - - * Fixed pool pbuf memory leak in pbuf_alloc(). - Occured if not enough PBUF_POOL pbufs for a packet pbuf chain. - Reported by Savin Zlobec. - - * PBUF_POOL chains had their tot_len field not set for non-first - pbufs. Fixed in pbuf_alloc(). - - ++ New features: - - * Added PPP stack contributed by Marc Boucher - - ++ Changes: - - * Now drops short packets for ICMP/UDP/TCP protocols. More robust. - - * ARP queueuing now queues the latest packet instead of the first. - This is the RFC recommended behaviour, but can be overridden in - lwipopts.h. - -(0.6.2) - - ++ Bugfixes: - - * TCP has been fixed to deal with the new use of the pbuf->ref - counter. - - * DHCP dhcp_inform() crash bug fixed. - - ++ Changes: - - * Removed pbuf_pool_free_cache and pbuf_pool_alloc_cache. Also removed - pbuf_refresh(). This has sped up pbuf pool operations considerably. - Implemented by David Haas. - -(0.6.1) - - ++ New features: - - * The packet buffer implementation has been enhanced to support - zero-copy and copy-on-demand for packet buffers which have their - payloads in application-managed memory. - Implemented by David Haas. - - Use PBUF_REF to make a pbuf refer to RAM. lwIP will use zero-copy - if an outgoing packet can be directly sent on the link, or perform - a copy-on-demand when necessary. - - The application can safely assume the packet is sent, and the RAM - is available to the application directly after calling udp_send() - or similar function. - - ++ Bugfixes: - - * ARP_QUEUEING should now correctly work for all cases, including - PBUF_REF. - Implemented by Leon Woestenberg. - - ++ Changes: - - * IP_ADDR_ANY is no longer a NULL pointer. Instead, it is a pointer - to a '0.0.0.0' IP address. - - * The packet buffer implementation is changed. The pbuf->ref counter - meaning has changed, and several pbuf functions have been - adapted accordingly. - - * netif drivers have to be changed to set the hardware address length field - that must be initialized correctly by the driver (hint: 6 for Ethernet MAC). - See the contrib/ports/c16x cs8900 driver as a driver example. - - * netif's have a dhcp field that must be initialized to NULL by the driver. - See the contrib/ports/c16x cs8900 driver as a driver example. - -(0.5.x) This file has been unmaintained up to 0.6.1. All changes are - logged in CVS but have not been explained here. - -(0.5.3) Changes since version 0.5.2 - - ++ Bugfixes: - - * memp_malloc(MEMP_API_MSG) could fail with multiple application - threads because it wasn't protected by semaphores. - - ++ Other changes: - - * struct ip_addr now packed. - - * The name of the time variable in arp.c has been changed to ctime - to avoid conflicts with the time() function. - -(0.5.2) Changes since version 0.5.1 - - ++ New features: - - * A new TCP function, tcp_tmr(), now handles both TCP timers. - - ++ Bugfixes: - - * A bug in tcp_parseopt() could cause the stack to hang because of a - malformed TCP option. - - * The address of new connections in the accept() function in the BSD - socket library was not handled correctly. - - * pbuf_dechain() did not update the ->tot_len field of the tail. - - * Aborted TCP connections were not handled correctly in all - situations. - - ++ Other changes: - - * All protocol header structs are now packed. - - * The ->len field in the tcp_seg structure now counts the actual - amount of data, and does not add one for SYN and FIN segments. - -(0.5.1) Changes since version 0.5.0 - - ++ New features: - - * Possible to run as a user process under Linux. - - * Preliminary support for cross platform packed structs. - - * ARP timer now implemented. - - ++ Bugfixes: - - * TCP output queue length was badly initialized when opening - connections. - - * TCP delayed ACKs were not sent correctly. - - * Explicit initialization of BSS segment variables. - - * read() in BSD socket library could drop data. - - * Problems with memory alignment. - - * Situations when all TCP buffers were used could lead to - starvation. - - * TCP MSS option wasn't parsed correctly. - - * Problems with UDP checksum calculation. - - * IP multicast address tests had endianess problems. - - * ARP requests had wrong destination hardware address. - - ++ Other changes: - - * struct eth_addr changed from u16_t[3] array to u8_t[6]. - - * A ->linkoutput() member was added to struct netif. - - * TCP and UDP ->dest_* struct members where changed to ->remote_*. - - * ntoh* macros are now null definitions for big endian CPUs. - -(0.5.0) Changes since version 0.4.2 - - ++ New features: - - * Redesigned operating system emulation layer to make porting easier. - - * Better control over TCP output buffers. - - * Documenation added. - - ++ Bugfixes: - - * Locking issues in buffer management. - - * Bugfixes in the sequential API. - - * IP forwarding could cause memory leakage. This has been fixed. - - ++ Other changes: - - * Directory structure somewhat changed; the core/ tree has been - collapsed. - -(0.4.2) Changes since version 0.4.1 - - ++ New features: - - * Experimental ARP implementation added. - - * Skeleton Ethernet driver added. - - * Experimental BSD socket API library added. - - ++ Bugfixes: - - * In very intense situations, memory leakage could occur. This has - been fixed. - - ++ Other changes: - - * Variables named "data" and "code" have been renamed in order to - avoid name conflicts in certain compilers. - - * Variable++ have in appliciable cases been translated to ++variable - since some compilers generate better code in the latter case. - -(0.4.1) Changes since version 0.4 - - ++ New features: - - * TCP: Connection attempts time out earlier than data - transmissions. Nagle algorithm implemented. Push flag set on the - last segment in a burst. - - * UDP: experimental support for UDP-Lite extensions. - - ++ Bugfixes: - - * TCP: out of order segments were in some cases handled incorrectly, - and this has now been fixed. Delayed acknowledgements was broken - in 0.4, has now been fixed. Binding to an address that is in use - now results in an error. Reset connections sometimes hung an - application; this has been fixed. - - * Checksum calculation sometimes failed for chained pbufs with odd - lengths. This has been fixed. - - * API: a lot of bug fixes in the API. The UDP API has been improved - and tested. Error reporting and handling has been - improved. Logical flaws and race conditions for incoming TCP - connections has been found and removed. - - * Memory manager: alignment issues. Reallocating memory sometimes - failed, this has been fixed. - - * Generic library: bcopy was flawed and has been fixed. - - ++ Other changes: - - * API: all datatypes has been changed from generic ones such as - ints, to specified ones such as u16_t. Functions that return - errors now have the correct type (err_t). - - * General: A lot of code cleaned up and debugging code removed. Many - portability issues have been fixed. - - * The license was changed; the advertising clause was removed. - - * C64 port added. - - * Thanks: Huge thanks go to Dagan Galarneau, Horst Garnetzke, Petri - Kosunen, Mikael Caleres, and Frits Wilmink for reporting and - fixing bugs! - -(0.4) Changes since version 0.3.1 - - * Memory management has been radically changed; instead of - allocating memory from a shared heap, memory for objects that are - rapidly allocated and deallocated is now kept in pools. Allocation - and deallocation from those memory pools is very fast. The shared - heap is still present but is used less frequently. - - * The memory, memory pool, and packet buffer subsystems now support - 4-, 2-, or 1-byte alignment. - - * "Out of memory" situations are handled in a more robust way. - - * Stack usage has been reduced. - - * Easier configuration of lwIP parameters such as memory usage, - TTLs, statistics gathering, etc. All configuration parameters are - now kept in a single header file "lwipopts.h". - - * The directory structure has been changed slightly so that all - architecture specific files are kept under the src/arch - hierarchy. - - * Error propagation has been improved, both in the protocol modules - and in the API. - - * The code for the RTXC architecture has been implemented, tested - and put to use. - - * Bugs have been found and corrected in the TCP, UDP, IP, API, and - the Internet checksum modules. - - * Bugs related to porting between a 32-bit and a 16-bit architecture - have been found and corrected. - - * The license has been changed slightly to conform more with the - original BSD license, including the advertisement clause. - -(0.3.1) Changes since version 0.3 - - * Fix of a fatal bug in the buffer management. Pbufs with allocated - RAM never returned the RAM when the pbuf was deallocated. - - * TCP congestion control, window updates and retransmissions did not - work correctly. This has now been fixed. - - * Bugfixes in the API. - -(0.3) Changes since version 0.2 - - * New and improved directory structure. All include files are now - kept in a dedicated include/ directory. - - * The API now has proper error handling. A new function, - netconn_err(), now returns an error code for the connection in - case of errors. - - * Improvements in the memory management subsystem. The system now - keeps a pointer to the lowest free memory block. A new function, - mem_malloc2() tries to allocate memory once, and if it fails tries - to free some memory and retry the allocation. - - * Much testing has been done with limited memory - configurations. lwIP now does a better job when overloaded. - - * Some bugfixes and improvements to the buffer (pbuf) subsystem. - - * Many bugfixes in the TCP code: - - - Fixed a bug in tcp_close(). - - - The TCP receive window was incorrectly closed when out of - sequence segments was received. This has been fixed. - - - Connections are now timed-out of the FIN-WAIT-2 state. - - - The initial congestion window could in some cases be too - large. This has been fixed. - - - The retransmission queue could in some cases be screwed up. This - has been fixed. - - - TCP RST flag now handled correctly. - - - Out of sequence data was in some cases never delivered to the - application. This has been fixed. - - - Retransmitted segments now contain the correct acknowledgment - number and advertised window. - - - TCP retransmission timeout backoffs are not correctly computed - (ala BSD). After a number of retransmissions, TCP now gives up - the connection. - - * TCP connections now are kept on three lists, one for active - connections, one for listening connections, and one for - connections that are in TIME-WAIT. This greatly speeds up the fast - timeout processing for sending delayed ACKs. - - * TCP now provides proper feedback to the application when a - connection has been successfully set up. - - * More comments have been added to the code. The code has also been - somewhat cleaned up. - -(0.2) Initial public release. diff --git a/components/lwip/VERSION b/components/lwip/VERSION deleted file mode 100644 index 4276fd51a..000000000 --- a/components/lwip/VERSION +++ /dev/null @@ -1 +0,0 @@ -bf7fc41e \ No newline at end of file From c0491fc6f11a9a5937cf5a7cd2cd3155294a0f4f Mon Sep 17 00:00:00 2001 From: Hrishikesh Dhayagude Date: Wed, 31 Jul 2019 15:33:03 +0800 Subject: [PATCH 04/36] Minor: Fix some typos in Bluetooth examples --- examples/bluetooth/ble_ancs/main/ble_ancs_demo.c | 4 ++-- .../gatt_security_server/main/example_ble_sec_gatts_demo.c | 4 ++-- .../bt_spp_acceptor/main/example_spp_acceptor_demo.c | 4 ++-- .../bt_spp_initiator/main/example_spp_initiator_demo.c | 4 ++-- .../bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c | 4 ++-- .../main/example_spp_vfs_initiator_demo.c | 4 ++-- examples/bluetooth/nimble/blehr/main/main.c | 2 +- examples/bluetooth/nimble/bleprph/main/main.c | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/bluetooth/ble_ancs/main/ble_ancs_demo.c b/examples/bluetooth/ble_ancs/main/ble_ancs_demo.c index 28ca4629f..294a8a106 100644 --- a/examples/bluetooth/ble_ancs/main/ble_ancs_demo.c +++ b/examples/bluetooth/ble_ancs/main/ble_ancs_demo.c @@ -24,7 +24,7 @@ #include "ble_ancs.h" #define BLE_ANCS_TAG "BLE_ANCS" -#define EXCAMPLE_DEVICE_NAME "ESP_BLE_ANCS" +#define EXAMPLE_DEVICE_NAME "ESP_BLE_ANCS" #define PROFILE_A_APP_ID 0 #define PROFILE_NUM 1 #define ADV_CONFIG_FLAG (1 << 0) @@ -331,7 +331,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_ switch (event) { case ESP_GATTC_REG_EVT: ESP_LOGI(BLE_ANCS_TAG, "REG_EVT"); - esp_ble_gap_set_device_name(EXCAMPLE_DEVICE_NAME); + esp_ble_gap_set_device_name(EXAMPLE_DEVICE_NAME); esp_ble_gap_config_local_icon (ESP_BLE_APPEARANCE_GENERIC_WATCH); //generate a resolvable random address esp_ble_gap_config_local_privacy(true); diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c index 2c1a8186f..a7c80182f 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c @@ -25,7 +25,7 @@ #define HEART_PROFILE_NUM 1 #define HEART_PROFILE_APP_IDX 0 #define ESP_HEART_RATE_APP_ID 0x55 -#define EXCAMPLE_DEVICE_NAME "ESP_BLE_SECURITY" +#define EXAMPLE_DEVICE_NAME "ESP_BLE_SECURITY" #define HEART_RATE_SVC_INST_ID 0 #define GATTS_DEMO_CHAR_VAL_LEN_MAX 0x40 @@ -400,7 +400,7 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, ESP_LOGV(GATTS_TABLE_TAG, "event = %x\n",event); switch (event) { case ESP_GATTS_REG_EVT: - esp_ble_gap_set_device_name(EXCAMPLE_DEVICE_NAME); + esp_ble_gap_set_device_name(EXAMPLE_DEVICE_NAME); //generate a resolvable random address esp_ble_gap_config_local_privacy(true); esp_ble_gatts_create_attr_tab(heart_rate_gatt_db, gatts_if, diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/example_spp_acceptor_demo.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/example_spp_acceptor_demo.c index feadac152..cf82c2724 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/example_spp_acceptor_demo.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/example_spp_acceptor_demo.c @@ -26,7 +26,7 @@ #define SPP_TAG "SPP_ACCEPTOR_DEMO" #define SPP_SERVER_NAME "SPP_SERVER" -#define EXCAMPLE_DEVICE_NAME "ESP_SPP_ACCEPTOR" +#define EXAMPLE_DEVICE_NAME "ESP_SPP_ACCEPTOR" #define SPP_SHOW_DATA 0 #define SPP_SHOW_SPEED 1 #define SPP_SHOW_MODE SPP_SHOW_SPEED /*Choose show mode: show data or speed*/ @@ -56,7 +56,7 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) switch (event) { case ESP_SPP_INIT_EVT: ESP_LOGI(SPP_TAG, "ESP_SPP_INIT_EVT"); - esp_bt_dev_set_device_name(EXCAMPLE_DEVICE_NAME); + esp_bt_dev_set_device_name(EXAMPLE_DEVICE_NAME); esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); esp_spp_start_srv(sec_mask,role_slave, 0, SPP_SERVER_NAME); break; diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/example_spp_initiator_demo.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/example_spp_initiator_demo.c index a805b73e8..cd4365996 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/example_spp_initiator_demo.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/example_spp_initiator_demo.c @@ -25,7 +25,7 @@ #include "sys/time.h" #define SPP_TAG "SPP_INITIATOR_DEMO" -#define EXCAMPLE_DEVICE_NAME "ESP_SPP_INITIATOR" +#define EXAMPLE_DEVICE_NAME "ESP_SPP_INITIATOR" #define SPP_SHOW_DATA 0 #define SPP_SHOW_SPEED 1 @@ -103,7 +103,7 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) switch (event) { case ESP_SPP_INIT_EVT: ESP_LOGI(SPP_TAG, "ESP_SPP_INIT_EVT"); - esp_bt_dev_set_device_name(EXCAMPLE_DEVICE_NAME); + esp_bt_dev_set_device_name(EXAMPLE_DEVICE_NAME); esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); esp_bt_gap_start_discovery(inq_mode, inq_len, inq_num_rsps); diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c index a24d691ec..092756b72 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c @@ -38,7 +38,7 @@ #define SPP_TAG "SPP_ACCEPTOR_DEMO" #define SPP_SERVER_NAME "SPP_SERVER" -#define EXCAMPLE_DEVICE_NAME "ESP_SPP_ACCEPTOR" +#define EXAMPLE_DEVICE_NAME "ESP_SPP_ACCEPTOR" static const esp_spp_mode_t esp_spp_mode = ESP_SPP_MODE_VFS; @@ -75,7 +75,7 @@ static void esp_spp_cb(uint16_t e, void *p) switch (event) { case ESP_SPP_INIT_EVT: ESP_LOGI(SPP_TAG, "ESP_SPP_INIT_EVT"); - esp_bt_dev_set_device_name(EXCAMPLE_DEVICE_NAME); + esp_bt_dev_set_device_name(EXAMPLE_DEVICE_NAME); esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); esp_spp_start_srv(sec_mask,role_slave, 0, SPP_SERVER_NAME); break; diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c index ea8e79987..fc34a8f02 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c @@ -37,7 +37,7 @@ #include "sys/unistd.h" #define SPP_TAG "SPP_INITIATOR_DEMO" -#define EXCAMPLE_DEVICE_NAME "ESP_SPP_INITIATOR" +#define EXAMPLE_DEVICE_NAME "ESP_SPP_INITIATOR" static const esp_spp_mode_t esp_spp_mode = ESP_SPP_MODE_VFS; @@ -113,7 +113,7 @@ static void esp_spp_cb(uint16_t e, void *p) switch (event) { case ESP_SPP_INIT_EVT: ESP_LOGI(SPP_TAG, "ESP_SPP_INIT_EVT"); - esp_bt_dev_set_device_name(EXCAMPLE_DEVICE_NAME); + esp_bt_dev_set_device_name(EXAMPLE_DEVICE_NAME); esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); esp_bt_gap_start_discovery(inq_mode, inq_len, inq_num_rsps); diff --git a/examples/bluetooth/nimble/blehr/main/main.c b/examples/bluetooth/nimble/blehr/main/main.c index ca5b8d4df..f1b7180af 100644 --- a/examples/bluetooth/nimble/blehr/main/main.c +++ b/examples/bluetooth/nimble/blehr/main/main.c @@ -134,7 +134,7 @@ blehr_tx_hrate_stop(void) xTimerStop( blehr_tx_timer, 1000 / portTICK_PERIOD_MS ); } -/* Reset heartrate measurment */ +/* Reset heart rate measurement */ static void blehr_tx_hrate_reset(void) { diff --git a/examples/bluetooth/nimble/bleprph/main/main.c b/examples/bluetooth/nimble/bleprph/main/main.c index 58fc39a34..917e2246c 100644 --- a/examples/bluetooth/nimble/bleprph/main/main.c +++ b/examples/bluetooth/nimble/bleprph/main/main.c @@ -93,7 +93,7 @@ bleprph_advertise(void) BLE_HS_ADV_F_BREDR_UNSUP; /* Indicate that the TX power level field should be included; have the - * stack fill this value automatically. This is done by assiging the + * stack fill this value automatically. This is done by assigning the * special value BLE_HS_ADV_TX_PWR_LVL_AUTO. */ fields.tx_pwr_lvl_is_present = 1; @@ -135,7 +135,7 @@ bleprph_advertise(void) * * @param event The type of event being signalled. * @param ctxt Various information pertaining to the event. - * @param arg Application-specified argument; unuesd by + * @param arg Application-specified argument; unused by * bleprph. * * @return 0 if the application successfully handled the From ff325e84b65e88547ed5508ae1de82232f2d8f43 Mon Sep 17 00:00:00 2001 From: redchenjs Date: Mon, 1 Jul 2019 19:48:47 +0800 Subject: [PATCH 05/36] Bugfix(i2s): fixed i2s left/right channels swapped issue. The right channel data is in the high position, so the I2S_TX_MSB_RIGHT & I2S_RX_MSB_RIGHT bits should be set. Merges https://github.com/espressif/esp-idf/pull/3717 closes https://github.com/espressif/esp-idf/issues/3399 --- components/driver/i2s.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/driver/i2s.c b/components/driver/i2s.c index 56c418d15..d0c9831b8 100644 --- a/components/driver/i2s.c +++ b/components/driver/i2s.c @@ -944,7 +944,7 @@ static esp_err_t i2s_param_config(i2s_port_t i2s_num, const i2s_config_t *i2s_co I2S[i2s_num]->conf.rx_start = 0; if (i2s_config->mode & I2S_MODE_TX) { - I2S[i2s_num]->conf.tx_msb_right = 0; + I2S[i2s_num]->conf.tx_msb_right = 1; I2S[i2s_num]->conf.tx_right_first = 0; I2S[i2s_num]->conf.tx_slave_mod = 0; // Master @@ -956,7 +956,7 @@ static esp_err_t i2s_param_config(i2s_port_t i2s_num, const i2s_config_t *i2s_co } if (i2s_config->mode & I2S_MODE_RX) { - I2S[i2s_num]->conf.rx_msb_right = 0; + I2S[i2s_num]->conf.rx_msb_right = 1; I2S[i2s_num]->conf.rx_right_first = 0; I2S[i2s_num]->conf.rx_slave_mod = 0; // Master I2S[i2s_num]->fifo_conf.rx_fifo_mod_force_en = 1; From a2155ff52dc627027bd6147ba6be90632f02f7b3 Mon Sep 17 00:00:00 2001 From: "Michael (XIAO Xufeng)" Date: Sat, 6 Jul 2019 12:43:35 +0800 Subject: [PATCH 06/36] idf_monitor: improve the responding of console commands --- tools/idf_monitor.py | 301 +++++++++++++++++++++++++++---------------- 1 file changed, 191 insertions(+), 110 deletions(-) diff --git a/tools/idf_monitor.py b/tools/idf_monitor.py index f68020613..5320149db 100755 --- a/tools/idf_monitor.py +++ b/tools/idf_monitor.py @@ -52,6 +52,7 @@ import ctypes import types from distutils.version import StrictVersion from io import open +import textwrap key_description = miniterm.key_description @@ -67,6 +68,15 @@ CTRL_P = '\x10' CTRL_L = '\x0c' CTRL_RBRACKET = '\x1d' # Ctrl+] +# Command parsed from console inputs +CMD_STOP = 1 +CMD_RESET = 2 +CMD_MAKE = 3 +CMD_APP_FLASH = 4 +CMD_OUTPUT_TOGGLE = 5 +CMD_TOGGLE_LOGGING = 6 +CMD_ENTER_BOOT = 7 + # ANSI terminal codes (if changed, regular expressions in LineMatcher need to be udpated) ANSI_RED = '\033[1;31m' ANSI_YELLOW = '\033[0;33m' @@ -92,6 +102,7 @@ __version__ = "1.1" TAG_KEY = 0 TAG_SERIAL = 1 TAG_SERIAL_FLUSH = 2 +TAG_CMD = 3 # regex matches an potential PC value (0x4xxxxxxx) MATCH_PCADDR = re.compile(r'0x4[0-9a-f]{7}', re.IGNORECASE) @@ -149,10 +160,12 @@ class ConsoleReader(StoppableThread): """ Read input keys from the console and push them to the queue, until stopped. """ - def __init__(self, console, event_queue, test_mode): + def __init__(self, console, event_queue, cmd_queue, parser, test_mode): super(ConsoleReader, self).__init__() self.console = console self.event_queue = event_queue + self.cmd_queue = cmd_queue + self.parser = parser self.test_mode = test_mode def run(self): @@ -181,7 +194,15 @@ class ConsoleReader(StoppableThread): except KeyboardInterrupt: c = '\x03' if c is not None: - self.event_queue.put((TAG_KEY, c), False) + ret = self.parser.parse(c) + if ret is not None: + (tag, cmd) = ret + # stop command should be executed last + if tag == TAG_CMD and cmd != CMD_STOP: + self.cmd_queue.put(ret) + else: + self.event_queue.put(ret) + finally: self.console.cleanup() @@ -204,6 +225,110 @@ class ConsoleReader(StoppableThread): fcntl.ioctl(self.console.fd, termios.TIOCSTI, b'\0') +class ConsoleParser(object): + + def __init__(self, eol="CRLF"): + self.translate_eol = { + "CRLF": lambda c: c.replace("\n", "\r\n"), + "CR": lambda c: c.replace("\n", "\r"), + "LF": lambda c: c.replace("\r", "\n"), + }[eol] + self.menu_key = CTRL_T + self.exit_key = CTRL_RBRACKET + self._pressed_menu_key = False + + def parse(self, key): + ret = None + if self._pressed_menu_key: + ret = self._handle_menu_key(key) + elif key == self.menu_key: + self._pressed_menu_key = True + elif key == self.exit_key: + ret = (TAG_CMD, CMD_STOP) + else: + key = self.translate_eol(key) + ret = (TAG_KEY, key) + return ret + + def _handle_menu_key(self, c): + ret = None + if c == self.exit_key or c == self.menu_key: # send verbatim + ret = (TAG_KEY, c) + elif c in [CTRL_H, 'h', 'H', '?']: + red_print(self.get_help_text()) + elif c == CTRL_R: # Reset device via RTS + ret = (TAG_CMD, CMD_RESET) + elif c == CTRL_F: # Recompile & upload + ret = (TAG_CMD, CMD_MAKE) + elif c in [CTRL_A, 'a', 'A']: # Recompile & upload app only + # "CTRL-A" cannot be captured with the default settings of the Windows command line, therefore, "A" can be used + # instead + ret = (TAG_CMD, CMD_APP_FLASH) + elif c == CTRL_Y: # Toggle output display + ret = (TAG_CMD, CMD_OUTPUT_TOGGLE) + elif c == CTRL_L: # Toggle saving output into file + ret = (TAG_CMD, CMD_TOGGLE_LOGGING) + elif c == CTRL_P: + yellow_print("Pause app (enter bootloader mode), press Ctrl-T Ctrl-R to restart") + # to fast trigger pause without press menu key + ret = (TAG_CMD, CMD_ENTER_BOOT) + else: + red_print('--- unknown menu character {} --'.format(key_description(c))) + + self._pressed_menu_key = False + return ret + + def get_help_text(self): + text = """\ + --- idf_monitor ({version}) - ESP-IDF monitor tool + --- based on miniterm from pySerial + --- + --- {exit:8} Exit program + --- {menu:8} Menu escape key, followed by: + --- Menu keys: + --- {menu:14} Send the menu character itself to remote + --- {exit:14} Send the exit character itself to remote + --- {reset:14} Reset target board via RTS line + --- {makecmd:14} Build & flash project + --- {appmake:14} Build & flash app only + --- {output:14} Toggle output display + --- {log:14} Toggle saving output into file + --- {pause:14} Reset target into bootloader to pause app via RTS line + """.format(version=__version__, + exit=key_description(self.exit_key), + menu=key_description(self.menu_key), + reset=key_description(CTRL_R), + makecmd=key_description(CTRL_F), + appmake=key_description(CTRL_A) + ' (or A)', + output=key_description(CTRL_Y), + log=key_description(CTRL_L), + pause=key_description(CTRL_P)) + return textwrap.dedent(text) + + def get_next_action_text(self): + text = """\ + --- Press {} to exit monitor. + --- Press {} to build & flash project. + --- Press {} to build & flash app. + --- Press any other key to resume monitor (resets target). + """.format(key_description(self.exit_key), + key_description(CTRL_F), + key_description(CTRL_A)) + return textwrap.dedent(text) + + def parse_next_action_key(self, c): + ret = None + if c == self.exit_key: + ret = (TAG_CMD, CMD_STOP) + elif c == CTRL_F: # Recompile & upload + ret = (TAG_CMD, CMD_MAKE) + elif c in [CTRL_A, 'a', 'A']: # Recompile & upload app only + # "CTRL-A" cannot be captured with the default settings of the Windows command line, therefore, "A" can be used + # instead + ret = (TAG_CMD, CMD_APP_FLASH) + return ret + + class SerialReader(StoppableThread): """ Read serial data from the serial port and push to the event queue, until stopped. @@ -313,6 +438,7 @@ class Monitor(object): def __init__(self, serial_instance, elf_file, print_filter, make="make", toolchain_prefix=DEFAULT_TOOLCHAIN_PREFIX, eol="CRLF"): super(Monitor, self).__init__() self.event_queue = queue.Queue() + self.cmd_queue = queue.Queue() self.console = miniterm.Console() if os.name == 'nt': sys.stderr = ANSIColorConverter(sys.stderr, decode_output=True) @@ -331,7 +457,8 @@ class Monitor(object): socket_mode = serial_instance.port.startswith("socket://") # testing hook - data from serial can make exit the monitor self.serial = serial_instance - self.console_reader = ConsoleReader(self.console, self.event_queue, socket_mode) + self.console_parser = ConsoleParser(eol) + self.console_reader = ConsoleReader(self.console, self.event_queue, self.cmd_queue, self.console_parser, socket_mode) self.serial_reader = SerialReader(self.serial, self.event_queue) self.elf_file = elf_file if not os.path.exists(make): @@ -339,17 +466,8 @@ class Monitor(object): else: self.make = make self.toolchain_prefix = toolchain_prefix - self.menu_key = CTRL_T - self.exit_key = CTRL_RBRACKET - - self.translate_eol = { - "CRLF": lambda c: c.replace("\n", "\r\n"), - "CR": lambda c: c.replace("\n", "\r"), - "LF": lambda c: c.replace("\r", "\n"), - }[eol] # internal state - self._pressed_menu_key = False self._last_line_part = b"" self._gdb_buffer = b"" self._pc_address_buffer = b"" @@ -368,9 +486,24 @@ class Monitor(object): self.serial_reader.start() try: while self.console_reader.alive and self.serial_reader.alive: - (event_tag, data) = self.event_queue.get() - if event_tag == TAG_KEY: - self.handle_key(data) + try: + item = self.cmd_queue.get_nowait() + except queue.Empty: + try: + item = self.event_queue.get(False, 0.001) + except queue.Empty: + continue + + (event_tag, data) = item + if event_tag == TAG_CMD: + self.handle_commands(data) + elif event_tag == TAG_KEY: + try: + self.serial.write(codecs.encode(data)) + except serial.SerialException: + pass # this shouldn't happen, but sometimes port has closed in serial thread + except UnicodeEncodeError: + pass # this can happen if a non-ascii character was passed, ignoring elif event_tag == TAG_SERIAL: self.handle_serial_input(data) if self._invoke_processing_last_line_timer is not None: @@ -400,24 +533,6 @@ class Monitor(object): pass sys.stderr.write(ANSI_NORMAL + "\n") - def handle_key(self, key): - if self._pressed_menu_key: - self.handle_menu_key(key) - self._pressed_menu_key = False - elif key == self.menu_key: - self._pressed_menu_key = True - elif key == self.exit_key: - self.console_reader.stop() - self.serial_reader.stop() - else: - try: - key = self.translate_eol(key) - self.serial.write(codecs.encode(key)) - except serial.SerialException: - pass # this shouldn't happen, but sometimes port has closed in serial thread - except UnicodeEncodeError: - pass # this can happen if a non-ascii character was passed, ignoring - def handle_serial_input(self, data, finalize_line=False): sp = data.split(b'\n') if self._last_line_part != b"": @@ -429,7 +544,7 @@ class Monitor(object): self._last_line_part = sp.pop() for line in sp: if line != b"": - if self._serial_check_exit and line == self.exit_key.encode('latin-1'): + if self._serial_check_exit and line == self.console_parser.exit_key.encode('latin-1'): raise SerialStopException() if self._force_line_print or self._line_matcher.match(line.decode(errors="ignore")): self._print(line + b'\n') @@ -465,65 +580,6 @@ class Monitor(object): for m in re.finditer(MATCH_PCADDR, line.decode(errors="ignore")): self.lookup_pc_address(m.group()) - def handle_menu_key(self, c): - if c == self.exit_key or c == self.menu_key: # send verbatim - self.serial.write(codecs.encode(c)) - elif c in [CTRL_H, 'h', 'H', '?']: - red_print(self.get_help_text()) - elif c == CTRL_R: # Reset device via RTS - self.serial.setRTS(True) - time.sleep(0.2) - self.serial.setRTS(False) - self.output_enable(True) - elif c == CTRL_F: # Recompile & upload - self.run_make("flash") - elif c in [CTRL_A, 'a', 'A']: # Recompile & upload app only - # "CTRL-A" cannot be captured with the default settings of the Windows command line, therefore, "A" can be used - # instead - self.run_make("app-flash") - elif c == CTRL_Y: # Toggle output display - self.output_toggle() - elif c == CTRL_L: # Toggle saving output into file - self.toggle_logging() - elif c == CTRL_P: - yellow_print("Pause app (enter bootloader mode), press Ctrl-T Ctrl-R to restart") - # to fast trigger pause without press menu key - self.serial.setDTR(False) # IO0=HIGH - self.serial.setRTS(True) # EN=LOW, chip in reset - time.sleep(1.3) # timeouts taken from esptool.py, includes esp32r0 workaround. defaults: 0.1 - self.serial.setDTR(True) # IO0=LOW - self.serial.setRTS(False) # EN=HIGH, chip out of reset - time.sleep(0.45) # timeouts taken from esptool.py, includes esp32r0 workaround. defaults: 0.05 - self.serial.setDTR(False) # IO0=HIGH, done - else: - red_print('--- unknown menu character {} --'.format(key_description(c))) - - def get_help_text(self): - return """ ---- idf_monitor ({version}) - ESP-IDF monitor tool ---- based on miniterm from pySerial ---- ---- {exit:8} Exit program ---- {menu:8} Menu escape key, followed by: ---- Menu keys: ---- {menu:14} Send the menu character itself to remote ---- {exit:14} Send the exit character itself to remote ---- {reset:14} Reset target board via RTS line ---- {makecmd:14} Build & flash project ---- {appmake:14} Build & flash app only ---- {output:14} Toggle output display ---- {log:14} Toggle saving output into file ---- {pause:14} Reset target into bootloader to pause app via RTS line -""".format(version=__version__, - exit=key_description(self.exit_key), - menu=key_description(self.menu_key), - reset=key_description(CTRL_R), - makecmd=key_description(CTRL_F), - appmake=key_description(CTRL_A) + ' (or A)', - output=key_description(CTRL_Y), - log=key_description(CTRL_L), - pause=key_description(CTRL_P)) - def __enter__(self): """ Use 'with self' to temporarily disable monitoring behaviour """ self.serial_reader.stop() @@ -537,25 +593,22 @@ class Monitor(object): def prompt_next_action(self, reason): self.console.setup() # set up console to trap input characters try: - red_print(""" ---- {} ---- Press {} to exit monitor. ---- Press {} to build & flash project. ---- Press {} to build & flash app. ---- Press any other key to resume monitor (resets target).""".format(reason, - key_description(self.exit_key), - key_description(CTRL_F), - key_description(CTRL_A))) + red_print("--- {}".format(reason)) + red_print(self.console_parser.get_next_action_text()) + k = CTRL_T # ignore CTRL-T here, so people can muscle-memory Ctrl-T Ctrl-F, etc. while k == CTRL_T: k = self.console.getkey() finally: self.console.cleanup() - if k == self.exit_key: - self.event_queue.put((TAG_KEY, k)) - elif k in [CTRL_F, CTRL_A]: - self.event_queue.put((TAG_KEY, self.menu_key)) - self.event_queue.put((TAG_KEY, k)) + ret = self.console_parser.parse_next_action_key(k) + if ret is not None: + cmd = ret[1] + if cmd == CMD_STOP: + # the stop command should be handled last + self.event_queue.put(ret) + else: + self.cmd_queue.put(ret) def run_make(self, target): with self: @@ -676,6 +729,34 @@ class Monitor(object): # don't fill-up the screen with the previous errors (probably consequent prints would fail also) self.stop_logging() + def handle_commands(self, cmd): + if cmd == CMD_STOP: + self.console_reader.stop() + self.serial_reader.stop() + elif cmd == CMD_RESET: + self.serial.setRTS(True) + time.sleep(0.2) + self.serial.setRTS(False) + self.output_enable(True) + elif cmd == CMD_MAKE: + self.run_make("flash") + elif cmd == CMD_APP_FLASH: + self.run_make("app-flash") + elif cmd == CMD_OUTPUT_TOGGLE: + self.output_toggle() + elif cmd == CMD_TOGGLE_LOGGING: + self.toggle_logging() + elif cmd == CMD_ENTER_BOOT: + self.serial.setDTR(False) # IO0=HIGH + self.serial.setRTS(True) # EN=LOW, chip in reset + time.sleep(1.3) # timeouts taken from esptool.py, includes esp32r0 workaround. defaults: 0.1 + self.serial.setDTR(True) # IO0=LOW + self.serial.setRTS(False) # EN=HIGH, chip out of reset + time.sleep(0.45) # timeouts taken from esptool.py, includes esp32r0 workaround. defaults: 0.05 + self.serial.setDTR(False) # IO0=HIGH, done + else: + raise RuntimeError("Bad command data %d" % (cmd)) + def main(): parser = argparse.ArgumentParser("idf_monitor - a serial output monitor for esp-idf") @@ -748,9 +829,9 @@ def main(): yellow_print('--- idf_monitor on {p.name} {p.baudrate} ---'.format( p=serial_instance)) yellow_print('--- Quit: {} | Menu: {} | Help: {} followed by {} ---'.format( - key_description(monitor.exit_key), - key_description(monitor.menu_key), - key_description(monitor.menu_key), + key_description(monitor.console_parser.exit_key), + key_description(monitor.console_parser.menu_key), + key_description(monitor.console_parser.menu_key), key_description(CTRL_H))) if args.print_filter != DEFAULT_PRINT_FILTER: yellow_print('--- Print filter: {} ---'.format(args.print_filter)) From 50629eec271e5815614f607c35a85381a18a734a Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Tue, 16 Jul 2019 13:49:27 +0700 Subject: [PATCH 07/36] tools: Add a script to fix up empty prototypes --- tools/ci/executable-list.txt | 1 + tools/ci/fix_empty_prototypes.sh | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100755 tools/ci/fix_empty_prototypes.sh diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index 9ae3ae702..4e580c5a8 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -39,6 +39,7 @@ tools/ci/check_idf_version.sh tools/ci/check_ut_cmake_make.sh tools/ci/checkout_project_ref.py tools/ci/envsubst.py +tools/ci/fix_empty_prototypes.sh tools/ci/get-full-sources.sh tools/ci/get_supported_examples.sh tools/ci/mirror-submodule-update.sh diff --git a/tools/ci/fix_empty_prototypes.sh b/tools/ci/fix_empty_prototypes.sh new file mode 100755 index 000000000..0aade7861 --- /dev/null +++ b/tools/ci/fix_empty_prototypes.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# This script finds and fixes up empty prototypes, to satisfy `-Wstrict-prototypes` and to сomply the C Standard + +set -o errexit +set -o pipefail +set -o nounset + +ctags -R -f - --c-kinds=pf --languages="c" --langmap=c:.c.h | grep "([[:space:]]*)" > tmp_ctags.txt || : + +ctags -R -f - --c-kinds=pf --languages="c++" --langmap=c++:.cpp | grep "([[:space:]]*)" | grep -F 'extern "C"' >> tmp_ctags.txt || : + +while read TAGLINE; do + + # a format of ctags: + # https://en.wikipedia.org/wiki/Ctags + + # a 2nd column, + FILENAME=$(printf "$TAGLINE" | sed -E "s/([^[:space:]]+)[[:space:]]([^[:space:]]+)[[:space:]](.+)\;\".*/\2/g") + + # a 3rd column + # a pattern + # /^ void sdmmc_host_dma_stop ( );$/ + OLDLINE=$(printf "$TAGLINE" | sed -E "s/([^[:space:]]+)[[:space:]]([^[:space:]]+)[[:space:]](.+)\;\".*/\3/g") + + # remove leading and trailng '/'-s + OLDLINE="${OLDLINE#/}" + OLDLINE="${OLDLINE%/}" + + # remove leading '^' and trailing '$' + OLDLINE="${OLDLINE#^}" + OLDLINE="${OLDLINE%$}" + + + OLDBRACERS=$(printf "$OLDLINE" | sed "s/.*\(([[:space:]]*)\).*/\1/") + NEWBRACERS="(void)" + + NEWLINE=${OLDLINE/$OLDBRACERS/$NEWBRACERS} + + # escaping + OLDLINE=$(printf "%q" "$OLDLINE") + NEWLINE=$(printf "%q" "$NEWLINE") + + sed -i -E 's,'"^$OLDLINE\$"','"$NEWLINE"',' $FILENAME + +done < tmp_ctags.txt + +echo "+++" +echo "Also 'git grep -E \"^.*\([^\)]+\) *\(\).*$\"' will help to find some callback declarations" +echo "+++" From afbaf74007e89d016dbade4072bf2e7a3874139a Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Tue, 16 Jul 2019 16:33:30 +0700 Subject: [PATCH 08/36] tools: Mass fixing of empty prototypes (for -Wstrict-prototypes) --- components/app_trace/app_trace.c | 20 ++--- components/app_trace/gcov/gcov_rtio.c | 2 +- components/app_trace/heap_trace_tohost.c | 2 +- components/app_trace/include/esp_app_trace.h | 2 +- .../sys_view/Config/SEGGER_RTT_Conf.h | 4 +- .../sys_view/Config/SEGGER_SYSVIEW_Conf.h | 2 +- .../Config/SEGGER_SYSVIEW_Config_FreeRTOS.c | 10 +-- components/app_trace/test/test_trace.c | 6 +- components/app_update/esp_ota_ops.c | 6 +- components/app_update/include/esp_ota_ops.h | 6 +- components/app_update/test/test_switch_ota.c | 2 +- .../subproject/main/bootloader_start.c | 4 +- .../include/bootloader_common.h | 2 +- .../include/bootloader_flash_config.h | 4 +- .../include/esp_flash_encrypt.h | 4 +- .../include_bootloader/bootloader_flash.h | 2 +- .../include_bootloader/bootloader_init.h | 2 +- .../include_bootloader/bootloader_sha.h | 2 +- .../include_bootloader/flash_qio_mode.h | 2 +- .../bootloader_support/src/bootloader_clock.c | 2 +- .../src/bootloader_common.c | 2 +- .../bootloader_support/src/bootloader_flash.c | 4 +- .../src/bootloader_flash_config.c | 4 +- .../bootloader_support/src/bootloader_init.c | 8 +- .../src/esp32/bootloader_sha.c | 2 +- .../src/esp32/flash_encrypt.c | 4 +- .../src/esp32/secure_boot.c | 2 +- .../bootloader_support/src/flash_encrypt.c | 4 +- .../bootloader_support/src/flash_qio_mode.c | 18 ++--- .../src/idf/bootloader_sha.c | 2 +- .../bt/host/bluedroid/api/esp_spp_api.c | 4 +- .../bluedroid/api/include/api/esp_spp_api.h | 2 +- .../bt/host/bluedroid/bta/dm/bta_dm_main.c | 4 +- .../bt/host/bluedroid/bta/dm/bta_dm_pm.c | 4 +- .../bt/host/bluedroid/bta/gatt/bta_gattc_co.c | 2 +- .../bta/hf_client/bta_hf_client_at.c | 6 +- .../bta/hf_client/include/bta_hf_client_int.h | 2 +- .../bluedroid/bta/include/bta/bta_gatt_api.h | 2 +- .../bt/host/bluedroid/bta/jv/bta_jv_act.c | 2 +- .../bluedroid/btc/core/btc_profile_queue.c | 2 +- .../btc/profile/std/a2dp/btc_a2dp_source.c | 2 +- .../btc/profile/std/smp/esp_app_sec.c | 2 +- .../bluedroid/btc/profile/std/spp/btc_spp.c | 2 +- .../bt/host/bluedroid/device/controller.c | 2 +- .../device/include/device/controller.h | 2 +- components/bt/host/bluedroid/hci/hci_hal_h4.c | 4 +- components/bt/host/bluedroid/hci/hci_layer.c | 4 +- .../host/bluedroid/hci/hci_packet_factory.c | 2 +- .../bt/host/bluedroid/hci/hci_packet_parser.c | 2 +- .../bluedroid/hci/include/hci/hci_layer.h | 2 +- .../hci/include/hci/hci_packet_factory.h | 2 +- .../hci/include/hci/hci_packet_parser.h | 2 +- .../hci/include/hci/packet_fragmenter.h | 2 +- .../bt/host/bluedroid/hci/packet_fragmenter.c | 6 +- components/bt/host/bluedroid/main/bte_main.c | 4 +- .../bt/host/bluedroid/stack/avdt/avdt_api.c | 4 +- .../bluedroid/stack/btm/btm_ble_adv_filter.c | 2 +- .../host/bluedroid/stack/btm/btm_ble_bgconn.c | 6 +- .../bt/host/bluedroid/stack/btm/btm_ble_gap.c | 4 +- .../bluedroid/stack/btm/btm_ble_multi_adv.c | 2 +- .../stack/include/stack/btm_ble_api.h | 6 +- components/coap/port/coap_io.c | 2 +- components/console/commands.c | 4 +- components/console/esp_console.h | 4 +- components/console/linenoise/linenoise.c | 8 +- components/console/linenoise/linenoise.h | 2 +- components/cxx/cxx_guards.cpp | 4 +- components/driver/adc1_i2s_private.h | 8 +- components/driver/can.c | 28 +++---- components/driver/gpio.c | 2 +- components/driver/i2c.c | 2 +- components/driver/i2s.c | 2 +- components/driver/include/driver/adc.h | 8 +- .../include/driver/adc2_wifi_internal.h | 4 +- components/driver/include/driver/can.h | 12 +-- components/driver/include/driver/dac.h | 4 +- components/driver/include/driver/gpio.h | 2 +- components/driver/include/driver/i2c.h | 2 +- components/driver/include/driver/ledc.h | 2 +- components/driver/include/driver/rtc_io.h | 2 +- components/driver/include/driver/sdio_slave.h | 10 +-- components/driver/include/driver/sdmmc_host.h | 4 +- components/driver/include/driver/sdspi_host.h | 4 +- components/driver/include/driver/spi_common.h | 2 +- components/driver/include/driver/touch_pad.h | 18 ++--- .../driver/include/driver/uart_select.h | 2 +- components/driver/ledc.c | 2 +- components/driver/rmt.c | 2 +- components/driver/rtc_module.c | 50 ++++++------ components/driver/sdio_slave.c | 78 +++++++++---------- components/driver/sdmmc_host.c | 18 ++--- components/driver/sdmmc_private.h | 12 +-- components/driver/sdmmc_transaction.c | 12 +-- components/driver/sdspi_host.c | 4 +- components/driver/spi_common.c | 2 +- components/driver/test/test_i2c.c | 20 ++--- components/driver/test/test_rmt.c | 4 +- components/driver/test/test_spi_sio.c | 4 +- components/driver/test/test_spi_slave.c | 2 +- components/driver/test/test_timer.c | 4 +- components/driver/test/test_uart.c | 6 +- components/driver/uart.c | 2 +- components/efuse/include/esp_efuse.h | 2 +- components/efuse/src/esp_efuse_fields.c | 4 +- components/efuse/src/esp_efuse_utility.c | 10 +-- components/efuse/src/esp_efuse_utility.h | 8 +- components/esp-tls/esp_tls.c | 8 +- components/esp-tls/esp_tls.h | 8 +- components/esp32/brownout.c | 4 +- components/esp32/cache_err_int.c | 4 +- components/esp32/clk.c | 2 +- components/esp32/cpu_start.c | 8 +- components/esp32/crosscore_int.c | 4 +- components/esp32/esp_clk_internal.h | 2 +- components/esp32/esp_himem.c | 8 +- components/esp32/esp_timer_esp32.c | 14 ++-- components/esp32/include/esp32/brownout.h | 2 +- .../esp32/include/esp32/cache_err_int.h | 4 +- components/esp32/include/esp32/clk.h | 4 +- components/esp32/include/esp32/himem.h | 6 +- components/esp32/include/esp32/spiram.h | 14 ++-- components/esp32/include/esp_intr_alloc.h | 4 +- components/esp32/include/esp_sleep.h | 16 ++-- components/esp32/int_wdt.c | 4 +- components/esp32/intr_alloc.c | 4 +- components/esp32/panic.c | 16 ++-- components/esp32/pm_esp32.c | 18 ++--- components/esp32/pm_trace.c | 2 +- components/esp32/reset_reason.c | 4 +- components/esp32/sleep_modes.c | 38 ++++----- components/esp32/spiram.c | 20 ++--- components/esp32/spiram_psram.c | 2 +- components/esp32/spiram_psram.h | 2 +- components/esp32/system_api.c | 6 +- components/esp32/task_wdt.c | 8 +- components/esp32/test/test_4mpsram.c | 2 +- components/esp32/test/test_ahb_arb.c | 4 +- components/esp32/test/test_esp_timer.c | 8 +- components/esp32/test/test_intr_alloc.c | 2 +- components/esp32/test/test_pm.c | 4 +- components/esp32/test/test_reset_reason.c | 36 ++++----- components/esp32/test/test_sleep.c | 20 ++--- components/esp32/test/test_stack_check.c | 2 +- components/esp_adc_cal/esp_adc_cal.c | 6 +- components/esp_common/include/esp_int_wdt.h | 4 +- .../include/esp_private/crosscore_int.h | 2 +- .../include/esp_private/esp_timer_impl.h | 10 +-- .../esp_common/include/esp_private/pm_impl.h | 10 +-- .../esp_common/include/esp_private/pm_trace.h | 2 +- .../include/esp_private/system_internal.h | 2 +- components/esp_common/include/esp_task_wdt.h | 6 +- components/esp_common/include/esp_timer.h | 8 +- components/esp_common/src/dbg_stubs.c | 2 +- components/esp_common/src/esp_timer.c | 16 ++-- components/esp_common/src/freertos_hooks.c | 4 +- components/esp_common/src/ipc.c | 4 +- components/esp_event/default_event_loop.c | 4 +- components/esp_event/esp_event.c | 2 +- components/esp_event/event_loop_legacy.c | 2 +- components/esp_event/include/esp_event.h | 4 +- .../esp_event/include/esp_event_legacy.h | 4 +- .../private_include/esp_event_private.h | 2 +- components/esp_event/test/test_event.c | 8 +- components/esp_gdbstub/esp32/gdbstub_esp32.c | 4 +- .../private_include/esp_gdbstub_common.h | 8 +- components/esp_gdbstub/src/gdbstub.c | 12 +-- components/esp_gdbstub/src/packet.c | 4 +- components/esp_http_client/lib/http_header.c | 2 +- .../esp_http_client/lib/include/http_header.h | 2 +- components/esp_http_server/src/httpd_sess.c | 2 +- .../esp_http_server/src/port/esp32/osal.h | 4 +- .../esp_local_ctrl/include/esp_local_ctrl.h | 4 +- components/esp_ringbuf/test/test_ringbuf.c | 10 +-- .../esp_rom/include/esp32/rom/tbconsole.h | 2 +- .../esp_websocket_client.c | 2 +- components/esp_wifi/include/esp_phy_init.h | 2 +- components/esp_wifi/include/phy.h | 2 +- components/esp_wifi/src/phy_init.c | 4 +- components/esp_wifi/src/wifi_init.c | 4 +- components/esp_wifi/test/test_phy_rtc.c | 4 +- .../espcoredump/include/esp_core_dump.h | 2 +- .../include_core_dump/esp_core_dump_priv.h | 2 +- components/espcoredump/src/core_dump_common.c | 2 +- components/espcoredump/src/core_dump_flash.c | 2 +- components/espcoredump/src/core_dump_uart.c | 2 +- components/espcoredump/test/test_core_dump.c | 4 +- components/fatfs/test/test_fatfs_rawflash.c | 2 +- components/fatfs/test/test_fatfs_spiflash.c | 4 +- components/fatfs/vfs/esp_vfs_fat.h | 4 +- components/fatfs/vfs/vfs_fat.c | 4 +- components/fatfs/vfs/vfs_fat_sdmmc.c | 2 +- .../freemodbus/common/esp_modbus_master.c | 4 +- .../freemodbus/common/esp_modbus_slave.c | 4 +- components/freemodbus/port/port.c | 4 +- components/freemodbus/port/port.h | 4 +- components/freemodbus/port/portserial.c | 4 +- components/freemodbus/port/portserial_m.c | 4 +- components/freemodbus/port/porttimer.c | 6 +- components/freemodbus/port/porttimer_m.c | 10 +-- .../modbus_controller/mbc_serial_slave.c | 2 +- .../freertos/include/freertos/portable.h | 6 +- .../freertos/include/freertos/portmacro.h | 6 +- components/freertos/port.c | 6 +- components/freertos/tasks.c | 2 +- .../test/test_freertos_backported_functions.c | 2 +- .../freertos/test/test_freertos_eventgroups.c | 6 +- .../freertos/test/test_freertos_task_notify.c | 2 +- .../freertos/test/test_task_suspend_resume.c | 6 +- components/heap/heap_caps.c | 2 +- components/heap/heap_caps_init.c | 4 +- components/heap/include/esp_heap_caps.h | 2 +- components/heap/include/esp_heap_caps_init.h | 4 +- components/heap/test/test_malloc.c | 4 +- components/heap/test/test_malloc_caps.c | 2 +- components/libsodium/test/test_sodium.c | 14 ++-- components/log/log.c | 10 +-- components/lwip/apps/dhcpserver/dhcpserver.c | 2 +- .../lwip/include/apps/dhcpserver/dhcpserver.h | 2 +- .../lwip/port/esp32/include/arch/vfs_lwip.h | 2 +- components/lwip/port/esp32/vfs_lwip.c | 4 +- components/lwip/test_afl_host/dhcp_di.h | 2 +- components/lwip/test_afl_host/dhcpserver_di.h | 2 +- components/lwip/test_afl_host/dns_di.h | 2 +- .../lwip/test_afl_host/test_dhcp_client.c | 2 +- .../lwip/test_afl_host/test_dhcp_server.c | 2 +- components/lwip/test_afl_host/test_dns.c | 2 +- components/mbedtls/port/esp_bignum.c | 2 +- .../mbedtls/test/test_apb_dport_access.c | 8 +- .../mbedtls/test/test_apb_dport_access.h | 4 +- components/mdns/include/mdns.h | 6 +- components/mdns/include/mdns_console.h | 2 +- components/mdns/mdns.c | 30 +++---- components/mdns/mdns_console.c | 40 +++++----- components/mdns/mdns_networking.c | 6 +- .../mdns/test_afl_fuzz_host/esp32_compat.h | 2 +- .../mdns/test_afl_fuzz_host/esp32_mock.c | 4 +- .../mdns/test_afl_fuzz_host/esp32_mock.h | 2 +- components/mdns/test_afl_fuzz_host/mdns_di.h | 2 +- components/mdns/test_afl_fuzz_host/test.c | 4 +- components/newlib/heap.c | 6 +- components/newlib/locks.c | 2 +- .../newlib/platform_include/esp_newlib.h | 8 +- components/newlib/pthread.c | 2 +- components/newlib/reent_init.c | 6 +- components/newlib/syscall_table.c | 2 +- components/newlib/syscalls.c | 2 +- components/newlib/time.c | 16 ++-- components/nvs_flash/src/nvs_api.cpp | 2 +- .../openssl/include/internal/ssl_x509.h | 2 +- components/openssl/library/ssl_x509.c | 2 +- .../protocomm/include/common/protocomm.h | 2 +- components/protocomm/src/common/protocomm.c | 2 +- .../protocomm/src/simple_ble/simple_ble.c | 6 +- .../protocomm/src/simple_ble/simple_ble.h | 6 +- components/pthread/include/esp_pthread.h | 2 +- components/pthread/pthread.c | 6 +- components/pthread/pthread_cond_var.c | 2 +- components/pthread/pthread_internal.h | 2 +- components/pthread/pthread_local_storage.c | 4 +- components/sdmmc/test/test_sd.c | 4 +- components/sdmmc/test/test_sdio.c | 2 +- components/soc/esp32/cpu_util.c | 2 +- components/soc/esp32/include/soc/cpu.h | 8 +- components/soc/esp32/include/soc/rtc.h | 28 +++---- components/soc/esp32/rtc_clk.c | 36 ++++----- components/soc/esp32/rtc_clk_init.c | 4 +- components/soc/esp32/rtc_init.c | 2 +- components/soc/esp32/rtc_pm.c | 8 +- components/soc/esp32/rtc_time.c | 4 +- components/soc/esp32/rtc_wdt.c | 16 ++-- components/soc/esp32/test/test_rtc_clk.c | 2 +- components/soc/include/soc/rtc_wdt.h | 16 ++-- .../soc/include/soc/soc_memory_layout.h | 2 +- components/soc/src/memory_layout_utils.c | 4 +- components/spi_flash/cache_utils.c | 30 +++---- components/spi_flash/cache_utils.h | 14 ++-- components/spi_flash/esp_flash_api.c | 2 +- components/spi_flash/esp_flash_spi_init.c | 4 +- components/spi_flash/flash_mmap.c | 6 +- components/spi_flash/flash_ops.c | 24 +++--- components/spi_flash/include/esp_flash.h | 4 +- components/spi_flash/include/esp_spi_flash.h | 16 ++-- components/spi_flash/partition.c | 4 +- components/spi_flash/sim/flash_mock.cpp | 2 +- components/spi_flash/sim/flash_mock_util.c | 16 ++-- components/spi_flash/sim/stubs/log/log.c | 2 +- components/spi_flash/spi_flash_rom_patch.c | 6 +- components/spi_flash/test/test_esp_flash.c | 2 +- .../spi_flash/test/test_flash_encryption.c | 2 +- components/spi_flash/test/test_mmap.c | 2 +- components/spi_flash/test/test_read_write.c | 2 +- components/spiffs/test/test_spiffs.c | 4 +- .../tcp_transport/include/esp_transport.h | 4 +- .../tcp_transport/include/esp_transport_ssl.h | 2 +- .../tcp_transport/include/esp_transport_tcp.h | 2 +- components/tcp_transport/transport.c | 4 +- components/tcp_transport/transport_ssl.c | 2 +- components/tcp_transport/transport_tcp.c | 2 +- components/tcpip_adapter/event_handlers.c | 8 +- .../tcpip_adapter/include/tcpip_adapter.h | 8 +- components/unity/include/unity_test_runner.h | 4 +- components/unity/unity_port_esp32.c | 2 +- components/unity/unity_runner.c | 4 +- components/vfs/include/esp_vfs_dev.h | 2 +- components/vfs/test/test_vfs_access.c | 4 +- components/vfs/test/test_vfs_select.c | 6 +- components/vfs/test/test_vfs_uart.c | 2 +- components/vfs/vfs.c | 2 +- components/vfs/vfs_uart.c | 6 +- .../src/esp_supplicant/esp_wpa_main.c | 4 +- .../bluetooth/ble_ancs/main/ble_ancs_demo.c | 2 +- .../main/ble_compatibility_test.c | 2 +- .../ble_eddystone/main/esp_eddystone_demo.c | 2 +- .../main/ble_hidd_demo_main.c | 2 +- .../ble/ble_ibeacon/main/ibeacon_demo.c | 2 +- .../ble/ble_spp_client/main/spp_client_demo.c | 2 +- .../ble_spp_server/main/ble_spp_server_demo.c | 2 +- .../main/example_ble_client_throughput.c | 2 +- .../main/example_ble_server_throughput.c | 2 +- .../ble/blufi/main/blufi_example_main.c | 2 +- .../ble/gatt_client/main/gattc_demo.c | 2 +- .../main/example_ble_sec_gattc_demo.c | 2 +- .../main/example_ble_sec_gatts_demo.c | 2 +- .../ble/gatt_server/main/gatts_demo.c | 2 +- .../main/gatts_table_creat_demo.c | 2 +- .../main/gattc_multi_connect.c | 2 +- .../classic_bt/a2dp_sink/main/main.c | 2 +- .../classic_bt/a2dp_source/main/main.c | 2 +- .../bt_discovery/main/bt_discovery.c | 2 +- .../main/example_spp_acceptor_demo.c | 2 +- .../main/example_spp_initiator_demo.c | 2 +- .../main/example_spp_vfs_acceptor_demo.c | 2 +- .../main/example_spp_vfs_initiator_demo.c | 2 +- .../coex/a2dp_gatts_coex/main/main.c | 2 +- .../gattc_gatts_coex/main/gattc_gatts_coex.c | 2 +- .../main/controller_hci_uart_demo.c | 2 +- .../hci/controller_vhci_ble_adv/main/app_bt.c | 2 +- .../ble_mesh_node/main/ble_mesh_adapter.c | 6 +- .../ble_mesh_node/main/ble_mesh_adapter.h | 6 +- .../main/ble_mesh_console_decl.h | 10 +-- .../main/ble_mesh_console_main.c | 4 +- .../main/ble_mesh_console_system.c | 14 ++-- .../main/ble_mesh_register_node_cmd.c | 10 +-- .../main/ble_mesh_register_server_cmd.c | 6 +- .../ble_mesh_node/main/register_bluetooth.c | 8 +- .../main/ble_mesh_adapter.c | 8 +- .../main/ble_mesh_adapter.h | 8 +- .../main/ble_mesh_console_decl.h | 14 ++-- .../main/ble_mesh_console_main.c | 4 +- .../main/ble_mesh_console_system.c | 14 ++-- .../main/ble_mesh_reg_cfg_client_cmd.c | 6 +- .../main/ble_mesh_reg_gen_onoff_client_cmd.c | 6 +- .../main/ble_mesh_reg_test_perf_client_cmd.c | 6 +- .../main/ble_mesh_register_node_cmd.c | 8 +- .../main/ble_mesh_register_provisioner_cmd.c | 8 +- .../main/register_bluetooth.c | 6 +- .../components/iperf/cmd_wifi.c | 2 +- .../main/ble_mesh_demo_main.c | 2 +- .../bluetooth/nimble/blemesh/main/app_mesh.c | 2 +- examples/bluetooth/nimble/bleprph/main/scli.c | 4 +- examples/build_system/cmake/idf_as_lib/main.c | 2 +- .../cmake/idf_as_lib/stubs/esp32/cpu_start.c | 4 +- .../cmake/idf_as_lib/stubs/esp32/flash_ops.c | 2 +- .../stubs/spi_flash/esp_spi_flash.h | 2 +- .../protocol_examples_common/connect.c | 16 ++-- .../include/protocol_examples_common.h | 6 +- .../protocol_examples_common/stdin_out.c | 2 +- .../basic/main/ethernet_example_main.c | 2 +- .../eth2ap/main/ethernet_example_main.c | 2 +- examples/ethernet/iperf/main/cmd_ethernet.c | 2 +- examples/ethernet/iperf/main/cmd_ethernet.h | 2 +- .../iperf/main/ethernet_example_main.c | 8 +- examples/get-started/blink/main/blink.c | 2 +- .../hello_world/main/hello_world_main.c | 2 +- .../peripherals/adc/main/adc1_example_main.c | 4 +- .../can_alert_and_recovery_example_main.c | 2 +- .../can_network_example_listen_only_main.c | 2 +- .../main/can_network_example_master_main.c | 2 +- .../main/can_network_example_slave_main.c | 2 +- .../main/can_self_test_example_main.c | 2 +- .../peripherals/gpio/main/gpio_example_main.c | 2 +- .../i2c/i2c_self_test/main/i2c_example_main.c | 6 +- .../i2c/i2c_tools/main/cmd_i2ctools.c | 2 +- .../i2c_tools/main/i2ctools_example_main.c | 8 +- .../peripherals/i2s/main/i2s_example_main.c | 2 +- .../peripherals/i2s_adc_dac/main/app_main.c | 10 +-- .../peripherals/ledc/main/ledc_example_main.c | 2 +- .../main/mcpwm_basic_config_example.c | 6 +- .../mcpwm_bldc_control_hall_sensor_example.c | 6 +- .../main/mcpwm_brushed_dc_control_example.c | 4 +- .../main/mcpwm_servo_control_example.c | 4 +- .../peripherals/pcnt/main/pcnt_example_main.c | 2 +- .../rmt_nec_tx_rx/main/infrared_nec_main.c | 10 +-- .../peripherals/rmt_tx/main/rmt_tx_main.c | 2 +- .../peripherals/sdio/host/main/app_main.c | 6 +- .../peripherals/sdio/slave/main/app_main.c | 8 +- .../sigmadelta/main/sigmadelta_example_main.c | 2 +- .../spi_master/main/pretty_effect.c | 2 +- .../spi_master/main/pretty_effect.h | 2 +- .../spi_master/main/spi_master_example_main.c | 2 +- .../spi_slave/receiver/main/app_main.c | 2 +- .../spi_slave/sender/main/app_main.c | 2 +- .../main/timer_group_example_main.c | 2 +- .../main/tp_interrupt_main.c | 4 +- .../touch_pad_read/main/tp_read_main.c | 4 +- .../main/nmea_parser_example_main.c | 2 +- .../main/uart_async_rxtxtasks_main.c | 8 +- .../uart_echo/main/uart_echo_example_main.c | 4 +- .../uart/uart_echo_rs485/main/rs485_example.c | 4 +- .../main/uart_events_example_main.c | 2 +- .../main/uart_select_example_main.c | 4 +- .../asio/chat_client/main/chat_client.cpp | 2 +- .../asio/chat_server/main/chat_server.cpp | 2 +- .../asio/tcp_echo_server/main/echo_server.cpp | 2 +- .../udp_echo_server/main/udp_echo_server.cpp | 2 +- .../main/esp_http_client_example.c | 30 +++---- .../protocols/esp_local_ctrl/main/app_main.c | 4 +- .../main/http2_request_example_main.c | 2 +- .../main/http_request_example_main.c | 2 +- .../http_server/advanced_tests/main/main.c | 2 +- .../http_server/advanced_tests/main/tests.c | 4 +- .../http_server/file_serving/main/main.c | 2 +- .../persistent_sockets/main/main.c | 2 +- .../restful_server/main/esp_rest_main.c | 2 +- .../protocols/http_server/simple/main/main.c | 2 +- .../main/https_mbedtls_example_main.c | 2 +- .../main/https_request_example_main.c | 2 +- examples/protocols/https_server/main/main.c | 2 +- .../protocols/mdns/main/mdns_example_main.c | 6 +- .../modbus_master/main/include/sense_modbus.h | 2 +- .../protocols/modbus_master/main/sense_main.c | 4 +- .../modbus_master/main/sense_modbus.c | 4 +- .../protocols/modbus_slave/main/freemodbus.c | 4 +- .../mqtt/publish_test/main/publish_test.c | 2 +- examples/protocols/mqtt/ssl/main/app_main.c | 2 +- .../mqtt/ssl_mutual_auth/main/app_main.c | 2 +- examples/protocols/mqtt/tcp/main/app_main.c | 2 +- examples/protocols/mqtt/ws/main/app_main.c | 2 +- examples/protocols/mqtt/wss/main/app_main.c | 2 +- .../pppos_client/main/pppos_client_main.c | 2 +- .../protocols/sntp/main/sntp_example_main.c | 2 +- .../sockets/tcp_client/main/tcp_client.c | 2 +- .../sockets/tcp_server/main/tcp_server.c | 2 +- .../sockets/udp_client/main/udp_client.c | 2 +- .../main/udp_multicast_example_main.c | 6 +- .../sockets/udp_server/main/udp_server.c | 2 +- .../websocket/main/websocket_example.c | 2 +- .../provisioning/ble_prov/main/app_main.c | 8 +- .../provisioning/console_prov/main/app_main.c | 6 +- .../custom_config/main/app_main.c | 6 +- examples/provisioning/manager/main/app_main.c | 4 +- .../provisioning/softap_prov/main/app_main.c | 6 +- .../main/flash_encrypt_main.c | 2 +- .../main/ext_flash_fatfs_example_main.c | 4 +- .../nvs_rw_blob/main/nvs_blob_example_main.c | 2 +- .../main/nvs_value_example_main.c | 2 +- .../spiffsgen/main/spiffsgen_example_main.c | 4 +- .../main/app_trace_to_host_example_main.c | 2 +- .../main/base_mac_address_example_main.c | 2 +- .../console/components/cmd_nvs/cmd_nvs.c | 2 +- .../console/components/cmd_nvs/cmd_nvs.h | 2 +- .../components/cmd_system/cmd_system.c | 30 +++---- .../components/cmd_system/cmd_system.h | 2 +- examples/system/console/main/cmd_wifi.c | 2 +- examples/system/console/main/cmd_wifi.h | 2 +- .../console/main/console_example_main.c | 8 +- .../main/exception_example_main.cpp | 2 +- .../system/cpp_pthread/main/cpp_pthread.cpp | 2 +- .../deep_sleep/main/deep_sleep_example_main.c | 6 +- .../esp_timer/main/esp_timer_example_main.c | 2 +- .../freertos/real_time_stats/main/main.c | 2 +- examples/system/gcov/main/gcov_example.c | 2 +- examples/system/himem/main/himem_test_main.c | 2 +- .../main/light_sleep_example_main.c | 2 +- .../system/network_tests/main/net_suite.c | 2 +- .../main/advanced_https_ota_example.c | 2 +- .../main/native_ota_example.c | 4 +- .../system/ota/otatool/main/otatool_main.c | 2 +- .../main/simple_ota_example.c | 2 +- examples/system/select/main/select_example.c | 10 +-- .../sysview_tracing/main/sysview_tracing.c | 2 +- .../main/sysview_heap_log.c | 2 +- .../main/task_watchdog_example_main.c | 2 +- examples/system/ulp/main/ulp_example_main.c | 10 +-- .../ulp_adc/main/ulp_adc_example_main.c | 10 +-- .../test/main/example_unit_test_test.c | 2 +- .../wifi/espnow/main/espnow_example_main.c | 2 +- .../softAP/main/softap_example_main.c | 4 +- .../station/main/station_example_main.c | 4 +- examples/wifi/iperf/main/cmd_wifi.c | 2 +- examples/wifi/iperf/main/iperf_example_main.c | 2 +- examples/wifi/power_save/main/power_save.c | 2 +- examples/wifi/scan/main/scan.c | 2 +- .../wifi/simple_sniffer/main/cmd_sniffer.c | 4 +- .../wifi/simple_sniffer/main/cmd_sniffer.h | 2 +- .../main/simple_sniffer_example_main.c | 12 +-- .../wifi/smart_config/main/smartconfig_main.c | 2 +- .../main/wpa2_enterprise_main.c | 2 +- examples/wifi/wps/main/wps.c | 2 +- tools/esp_app_trace/test/sysview/blink.c | 2 +- tools/kconfig/nconf.gui.c | 2 +- .../test_utils/include/test_utils.h | 10 +-- .../components/test_utils/ref_clock.c | 6 +- .../components/test_utils/test_runner.c | 4 +- .../components/test_utils/test_utils.c | 4 +- tools/unit-test-app/main/app_main.c | 2 +- .../tool_setup/cmdlinerunner/cmdlinerunner.c | 4 +- 507 files changed, 1295 insertions(+), 1295 deletions(-) diff --git a/components/app_trace/app_trace.c b/components/app_trace/app_trace.c index 5a577a70d..c85ad6a2a 100644 --- a/components/app_trace/app_trace.c +++ b/components/app_trace/app_trace.c @@ -360,7 +360,7 @@ static esp_apptrace_hw_t s_trace_hw[ESP_APPTRACE_HW_MAX] = { } }; -static inline int esp_apptrace_log_lock() +static inline int esp_apptrace_log_lock(void) { #if ESP_APPTRACE_PRINT_LOCK esp_apptrace_tmo_t tmo; @@ -372,14 +372,14 @@ static inline int esp_apptrace_log_lock() #endif } -static inline void esp_apptrace_log_unlock() +static inline void esp_apptrace_log_unlock(void) { #if ESP_APPTRACE_PRINT_LOCK esp_apptrace_lock_give(&s_log_lock); #endif } -static inline esp_err_t esp_apptrace_lock_initialize() +static inline esp_err_t esp_apptrace_lock_initialize(void) { #if CONFIG_ESP32_APPTRACE_LOCK_ENABLE esp_apptrace_lock_init(&s_trace_buf.lock); @@ -387,7 +387,7 @@ static inline esp_err_t esp_apptrace_lock_initialize() return ESP_OK; } -static inline esp_err_t esp_apptrace_lock_cleanup() +static inline esp_err_t esp_apptrace_lock_cleanup(void) { return ESP_OK; } @@ -403,7 +403,7 @@ esp_err_t esp_apptrace_lock(esp_apptrace_tmo_t *tmo) return ESP_OK; } -esp_err_t esp_apptrace_unlock() +esp_err_t esp_apptrace_unlock(void) { esp_err_t ret = ESP_OK; #if CONFIG_ESP32_APPTRACE_LOCK_ENABLE @@ -413,7 +413,7 @@ esp_err_t esp_apptrace_unlock() } #if CONFIG_ESP32_APPTRACE_DEST_TRAX -static void esp_apptrace_trax_init() +static void esp_apptrace_trax_init(void) { // Stop trace, if any (on the current CPU) eri_write(ERI_TRAX_TRAXCTRL, TRAXCTRL_TRSTP); @@ -449,7 +449,7 @@ static void esp_apptrace_trax_pend_chunk_sz_update(uint16_t size) } } -static uint16_t esp_apptrace_trax_pend_chunk_sz_get() +static uint16_t esp_apptrace_trax_pend_chunk_sz_get(void) { uint16_t ch_sz; ESP_APPTRACE_LOGD("Get chunk enter %d w-r-s %d-%d-%d", s_trace_buf.trax.cur_pending_chunk_sz, @@ -467,7 +467,7 @@ static uint16_t esp_apptrace_trax_pend_chunk_sz_get() #endif // assumed to be protected by caller from multi-core/thread access -static esp_err_t esp_apptrace_trax_block_switch() +static esp_err_t esp_apptrace_trax_block_switch(void) { int prev_block_num = s_trace_buf.trax.state.in_block % 2; int new_block_num = prev_block_num ? (0) : (1); @@ -845,7 +845,7 @@ static esp_err_t esp_apptrace_trax_status_reg_get(uint32_t *val) return ESP_OK; } -static esp_err_t esp_apptrace_trax_dest_init() +static esp_err_t esp_apptrace_trax_dest_init(void) { for (int i = 0; i < ESP_APPTRACE_TRAX_BLOCKS_NUM; i++) { s_trace_buf.trax.blocks[i].start = (uint8_t *)s_trax_blocks[i]; @@ -874,7 +874,7 @@ static esp_err_t esp_apptrace_trax_dest_init() } #endif -esp_err_t esp_apptrace_init() +esp_err_t esp_apptrace_init(void) { int res; diff --git a/components/app_trace/gcov/gcov_rtio.c b/components/app_trace/gcov/gcov_rtio.c index 41306b288..d01d7c6b6 100644 --- a/components/app_trace/gcov/gcov_rtio.c +++ b/components/app_trace/gcov/gcov_rtio.c @@ -114,7 +114,7 @@ static int esp_dbg_stub_gcov_entry(void) #endif } -void esp_gcov_dump() +void esp_gcov_dump(void) { // disable IRQs on this CPU, other CPU is halted by OpenOCD unsigned irq_state = portENTER_CRITICAL_NESTED(); diff --git a/components/app_trace/heap_trace_tohost.c b/components/app_trace/heap_trace_tohost.c index 764022aba..41dd92a65 100644 --- a/components/app_trace/heap_trace_tohost.c +++ b/components/app_trace/heap_trace_tohost.c @@ -32,7 +32,7 @@ static bool s_tracing; -esp_err_t heap_trace_init_tohost() +esp_err_t heap_trace_init_tohost(void) { if (s_tracing) { return ESP_ERR_INVALID_STATE; diff --git a/components/app_trace/include/esp_app_trace.h b/components/app_trace/include/esp_app_trace.h index a623ada7f..822b698ee 100644 --- a/components/app_trace/include/esp_app_trace.h +++ b/components/app_trace/include/esp_app_trace.h @@ -33,7 +33,7 @@ typedef enum { * * @return ESP_OK on success, otherwise see esp_err_t */ -esp_err_t esp_apptrace_init(); +esp_err_t esp_apptrace_init(void); /** * @brief Configures down buffer. diff --git a/components/app_trace/sys_view/Config/SEGGER_RTT_Conf.h b/components/app_trace/sys_view/Config/SEGGER_RTT_Conf.h index 2325944e5..a46879780 100644 --- a/components/app_trace/sys_view/Config/SEGGER_RTT_Conf.h +++ b/components/app_trace/sys_view/Config/SEGGER_RTT_Conf.h @@ -285,12 +285,12 @@ Revision: $Rev: 5626 $ * RTT lock configuration fallback */ #ifndef SEGGER_RTT_LOCK - void SEGGER_SYSVIEW_X_RTT_Lock(); + void SEGGER_SYSVIEW_X_RTT_Lock(void); #define SEGGER_RTT_LOCK() SEGGER_SYSVIEW_X_RTT_Lock() // Lock RTT (nestable) (i.e. disable interrupts) #endif #ifndef SEGGER_RTT_UNLOCK - void SEGGER_SYSVIEW_X_RTT_Unlock(); + void SEGGER_SYSVIEW_X_RTT_Unlock(void); #define SEGGER_RTT_UNLOCK() SEGGER_SYSVIEW_X_RTT_Unlock() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state) #endif diff --git a/components/app_trace/sys_view/Config/SEGGER_SYSVIEW_Conf.h b/components/app_trace/sys_view/Config/SEGGER_SYSVIEW_Conf.h index 2968c6e02..aee813a3b 100644 --- a/components/app_trace/sys_view/Config/SEGGER_SYSVIEW_Conf.h +++ b/components/app_trace/sys_view/Config/SEGGER_SYSVIEW_Conf.h @@ -166,7 +166,7 @@ Revision: $Rev: 5927 $ #define SEGGER_SYSVIEW_GET_INTERRUPT_ID() SEGGER_SYSVIEW_X_GetInterruptId() // Get the currently active interrupt Id from the user-provided function. #endif -unsigned SEGGER_SYSVIEW_X_SysView_Lock(); +unsigned SEGGER_SYSVIEW_X_SysView_Lock(void); void SEGGER_SYSVIEW_X_SysView_Unlock(unsigned int_state); // to be recursive save IRQ status on the stack of the caller #define SEGGER_SYSVIEW_LOCK() unsigned _SYSVIEW_int_state = SEGGER_SYSVIEW_X_SysView_Lock() diff --git a/components/app_trace/sys_view/Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c b/components/app_trace/sys_view/Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c index 90db930d5..b1e9fc14e 100644 --- a/components/app_trace/sys_view/Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c +++ b/components/app_trace/sys_view/Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c @@ -244,7 +244,7 @@ static void _cbSendSystemDesc(void) { * ********************************************************************** */ -static void SEGGER_SYSVIEW_TS_Init() +static void SEGGER_SYSVIEW_TS_Init(void) { /* We only need to initialize something if we use Timer Group. * esp_timer and ccount can be used as is. @@ -316,7 +316,7 @@ void SEGGER_SYSVIEW_Conf(void) { SEGGER_SYSVIEW_DisableEvents(disable_evts); } -U32 SEGGER_SYSVIEW_X_GetTimestamp() +U32 SEGGER_SYSVIEW_X_GetTimestamp(void) { #if TS_USE_TIMERGROUP uint64_t ts = 0; @@ -329,15 +329,15 @@ U32 SEGGER_SYSVIEW_X_GetTimestamp() #endif } -void SEGGER_SYSVIEW_X_RTT_Lock() +void SEGGER_SYSVIEW_X_RTT_Lock(void) { } -void SEGGER_SYSVIEW_X_RTT_Unlock() +void SEGGER_SYSVIEW_X_RTT_Unlock(void) { } -unsigned SEGGER_SYSVIEW_X_SysView_Lock() +unsigned SEGGER_SYSVIEW_X_SysView_Lock(void) { esp_apptrace_tmo_t tmo; esp_apptrace_tmo_init(&tmo, SEGGER_LOCK_WAIT_TMO); diff --git a/components/app_trace/test/test_trace.c b/components/app_trace/test/test_trace.c index 6d95a87c5..3037ab431 100644 --- a/components/app_trace/test/test_trace.c +++ b/components/app_trace/test/test_trace.c @@ -125,7 +125,7 @@ typedef struct { static SemaphoreHandle_t s_print_lock; #endif -static uint64_t esp_apptrace_test_ts_get(); +static uint64_t esp_apptrace_test_ts_get(void); static void esp_apptrace_test_timer_isr(void *arg) { @@ -383,7 +383,7 @@ static void esp_apptrace_test_task_crash(void *p) static int s_ts_timer_group, s_ts_timer_idx; -static uint64_t esp_apptrace_test_ts_get() +static uint64_t esp_apptrace_test_ts_get(void) { uint64_t ts = 0; timer_get_counter_value(s_ts_timer_group, s_ts_timer_idx, &ts); @@ -413,7 +413,7 @@ static void esp_apptrace_test_ts_init(int timer_group, int timer_idx) timer_start(timer_group, timer_idx); } -static void esp_apptrace_test_ts_cleanup() +static void esp_apptrace_test_ts_cleanup(void) { timer_config_t config; diff --git a/components/app_update/esp_ota_ops.c b/components/app_update/esp_ota_ops.c index df6d8a906..7ef5c68c5 100644 --- a/components/app_update/esp_ota_ops.c +++ b/components/app_update/esp_ota_ops.c @@ -687,12 +687,12 @@ static esp_err_t esp_ota_current_ota_is_workable(bool valid) return ESP_OK; } -esp_err_t esp_ota_mark_app_valid_cancel_rollback() +esp_err_t esp_ota_mark_app_valid_cancel_rollback(void) { return esp_ota_current_ota_is_workable(true); } -esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot() +esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot(void) { return esp_ota_current_ota_is_workable(false); } @@ -715,7 +715,7 @@ static int get_last_invalid_otadata(const esp_ota_select_entry_t *two_otadata) return num_invalid_otadata; } -const esp_partition_t* esp_ota_get_last_invalid_partition() +const esp_partition_t* esp_ota_get_last_invalid_partition(void) { esp_ota_select_entry_t otadata[2]; if (read_otadata(otadata) == NULL) { diff --git a/components/app_update/include/esp_ota_ops.h b/components/app_update/include/esp_ota_ops.h index 73ca8a302..4dc2b80fe 100644 --- a/components/app_update/include/esp_ota_ops.h +++ b/components/app_update/include/esp_ota_ops.h @@ -221,7 +221,7 @@ esp_err_t esp_ota_get_partition_description(const esp_partition_t *partition, es * @return * - ESP_OK: if successful. */ -esp_err_t esp_ota_mark_app_valid_cancel_rollback(); +esp_err_t esp_ota_mark_app_valid_cancel_rollback(void); /** * @brief This function is called to roll back to the previously workable app with reboot. @@ -233,14 +233,14 @@ esp_err_t esp_ota_mark_app_valid_cancel_rollback(); * - ESP_FAIL: if not successful. * - ESP_ERR_OTA_ROLLBACK_FAILED: The rollback is not possible due to flash does not have any apps. */ -esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot(); +esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot(void); /** * @brief Returns last partition with invalid state (ESP_OTA_IMG_INVALID or ESP_OTA_IMG_ABORTED). * * @return partition. */ -const esp_partition_t* esp_ota_get_last_invalid_partition(); +const esp_partition_t* esp_ota_get_last_invalid_partition(void); /** * @brief Returns state for given partition. diff --git a/components/app_update/test/test_switch_ota.c b/components/app_update/test/test_switch_ota.c index bfa7b25be..232bfbc88 100644 --- a/components/app_update/test/test_switch_ota.c +++ b/components/app_update/test/test_switch_ota.c @@ -118,7 +118,7 @@ static void reboot_as_deep_sleep(void) /* @brief Copies a current app to next partition (OTA0-15), after that ESP is rebooting and run this (the next) OTAx. */ -static void copy_current_app_to_next_part_and_reboot() +static void copy_current_app_to_next_part_and_reboot(void) { const esp_partition_t *cur_app = esp_ota_get_running_partition(); copy_current_app_to_next_part(cur_app, get_next_update_partition()); diff --git a/components/bootloader/subproject/main/bootloader_start.c b/components/bootloader/subproject/main/bootloader_start.c index 7a7e76aa6..e9bd32d88 100644 --- a/components/bootloader/subproject/main/bootloader_start.c +++ b/components/bootloader/subproject/main/bootloader_start.c @@ -34,7 +34,7 @@ static int selected_boot_partition(const bootloader_state_t *bs); * The hardware is mostly uninitialized, flash cache is down and the app CPU is in reset. * We do have a stack, so we can do the initialization in C. */ -void __attribute__((noreturn)) call_start_cpu0() +void __attribute__((noreturn)) call_start_cpu0(void) { // 1. Hardware initialization if (bootloader_init() != ESP_OK) { @@ -113,7 +113,7 @@ static int selected_boot_partition(const bootloader_state_t *bs) } // Return global reent struct if any newlib functions are linked to bootloader -struct _reent* __getreent() { +struct _reent* __getreent(void) { return _GLOBAL_REENT; } diff --git a/components/bootloader_support/include/bootloader_common.h b/components/bootloader_support/include/bootloader_common.h index 2475d842a..4b887f55f 100644 --- a/components/bootloader_support/include/bootloader_common.h +++ b/components/bootloader_support/include/bootloader_common.h @@ -144,7 +144,7 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t /** * @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode. */ -void bootloader_common_vddsdio_configure(); +void bootloader_common_vddsdio_configure(void); #ifdef __cplusplus } diff --git a/components/bootloader_support/include/bootloader_flash_config.h b/components/bootloader_support/include/bootloader_flash_config.h index 2f716cce2..98c169f48 100644 --- a/components/bootloader_support/include/bootloader_flash_config.h +++ b/components/bootloader_support/include/bootloader_flash_config.h @@ -25,7 +25,7 @@ extern "C" { * * @return None */ -void bootloader_flash_update_id(); +void bootloader_flash_update_id(void); /** * @brief Set the flash CS setup and hold time. @@ -35,7 +35,7 @@ void bootloader_flash_update_id(); * * @return None */ -void bootloader_flash_cs_timing_config(); +void bootloader_flash_cs_timing_config(void); /** * @brief Configure SPI flash clock. diff --git a/components/bootloader_support/include/esp_flash_encrypt.h b/components/bootloader_support/include/esp_flash_encrypt.h index c0de5ca17..028842d97 100644 --- a/components/bootloader_support/include/esp_flash_encrypt.h +++ b/components/bootloader_support/include/esp_flash_encrypt.h @@ -122,7 +122,7 @@ esp_err_t esp_flash_encrypt_region(uint32_t src_addr, size_t data_length); * serial re-flashing of an unauthorised code in absence of secure boot. * */ -void esp_flash_write_protect_crypt_cnt(); +void esp_flash_write_protect_crypt_cnt(void); /** @brief Return the flash encryption mode * @@ -131,7 +131,7 @@ void esp_flash_write_protect_crypt_cnt(); * * @return */ -esp_flash_enc_mode_t esp_get_flash_encryption_mode(); +esp_flash_enc_mode_t esp_get_flash_encryption_mode(void); #ifdef __cplusplus } diff --git a/components/bootloader_support/include_bootloader/bootloader_flash.h b/components/bootloader_support/include_bootloader/bootloader_flash.h index 6ac724646..18baad594 100644 --- a/components/bootloader_support/include_bootloader/bootloader_flash.h +++ b/components/bootloader_support/include_bootloader/bootloader_flash.h @@ -35,7 +35,7 @@ * * @return Number of free pages */ -uint32_t bootloader_mmap_get_free_pages(); +uint32_t bootloader_mmap_get_free_pages(void); /** * @brief Map a region of flash to data memory diff --git a/components/bootloader_support/include_bootloader/bootloader_init.h b/components/bootloader_support/include_bootloader/bootloader_init.h index 443a207cf..9c1f8719a 100644 --- a/components/bootloader_support/include_bootloader/bootloader_init.h +++ b/components/bootloader_support/include_bootloader/bootloader_init.h @@ -25,4 +25,4 @@ * @return ESP_OK - If the setting is successful. * ESP_FAIL - If the setting is not successful. */ -esp_err_t bootloader_init(); +esp_err_t bootloader_init(void); diff --git a/components/bootloader_support/include_bootloader/bootloader_sha.h b/components/bootloader_support/include_bootloader/bootloader_sha.h index 3bfefb9f5..99db64b99 100644 --- a/components/bootloader_support/include_bootloader/bootloader_sha.h +++ b/components/bootloader_support/include_bootloader/bootloader_sha.h @@ -26,7 +26,7 @@ typedef void *bootloader_sha256_handle_t; -bootloader_sha256_handle_t bootloader_sha256_start(); +bootloader_sha256_handle_t bootloader_sha256_start(void); void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len); diff --git a/components/bootloader_support/include_bootloader/flash_qio_mode.h b/components/bootloader_support/include_bootloader/flash_qio_mode.h index 98e2fd22a..7f70d5bb0 100644 --- a/components/bootloader_support/include_bootloader/flash_qio_mode.h +++ b/components/bootloader_support/include_bootloader/flash_qio_mode.h @@ -30,7 +30,7 @@ void bootloader_enable_qio_mode(void); * mfg_id = (ID >> 16) & 0xFF; flash_id = ID & 0xffff; */ -uint32_t bootloader_read_flash_id(); +uint32_t bootloader_read_flash_id(void); #ifdef __cplusplus } diff --git a/components/bootloader_support/src/bootloader_clock.c b/components/bootloader_support/src/bootloader_clock.c index fda86b207..3befda16d 100644 --- a/components/bootloader_support/src/bootloader_clock.c +++ b/components/bootloader_support/src/bootloader_clock.c @@ -18,7 +18,7 @@ #include "soc/dport_reg.h" #include "soc/efuse_periph.h" -void bootloader_clock_configure() +void bootloader_clock_configure(void) { // ROM bootloader may have put a lot of text into UART0 FIFO. // Wait for it to be printed. diff --git a/components/bootloader_support/src/bootloader_common.c b/components/bootloader_support/src/bootloader_common.c index ed0169a96..a10fb2f2a 100644 --- a/components/bootloader_support/src/bootloader_common.c +++ b/components/bootloader_support/src/bootloader_common.c @@ -256,7 +256,7 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t return ESP_OK; } -void bootloader_common_vddsdio_configure() +void bootloader_common_vddsdio_configure(void) { #if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config(); diff --git a/components/bootloader_support/src/bootloader_flash.c b/components/bootloader_support/src/bootloader_flash.c index 6b25addf2..09ed73deb 100644 --- a/components/bootloader_support/src/bootloader_flash.c +++ b/components/bootloader_support/src/bootloader_flash.c @@ -25,7 +25,7 @@ static const char *TAG = "bootloader_mmap"; static spi_flash_mmap_handle_t map; -uint32_t bootloader_mmap_get_free_pages() +uint32_t bootloader_mmap_get_free_pages(void) { return spi_flash_mmap_get_free_pages(SPI_FLASH_MMAP_DATA); } @@ -103,7 +103,7 @@ static bool mapped; // Current bootloader mapping (ab)used for bootloader_read() static uint32_t current_read_mapping = UINT32_MAX; -uint32_t bootloader_mmap_get_free_pages() +uint32_t bootloader_mmap_get_free_pages(void) { /** * Allow mapping up to 50 of the 51 available MMU blocks (last one used for reads) diff --git a/components/bootloader_support/src/bootloader_flash_config.c b/components/bootloader_support/src/bootloader_flash_config.c index 53360848a..091727e33 100644 --- a/components/bootloader_support/src/bootloader_flash_config.c +++ b/components/bootloader_support/src/bootloader_flash_config.c @@ -27,12 +27,12 @@ #include "flash_qio_mode.h" #include "bootloader_flash_config.h" -void bootloader_flash_update_id() +void bootloader_flash_update_id(void) { g_rom_flashchip.device_id = bootloader_read_flash_id(); } -void IRAM_ATTR bootloader_flash_cs_timing_config() +void IRAM_ATTR bootloader_flash_cs_timing_config(void) { SET_PERI_REG_MASK(SPI_USER_REG(0), SPI_CS_HOLD_M | SPI_CS_SETUP_M); SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S); diff --git a/components/bootloader_support/src/bootloader_init.c b/components/bootloader_support/src/bootloader_init.c index 67ec3626c..26b8fd0b3 100644 --- a/components/bootloader_support/src/bootloader_init.c +++ b/components/bootloader_support/src/bootloader_init.c @@ -61,7 +61,7 @@ extern int _data_end; static const char* TAG = "boot"; -static esp_err_t bootloader_main(); +static esp_err_t bootloader_main(void); static void print_flash_info(const esp_image_header_t* pfhdr); static void update_flash_config(const esp_image_header_t* pfhdr); static void bootloader_init_flash_configure(const esp_image_header_t* pfhdr); @@ -69,7 +69,7 @@ static void uart_console_configure(void); static void wdt_reset_check(void); -esp_err_t bootloader_init() +esp_err_t bootloader_init(void) { cpu_configure_region_protection(); cpu_init_memctl(); @@ -117,7 +117,7 @@ esp_err_t bootloader_init() return ESP_OK; } -static esp_err_t bootloader_main() +static esp_err_t bootloader_main(void) { bootloader_common_vddsdio_configure(); /* Read and keep flash ID, for further use. */ @@ -434,7 +434,7 @@ void __assert_func(const char *file, int line, const char *func, const char *exp while(1) {} } -void abort() +void abort(void) { #if !CONFIG_ESP32_PANIC_SILENT_REBOOT ets_printf("abort() was called at PC 0x%08x\r\n", (intptr_t)__builtin_return_address(0) - 3); diff --git a/components/bootloader_support/src/esp32/bootloader_sha.c b/components/bootloader_support/src/esp32/bootloader_sha.c index f42c8b663..6ebbab875 100644 --- a/components/bootloader_support/src/esp32/bootloader_sha.c +++ b/components/bootloader_support/src/esp32/bootloader_sha.c @@ -27,7 +27,7 @@ static const size_t BLOCK_WORDS = (64 / sizeof(uint32_t)); // Words in final SHA256 digest static const size_t DIGEST_WORDS = (32 / sizeof(uint32_t)); -bootloader_sha256_handle_t bootloader_sha256_start() +bootloader_sha256_handle_t bootloader_sha256_start(void) { // Enable SHA hardware ets_sha_enable(); diff --git a/components/bootloader_support/src/esp32/flash_encrypt.c b/components/bootloader_support/src/esp32/flash_encrypt.c index 7b816e292..41925de27 100644 --- a/components/bootloader_support/src/esp32/flash_encrypt.c +++ b/components/bootloader_support/src/esp32/flash_encrypt.c @@ -38,7 +38,7 @@ static const char *TAG = "flash_encrypt"; /* Static functions for stages of flash encryption */ static esp_err_t initialise_flash_encryption(void); static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_crypt_wr_dis); -static esp_err_t encrypt_bootloader(); +static esp_err_t encrypt_bootloader(void); static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partition_table, int *num_partitions); static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partition); @@ -223,7 +223,7 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry return ESP_OK; } -static esp_err_t encrypt_bootloader() +static esp_err_t encrypt_bootloader(void) { esp_err_t err; uint32_t image_length; diff --git a/components/bootloader_support/src/esp32/secure_boot.c b/components/bootloader_support/src/esp32/secure_boot.c index 65fda0956..023d28142 100644 --- a/components/bootloader_support/src/esp32/secure_boot.c +++ b/components/bootloader_support/src/esp32/secure_boot.c @@ -95,7 +95,7 @@ static bool secure_boot_generate(uint32_t image_len){ } /* Burn values written to the efuse write registers */ -static inline void burn_efuses() +static inline void burn_efuses(void) { esp_efuse_burn_new_values(); } diff --git a/components/bootloader_support/src/flash_encrypt.c b/components/bootloader_support/src/flash_encrypt.c index 606cb79fb..d64d2fd9d 100644 --- a/components/bootloader_support/src/flash_encrypt.c +++ b/components/bootloader_support/src/flash_encrypt.c @@ -17,7 +17,7 @@ #include "esp_efuse_table.h" #include "esp_flash_encrypt.h" -void esp_flash_write_protect_crypt_cnt() +void esp_flash_write_protect_crypt_cnt(void) { uint8_t flash_crypt_cnt_wr_dis = 0; esp_efuse_read_field_blob(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT, &flash_crypt_cnt_wr_dis, 1); @@ -26,7 +26,7 @@ void esp_flash_write_protect_crypt_cnt() } } -esp_flash_enc_mode_t esp_get_flash_encryption_mode() +esp_flash_enc_mode_t esp_get_flash_encryption_mode(void) { uint8_t efuse_flash_crypt_cnt_wr_protected = 0; uint8_t dis_dl_enc = 0, dis_dl_dec = 0, dis_dl_cache = 0; diff --git a/components/bootloader_support/src/flash_qio_mode.c b/components/bootloader_support/src/flash_qio_mode.c index db486c73e..06a8fcada 100644 --- a/components/bootloader_support/src/flash_qio_mode.c +++ b/components/bootloader_support/src/flash_qio_mode.c @@ -53,11 +53,11 @@ typedef struct __attribute__((packed)) { } qio_info_t; /* Read 8 bit status using RDSR command */ -static unsigned read_status_8b_rdsr(); +static unsigned read_status_8b_rdsr(void); /* Read 8 bit status (second byte) using RDSR2 command */ -static unsigned read_status_8b_rdsr2(); +static unsigned read_status_8b_rdsr2(void); /* read 16 bit status using RDSR & RDSR2 (low and high bytes) */ -static unsigned read_status_16b_rdsr_rdsr2(); +static unsigned read_status_16b_rdsr_rdsr2(void); /* Write 8 bit status using WRSR */ static void write_status_8b_wrsr(unsigned new_status); @@ -67,7 +67,7 @@ static void write_status_8b_wrsr2(unsigned new_status); static void write_status_16b_wrsr(unsigned new_status); /* Read 8 bit status of XM25QU64A */ -static unsigned read_status_8b_xmc25qu64a(); +static unsigned read_status_8b_xmc25qu64a(void); /* Write 8 bit status of XM25QU64A */ static void write_status_8b_xmc25qu64a(unsigned new_status); @@ -121,7 +121,7 @@ static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8 /* dummy_len_plus values defined in ROM for SPI flash configuration */ extern uint8_t g_rom_spiflash_dummy_len_plus[]; -uint32_t bootloader_read_flash_id() +uint32_t bootloader_read_flash_id(void) { uint32_t id = execute_flash_command(CMD_RDID, 0, 0, 24); id = ((id & 0xff) << 16) | ((id >> 16) & 0xff) | (id & 0xff00); @@ -223,17 +223,17 @@ static esp_err_t enable_qio_mode(read_status_fn_t read_status_fn, return ESP_OK; } -static unsigned read_status_8b_rdsr() +static unsigned read_status_8b_rdsr(void) { return execute_flash_command(CMD_RDSR, 0, 0, 8); } -static unsigned read_status_8b_rdsr2() +static unsigned read_status_8b_rdsr2(void) { return execute_flash_command(CMD_RDSR2, 0, 0, 8); } -static unsigned read_status_16b_rdsr_rdsr2() +static unsigned read_status_16b_rdsr_rdsr2(void) { return execute_flash_command(CMD_RDSR, 0, 0, 8) | (execute_flash_command(CMD_RDSR2, 0, 0, 8) << 8); } @@ -253,7 +253,7 @@ static void write_status_16b_wrsr(unsigned new_status) execute_flash_command(CMD_WRSR, new_status, 16, 0); } -static unsigned read_status_8b_xmc25qu64a() +static unsigned read_status_8b_xmc25qu64a(void) { execute_flash_command(CMD_OTPEN, 0, 0, 0); /* Enter OTP mode */ esp_rom_spiflash_wait_idle(&g_rom_flashchip); diff --git a/components/bootloader_support/src/idf/bootloader_sha.c b/components/bootloader_support/src/idf/bootloader_sha.c index 7dc4f7429..849c86b38 100644 --- a/components/bootloader_support/src/idf/bootloader_sha.c +++ b/components/bootloader_support/src/idf/bootloader_sha.c @@ -18,7 +18,7 @@ #include #include -bootloader_sha256_handle_t bootloader_sha256_start() +bootloader_sha256_handle_t bootloader_sha256_start(void) { mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)malloc(sizeof(mbedtls_sha256_context)); if (!ctx) { diff --git a/components/bt/host/bluedroid/api/esp_spp_api.c b/components/bt/host/bluedroid/api/esp_spp_api.c index 57c2e317a..d68511cf4 100644 --- a/components/bt/host/bluedroid/api/esp_spp_api.c +++ b/components/bt/host/bluedroid/api/esp_spp_api.c @@ -54,7 +54,7 @@ esp_err_t esp_spp_init(esp_spp_mode_t mode) return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } -esp_err_t esp_spp_deinit() +esp_err_t esp_spp_deinit(void) { btc_msg_t msg; btc_spp_args_t arg; @@ -164,7 +164,7 @@ esp_err_t esp_spp_write(uint32_t handle, int len, uint8_t *p_data) return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), btc_spp_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } -esp_err_t esp_spp_vfs_register() +esp_err_t esp_spp_vfs_register(void) { ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); diff --git a/components/bt/host/bluedroid/api/include/api/esp_spp_api.h b/components/bt/host/bluedroid/api/include/api/esp_spp_api.h index 31bcf1c68..1b96cbbe0 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_spp_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_spp_api.h @@ -205,7 +205,7 @@ esp_err_t esp_spp_init(esp_spp_mode_t mode); * - ESP_OK: success * - other: failed */ -esp_err_t esp_spp_deinit(); +esp_err_t esp_spp_deinit(void); /** diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c index d62974ea2..aa4b3250d 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c @@ -360,7 +360,7 @@ const tBTA_DM_ST_TBL bta_dm_search_st_tbl[] = { ** Returns void ** *******************************************************************************/ -void bta_dm_sm_disable( ) +void bta_dm_sm_disable(void) { bta_sys_deregister( BTA_ID_DM ); } @@ -412,7 +412,7 @@ BOOLEAN bta_dm_sm_execute(BT_HDR *p_msg) ** Returns void ** *******************************************************************************/ -void bta_dm_search_sm_disable( ) +void bta_dm_search_sm_disable(void) { bta_sys_deregister( BTA_ID_DM_SEARCH ); diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_pm.c b/components/bt/host/bluedroid/bta/dm/bta_dm_pm.c index 5b0978bf5..ff42a65a1 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_pm.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_pm.c @@ -46,7 +46,7 @@ static void bta_dm_pm_timer_cback(void *p_tle); static void bta_dm_pm_btm_cback(BD_ADDR bd_addr, tBTM_PM_STATUS status, UINT16 value, UINT8 hci_status); static BOOLEAN bta_dm_pm_park(BD_ADDR peer_addr); static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index); -static BOOLEAN bta_dm_pm_is_sco_active (); +static BOOLEAN bta_dm_pm_is_sco_active (void); static void bta_dm_pm_hid_check(BOOLEAN bScoActive); static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisable); static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer, @@ -1001,7 +1001,7 @@ void bta_dm_pm_timer(tBTA_DM_MSG *p_data) ** Returns BOOLEAN. TRUE if SCO active, else FALSE ** *******************************************************************************/ -static BOOLEAN bta_dm_pm_is_sco_active () +static BOOLEAN bta_dm_pm_is_sco_active (void) { int j; BOOLEAN bScoActive = FALSE; diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_co.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_co.c index a336c2314..0573b7bf7 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_co.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_co.c @@ -48,7 +48,7 @@ static void getFilename(char *buffer, BD_ADDR bda) , bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]); } -static void cacheClose() +static void cacheClose(void) { if (sCacheFD != 0) { fclose(sCacheFD); diff --git a/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_at.c b/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_at.c index 33ae29348..43a2af6ab 100644 --- a/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_at.c +++ b/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_at.c @@ -94,7 +94,7 @@ UINT32 service_index = 0; BOOLEAN service_availability = TRUE; /* helper functions for handling AT commands queueing */ -static void bta_hf_client_handle_ok(); +static void bta_hf_client_handle_ok(void); static void bta_hf_client_clear_queued_at(void) { @@ -268,7 +268,7 @@ static void bta_hf_client_start_at_hold_timer(void) ** No buffer parsing is being done here. *******************************************************************************/ -static void bta_hf_client_handle_ok() +static void bta_hf_client_handle_ok(void) { APPL_TRACE_DEBUG("%s", __FUNCTION__); @@ -342,7 +342,7 @@ static void bta_hf_client_handle_error(tBTA_HF_CLIENT_AT_RESULT_TYPE type, UINT1 bta_hf_client_send_queued_at(); } -static void bta_hf_client_handle_ring() +static void bta_hf_client_handle_ring(void) { APPL_TRACE_DEBUG("%s", __FUNCTION__); bta_hf_client_evt_val(BTA_HF_CLIENT_RING_INDICATION, 0); diff --git a/components/bt/host/bluedroid/bta/hf_client/include/bta_hf_client_int.h b/components/bt/host/bluedroid/bta/hf_client/include/bta_hf_client_int.h index 60dfc759c..fd52b3aef 100644 --- a/components/bt/host/bluedroid/bta/hf_client/include/bta_hf_client_int.h +++ b/components/bt/host/bluedroid/bta/hf_client/include/bta_hf_client_int.h @@ -212,7 +212,7 @@ extern void bta_hf_client_sm_execute(UINT16 event, extern void bta_hf_client_slc_seq(BOOLEAN error); extern void bta_hf_client_collision_cback (tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr); -extern void bta_hf_client_resume_open (); +extern void bta_hf_client_resume_open (void); /* SDP functions */ extern BOOLEAN bta_hf_client_add_record(char *p_service_name, diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h index 664536ddd..d2d89f078 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h @@ -1205,7 +1205,7 @@ extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id); ** Returns None ** *******************************************************************************/ -extern void BTA_GATTS_Init(); +extern void BTA_GATTS_Init(void); /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/bta/jv/bta_jv_act.c b/components/bt/host/bluedroid/bta/jv/bta_jv_act.c index ecef90b12..eca76c9a4 100644 --- a/components/bt/host/bluedroid/bta/jv/bta_jv_act.c +++ b/components/bt/host/bluedroid/bta/jv/bta_jv_act.c @@ -683,7 +683,7 @@ void bta_jv_disable (tBTA_JV_MSG *p_data) * list. * If no free PSMs exist, 0 will be returned. */ -static UINT16 bta_jv_get_free_psm() +static UINT16 bta_jv_get_free_psm(void) { const int cnt = sizeof(bta_jv_cb.free_psm_list) / sizeof(bta_jv_cb.free_psm_list[0]); for (int i = 0; i < cnt; i++) { diff --git a/components/bt/host/bluedroid/btc/core/btc_profile_queue.c b/components/bt/host/bluedroid/btc/core/btc_profile_queue.c index 6d01b0d19..3e5603db8 100644 --- a/components/bt/host/bluedroid/btc/core/btc_profile_queue.c +++ b/components/bt/host/bluedroid/btc/core/btc_profile_queue.c @@ -60,7 +60,7 @@ static void queue_int_add(connect_node_t *p_param) list_append(connect_queue, p_node); } -static void queue_int_advance() +static void queue_int_advance(void) { if (connect_queue && !list_is_empty(connect_queue)) { list_remove(connect_queue, list_front(connect_queue)); diff --git a/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c b/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c index aff552113..9cf21b91a 100644 --- a/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c +++ b/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c @@ -424,7 +424,7 @@ static void btc_a2dp_source_data_post(void) osi_thread_post(a2dp_source_local_param.btc_aa_src_task_hdl, btc_a2dp_source_handle_timer, NULL, 2, OSI_THREAD_MAX_TIMEOUT); } -static UINT64 time_now_us() +static UINT64 time_now_us(void) { #if _POSIX_TIMERS struct timespec ts_now; diff --git a/components/bt/host/bluedroid/btc/profile/std/smp/esp_app_sec.c b/components/bt/host/bluedroid/btc/profile/std/smp/esp_app_sec.c index e1ec079b4..c6bbadea7 100644 --- a/components/bt/host/bluedroid/btc/profile/std/smp/esp_app_sec.c +++ b/components/bt/host/bluedroid/btc/profile/std/smp/esp_app_sec.c @@ -79,7 +79,7 @@ void app_ble_sec_gen_ltk(UINT8 key_size) ** Returns NULL ** *******************************************************************************/ -void app_ble_sec_init() +void app_ble_sec_init(void) { // Reset Security Environment memset(&app_sec_env, 0, sizeof(app_sec_env)); diff --git a/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c b/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c index 93636ef71..912c57035 100644 --- a/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c +++ b/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c @@ -837,7 +837,7 @@ static ssize_t spp_vfs_read(int fd, void * dst, size_t size) return item_size; } -esp_err_t btc_spp_vfs_register() +esp_err_t btc_spp_vfs_register(void) { esp_vfs_t vfs = { .flags = ESP_VFS_FLAG_DEFAULT, diff --git a/components/bt/host/bluedroid/device/controller.c b/components/bt/host/bluedroid/device/controller.c index 96c773ebe..2c2ac129f 100644 --- a/components/bt/host/bluedroid/device/controller.c +++ b/components/bt/host/bluedroid/device/controller.c @@ -544,7 +544,7 @@ static const controller_t interface = { #endif /* (BTM_SCO_HCI_INCLUDED == TRUE) */ }; -const controller_t *controller_get_interface() +const controller_t *controller_get_interface(void) { static bool loaded = false; if (!loaded) { diff --git a/components/bt/host/bluedroid/device/include/device/controller.h b/components/bt/host/bluedroid/device/include/device/controller.h index 704b456d7..bb0986352 100644 --- a/components/bt/host/bluedroid/device/include/device/controller.h +++ b/components/bt/host/bluedroid/device/include/device/controller.h @@ -86,6 +86,6 @@ typedef struct controller_t { #endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */ } controller_t; -const controller_t *controller_get_interface(); +const controller_t *controller_get_interface(void); #endif /*_CONTROLLER_H_*/ diff --git a/components/bt/host/bluedroid/hci/hci_hal_h4.c b/components/bt/host/bluedroid/hci/hci_hal_h4.c index 031d2c028..85d3598dc 100644 --- a/components/bt/host/bluedroid/hci/hci_hal_h4.c +++ b/components/bt/host/bluedroid/hci/hci_hal_h4.c @@ -121,7 +121,7 @@ static bool hal_open(const hci_hal_callbacks_t *upper_callbacks, void *task_thre return true; } -static void hal_close() +static void hal_close(void) { hci_hal_env_deinit(); @@ -367,7 +367,7 @@ static const hci_hal_t interface = { transmit_data, }; -const hci_hal_t *hci_hal_h4_get_interface() +const hci_hal_t *hci_hal_h4_get_interface(void) { return &interface; } diff --git a/components/bt/host/bluedroid/hci/hci_layer.c b/components/bt/host/bluedroid/hci/hci_layer.c index 6c285339c..2068062bf 100644 --- a/components/bt/host/bluedroid/hci/hci_layer.c +++ b/components/bt/host/bluedroid/hci/hci_layer.c @@ -535,7 +535,7 @@ static waiting_command_t *get_waiting_command(command_opcode_t opcode) return NULL; } -static void init_layer_interface() +static void init_layer_interface(void) { if (!interface_created) { interface.transmit_command = transmit_command; @@ -555,7 +555,7 @@ static const packet_fragmenter_callbacks_t packet_fragmenter_callbacks = { fragmenter_transmit_finished }; -const hci_t *hci_layer_get_interface() +const hci_t *hci_layer_get_interface(void) { hal = hci_hal_h4_get_interface(); packet_fragmenter = packet_fragmenter_get_interface(); diff --git a/components/bt/host/bluedroid/hci/hci_packet_factory.c b/components/bt/host/bluedroid/hci/hci_packet_factory.c index 19641d104..0145a138b 100644 --- a/components/bt/host/bluedroid/hci/hci_packet_factory.c +++ b/components/bt/host/bluedroid/hci/hci_packet_factory.c @@ -273,7 +273,7 @@ static const hci_packet_factory_t interface = { make_write_default_erroneous_data_report, }; -const hci_packet_factory_t *hci_packet_factory_get_interface() +const hci_packet_factory_t *hci_packet_factory_get_interface(void) { return &interface; } diff --git a/components/bt/host/bluedroid/hci/hci_packet_parser.c b/components/bt/host/bluedroid/hci/hci_packet_parser.c index eb4dc72f0..a99ef8b0d 100644 --- a/components/bt/host/bluedroid/hci/hci_packet_parser.c +++ b/components/bt/host/bluedroid/hci/hci_packet_parser.c @@ -250,7 +250,7 @@ static const hci_packet_parser_t interface = { parse_ble_read_suggested_default_data_length_response }; -const hci_packet_parser_t *hci_packet_parser_get_interface() +const hci_packet_parser_t *hci_packet_parser_get_interface(void) { return &interface; } diff --git a/components/bt/host/bluedroid/hci/include/hci/hci_layer.h b/components/bt/host/bluedroid/hci/include/hci/hci_layer.h index 8fa5165e9..6bfacdff5 100644 --- a/components/bt/host/bluedroid/hci/include/hci/hci_layer.h +++ b/components/bt/host/bluedroid/hci/include/hci/hci_layer.h @@ -92,7 +92,7 @@ typedef struct hci_t { void (*transmit_downward)(uint16_t type, void *data); } hci_t; -const hci_t *hci_layer_get_interface(); +const hci_t *hci_layer_get_interface(void); int hci_start_up(void); void hci_shut_down(void); diff --git a/components/bt/host/bluedroid/hci/include/hci/hci_packet_factory.h b/components/bt/host/bluedroid/hci/include/hci/hci_packet_factory.h index fd8731fbc..37ced06be 100644 --- a/components/bt/host/bluedroid/hci/include/hci/hci_packet_factory.h +++ b/components/bt/host/bluedroid/hci/include/hci/hci_packet_factory.h @@ -48,6 +48,6 @@ typedef struct { BT_HDR *(*make_write_default_erroneous_data_report)(uint8_t enable); } hci_packet_factory_t; -const hci_packet_factory_t *hci_packet_factory_get_interface(); +const hci_packet_factory_t *hci_packet_factory_get_interface(void); #endif /*_HCI_PACKET_FACTORY_H_*/ diff --git a/components/bt/host/bluedroid/hci/include/hci/hci_packet_parser.h b/components/bt/host/bluedroid/hci/include/hci/hci_packet_parser.h index b0cc4b3b4..e20e52fb5 100644 --- a/components/bt/host/bluedroid/hci/include/hci/hci_packet_parser.h +++ b/components/bt/host/bluedroid/hci/include/hci/hci_packet_parser.h @@ -97,6 +97,6 @@ typedef struct { ); } hci_packet_parser_t; -const hci_packet_parser_t *hci_packet_parser_get_interface(); +const hci_packet_parser_t *hci_packet_parser_get_interface(void); #endif /*_HCI_PACKET_PARSER_H_*/ diff --git a/components/bt/host/bluedroid/hci/include/hci/packet_fragmenter.h b/components/bt/host/bluedroid/hci/include/hci/packet_fragmenter.h index 285555427..02a13fb95 100644 --- a/components/bt/host/bluedroid/hci/include/hci/packet_fragmenter.h +++ b/components/bt/host/bluedroid/hci/include/hci/packet_fragmenter.h @@ -57,6 +57,6 @@ typedef struct packet_fragmenter_t { void (*reassemble_and_dispatch)(BT_HDR *packet); } packet_fragmenter_t; -const packet_fragmenter_t *packet_fragmenter_get_interface(); +const packet_fragmenter_t *packet_fragmenter_get_interface(void); #endif /* _PACKET_FRAGMENTER_H_ */ diff --git a/components/bt/host/bluedroid/hci/packet_fragmenter.c b/components/bt/host/bluedroid/hci/packet_fragmenter.c index 87cb99c74..53c6b7721 100644 --- a/components/bt/host/bluedroid/hci/packet_fragmenter.c +++ b/components/bt/host/bluedroid/hci/packet_fragmenter.c @@ -55,14 +55,14 @@ static void init(const packet_fragmenter_callbacks_t *result_callbacks) partial_packets = hash_map_new(NUMBER_OF_BUCKETS, hash_function_naive, NULL, NULL, NULL); } -static void cleanup() +static void cleanup(void) { if (partial_packets) { hash_map_free(partial_packets); } } -static BT_HDR *fragment_get_current_packet() +static BT_HDR *fragment_get_current_packet(void) { return current_fragment_packet; } @@ -224,7 +224,7 @@ static const packet_fragmenter_t interface = { reassemble_and_dispatch }; -const packet_fragmenter_t *packet_fragmenter_get_interface() +const packet_fragmenter_t *packet_fragmenter_get_interface(void) { controller = controller_get_interface(); return &interface; diff --git a/components/bt/host/bluedroid/main/bte_main.c b/components/bt/host/bluedroid/main/bte_main.c index 61c30e282..c47bdc15f 100644 --- a/components/bt/host/bluedroid/main/bte_main.c +++ b/components/bt/host/bluedroid/main/bte_main.c @@ -195,7 +195,7 @@ void bte_main_enable_lpm(BOOLEAN enable) ** Returns None ** ******************************************************************************/ -void bte_main_lpm_allow_bt_device_sleep() +void bte_main_lpm_allow_bt_device_sleep(void) { /**/ //hci->send_low_power_command(LPM_WAKE_DEASSERT); @@ -210,7 +210,7 @@ void bte_main_lpm_allow_bt_device_sleep() ** Returns None ** ******************************************************************************/ -void bte_main_lpm_wake_bt_device() +void bte_main_lpm_wake_bt_device(void) { //hci->send_low_power_command(LPM_WAKE_ASSERT); } diff --git a/components/bt/host/bluedroid/stack/avdt/avdt_api.c b/components/bt/host/bluedroid/stack/avdt/avdt_api.c index 88d374130..c0adc07e6 100644 --- a/components/bt/host/bluedroid/stack/avdt/avdt_api.c +++ b/components/bt/host/bluedroid/stack/avdt/avdt_api.c @@ -171,7 +171,7 @@ void AVDT_Deregister(void) ** Returns void. ** *******************************************************************************/ -void AVDT_SINK_Activate() +void AVDT_SINK_Activate(void) { tAVDT_SCB *p_scb = &avdt_cb.scb[0]; int i; @@ -200,7 +200,7 @@ void AVDT_SINK_Activate() ** Returns void. ** *******************************************************************************/ -void AVDT_SINK_Deactivate() +void AVDT_SINK_Deactivate(void) { tAVDT_SCB *p_scb = &avdt_cb.scb[0]; int i; diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_adv_filter.c b/components/bt/host/bluedroid/stack/btm/btm_ble_adv_filter.c index 438485359..54cdc189f 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_adv_filter.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_adv_filter.c @@ -90,7 +90,7 @@ static UINT8 btm_ble_cs_update_pf_counter(tBTM_BLE_SCAN_COND_OP action, ** Returns status ** *******************************************************************************/ -tBTM_STATUS btm_ble_obtain_vsc_details() +tBTM_STATUS btm_ble_obtain_vsc_details(void) { tBTM_STATUS st = BTM_SUCCESS; diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c index 3721471f8..9fd3bd26f 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c @@ -60,7 +60,7 @@ static bool bdaddr_equality_fn(const void *x, const void *y) return bdaddr_equals((bt_bdaddr_t *)x, (bt_bdaddr_t *)y); } -static void background_connections_lazy_init() +static void background_connections_lazy_init(void) { if (!background_connections) { background_connections = hash_map_new(background_connection_buckets, @@ -91,7 +91,7 @@ static BOOLEAN background_connection_remove(bt_bdaddr_t *address) return FALSE; } -static void background_connections_clear() +static void background_connections_clear(void) { if (background_connections) { hash_map_clear(background_connections); @@ -110,7 +110,7 @@ static bool background_connections_pending_cb(hash_map_entry_t *hash_entry, void return true; } -static bool background_connections_pending() +static bool background_connections_pending(void) { bool pending_connections = false; if (background_connections) { diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c index caacad51c..c18d941a1 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -2017,7 +2017,7 @@ UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length) ** BTM_BLE_GENRAL_DISCOVERABLE ** *******************************************************************************/ -UINT16 BTM_BleReadDiscoverability() +UINT16 BTM_BleReadDiscoverability(void) { BTM_TRACE_API("%s\n", __FUNCTION__); @@ -2034,7 +2034,7 @@ UINT16 BTM_BleReadDiscoverability() ** Returns BTM_BLE_NON_CONNECTABLE or BTM_BLE_CONNECTABLE ** *******************************************************************************/ -UINT16 BTM_BleReadConnectability() +UINT16 BTM_BleReadConnectability(void) { BTM_TRACE_API ("%s\n", __FUNCTION__); diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_multi_adv.c b/components/bt/host/bluedroid/stack/btm/btm_ble_multi_adv.c index a3ad60443..b18d68e39 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_multi_adv.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_multi_adv.c @@ -769,7 +769,7 @@ void btm_ble_multi_adv_vse_cback(UINT8 len, UINT8 *p) ** Returns void ** *******************************************************************************/ -void btm_ble_multi_adv_init() +void btm_ble_multi_adv_init(void) { #if BTM_DYNAMIC_MEMORY == TRUE btm_multi_adv_cb_ptr = (tBTM_BLE_MULTI_ADV_CB *)osi_malloc(sizeof(tBTM_BLE_MULTI_ADV_CB)); diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h index 2ac01ea2e..a8900ec32 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h @@ -1626,7 +1626,7 @@ BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type); ** BTM_BLE_GENRAL_DISCOVERABLE ** *******************************************************************************/ -UINT16 BTM_BleReadDiscoverability(); +UINT16 BTM_BleReadDiscoverability(void); /******************************************************************************* ** @@ -1639,7 +1639,7 @@ UINT16 BTM_BleReadDiscoverability(); ** *******************************************************************************/ //extern -UINT16 BTM_BleReadConnectability (); +UINT16 BTM_BleReadConnectability (void); void BTM_Recovery_Pre_State(void); @@ -1755,7 +1755,7 @@ void BTM_BleEnableMixedPrivacyMode(BOOLEAN mixed_on); ** *******************************************************************************/ //extern -UINT8 BTM_BleMaxMultiAdvInstanceCount(); +UINT8 BTM_BleMaxMultiAdvInstanceCount(void); /******************************************************************************* ** diff --git a/components/coap/port/coap_io.c b/components/coap/port/coap_io.c index a8f35c180..00c0ad1d3 100644 --- a/components/coap/port/coap_io.c +++ b/components/coap/port/coap_io.c @@ -80,7 +80,7 @@ void coap_free_endpoint(coap_endpoint_t *ep); static int ep_initialized = 0; struct coap_endpoint_t * - coap_malloc_endpoint() { + coap_malloc_endpoint(void) { static struct coap_endpoint_t ep; if (ep_initialized) { diff --git a/components/console/commands.c b/components/console/commands.c index 52d1675a1..de5cf8edb 100644 --- a/components/console/commands.c +++ b/components/console/commands.c @@ -70,7 +70,7 @@ esp_err_t esp_console_init(const esp_console_config_t *config) return ESP_OK; } -esp_err_t esp_console_deinit() +esp_err_t esp_console_deinit(void) { if (!s_tmp_line_buf) { return ESP_ERR_INVALID_STATE; @@ -232,7 +232,7 @@ static int help_command(int argc, char **argv) } -esp_err_t esp_console_register_help_command() +esp_err_t esp_console_register_help_command(void) { esp_console_cmd_t command = { .command = "help", diff --git a/components/console/esp_console.h b/components/console/esp_console.h index 45a10b7a2..e4865d29f 100644 --- a/components/console/esp_console.h +++ b/components/console/esp_console.h @@ -52,7 +52,7 @@ esp_err_t esp_console_init(const esp_console_config_t* config); * - ESP_OK on success * - ESP_ERR_INVALID_STATE if not initialized yet */ -esp_err_t esp_console_deinit(); +esp_err_t esp_console_deinit(void); /** @@ -185,7 +185,7 @@ const char *esp_console_get_hint(const char *buf, int *color, int *bold); * - ESP_OK on success * - ESP_ERR_INVALID_STATE, if esp_console_init wasn't called */ -esp_err_t esp_console_register_help_command(); +esp_err_t esp_console_register_help_command(void); #ifdef __cplusplus } diff --git a/components/console/linenoise/linenoise.c b/components/console/linenoise/linenoise.c index f88a24620..f78e238af 100644 --- a/components/console/linenoise/linenoise.c +++ b/components/console/linenoise/linenoise.c @@ -205,7 +205,7 @@ void linenoiseSetDumbMode(int set) { /* Use the ESC [6n escape sequence to query the horizontal cursor position * and return it. On error -1 is returned, on success the position of the * cursor. */ -static int getCursorPosition() { +static int getCursorPosition(void) { char buf[32]; int cols, rows; unsigned int i = 0; @@ -228,7 +228,7 @@ static int getCursorPosition() { /* Try to get the number of columns in the current terminal, or assume 80 * if it fails. */ -static int getColumns() { +static int getColumns(void) { int start, cols; /* Get the initial position so we can restore it later. */ @@ -887,7 +887,7 @@ static int linenoiseEdit(char *buf, size_t buflen, const char *prompt) return l.len; } -int linenoiseProbe() { +int linenoiseProbe(void) { /* Switch to non-blocking mode */ int flags = fcntl(STDIN_FILENO, F_GETFL); flags |= O_NONBLOCK; @@ -1000,7 +1000,7 @@ void linenoiseFree(void *ptr) { /* ================================ History ================================= */ -void linenoiseHistoryFree() { +void linenoiseHistoryFree(void) { if (history) { for (int j = 0; j < history_len; j++) { free(history[j]); diff --git a/components/console/linenoise/linenoise.h b/components/console/linenoise/linenoise.h index a82701f83..04c6f8b0c 100644 --- a/components/console/linenoise/linenoise.h +++ b/components/console/linenoise/linenoise.h @@ -63,7 +63,7 @@ int linenoiseHistoryAdd(const char *line); int linenoiseHistorySetMaxLen(int len); int linenoiseHistorySave(const char *filename); int linenoiseHistoryLoad(const char *filename); -void linenoiseHistoryFree(); +void linenoiseHistoryFree(void); void linenoiseClearScreen(void); void linenoiseSetMultiLine(int ml); void linenoiseSetDumbMode(int set); diff --git a/components/cxx/cxx_guards.cpp b/components/cxx/cxx_guards.cpp index 48819a7ab..640cf1775 100644 --- a/components/cxx/cxx_guards.cpp +++ b/components/cxx/cxx_guards.cpp @@ -36,7 +36,7 @@ static size_t s_static_init_max_waiting_count = 0; //!< maximum ever va extern "C" int __cxa_guard_acquire(__guard* pg); extern "C" void __cxa_guard_release(__guard* pg); extern "C" void __cxa_guard_abort(__guard* pg); -extern "C" void __cxa_guard_dummy(); +extern "C" void __cxa_guard_dummy(void); /** * Layout of the guard object (defined by the ABI). @@ -215,6 +215,6 @@ extern "C" void __cxa_guard_abort(__guard* pg) * Dummy function used to force linking this file instead of the same one in libstdc++. * This works via -u __cxa_guard_dummy flag in component.mk */ -extern "C" void __cxa_guard_dummy() +extern "C" void __cxa_guard_dummy(void) { } diff --git a/components/driver/adc1_i2s_private.h b/components/driver/adc1_i2s_private.h index cc592ffe1..76da3da02 100644 --- a/components/driver/adc1_i2s_private.h +++ b/components/driver/adc1_i2s_private.h @@ -29,7 +29,7 @@ extern "C" { * This is an internal API for I2S module to call to enable I2S-ADC function. * Note that adc_power_off() can still power down ADC. */ -void adc_power_always_on(); +void adc_power_always_on(void); /** * @brief For I2S dma to claim the usage of ADC1. @@ -41,7 +41,7 @@ void adc_power_always_on(); * - ESP_OK success * - ESP_ERR_TIMEOUT reserved for future use. Currently the function will wait until success. */ -esp_err_t adc1_i2s_mode_acquire(); +esp_err_t adc1_i2s_mode_acquire(void); /** * @brief For ADC1 to claim the usage of ADC1. @@ -53,7 +53,7 @@ esp_err_t adc1_i2s_mode_acquire(); * - ESP_OK success * - ESP_ERR_TIMEOUT reserved for future use. Currently the function will wait until success. */ -esp_err_t adc1_adc_mode_acquire(); +esp_err_t adc1_adc_mode_acquire(void); /** * @brief to let other tasks use the ADC1 when I2S is not work. @@ -63,7 +63,7 @@ esp_err_t adc1_adc_mode_acquire(); * * @return always return ESP_OK. */ -esp_err_t adc1_lock_release(); +esp_err_t adc1_lock_release(void); #ifdef __cplusplus } diff --git a/components/driver/can.c b/components/driver/can.c index 0ddf89296..ec843e492 100644 --- a/components/driver/can.c +++ b/components/driver/can.c @@ -141,7 +141,7 @@ static portMUX_TYPE can_spinlock = portMUX_INITIALIZER_UNLOCKED; /* ------------------- Configuration Register Functions---------------------- */ -static inline esp_err_t can_enter_reset_mode() +static inline esp_err_t can_enter_reset_mode(void) { /* Enter reset mode (required to write to configuration registers). Reset mode also prevents all CAN activity on the current module and is automatically @@ -151,7 +151,7 @@ static inline esp_err_t can_enter_reset_mode() return ESP_OK; } -static inline esp_err_t can_exit_reset_mode() +static inline esp_err_t can_exit_reset_mode(void) { /* Exiting reset mode will return the CAN module to operating mode. Reset mode must also be exited in order to trigger BUS-OFF recovery sequence. */ @@ -160,7 +160,7 @@ static inline esp_err_t can_exit_reset_mode() return ESP_OK; } -static inline void can_config_pelican() +static inline void can_config_pelican(void) { //Use PeliCAN address layout. Exposes extra registers CAN.clock_divider_reg.can_mode = 1; @@ -286,23 +286,23 @@ static void can_set_tx_buffer_and_transmit(can_frame_t *frame) can_set_command(command); } -static inline uint32_t can_get_status() +static inline uint32_t can_get_status(void) { return CAN.status_reg.val; } -static inline uint32_t can_get_interrupt_reason() +static inline uint32_t can_get_interrupt_reason(void) { return CAN.interrupt_reg.val; } -static inline uint32_t can_get_arbitration_lost_capture() +static inline uint32_t can_get_arbitration_lost_capture(void) { return CAN.arbitration_lost_captue_reg.val; //Todo: ALC read only to re-arm arb lost interrupt. Add function to decode ALC } -static inline uint32_t can_get_error_code_capture() +static inline uint32_t can_get_error_code_capture(void) { return CAN.error_code_capture_reg.val; //Todo: ECC read only to re-arm bus error interrupt. Add function to decode ECC @@ -328,7 +328,7 @@ static inline void can_get_rx_buffer_and_clear(can_frame_t *frame) can_set_command(CMD_RELEASE_RX_BUFF); } -static inline uint32_t can_get_rx_message_counter() +static inline uint32_t can_get_rx_message_counter(void) { return CAN.rx_message_counter_reg.val; } @@ -725,7 +725,7 @@ esp_err_t can_driver_install(const can_general_config_t *g_config, const can_tim return ret; } -esp_err_t can_driver_uninstall() +esp_err_t can_driver_uninstall(void) { can_obj_t *p_can_obj_dummy; @@ -761,7 +761,7 @@ esp_err_t can_driver_uninstall() return ESP_OK; } -esp_err_t can_start() +esp_err_t can_start(void) { //Check state CAN_ENTER_CRITICAL(); @@ -791,7 +791,7 @@ esp_err_t can_start() return ESP_OK; } -esp_err_t can_stop() +esp_err_t can_stop(void) { //Check state CAN_ENTER_CRITICAL(); @@ -928,7 +928,7 @@ esp_err_t can_reconfigure_alerts(uint32_t alerts_enabled, uint32_t *current_aler return ESP_OK; } -esp_err_t can_initiate_recovery() +esp_err_t can_initiate_recovery(void) { CAN_ENTER_CRITICAL(); //Check state @@ -982,7 +982,7 @@ esp_err_t can_get_status_info(can_status_info_t *status_info) return ESP_OK; } -esp_err_t can_clear_transmit_queue() +esp_err_t can_clear_transmit_queue(void) { //Check State CAN_CHECK(p_can_obj != NULL, ESP_ERR_INVALID_STATE); @@ -997,7 +997,7 @@ esp_err_t can_clear_transmit_queue() return ESP_OK; } -esp_err_t can_clear_receive_queue() +esp_err_t can_clear_receive_queue(void) { //Check State CAN_CHECK(p_can_obj != NULL, ESP_ERR_INVALID_STATE); diff --git a/components/driver/gpio.c b/components/driver/gpio.c index f9ae07c37..96fc7a665 100644 --- a/components/driver/gpio.c +++ b/components/driver/gpio.c @@ -419,7 +419,7 @@ esp_err_t gpio_install_isr_service(int intr_alloc_flags) return ret; } -void gpio_uninstall_isr_service() +void gpio_uninstall_isr_service(void) { if (gpio_isr_func == NULL) { return; diff --git a/components/driver/i2c.c b/components/driver/i2c.c index aeadfaada..556dcdf1f 100644 --- a/components/driver/i2c.c +++ b/components/driver/i2c.c @@ -942,7 +942,7 @@ esp_err_t i2c_set_pin(i2c_port_t i2c_num, int sda_io_num, int scl_io_num, gpio_p return ESP_OK; } -i2c_cmd_handle_t i2c_cmd_link_create() +i2c_cmd_handle_t i2c_cmd_link_create(void) { #if !CONFIG_SPIRAM_USE_MALLOC i2c_cmd_desc_t* cmd_desc = (i2c_cmd_desc_t*) calloc(1, sizeof(i2c_cmd_desc_t)); diff --git a/components/driver/i2s.c b/components/driver/i2s.c index d0c9831b8..fe90c9c78 100644 --- a/components/driver/i2s.c +++ b/components/driver/i2s.c @@ -740,7 +740,7 @@ esp_err_t i2s_set_dac_mode(i2s_dac_mode_t dac_mode) return ESP_OK; } -static esp_err_t _i2s_adc_mode_recover() +static esp_err_t _i2s_adc_mode_recover(void) { I2S_CHECK(((_i2s_adc_unit != -1) && (_i2s_adc_channel != -1)), "i2s ADC recover error, not initialized...", ESP_ERR_INVALID_ARG); return adc_i2s_mode_init(_i2s_adc_unit, _i2s_adc_channel); diff --git a/components/driver/include/driver/adc.h b/components/driver/include/driver/adc.h index 91eb18fd2..df166b1c8 100644 --- a/components/driver/include/driver/adc.h +++ b/components/driver/include/driver/adc.h @@ -229,13 +229,13 @@ int adc1_get_voltage(adc1_channel_t channel) __attribute__((deprecated)); /** * @brief Enable ADC power */ -void adc_power_on(); +void adc_power_on(void); /** * @brief Power off SAR ADC * This function will force power down for ADC */ -void adc_power_off(); +void adc_power_off(void); /** * @brief Initialize ADC pad @@ -292,7 +292,7 @@ esp_err_t adc_i2s_mode_init(adc_unit_t adc_unit, adc_channel_t channel); * Note that adc1_config_channel_atten, adc1_config_width functions need * to be called to configure ADC1 channels, before ADC1 is used by the ULP. */ -void adc1_ulp_enable(); +void adc1_ulp_enable(void); /** * @brief Read Hall Sensor @@ -313,7 +313,7 @@ void adc1_ulp_enable(); * * @return The hall sensor reading. */ -int hall_sensor_read(); +int hall_sensor_read(void); /** * @brief Get the gpio number of a specific ADC2 channel. diff --git a/components/driver/include/driver/adc2_wifi_internal.h b/components/driver/include/driver/adc2_wifi_internal.h index ba5c32ead..833d97d96 100644 --- a/components/driver/include/driver/adc2_wifi_internal.h +++ b/components/driver/include/driver/adc2_wifi_internal.h @@ -31,7 +31,7 @@ extern "C" { * - ESP_OK success * - ESP_ERR_TIMEOUT reserved for future use. Currently the function will wait until success. */ -esp_err_t adc2_wifi_acquire(); +esp_err_t adc2_wifi_acquire(void); /** @@ -42,7 +42,7 @@ esp_err_t adc2_wifi_acquire(); * * @return always return ESP_OK. */ -esp_err_t adc2_wifi_release(); +esp_err_t adc2_wifi_release(void); #ifdef __cplusplus } diff --git a/components/driver/include/driver/can.h b/components/driver/include/driver/can.h index 8c1d4200f..074ead380 100644 --- a/components/driver/include/driver/can.h +++ b/components/driver/include/driver/can.h @@ -238,7 +238,7 @@ esp_err_t can_driver_install(const can_general_config_t *g_config, const can_tim * - ESP_OK: Successfully uninstalled CAN driver * - ESP_ERR_INVALID_STATE: Driver is not in stopped/bus-off state, or is not installed */ -esp_err_t can_driver_uninstall(); +esp_err_t can_driver_uninstall(void); /** * @brief Start the CAN driver @@ -253,7 +253,7 @@ esp_err_t can_driver_uninstall(); * - ESP_OK: CAN driver is now running * - ESP_ERR_INVALID_STATE: Driver is not in stopped state, or is not installed */ -esp_err_t can_start(); +esp_err_t can_start(void); /** * @brief Stop the CAN driver @@ -272,7 +272,7 @@ esp_err_t can_start(); * - ESP_OK: CAN driver is now Stopped * - ESP_ERR_INVALID_STATE: Driver is not in running state, or is not installed */ -esp_err_t can_stop(); +esp_err_t can_stop(void); /** * @brief Transmit a CAN message @@ -379,7 +379,7 @@ esp_err_t can_reconfigure_alerts(uint32_t alerts_enabled, uint32_t *current_aler * - ESP_OK: Bus recovery started * - ESP_ERR_INVALID_STATE: CAN driver is not in the bus-off state, or is not installed */ -esp_err_t can_initiate_recovery(); +esp_err_t can_initiate_recovery(void); /** * @brief Get current status information of the CAN driver @@ -405,7 +405,7 @@ esp_err_t can_get_status_info(can_status_info_t *status_info); * - ESP_OK: Transmit queue cleared * - ESP_ERR_INVALID_STATE: CAN driver is not installed or TX queue is disabled */ -esp_err_t can_clear_transmit_queue(); +esp_err_t can_clear_transmit_queue(void); /** * @brief Clear the receive queue @@ -419,7 +419,7 @@ esp_err_t can_clear_transmit_queue(); * - ESP_OK: Transmit queue cleared * - ESP_ERR_INVALID_STATE: CAN driver is not installed */ -esp_err_t can_clear_receive_queue(); +esp_err_t can_clear_receive_queue(void); #ifdef __cplusplus } diff --git a/components/driver/include/driver/dac.h b/components/driver/include/driver/dac.h index 1e60263c2..5ed96e201 100644 --- a/components/driver/include/driver/dac.h +++ b/components/driver/include/driver/dac.h @@ -99,12 +99,12 @@ esp_err_t dac_output_disable(dac_channel_t channel); /** * @brief Enable DAC output data from I2S */ -esp_err_t dac_i2s_enable(); +esp_err_t dac_i2s_enable(void); /** * @brief Disable DAC output data from I2S */ -esp_err_t dac_i2s_disable(); +esp_err_t dac_i2s_disable(void); #ifdef __cplusplus } #endif diff --git a/components/driver/include/driver/gpio.h b/components/driver/include/driver/gpio.h index 9933cba81..11425201d 100644 --- a/components/driver/include/driver/gpio.h +++ b/components/driver/include/driver/gpio.h @@ -475,7 +475,7 @@ esp_err_t gpio_install_isr_service(int intr_alloc_flags); /** * @brief Uninstall the driver's GPIO ISR service, freeing related resources. */ -void gpio_uninstall_isr_service(); +void gpio_uninstall_isr_service(void); /** * @brief Add ISR handler for the corresponding GPIO pin. diff --git a/components/driver/include/driver/i2c.h b/components/driver/include/driver/i2c.h index 0bd0e2aae..57204cc60 100644 --- a/components/driver/include/driver/i2c.h +++ b/components/driver/include/driver/i2c.h @@ -224,7 +224,7 @@ esp_err_t i2c_set_pin(i2c_port_t i2c_num, int sda_io_num, int scl_io_num, * * @return i2c command link handler */ -i2c_cmd_handle_t i2c_cmd_link_create(); +i2c_cmd_handle_t i2c_cmd_link_create(void); /** * @brief Free I2C command link diff --git a/components/driver/include/driver/ledc.h b/components/driver/include/driver/ledc.h index 6a82c19a2..17875783f 100644 --- a/components/driver/include/driver/ledc.h +++ b/components/driver/include/driver/ledc.h @@ -435,7 +435,7 @@ esp_err_t ledc_fade_func_install(int intr_alloc_flags); * @brief Uninstall LEDC fade function. * */ -void ledc_fade_func_uninstall(); +void ledc_fade_func_uninstall(void); /** * @brief Start LEDC fading. diff --git a/components/driver/include/driver/rtc_io.h b/components/driver/include/driver/rtc_io.h index c636f61cc..a2f37a3e7 100644 --- a/components/driver/include/driver/rtc_io.h +++ b/components/driver/include/driver/rtc_io.h @@ -219,7 +219,7 @@ esp_err_t rtc_gpio_isolate(gpio_num_t gpio_num); * Force hold signal is enabled before going into deep sleep for pins which * are used for EXT1 wakeup. */ -void rtc_gpio_force_hold_dis_all(); +void rtc_gpio_force_hold_dis_all(void); /** * @brief Set RTC GPIO pad drive capability diff --git a/components/driver/include/driver/sdio_slave.h b/components/driver/include/driver/sdio_slave.h index 93f08d94a..005e469cd 100644 --- a/components/driver/include/driver/sdio_slave.h +++ b/components/driver/include/driver/sdio_slave.h @@ -111,7 +111,7 @@ esp_err_t sdio_slave_initialize(sdio_slave_config_t *config); /** De-initialize the sdio slave driver to release the resources. */ -void sdio_slave_deinit(); +void sdio_slave_deinit(void); /** Start hardware for sending and receiving, as well as set the IOREADY1 to 1. * @@ -122,19 +122,19 @@ void sdio_slave_deinit(); * - ESP_ERR_INVALID_STATE if already started. * - ESP_OK otherwise. */ -esp_err_t sdio_slave_start(); +esp_err_t sdio_slave_start(void); /** Stop hardware from sending and receiving, also set IOREADY1 to 0. * * @note this will not clear the data already in the driver, and also not reset the PKT_LEN and TOKEN1 counting. Call ``sdio_slave_reset`` to do that. */ -void sdio_slave_stop(); +void sdio_slave_stop(void); /** Clear the data still in the driver, as well as reset the PKT_LEN and TOKEN1 counting. * * @return always return ESP_OK. */ -esp_err_t sdio_slave_reset(); +esp_err_t sdio_slave_reset(void); /*--------------------------------------------------------------------------- * Receive @@ -263,7 +263,7 @@ esp_err_t sdio_slave_write_reg(int pos, uint8_t reg); * * @return the interrupt mask. */ -sdio_slave_hostint_t sdio_slave_get_host_intena(); +sdio_slave_hostint_t sdio_slave_get_host_intena(void); /** Set the interrupt enable for host. * diff --git a/components/driver/include/driver/sdmmc_host.h b/components/driver/include/driver/sdmmc_host.h index 4e2db0994..8cd403d85 100644 --- a/components/driver/include/driver/sdmmc_host.h +++ b/components/driver/include/driver/sdmmc_host.h @@ -91,7 +91,7 @@ typedef struct { * - ESP_ERR_INVALID_STATE if sdmmc_host_init was already called * - ESP_ERR_NO_MEM if memory can not be allocated */ -esp_err_t sdmmc_host_init(); +esp_err_t sdmmc_host_init(void); /** * @brief Initialize given slot of SDMMC peripheral @@ -218,7 +218,7 @@ esp_err_t sdmmc_host_io_int_wait(int slot, TickType_t timeout_ticks); * - ESP_OK on success * - ESP_ERR_INVALID_STATE if sdmmc_host_init function has not been called */ -esp_err_t sdmmc_host_deinit(); +esp_err_t sdmmc_host_deinit(void); /** * @brief Enable the pull-ups of sd pins. diff --git a/components/driver/include/driver/sdspi_host.h b/components/driver/include/driver/sdspi_host.h index 605cd7624..8cb922803 100644 --- a/components/driver/include/driver/sdspi_host.h +++ b/components/driver/include/driver/sdspi_host.h @@ -91,7 +91,7 @@ typedef struct { * - ESP_OK on success * - other error codes may be returned in future versions */ -esp_err_t sdspi_host_init(); +esp_err_t sdspi_host_init(void); /** * @brief Initialize SD SPI driver for the specific SPI controller @@ -159,7 +159,7 @@ esp_err_t sdspi_host_set_card_clk(int slot, uint32_t freq_khz); * - ESP_OK on success * - ESP_ERR_INVALID_STATE if sdspi_host_init function has not been called */ -esp_err_t sdspi_host_deinit(); +esp_err_t sdspi_host_deinit(void); /** * @brief Enable SDIO interrupt. diff --git a/components/driver/include/driver/spi_common.h b/components/driver/include/driver/spi_common.h index b44159546..8f7c97f3d 100644 --- a/components/driver/include/driver/spi_common.h +++ b/components/driver/include/driver/spi_common.h @@ -381,7 +381,7 @@ bool spicommon_dmaworkaround_req_reset(int dmachan, dmaworkaround_cb_t cb, void * * @return True when a DMA reset is requested but hasn't completed yet. False otherwise. */ -bool spicommon_dmaworkaround_reset_in_progress(); +bool spicommon_dmaworkaround_reset_in_progress(void); /** diff --git a/components/driver/include/driver/touch_pad.h b/components/driver/include/driver/touch_pad.h index 0c3884ded..53d5b3738 100644 --- a/components/driver/include/driver/touch_pad.h +++ b/components/driver/include/driver/touch_pad.h @@ -117,7 +117,7 @@ typedef intr_handle_t touch_isr_handle_t; * - ESP_OK Success * - ESP_FAIL Touch pad init error */ -esp_err_t touch_pad_init(); +esp_err_t touch_pad_init(void); /** * @brief Un-install touch pad driver. @@ -126,7 +126,7 @@ esp_err_t touch_pad_init(); * - ESP_OK Success * - ESP_FAIL Touch pad driver not initialized */ -esp_err_t touch_pad_deinit(); +esp_err_t touch_pad_deinit(void); /** * @brief Configure touch pad interrupt threshold. @@ -364,7 +364,7 @@ esp_err_t touch_pad_get_fsm_mode(touch_fsm_mode_t *mode); * @return * - ESP_OK on success */ -esp_err_t touch_pad_sw_start(); +esp_err_t touch_pad_sw_start(void); /** * @brief Set touch sensor interrupt threshold @@ -468,28 +468,28 @@ esp_err_t touch_pad_clear_group_mask(uint16_t set1_mask, uint16_t set2_mask, uin * @return * - ESP_OK on success */ -esp_err_t touch_pad_clear_status(); +esp_err_t touch_pad_clear_status(void); /** * @brief Get the touch sensor status, usually used in ISR to decide which pads are 'touched'. * @return * - touch status */ -uint32_t touch_pad_get_status(); +uint32_t touch_pad_get_status(void); /** * @brief To enable touch pad interrupt * @return * - ESP_OK on success */ -esp_err_t touch_pad_intr_enable(); +esp_err_t touch_pad_intr_enable(void); /** * @brief To disable touch pad interrupt * @return * - ESP_OK on success */ -esp_err_t touch_pad_intr_disable(); +esp_err_t touch_pad_intr_disable(void); /** * @brief set touch pad filter calibration period, in ms. @@ -539,7 +539,7 @@ esp_err_t touch_pad_filter_start(uint32_t filter_period_ms); * - ESP_OK Success * - ESP_ERR_INVALID_STATE driver state error */ -esp_err_t touch_pad_filter_stop(); +esp_err_t touch_pad_filter_stop(void); /** * @brief delete touch pad filter driver and release the memory @@ -548,7 +548,7 @@ esp_err_t touch_pad_filter_stop(); * - ESP_OK Success * - ESP_ERR_INVALID_STATE driver state error */ -esp_err_t touch_pad_filter_delete(); +esp_err_t touch_pad_filter_delete(void); /** * @brief Get the touch pad which caused wakeup from sleep diff --git a/components/driver/include/driver/uart_select.h b/components/driver/include/driver/uart_select.h index 24f06c1de..f7a21a315 100644 --- a/components/driver/include/driver/uart_select.h +++ b/components/driver/include/driver/uart_select.h @@ -40,7 +40,7 @@ void uart_set_select_notif_callback(uart_port_t uart_num, uart_select_notif_call /** * @brief Get mutex guarding select() notifications */ -portMUX_TYPE *uart_get_selectlock(); +portMUX_TYPE *uart_get_selectlock(void); #ifdef __cplusplus } diff --git a/components/driver/ledc.c b/components/driver/ledc.c index 92a055cbc..ff992d147 100644 --- a/components/driver/ledc.c +++ b/components/driver/ledc.c @@ -712,7 +712,7 @@ esp_err_t ledc_fade_func_install(int intr_alloc_flags) return ledc_isr_register(ledc_fade_isr, NULL, intr_alloc_flags | ESP_INTR_FLAG_IRAM, &s_ledc_fade_isr_handle); } -void ledc_fade_func_uninstall() +void ledc_fade_func_uninstall(void) { if (s_ledc_fade_rec == NULL) { return; diff --git a/components/driver/rmt.c b/components/driver/rmt.c index 10605d2e2..38380da30 100644 --- a/components/driver/rmt.c +++ b/components/driver/rmt.c @@ -321,7 +321,7 @@ esp_err_t rmt_get_status(rmt_channel_t channel, uint32_t* status) return ESP_OK; } -rmt_data_mode_t rmt_get_data_mode() +rmt_data_mode_t rmt_get_data_mode(void) { return (rmt_data_mode_t) (RMT.apb_conf.fifo_mask); } diff --git a/components/driver/rtc_module.c b/components/driver/rtc_module.c index 1be5c645c..d5954c9e6 100644 --- a/components/driver/rtc_module.c +++ b/components/driver/rtc_module.c @@ -368,7 +368,7 @@ esp_err_t rtc_gpio_isolate(gpio_num_t gpio_num) return ESP_OK; } -void rtc_gpio_force_hold_dis_all() +void rtc_gpio_force_hold_dis_all(void) { for (int gpio = 0; gpio < GPIO_PIN_COUNT; ++gpio) { const rtc_gpio_desc_t* desc = &rtc_gpio_desc[gpio]; @@ -657,7 +657,7 @@ esp_err_t touch_pad_get_fsm_mode(touch_fsm_mode_t *mode) return ESP_OK; } -esp_err_t touch_pad_sw_start() +esp_err_t touch_pad_sw_start(void) { portENTER_CRITICAL(&rtc_spinlock); SENS.sar_touch_ctrl2.touch_start_en = 0; @@ -772,13 +772,13 @@ esp_err_t touch_pad_clear_group_mask(uint16_t set1_mask, uint16_t set2_mask, uin return ESP_OK; } -uint32_t IRAM_ATTR touch_pad_get_status() +uint32_t IRAM_ATTR touch_pad_get_status(void) { uint32_t status = SENS.sar_touch_ctrl2.touch_meas_en; return TOUCH_BITS_SWAP(status); } -esp_err_t IRAM_ATTR touch_pad_clear_status() +esp_err_t IRAM_ATTR touch_pad_clear_status(void) { portENTER_CRITICAL(&rtc_spinlock); SENS.sar_touch_ctrl2.touch_meas_en_clr = 1; @@ -786,7 +786,7 @@ esp_err_t IRAM_ATTR touch_pad_clear_status() return ESP_OK; } -esp_err_t touch_pad_intr_enable() +esp_err_t touch_pad_intr_enable(void) { portENTER_CRITICAL(&rtc_spinlock); RTCCNTL.int_ena.rtc_touch = 1; @@ -794,7 +794,7 @@ esp_err_t touch_pad_intr_enable() return ESP_OK; } -esp_err_t touch_pad_intr_disable() +esp_err_t touch_pad_intr_disable(void) { portENTER_CRITICAL(&rtc_spinlock); RTCCNTL.int_ena.rtc_touch = 0; @@ -834,7 +834,7 @@ esp_err_t touch_pad_config(touch_pad_t touch_num, uint16_t threshold) return ESP_OK; } -esp_err_t touch_pad_init() +esp_err_t touch_pad_init(void) { if (rtc_touch_mux == NULL) { rtc_touch_mux = xSemaphoreCreateMutex(); @@ -852,7 +852,7 @@ esp_err_t touch_pad_init() return ESP_OK; } -esp_err_t touch_pad_deinit() +esp_err_t touch_pad_deinit(void) { RTC_MODULE_CHECK(rtc_touch_mux != NULL, "Touch pad not initialized", ESP_FAIL); if (s_touch_pad_filter != NULL) { @@ -1006,7 +1006,7 @@ err_no_mem: return ESP_ERR_NO_MEM; } -esp_err_t touch_pad_filter_stop() +esp_err_t touch_pad_filter_stop(void) { RTC_MODULE_CHECK(s_touch_pad_filter != NULL, "Touch pad filter not initialized", ESP_ERR_INVALID_STATE); RTC_MODULE_CHECK(rtc_touch_mux != NULL, "Touch pad not initialized", ESP_ERR_INVALID_STATE); @@ -1022,7 +1022,7 @@ esp_err_t touch_pad_filter_stop() return ret; } -esp_err_t touch_pad_filter_delete() +esp_err_t touch_pad_filter_delete(void) { RTC_MODULE_CHECK(s_touch_pad_filter != NULL, "Touch pad filter not initialized", ESP_ERR_INVALID_STATE); RTC_MODULE_CHECK(rtc_touch_mux != NULL, "Touch pad not initialized", ESP_ERR_INVALID_STATE); @@ -1143,14 +1143,14 @@ static esp_err_t adc_set_atten(adc_unit_t adc_unit, adc_channel_t channel, adc_a return ESP_OK; } -void adc_power_always_on() +void adc_power_always_on(void) { portENTER_CRITICAL(&rtc_spinlock); SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_PU; portEXIT_CRITICAL(&rtc_spinlock); } -void adc_power_on() +void adc_power_on(void) { portENTER_CRITICAL(&rtc_spinlock); //The power FSM controlled mode saves more power, while the ADC noise may get increased. @@ -1168,7 +1168,7 @@ void adc_power_on() portEXIT_CRITICAL(&rtc_spinlock); } -void adc_power_off() +void adc_power_off(void) { portENTER_CRITICAL(&rtc_spinlock); //Bit1 0:Fsm 1: SW mode @@ -1474,7 +1474,7 @@ esp_err_t adc1_config_width(adc_bits_width_t width_bit) return ESP_OK; } -static inline void adc1_fsm_disable() +static inline void adc1_fsm_disable(void) { //channel is set in the convert function SENS.sar_meas_wait2.force_xpd_amp = SENS_FORCE_XPD_AMP_PD; @@ -1487,7 +1487,7 @@ static inline void adc1_fsm_disable() SENS.sar_meas_wait2.sar_amp_wait3 = 1; } -esp_err_t adc1_i2s_mode_acquire() +esp_err_t adc1_i2s_mode_acquire(void) { //lazy initialization //for i2s, block until acquire the lock @@ -1501,7 +1501,7 @@ esp_err_t adc1_i2s_mode_acquire() return ESP_OK; } -esp_err_t adc1_adc_mode_acquire() +esp_err_t adc1_adc_mode_acquire(void) { //lazy initialization //for adc1, block until acquire the lock @@ -1517,7 +1517,7 @@ esp_err_t adc1_adc_mode_acquire() return ESP_OK; } -esp_err_t adc1_lock_release() +esp_err_t adc1_lock_release(void) { RTC_MODULE_CHECK((uint32_t*)adc1_i2s_lock != NULL, "adc1 lock release called before acquire", ESP_ERR_INVALID_STATE ); // for now the WiFi would use ADC2 and set xpd_sar force on. @@ -1548,7 +1548,7 @@ int adc1_get_raw(adc1_channel_t channel) return adc_value; } -int adc1_get_voltage(adc1_channel_t channel) //Deprecated. Use adc1_get_raw() instead +int adc1_get_voltage(adc1_channel_t channel) //Deprecated. Use adc1_get_raw(void) instead { return adc1_get_raw(channel); } @@ -1611,7 +1611,7 @@ esp_err_t adc2_pad_get_io_num(adc2_channel_t channel, gpio_num_t *gpio_num) return ESP_OK; } -esp_err_t adc2_wifi_acquire() +esp_err_t adc2_wifi_acquire(void) { //lazy initialization //for wifi, block until acquire the lock @@ -1620,7 +1620,7 @@ esp_err_t adc2_wifi_acquire() return ESP_OK; } -esp_err_t adc2_wifi_release() +esp_err_t adc2_wifi_release(void) { RTC_MODULE_CHECK((uint32_t*)adc2_wifi_lock != NULL, "wifi release called before acquire", ESP_ERR_INVALID_STATE ); @@ -1878,7 +1878,7 @@ esp_err_t dac_out_voltage(dac_channel_t channel, uint8_t dac_value) return ESP_OK; } -esp_err_t dac_i2s_enable() +esp_err_t dac_i2s_enable(void) { portENTER_CRITICAL(&rtc_spinlock); SET_PERI_REG_MASK(SENS_SAR_DAC_CTRL1_REG, SENS_DAC_DIG_FORCE_M | SENS_DAC_CLK_INV_M); @@ -1886,7 +1886,7 @@ esp_err_t dac_i2s_enable() return ESP_OK; } -esp_err_t dac_i2s_disable() +esp_err_t dac_i2s_disable(void) { portENTER_CRITICAL(&rtc_spinlock); CLEAR_PERI_REG_MASK(SENS_SAR_DAC_CTRL1_REG, SENS_DAC_DIG_FORCE_M | SENS_DAC_CLK_INV_M); @@ -1903,7 +1903,7 @@ static inline void adc1_hall_enable(bool enable) RTCIO.hall_sens.xpd_hall = enable; } -static int hall_sensor_get_value() //hall sensor without LNA +static int hall_sensor_get_value(void) //hall sensor without LNA { int Sens_Vp0; int Sens_Vn0; @@ -1932,7 +1932,7 @@ static int hall_sensor_get_value() //hall sensor without LNA return hall_value; } -int hall_sensor_read() +int hall_sensor_read(void) { adc_gpio_init(ADC_UNIT_1, ADC1_CHANNEL_0); adc_gpio_init(ADC_UNIT_1, ADC1_CHANNEL_3); @@ -1974,7 +1974,7 @@ static void rtc_isr(void* arg) REG_WRITE(RTC_CNTL_INT_CLR_REG, status); } -static esp_err_t rtc_isr_ensure_installed() +static esp_err_t rtc_isr_ensure_installed(void) { esp_err_t err = ESP_OK; portENTER_CRITICAL(&s_rtc_isr_handler_list_lock); diff --git a/components/driver/sdio_slave.c b/components/driver/sdio_slave.c index 12d106ae5..0d639d802 100644 --- a/components/driver/sdio_slave.c +++ b/components/driver/sdio_slave.c @@ -215,17 +215,17 @@ static void sdio_intr_host(void*); static void sdio_intr_send(void*); static void sdio_intr_recv(void*); -static esp_err_t send_flush_data(); -static esp_err_t send_reset_counter(); -static void recv_flush_data(); -static void recv_reset_counter(); +static esp_err_t send_flush_data(void); +static esp_err_t send_reset_counter(void); +static void recv_flush_data(void); +static void recv_reset_counter(void); -static esp_err_t send_start(); -static void send_stop(); -static esp_err_t recv_start(); -static void recv_stop(); +static esp_err_t send_start(void); +static void send_stop(void); +static esp_err_t recv_start(void); +static void recv_stop(void); -static void deinit_context(); +static void deinit_context(void); /**************** Ring buffer for SDIO use *****************/ @@ -395,7 +395,7 @@ static void __attribute((unused)) dump_ll(lldesc_t *queue) ESP_EARLY_LOGI(TAG, "total: %d", cnt); } -static inline void deinit_context() +static inline void deinit_context(void) { context.config = (sdio_slave_config_t){}; for(int i = 0; i < 9; i++) { @@ -417,7 +417,7 @@ esp_err_t link_desc_to_last(uint8_t* desc, void* arg) return ESP_OK; } -static esp_err_t init_ringbuf() +static esp_err_t init_ringbuf(void) { esp_err_t ret = sdio_ringbuf_init(&context.sendbuf, sizeof(buf_desc_t), context.config.send_queue_size); if (ret != ESP_OK) return ret; @@ -591,7 +591,7 @@ esp_err_t sdio_slave_initialize(sdio_slave_config_t *config) return ESP_OK; } -void sdio_slave_deinit() +void sdio_slave_deinit(void) { esp_err_t ret = esp_intr_free(context.intr_handle); assert(ret==ESP_OK); @@ -599,7 +599,7 @@ void sdio_slave_deinit() deinit_context(); } -esp_err_t sdio_slave_start() +esp_err_t sdio_slave_start(void) { esp_err_t ret; HOST.slc0_int_clr.val = UINT32_MAX;//clear all interrupts @@ -611,7 +611,7 @@ esp_err_t sdio_slave_start() return ESP_OK; } -esp_err_t sdio_slave_reset() +esp_err_t sdio_slave_reset(void) { send_flush_data(); send_reset_counter(); @@ -620,7 +620,7 @@ esp_err_t sdio_slave_reset() return ESP_OK; } -void sdio_slave_stop() +void sdio_slave_stop(void) { HINF.cfg_data1.sdio_ioready1 = 0; //set IO ready to 1 to stop host from using send_stop(); @@ -696,7 +696,7 @@ esp_err_t sdio_slave_write_reg(int pos, uint8_t reg) return ESP_OK; } -sdio_slave_hostint_t sdio_slave_get_host_intena() +sdio_slave_hostint_t sdio_slave_get_host_intena(void) { return HOST.slc0_func1_int_ena.val; } @@ -742,12 +742,12 @@ static inline void send_start_transmission(const void* desc) SLC.slc0_rx_link.start = 1; } -static inline void send_stop_ll_operation() +static inline void send_stop_ll_operation(void) { SLC.slc0_rx_link.stop = 1; } -static inline uint32_t send_length_read() +static inline uint32_t send_length_read(void) { return HOST.pkt_len.reg_slc0_len; } @@ -760,7 +760,7 @@ DMA_ATTR static const buf_desc_t start_desc = { .eof = 1, }; -static inline void send_isr_invoker_enable() +static inline void send_isr_invoker_enable(void) { //force trigger rx_done interrupt. the interrupt is abused to invoke ISR from the app by the enable bit and never cleared. send_start_transmission(&start_desc); @@ -770,29 +770,29 @@ static inline void send_isr_invoker_enable() send_stop_ll_operation(); } -static inline void send_isr_invoker_disable() +static inline void send_isr_invoker_disable(void) { SLC.slc0_int_clr.rx_done = 1; } -static inline void send_intr_enable() +static inline void send_intr_enable(void) { SLC.slc0_int_ena.rx_eof = 1; send_isr_invoker_enable(); } -static inline void send_intr_disable() +static inline void send_intr_disable(void) { send_isr_invoker_disable(); SLC.slc0_int_ena.rx_eof = 0; } -static inline void send_isr_invoke() +static inline void send_isr_invoke(void) { SLC.slc0_int_ena.rx_done = 1; } -static inline send_state_t send_get_state() +static inline send_state_t send_get_state(void) { return context.send_state; } @@ -803,7 +803,7 @@ static inline void send_set_state(send_state_t state) } //start hw operation with existing data (if exist) -static esp_err_t send_start() +static esp_err_t send_start(void) { SDIO_SLAVE_CHECK(send_get_state() == STATE_IDLE, "already started", ESP_ERR_INVALID_STATE); @@ -814,7 +814,7 @@ static esp_err_t send_start() } //only stop hw operations, no touch to data as well as counter -static void send_stop() +static void send_stop(void) { SLC.slc0_rx_link.stop = 1; send_intr_disable(); @@ -866,7 +866,7 @@ static inline esp_err_t send_isr_check_new_pkt(portBASE_TYPE *yield) return ESP_OK; } -static inline esp_err_t send_isr_new_packet() +static inline esp_err_t send_isr_new_packet(void) { // since eof is changed, we have to stop and reset the link list, // and restart new link list operation @@ -973,7 +973,7 @@ esp_err_t sdio_slave_transmit(uint8_t* addr, size_t len) } //clear data but keep counter -static esp_err_t send_flush_data() +static esp_err_t send_flush_data(void) { //only works in idle state / wait to send state SDIO_SLAVE_CHECK(send_get_state() == STATE_IDLE, @@ -1019,7 +1019,7 @@ static esp_err_t send_flush_data() } //clear counter but keep data -static esp_err_t send_reset_counter() +static esp_err_t send_reset_counter(void) { SDIO_SLAVE_CHECK(send_get_state() == STATE_IDLE, "reset counter when transmission started", ESP_ERR_INVALID_STATE); @@ -1061,28 +1061,28 @@ static esp_err_t send_reset_counter() #define CHECK_HANDLE_IDLE(desc) do { if (desc == NULL || !desc->not_receiving) {\ return ESP_ERR_INVALID_ARG; } } while(0) -static inline void critical_enter_recv() +static inline void critical_enter_recv(void) { portENTER_CRITICAL(&context.recv_spinlock); } -static inline void critical_exit_recv() +static inline void critical_exit_recv(void) { portEXIT_CRITICAL(&context.recv_spinlock); } -static inline void recv_size_inc() +static inline void recv_size_inc(void) { // fields wdata and inc_more should be written by the same instruction. SLC.slc0_token1.val = FIELD_TO_VALUE2(SLC_SLC0_TOKEN1_WDATA, 1) | FIELD_TO_VALUE2(SLC_SLC0_TOKEN1_INC_MORE, 1); } -static inline void recv_size_reset() +static inline void recv_size_reset(void) { SLC.slc0_token1.val = FIELD_TO_VALUE2(SLC_SLC0_TOKEN1_WDATA, 0) | FIELD_TO_VALUE2(SLC_SLC0_TOKEN1_WR, 1); } -static inline buf_desc_t* recv_get_first_empty_buf() +static inline buf_desc_t* recv_get_first_empty_buf(void) { buf_stailq_t *const queue = &context.recv_link_list; buf_desc_t *desc = STAILQ_FIRST(queue); @@ -1092,7 +1092,7 @@ static inline buf_desc_t* recv_get_first_empty_buf() return desc; } -static esp_err_t recv_start() +static esp_err_t recv_start(void) { SLC.conf0.slc0_tx_rst = 1; SLC.conf0.slc0_tx_rst = 0; @@ -1113,14 +1113,14 @@ static esp_err_t recv_start() return ESP_OK; } -static void recv_stop() +static void recv_stop(void) { SLC.slc0_tx_link.stop = 1; SLC.slc0_int_ena.tx_done = 0; } // reset the counter, but keep the data -static void recv_reset_counter() +static void recv_reset_counter(void) { recv_size_reset(); @@ -1135,7 +1135,7 @@ static void recv_reset_counter() } // remove data, still increase the counter -static void recv_flush_data() +static void recv_flush_data(void) { buf_stailq_t *const queue = &context.recv_link_list; @@ -1276,7 +1276,7 @@ uint8_t* sdio_slave_recv_get_buf(sdio_slave_buf_handle_t handle, size_t *len_o) return desc->buf; } -static void __attribute((unused)) sdio_slave_recv_get_loaded_buffer_num() +static void __attribute((unused)) sdio_slave_recv_get_loaded_buffer_num(void) { buf_stailq_t *const queue = &context.recv_link_list; dump_queue(queue); diff --git a/components/driver/sdmmc_host.c b/components/driver/sdmmc_host.c index 7a8969fd2..c1361829b 100644 --- a/components/driver/sdmmc_host.c +++ b/components/driver/sdmmc_host.c @@ -30,7 +30,7 @@ static void sdmmc_isr(void* arg); -static void sdmmc_host_dma_init(); +static void sdmmc_host_dma_init(void); static const char* TAG = "sdmmc_periph"; @@ -40,7 +40,7 @@ static SemaphoreHandle_t s_io_intr_event; size_t s_slot_width[2] = {1,1}; -void sdmmc_host_reset() +void sdmmc_host_reset(void) { // Set reset bits SDMMC.ctrl.controller_reset = 1; @@ -97,7 +97,7 @@ static void sdmmc_host_set_clk_div(int div) ets_delay_us(10); } -static void sdmmc_host_input_clk_disable() +static void sdmmc_host_input_clk_disable(void) { SDMMC.clock.val = 0; } @@ -216,7 +216,7 @@ esp_err_t sdmmc_host_start_command(int slot, sdmmc_hw_cmd_t cmd, uint32_t arg) { return ESP_OK; } -esp_err_t sdmmc_host_init() +esp_err_t sdmmc_host_init(void) { if (s_intr_handle) { return ESP_ERR_INVALID_STATE; @@ -402,7 +402,7 @@ esp_err_t sdmmc_host_init_slot(int slot, const sdmmc_slot_config_t* slot_config) return ESP_OK; } -esp_err_t sdmmc_host_deinit() +esp_err_t sdmmc_host_deinit(void) { if (!s_intr_handle) { return ESP_ERR_INVALID_STATE; @@ -490,7 +490,7 @@ esp_err_t sdmmc_host_set_bus_ddr_mode(int slot, bool ddr_enabled) return ESP_OK; } -static void sdmmc_host_dma_init() +static void sdmmc_host_dma_init(void) { SDMMC.ctrl.dma_enable = 1; SDMMC.bmod.val = 0; @@ -501,7 +501,7 @@ static void sdmmc_host_dma_init() } -void sdmmc_host_dma_stop() +void sdmmc_host_dma_stop(void) { SDMMC.ctrl.use_internal_dma = 0; SDMMC.ctrl.dma_reset = 1; @@ -524,12 +524,12 @@ void sdmmc_host_dma_prepare(sdmmc_desc_t* desc, size_t block_size, size_t data_s sdmmc_host_dma_resume(); } -void sdmmc_host_dma_resume() +void sdmmc_host_dma_resume(void) { SDMMC.pldmnd = 1; } -bool sdmmc_host_card_busy() +bool sdmmc_host_card_busy(void) { return SDMMC.status.data_busy == 1; } diff --git a/components/driver/sdmmc_private.h b/components/driver/sdmmc_private.h index 9223dce31..94cea52d1 100644 --- a/components/driver/sdmmc_private.h +++ b/components/driver/sdmmc_private.h @@ -26,7 +26,7 @@ typedef struct { uint32_t dma_status; ///< masked DMA interrupt status } sdmmc_event_t; -void sdmmc_host_reset(); +void sdmmc_host_reset(void); esp_err_t sdmmc_host_start_command(int slot, sdmmc_hw_cmd_t cmd, uint32_t arg); @@ -34,13 +34,13 @@ esp_err_t sdmmc_host_wait_for_event(int tick_count, sdmmc_event_t* out_event); void sdmmc_host_dma_prepare(sdmmc_desc_t* desc, size_t block_size, size_t data_size); -void sdmmc_host_dma_stop(); +void sdmmc_host_dma_stop(void); -void sdmmc_host_dma_resume(); +void sdmmc_host_dma_resume(void); -bool sdmmc_host_card_busy(); +bool sdmmc_host_card_busy(void); -esp_err_t sdmmc_host_transaction_handler_init(); +esp_err_t sdmmc_host_transaction_handler_init(void); -void sdmmc_host_transaction_handler_deinit(); +void sdmmc_host_transaction_handler_deinit(void); diff --git a/components/driver/sdmmc_transaction.c b/components/driver/sdmmc_transaction.c index 6cddd4b8e..b2f0874b3 100644 --- a/components/driver/sdmmc_transaction.c +++ b/components/driver/sdmmc_transaction.c @@ -72,7 +72,7 @@ static bool s_is_app_cmd; // This flag is set if the next command is an APP co static esp_pm_lock_handle_t s_pm_lock; #endif -static esp_err_t handle_idle_state_events(); +static esp_err_t handle_idle_state_events(void); static sdmmc_hw_cmd_t make_hw_cmd(sdmmc_command_t* cmd); static esp_err_t handle_event(sdmmc_command_t* cmd, sdmmc_req_state_t* state, sdmmc_event_t* unhandled_events); @@ -80,10 +80,10 @@ static esp_err_t process_events(sdmmc_event_t evt, sdmmc_command_t* cmd, sdmmc_req_state_t* pstate, sdmmc_event_t* unhandled_events); static void process_command_response(uint32_t status, sdmmc_command_t* cmd); static void fill_dma_descriptors(size_t num_desc); -static size_t get_free_descriptors_count(); +static size_t get_free_descriptors_count(void); static bool wait_for_busy_cleared(int timeout_ms); -esp_err_t sdmmc_host_transaction_handler_init() +esp_err_t sdmmc_host_transaction_handler_init(void) { assert(s_request_mutex == NULL); s_request_mutex = xSemaphoreCreateMutex(); @@ -102,7 +102,7 @@ esp_err_t sdmmc_host_transaction_handler_init() return ESP_OK; } -void sdmmc_host_transaction_handler_deinit() +void sdmmc_host_transaction_handler_deinit(void) { assert(s_request_mutex); #ifdef CONFIG_PM_ENABLE @@ -182,7 +182,7 @@ out: return ret; } -static size_t get_free_descriptors_count() +static size_t get_free_descriptors_count(void) { const size_t next = s_cur_transfer.next_desc; size_t count = 0; @@ -234,7 +234,7 @@ static void fill_dma_descriptors(size_t num_desc) } } -static esp_err_t handle_idle_state_events() +static esp_err_t handle_idle_state_events(void) { /* Handle any events which have happened in between transfers. * Under current assumptions (no SDIO support) only card detect events diff --git a/components/driver/sdspi_host.c b/components/driver/sdspi_host.c index 3a36ed769..d3e37489f 100644 --- a/components/driver/sdspi_host.c +++ b/components/driver/sdspi_host.c @@ -225,12 +225,12 @@ static esp_err_t init_spi_dev(int slot, int clock_speed_hz) return spi_bus_add_device((spi_host_device_t) slot, &devcfg, &s_slots[slot].handle); } -esp_err_t sdspi_host_init() +esp_err_t sdspi_host_init(void) { return ESP_OK; } -esp_err_t sdspi_host_deinit() +esp_err_t sdspi_host_deinit(void) { for (size_t i = 0; i < sizeof(s_slots)/sizeof(s_slots[0]); ++i) { if (s_slots[i].handle) { diff --git a/components/driver/spi_common.c b/components/driver/spi_common.c index ff7501eaf..a8954d07c 100644 --- a/components/driver/spi_common.c +++ b/components/driver/spi_common.c @@ -394,7 +394,7 @@ bool IRAM_ATTR spicommon_dmaworkaround_req_reset(int dmachan, dmaworkaround_cb_t return ret; } -bool IRAM_ATTR spicommon_dmaworkaround_reset_in_progress() +bool IRAM_ATTR spicommon_dmaworkaround_reset_in_progress(void) { return (dmaworkaround_waiting_for_chan != 0); } diff --git a/components/driver/test/test_i2c.c b/components/driver/test/test_i2c.c index 2d8bb922f..bde591cb3 100644 --- a/components/driver/test/test_i2c.c +++ b/components/driver/test/test_i2c.c @@ -75,7 +75,7 @@ static void disp_buf(uint8_t *buf, int len) printf("\n"); } -static i2c_config_t i2c_master_init() +static i2c_config_t i2c_master_init(void) { i2c_config_t conf_master = { .mode = I2C_MODE_MASTER, @@ -88,7 +88,7 @@ static i2c_config_t i2c_master_init() return conf_master; } -static i2c_config_t i2c_slave_init() +static i2c_config_t i2c_slave_init(void) { i2c_config_t conf_slave = { .mode = I2C_MODE_SLAVE, @@ -252,7 +252,7 @@ TEST_CASE("I2C driver memory leaking check", "[i2c]") TEST_ASSERT_INT_WITHIN(100, size, esp_get_free_heap_size()); } -static void i2c_master_write_test() +static void i2c_master_write_test(void) { uint8_t *data_wr = (uint8_t *) malloc(DATA_LENGTH); int i; @@ -276,7 +276,7 @@ static void i2c_master_write_test() TEST_ESP_OK(i2c_driver_delete(I2C_MASTER_NUM)); } -static void i2c_slave_read_test() +static void i2c_slave_read_test(void) { uint8_t *data_rd = (uint8_t *) malloc(DATA_LENGTH); int size_rd = 0; @@ -308,7 +308,7 @@ static void i2c_slave_read_test() TEST_CASE_MULTIPLE_DEVICES("I2C master write slave test", "[i2c][test_env=UT_T2_I2C][timeout=150]", i2c_master_write_test, i2c_slave_read_test); -static void master_read_slave_test() +static void master_read_slave_test(void) { uint8_t *data_rd = (uint8_t *) malloc(DATA_LENGTH); memset(data_rd, 0, DATA_LENGTH); @@ -340,7 +340,7 @@ static void master_read_slave_test() i2c_driver_delete(I2C_MASTER_NUM); } -static void slave_write_buffer_test() +static void slave_write_buffer_test(void) { uint8_t *data_wr = (uint8_t *) malloc(DATA_LENGTH); int size_rd; @@ -367,7 +367,7 @@ static void slave_write_buffer_test() TEST_CASE_MULTIPLE_DEVICES("I2C master read slave test", "[i2c][test_env=UT_T2_I2C][timeout=150]", master_read_slave_test, slave_write_buffer_test); -static void i2c_master_write_read_test() +static void i2c_master_write_read_test(void) { uint8_t *data_rd = (uint8_t *) malloc(DATA_LENGTH); memset(data_rd, 0, DATA_LENGTH); @@ -409,7 +409,7 @@ static void i2c_master_write_read_test() i2c_driver_delete(I2C_MASTER_NUM); } -static void i2c_slave_read_write_test() +static void i2c_slave_read_write_test(void) { uint8_t *data_rd = (uint8_t *) malloc(DATA_LENGTH); memset(data_rd, 0, DATA_LENGTH); @@ -445,7 +445,7 @@ static void i2c_slave_read_write_test() TEST_CASE_MULTIPLE_DEVICES("I2C read and write test", "[i2c][test_env=UT_T2_I2C][timeout=150]", i2c_master_write_read_test, i2c_slave_read_write_test); -static void i2c_master_repeat_write() +static void i2c_master_repeat_write(void) { uint8_t *data_wr = (uint8_t *) malloc(DATA_LENGTH); int times = 3; @@ -471,7 +471,7 @@ static void i2c_master_repeat_write() i2c_driver_delete(I2C_MASTER_NUM); } -static void i2c_slave_repeat_read() +static void i2c_slave_repeat_read(void) { int size_rd = 0; int times = 3; diff --git a/components/driver/test/test_rmt.c b/components/driver/test/test_rmt.c index 7b186b2c5..a3014401c 100644 --- a/components/driver/test/test_rmt.c +++ b/components/driver/test/test_rmt.c @@ -262,7 +262,7 @@ static int get_rx_data(RingbufHandle_t rb) /** * @brief RMT transmitter initialization */ -static void tx_init() +static void tx_init(void) { // the sender once it send something, its frq is 38kHz, and the duty cycle is 50% rmt_tx_config_t tx_cfg = { @@ -289,7 +289,7 @@ static void tx_init() /** * @brief RMT receiver initialization */ -static void rx_init() +static void rx_init(void) { rmt_rx_config_t rx_cfg = { .filter_en = true, diff --git a/components/driver/test/test_spi_sio.c b/components/driver/test/test_spi_sio.c index 37d4065df..cb6964f6b 100644 --- a/components/driver/test/test_spi_sio.c +++ b/components/driver/test/test_spi_sio.c @@ -154,7 +154,7 @@ void test_sio_master_round(bool test_mosi) master_free_device_bus(spi); } -void test_sio_master() +void test_sio_master(void) { test_sio_master_round(true); unity_send_signal("master ready"); @@ -210,7 +210,7 @@ void test_sio_slave_round(bool test_mosi) spi_slave_free(TEST_SLAVE_HOST); } -void test_sio_slave() +void test_sio_slave(void) { test_sio_slave_round(true); unity_wait_for_signal("master ready"); diff --git a/components/driver/test/test_spi_slave.c b/components/driver/test/test_spi_slave.c index 668b78d29..c1e913c48 100644 --- a/components/driver/test/test_spi_slave.c +++ b/components/driver/test/test_spi_slave.c @@ -51,7 +51,7 @@ static void master_init_nodma( spi_device_handle_t* spi) TEST_ASSERT(ret==ESP_OK); } -static void slave_init() +static void slave_init(void) { //Configuration for the SPI bus spi_bus_config_t buscfg={ diff --git a/components/driver/test/test_timer.c b/components/driver/test/test_timer.c index 7f1d3c37f..bc5f3ae75 100644 --- a/components/driver/test/test_timer.c +++ b/components/driver/test/test_timer.c @@ -127,7 +127,7 @@ static void all_timer_init(timer_config_t config, bool flag) } // start all of timer -static void all_timer_start() +static void all_timer_start(void) { esp_err_t ret; ret = timer_start(TIMER_GROUP_0, TIMER_0); @@ -153,7 +153,7 @@ static void all_timer_set_counter_value(uint64_t set_timer_val) TEST_ASSERT(ret == ESP_OK); } -static void all_timer_pause() +static void all_timer_pause(void) { esp_err_t ret; ret = timer_pause(TIMER_GROUP_0, TIMER_0); diff --git a/components/driver/test/test_uart.c b/components/driver/test/test_uart.c index 8ef579c80..019604403 100644 --- a/components/driver/test/test_uart.c +++ b/components/driver/test/test_uart.c @@ -244,7 +244,7 @@ static uint16_t buffer_fill_random(uint8_t *buffer, size_t length) return crc; } -static void rs485_init() +static void rs485_init(void) { uart_config_t uart_config = { .baud_rate = UART_BAUD_115200, @@ -288,7 +288,7 @@ static esp_err_t print_packet_data(const char *str, uint8_t *buffer, uint16_t bu } // Slave test case for multi device -static void rs485_slave() +static void rs485_slave(void) { rs485_init(); uint8_t* slave_data = (uint8_t*) malloc(BUF_SIZE); @@ -327,7 +327,7 @@ static void rs485_slave() // Master test of multi device test case. // It forms packet with random data, apply generated CRC16 and sends to slave. // If response recieved correctly from slave means RS485 channel works. -static void rs485_master() +static void rs485_master(void) { uint16_t err_count = 0, good_count = 0; rs485_init(); diff --git a/components/driver/uart.c b/components/driver/uart.c index 20306c128..3367d1d04 100644 --- a/components/driver/uart.c +++ b/components/driver/uart.c @@ -1484,7 +1484,7 @@ void uart_set_select_notif_callback(uart_port_t uart_num, uart_select_notif_call } } -portMUX_TYPE *uart_get_selectlock() +portMUX_TYPE *uart_get_selectlock(void) { return &uart_selectlock; } diff --git a/components/efuse/include/esp_efuse.h b/components/efuse/include/esp_efuse.h index b2afdbd9a..0d7ed8373 100644 --- a/components/efuse/include/esp_efuse.h +++ b/components/efuse/include/esp_efuse.h @@ -322,7 +322,7 @@ void esp_efuse_write_random_key(uint32_t blk_wdata0_reg); /* @brief Return secure_version from efuse field. * @return Secure version from efuse field */ -uint32_t esp_efuse_read_secure_version(); +uint32_t esp_efuse_read_secure_version(void); /* @brief Check secure_version from app and secure_version and from efuse field. * diff --git a/components/efuse/src/esp_efuse_fields.c b/components/efuse/src/esp_efuse_fields.c index 5d440f383..01ed585d8 100644 --- a/components/efuse/src/esp_efuse_fields.c +++ b/components/efuse/src/esp_efuse_fields.c @@ -130,7 +130,7 @@ void esp_efuse_init(uint32_t offset, uint32_t size) esp_efuse_flash_size = size; } -static uint32_t emulate_secure_version_read() +static uint32_t emulate_secure_version_read(void) { uint32_t secure_version; uint32_t offset = esp_efuse_flash_offset; @@ -170,7 +170,7 @@ static void emulate_secure_version_write(uint32_t secure_version) #define EFUSE_BLK_RD_ANTI_ROLLBACK EFUSE_BLK3_RDATA4_REG #define EFUSE_BLK_WR_ANTI_ROLLBACK EFUSE_BLK3_WDATA4_REG -uint32_t esp_efuse_read_secure_version() +uint32_t esp_efuse_read_secure_version(void) { #ifdef CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK uint32_t secure_version; diff --git a/components/efuse/src/esp_efuse_utility.c b/components/efuse/src/esp_efuse_utility.c index 03ea26084..e3154b188 100644 --- a/components/efuse/src/esp_efuse_utility.c +++ b/components/efuse/src/esp_efuse_utility.c @@ -34,7 +34,7 @@ static const char *TAG = "efuse"; static uint32_t virt_blocks[COUNT_EFUSE_BLOCKS][COUNT_EFUSE_REG_PER_BLOCK]; /* Call the update function to seed virtual efuses during initialization */ -__attribute__((constructor)) void esp_efuse_utility_update_virt_blocks(); +__attribute__((constructor)) void esp_efuse_utility_update_virt_blocks(void); #endif @@ -222,7 +222,7 @@ void esp_efuse_utility_burn_efuses(void) // Erase the virt_blocks array. -void esp_efuse_utility_erase_virt_blocks() +void esp_efuse_utility_erase_virt_blocks(void) { #ifdef CONFIG_EFUSE_VIRTUAL memset(virt_blocks, 0, sizeof(virt_blocks)); @@ -230,7 +230,7 @@ void esp_efuse_utility_erase_virt_blocks() } // Fills the virt_blocks array by values from efuse_Rdata. -void esp_efuse_utility_update_virt_blocks() +void esp_efuse_utility_update_virt_blocks(void) { #ifdef CONFIG_EFUSE_VIRTUAL ESP_LOGI(TAG, "Loading virtual efuse blocks from real efuses"); @@ -247,7 +247,7 @@ void esp_efuse_utility_update_virt_blocks() } // Prints efuse values for all registers. -void esp_efuse_utility_debug_dump_blocks() +void esp_efuse_utility_debug_dump_blocks(void) { printf("EFUSE_BLKx:\n"); #ifdef CONFIG_EFUSE_VIRTUAL @@ -454,7 +454,7 @@ static void read_r_data(esp_efuse_block_t num_block, uint32_t* buf_r_data) // After esp_efuse_write.. functions EFUSE_BLKx_WDATAx_REG were filled is not coded values. // This function reads EFUSE_BLKx_WDATAx_REG registers, applies coding scheme and writes encoded values back to EFUSE_BLKx_WDATAx_REG. -esp_err_t esp_efuse_utility_apply_new_coding_scheme() +esp_err_t esp_efuse_utility_apply_new_coding_scheme(void) { uint8_t buf_w_data[COUNT_EFUSE_REG_PER_BLOCK * 4]; uint8_t buf_r_data[COUNT_EFUSE_REG_PER_BLOCK * 4]; diff --git a/components/efuse/src/esp_efuse_utility.h b/components/efuse/src/esp_efuse_utility.h index 18d8b5886..eadd80e02 100644 --- a/components/efuse/src/esp_efuse_utility.h +++ b/components/efuse/src/esp_efuse_utility.h @@ -112,17 +112,17 @@ void esp_efuse_utility_reset(void); /** * @brief Fills the virt_blocks array by values from efuse_Rdata. */ -void esp_efuse_utility_update_virt_blocks(); +void esp_efuse_utility_update_virt_blocks(void); /** * @brief Prints efuse values for all registers. */ -void esp_efuse_utility_debug_dump_blocks(); +void esp_efuse_utility_debug_dump_blocks(void); /** * @brief Erase the virt_blocks array. */ -void esp_efuse_utility_erase_virt_blocks(); +void esp_efuse_utility_erase_virt_blocks(void); /** * @brief Apply coding_scheme to write registers. @@ -131,7 +131,7 @@ void esp_efuse_utility_erase_virt_blocks(); * - ESP_OK: The operation was successfully completed. * - ESP_ERR_CODING: Error range of data does not match the coding scheme. */ -esp_err_t esp_efuse_utility_apply_new_coding_scheme(); +esp_err_t esp_efuse_utility_apply_new_coding_scheme(void); #ifdef __cplusplus } diff --git a/components/esp-tls/esp_tls.c b/components/esp-tls/esp_tls.c index 65cd789f3..cd9bd0257 100644 --- a/components/esp-tls/esp_tls.c +++ b/components/esp-tls/esp_tls.c @@ -158,7 +158,7 @@ err_freeaddr: return ret; } -esp_err_t esp_tls_init_global_ca_store() +esp_err_t esp_tls_init_global_ca_store(void) { if (global_cacert == NULL) { global_cacert = (mbedtls_x509_crt *)calloc(1, sizeof(mbedtls_x509_crt)); @@ -197,12 +197,12 @@ esp_err_t esp_tls_set_global_ca_store(const unsigned char *cacert_pem_buf, const return ESP_OK; } -mbedtls_x509_crt *esp_tls_get_global_ca_store() +mbedtls_x509_crt *esp_tls_get_global_ca_store(void) { return global_cacert; } -void esp_tls_free_global_ca_store() +void esp_tls_free_global_ca_store(void) { if (global_cacert) { mbedtls_x509_crt_free(global_cacert); @@ -797,7 +797,7 @@ void esp_tls_server_session_delete(esp_tls_t *tls) }; #endif /* ! CONFIG_ESP_TLS_SERVER */ -esp_tls_t *esp_tls_init() +esp_tls_t *esp_tls_init(void) { esp_tls_t *tls = (esp_tls_t *)calloc(1, sizeof(esp_tls_t)); if (!tls) { diff --git a/components/esp-tls/esp_tls.h b/components/esp-tls/esp_tls.h index 1c2f785ea..0c4caabaa 100644 --- a/components/esp-tls/esp_tls.h +++ b/components/esp-tls/esp_tls.h @@ -229,7 +229,7 @@ typedef struct esp_tls { * @return tls Pointer to esp-tls as esp-tls handle if successfully initialized, * NULL if allocation error */ -esp_tls_t *esp_tls_init(); +esp_tls_t *esp_tls_init(void); @@ -402,7 +402,7 @@ ssize_t esp_tls_get_bytes_avail(esp_tls_t *tls); * - ESP_OK if creating global CA store was successful. * - ESP_ERR_NO_MEM if an error occured when allocating the mbedTLS resources. */ -esp_err_t esp_tls_init_global_ca_store(); +esp_err_t esp_tls_init_global_ca_store(void); /** * @brief Set the global CA store with the buffer provided in pem format. @@ -435,7 +435,7 @@ esp_err_t esp_tls_set_global_ca_store(const unsigned char *cacert_pem_buf, const * - Pointer to the global CA store currently being used if successful. * - NULL if there is no global CA store set. */ -mbedtls_x509_crt *esp_tls_get_global_ca_store(); +mbedtls_x509_crt *esp_tls_get_global_ca_store(void); /** * @brief Free the global CA store currently being used. @@ -443,7 +443,7 @@ mbedtls_x509_crt *esp_tls_get_global_ca_store(); * The memory being used by the global CA store to store all the parsed certificates is * freed up. The application can call this API if it no longer needs the global CA store. */ -void esp_tls_free_global_ca_store(); +void esp_tls_free_global_ca_store(void); /** * @brief Returns last error in esp_tls with detailed mbedtls related error codes. diff --git a/components/esp32/brownout.c b/components/esp32/brownout.c index 35589330f..89f821c50 100644 --- a/components/esp32/brownout.c +++ b/components/esp32/brownout.c @@ -31,7 +31,7 @@ #define BROWNOUT_DET_LVL 0 #endif //CONFIG_ESP32_BROWNOUT_DET_LVL -static void rtc_brownout_isr_handler() +static void rtc_brownout_isr_handler(void) { /* Normally RTC ISR clears the interrupt flag after the application-supplied * handler returns. Since restart is called here, the flag needs to be @@ -47,7 +47,7 @@ static void rtc_brownout_isr_handler() esp_restart_noos(); } -void esp_brownout_init() +void esp_brownout_init(void) { REG_WRITE(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ENA /* Enable BOD */ diff --git a/components/esp32/cache_err_int.c b/components/esp32/cache_err_int.c index 079812023..30b294848 100644 --- a/components/esp32/cache_err_int.c +++ b/components/esp32/cache_err_int.c @@ -30,7 +30,7 @@ #include "soc/dport_reg.h" #include "sdkconfig.h" -void esp_cache_err_int_init() +void esp_cache_err_int_init(void) { uint32_t core_id = xPortGetCoreID(); ESP_INTR_DISABLE(ETS_CACHEERR_INUM); @@ -70,7 +70,7 @@ void esp_cache_err_int_init() ESP_INTR_ENABLE(ETS_CACHEERR_INUM); } -int IRAM_ATTR esp_cache_err_get_cpuid() +int IRAM_ATTR esp_cache_err_get_cpuid(void) { esp_dport_access_int_pause(); const uint32_t pro_mask = diff --git a/components/esp32/clk.c b/components/esp32/clk.c index 69f6057b4..fd5c47761 100644 --- a/components/esp32/clk.c +++ b/components/esp32/clk.c @@ -210,7 +210,7 @@ static void select_rtc_slow_clk(slow_clk_sel_t slow_clk) esp_clk_slowclk_cal_set(cal_val); } -void rtc_clk_select_rtc_slow_clk() +void rtc_clk_select_rtc_slow_clk(void) { select_rtc_slow_clk(RTC_SLOW_FREQ_32K_XTAL); } diff --git a/components/esp32/cpu_start.c b/components/esp32/cpu_start.c index f93e4cdf0..1dfa5c246 100644 --- a/components/esp32/cpu_start.c +++ b/components/esp32/cpu_start.c @@ -79,7 +79,7 @@ void start_cpu0(void) __attribute__((weak, alias("start_cpu0_default"))) __attribute__((noreturn)); void start_cpu0_default(void) IRAM_ATTR __attribute__((noreturn)); #if !CONFIG_FREERTOS_UNICORE -static void IRAM_ATTR call_start_cpu1() __attribute__((noreturn)); +static void IRAM_ATTR call_start_cpu1(void) __attribute__((noreturn)); void start_cpu1(void) __attribute__((weak, alias("start_cpu1_default"))) __attribute__((noreturn)); void start_cpu1_default(void) IRAM_ATTR __attribute__((noreturn)); static bool app_cpu_started = false; @@ -117,7 +117,7 @@ static bool s_spiram_okay=true; * and the app CPU is in reset. We do have a stack, so we can do the initialization in C. */ -void IRAM_ATTR call_start_cpu0() +void IRAM_ATTR call_start_cpu0(void) { #if CONFIG_FREERTOS_UNICORE RESET_REASON rst_reas[1]; @@ -277,7 +277,7 @@ static void wdt_reset_cpu1_info_enable(void) DPORT_REG_CLR_BIT(DPORT_APP_CPU_RECORD_CTRL_REG, DPORT_APP_CPU_RECORD_ENABLE); } -void IRAM_ATTR call_start_cpu1() +void IRAM_ATTR call_start_cpu1(void) { asm volatile (\ "wsr %0, vecbase\n" \ @@ -484,7 +484,7 @@ void start_cpu1_default(void) #endif //!CONFIG_FREERTOS_UNICORE #ifdef CONFIG_COMPILER_CXX_EXCEPTIONS -size_t __cxx_eh_arena_size_get() +size_t __cxx_eh_arena_size_get(void) { return CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE; } diff --git a/components/esp32/crosscore_int.c b/components/esp32/crosscore_int.c index 746060e44..24bb3fb26 100644 --- a/components/esp32/crosscore_int.c +++ b/components/esp32/crosscore_int.c @@ -43,7 +43,7 @@ static volatile uint32_t reason[ portNUM_PROCESSORS ]; ToDo: There is a small chance the CPU already has yielded when this ISR is serviced. In that case, it's running the intended task but the ISR will cause it to switch _away_ from it. portYIELD_FROM_ISR will probably just schedule the task again, but have to check that. */ -static inline void IRAM_ATTR esp_crosscore_isr_handle_yield() +static inline void IRAM_ATTR esp_crosscore_isr_handle_yield(void) { portYIELD_FROM_ISR(); } @@ -79,7 +79,7 @@ static void IRAM_ATTR esp_crosscore_isr(void *arg) { //Initialize the crosscore interrupt on this core. Call this once //on each active core. -void esp_crosscore_int_init() { +void esp_crosscore_int_init(void) { portENTER_CRITICAL(&reason_spinlock); reason[xPortGetCoreID()]=0; portEXIT_CRITICAL(&reason_spinlock); diff --git a/components/esp32/esp_clk_internal.h b/components/esp32/esp_clk_internal.h index 53af81c28..f1f896457 100644 --- a/components/esp32/esp_clk_internal.h +++ b/components/esp32/esp_clk_internal.h @@ -41,4 +41,4 @@ void esp_perip_clk_init(void); /* Selects an external clock source (32 kHz) for RTC. * Only internal use in unit test. */ -void rtc_clk_select_rtc_slow_clk(); +void rtc_clk_select_rtc_slow_clk(void); diff --git a/components/esp32/esp_himem.c b/components/esp32/esp_himem.c index 7053af341..c9c6a2631 100644 --- a/components/esp32/esp_himem.c +++ b/components/esp32/esp_himem.c @@ -117,13 +117,13 @@ static void set_bank(int virt_bank, int phys_bank, int ct) assert(r == 0); } -size_t esp_himem_get_phys_size() +size_t esp_himem_get_phys_size(void) { int paddr_start = (4096 * 1024) - (CACHE_BLOCKSIZE * SPIRAM_BANKSWITCH_RESERVE); return esp_spiram_get_size()-paddr_start; } -size_t esp_himem_get_free_size() +size_t esp_himem_get_free_size(void) { size_t ret=0; for (int i = 0; i < s_ramblockcnt; i++) { @@ -132,12 +132,12 @@ size_t esp_himem_get_free_size() return ret; } -size_t esp_himem_reserved_area_size() { +size_t esp_himem_reserved_area_size(void) { return CACHE_BLOCKSIZE * SPIRAM_BANKSWITCH_RESERVE; } -void __attribute__((constructor)) esp_himem_init() +void __attribute__((constructor)) esp_himem_init(void) { if (SPIRAM_BANKSWITCH_RESERVE == 0) return; int maxram=esp_spiram_get_size(); diff --git a/components/esp32/esp_timer_esp32.c b/components/esp32/esp_timer_esp32.c index cac4b819b..541ddc740 100644 --- a/components/esp32/esp_timer_esp32.c +++ b/components/esp32/esp_timer_esp32.c @@ -150,7 +150,7 @@ portMUX_TYPE s_time_update_lock = portMUX_INITIALIZER_UNLOCKED; #define TIMER_IS_AFTER_OVERFLOW(a) (ALARM_OVERFLOW_VAL < (a) && (a) <= FRC_TIMER_LOAD_VALUE(1)) // Check if timer overflow has happened (but was not handled by ISR yet) -static inline bool IRAM_ATTR timer_overflow_happened() +static inline bool IRAM_ATTR timer_overflow_happened(void) { if (s_overflow_happened) { return true; @@ -176,17 +176,17 @@ static inline void IRAM_ATTR timer_count_reload(void) REG_WRITE(FRC_TIMER_LOAD_REG(1), REG_READ(FRC_TIMER_COUNT_REG(1)) - ALARM_OVERFLOW_VAL); } -void esp_timer_impl_lock() +void esp_timer_impl_lock(void) { portENTER_CRITICAL(&s_time_update_lock); } -void esp_timer_impl_unlock() +void esp_timer_impl_unlock(void) { portEXIT_CRITICAL(&s_time_update_lock); } -uint64_t IRAM_ATTR esp_timer_impl_get_time() +uint64_t IRAM_ATTR esp_timer_impl_get_time(void) { uint32_t timer_val; uint64_t time_base; @@ -371,7 +371,7 @@ esp_err_t esp_timer_impl_init(intr_handler_t alarm_handler) return ESP_OK; } -void esp_timer_impl_deinit() +void esp_timer_impl_deinit(void) { esp_intr_disable(s_timer_interrupt_handle); @@ -386,13 +386,13 @@ void esp_timer_impl_deinit() // FIXME: This value is safe for 80MHz APB frequency. // Should be modified to depend on clock frequency. -uint64_t IRAM_ATTR esp_timer_impl_get_min_period_us() +uint64_t IRAM_ATTR esp_timer_impl_get_min_period_us(void) { return 50; } #ifdef ESP_TIMER_DYNAMIC_OVERFLOW_VAL -uint32_t esp_timer_impl_get_overflow_val() +uint32_t esp_timer_impl_get_overflow_val(void) { return s_alarm_overflow_val; } diff --git a/components/esp32/include/esp32/brownout.h b/components/esp32/include/esp32/brownout.h index 5a0b1aec0..dafba8dd7 100644 --- a/components/esp32/include/esp32/brownout.h +++ b/components/esp32/include/esp32/brownout.h @@ -16,6 +16,6 @@ #ifndef __ESP_BROWNOUT_H #define __ESP_BROWNOUT_H -void esp_brownout_init(); +void esp_brownout_init(void); #endif \ No newline at end of file diff --git a/components/esp32/include/esp32/cache_err_int.h b/components/esp32/include/esp32/cache_err_int.h index bcbd63e79..8881291a2 100644 --- a/components/esp32/include/esp32/cache_err_int.h +++ b/components/esp32/include/esp32/cache_err_int.h @@ -20,7 +20,7 @@ * to interrupt input number ETS_CACHEERR_INUM (see soc/soc.h). It is called * from the startup code. */ -void esp_cache_err_int_init(); +void esp_cache_err_int_init(void); /** @@ -30,4 +30,4 @@ void esp_cache_err_int_init(); * - APP_CPU_NUM, if APP_CPU has caused cache IA interrupt * - (-1) otherwise */ -int esp_cache_err_get_cpuid(); +int esp_cache_err_get_cpuid(void); diff --git a/components/esp32/include/esp32/clk.h b/components/esp32/include/esp32/clk.h index 9393fc1f5..4e32fd16e 100644 --- a/components/esp32/include/esp32/clk.h +++ b/components/esp32/include/esp32/clk.h @@ -29,7 +29,7 @@ * * @return the calibration value obtained using rtc_clk_cal, at startup time */ -uint32_t esp_clk_slowclk_cal_get(); +uint32_t esp_clk_slowclk_cal_get(void); /** * @brief Update the calibration value of RTC slow clock @@ -84,4 +84,4 @@ int esp_clk_xtal_freq(void); * * @return Value or RTC counter, expressed in microseconds */ -uint64_t esp_clk_rtc_time(); +uint64_t esp_clk_rtc_time(void); diff --git a/components/esp32/include/esp32/himem.h b/components/esp32/include/esp32/himem.h index 099d92601..0297725a1 100644 --- a/components/esp32/include/esp32/himem.h +++ b/components/esp32/include/esp32/himem.h @@ -125,14 +125,14 @@ esp_err_t esp_himem_unmap(esp_himem_rangehandle_t range, void *ptr, size_t len); * * @returns Amount of memory, in bytes */ -size_t esp_himem_get_phys_size(); +size_t esp_himem_get_phys_size(void); /** * @brief Get free amount of memory under control of himem API * * @returns Amount of free memory, in bytes */ -size_t esp_himem_get_free_size(); +size_t esp_himem_get_free_size(void); /** @@ -143,7 +143,7 @@ size_t esp_himem_get_free_size(); * * @returns Amount of reserved area, in bytes */ -size_t esp_himem_reserved_area_size(); +size_t esp_himem_reserved_area_size(void); #ifdef __cplusplus diff --git a/components/esp32/include/esp32/spiram.h b/components/esp32/include/esp32/spiram.h index a55872cd4..ccbca2c0b 100644 --- a/components/esp32/include/esp32/spiram.h +++ b/components/esp32/include/esp32/spiram.h @@ -34,14 +34,14 @@ typedef enum { * - ESP_SPIRAM_SIZE_INVALID if SPI RAM not enabled or not valid * - SPI RAM size */ -esp_spiram_size_t esp_spiram_get_chip_size(); +esp_spiram_size_t esp_spiram_get_chip_size(void); /** * @brief Initialize spiram interface/hardware. Normally called from cpu_start.c. * * @return ESP_OK on success */ -esp_err_t esp_spiram_init(); +esp_err_t esp_spiram_init(void); /** * @brief Configure Cache/MMU for access to external SPI RAM. @@ -52,7 +52,7 @@ esp_err_t esp_spiram_init(); * * @attention this function must be called with flash cache disabled. */ -void esp_spiram_init_cache(); +void esp_spiram_init_cache(void); /** @@ -63,13 +63,13 @@ void esp_spiram_init_cache(); * * @return true on success, false on failed memory test */ -bool esp_spiram_test(); +bool esp_spiram_test(void); /** * @brief Add the initialized SPI RAM to the heap allocator. */ -esp_err_t esp_spiram_add_to_heapalloc(); +esp_err_t esp_spiram_add_to_heapalloc(void); /** @@ -77,7 +77,7 @@ esp_err_t esp_spiram_add_to_heapalloc(); * * @return Size in bytes, or 0 if no external RAM chip support compiled in. */ -size_t esp_spiram_get_size(); +size_t esp_spiram_get_size(void); /** @@ -87,7 +87,7 @@ size_t esp_spiram_get_size(); * * This is meant for use from within the SPI flash code. */ -void esp_spiram_writeback_cache(); +void esp_spiram_writeback_cache(void); diff --git a/components/esp32/include/esp_intr_alloc.h b/components/esp32/include/esp_intr_alloc.h index d6893a07a..cafc178bf 100644 --- a/components/esp32/include/esp_intr_alloc.h +++ b/components/esp32/include/esp_intr_alloc.h @@ -282,13 +282,13 @@ esp_err_t esp_intr_set_in_iram(intr_handle_t handle, bool is_in_iram); /** * @brief Disable interrupts that aren't specifically marked as running from IRAM */ -void esp_intr_noniram_disable(); +void esp_intr_noniram_disable(void); /** * @brief Re-enable interrupts disabled by esp_intr_noniram_disable */ -void esp_intr_noniram_enable(); +void esp_intr_noniram_enable(void); /**@}*/ diff --git a/components/esp32/include/esp_sleep.h b/components/esp32/include/esp_sleep.h index 7791de6f7..7101bda07 100644 --- a/components/esp32/include/esp_sleep.h +++ b/components/esp32/include/esp_sleep.h @@ -98,7 +98,7 @@ esp_err_t esp_sleep_disable_wakeup_source(esp_sleep_source_t source); * - ESP_ERR_NOT_SUPPORTED if additional current by touch (CONFIG_ESP32_RTC_EXT_CRYST_ADDIT_CURRENT) is enabled. * - ESP_ERR_INVALID_STATE if ULP co-processor is not enabled or if wakeup triggers conflict */ -esp_err_t esp_sleep_enable_ulp_wakeup(); +esp_err_t esp_sleep_enable_ulp_wakeup(void); /** * @brief Enable wakeup by timer @@ -125,7 +125,7 @@ esp_err_t esp_sleep_enable_timer_wakeup(uint64_t time_in_us); * - ESP_ERR_NOT_SUPPORTED if additional current by touch (CONFIG_ESP32_RTC_EXT_CRYST_ADDIT_CURRENT) is enabled. * - ESP_ERR_INVALID_STATE if wakeup triggers conflict */ -esp_err_t esp_sleep_enable_touchpad_wakeup(); +esp_err_t esp_sleep_enable_touchpad_wakeup(void); /** * @brief Get the touch pad which caused wakeup @@ -134,7 +134,7 @@ esp_err_t esp_sleep_enable_touchpad_wakeup(); * * @return touch pad which caused wakeup */ -touch_pad_t esp_sleep_get_touchpad_wakeup_status(); +touch_pad_t esp_sleep_get_touchpad_wakeup_status(void); /** * @brief Enable wakeup using a pin @@ -213,7 +213,7 @@ esp_err_t esp_sleep_enable_ext1_wakeup(uint64_t mask, esp_sleep_ext1_wakeup_mode * - ESP_OK on success * - ESP_ERR_INVALID_STATE if wakeup triggers conflict */ -esp_err_t esp_sleep_enable_gpio_wakeup(); +esp_err_t esp_sleep_enable_gpio_wakeup(void); /** * @brief Enable wakeup from light sleep using UART @@ -239,7 +239,7 @@ esp_err_t esp_sleep_enable_uart_wakeup(int uart_num); * * @return bit mask, if GPIOn caused wakeup, BIT(n) will be set */ -uint64_t esp_sleep_get_ext1_wakeup_status(); +uint64_t esp_sleep_get_ext1_wakeup_status(void); /** * @brief Set power down mode for an RTC power domain in sleep mode @@ -260,7 +260,7 @@ esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain, * * This function does not return. */ -void esp_deep_sleep_start() __attribute__((noreturn)); +void esp_deep_sleep_start(void) __attribute__((noreturn)); /** * @brief Enter light sleep with the configured wakeup options @@ -269,7 +269,7 @@ void esp_deep_sleep_start() __attribute__((noreturn)); * - ESP_OK on success (returned after wakeup) * - ESP_ERR_INVALID_STATE if WiFi or BT is not stopped */ -esp_err_t esp_light_sleep_start(); +esp_err_t esp_light_sleep_start(void); /** * @brief Enter deep-sleep mode @@ -311,7 +311,7 @@ void system_deep_sleep(uint64_t time_in_us) __attribute__((noreturn, deprecated) * * @return cause of wake up from last sleep (deep sleep or light sleep) */ -esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause(); +esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause(void); /** diff --git a/components/esp32/int_wdt.c b/components/esp32/int_wdt.c index f42b98773..8f18f7157 100644 --- a/components/esp32/int_wdt.c +++ b/components/esp32/int_wdt.c @@ -69,7 +69,7 @@ static void IRAM_ATTR tick_hook(void) { #endif -void esp_int_wdt_init() { +void esp_int_wdt_init(void) { periph_module_enable(PERIPH_TIMG1_MODULE); TIMERG1.wdt_wprotect=TIMG_WDT_WKEY_VALUE; TIMERG1.wdt_config0.sys_reset_length=7; //3.2uS @@ -89,7 +89,7 @@ void esp_int_wdt_init() { timer_group_intr_enable(TIMER_GROUP_1, TIMG_WDT_INT_ENA_M); } -void esp_int_wdt_cpu_init() +void esp_int_wdt_cpu_init(void) { esp_register_freertos_tick_hook_for_cpu(tick_hook, xPortGetCoreID()); ESP_INTR_DISABLE(WDT_INT_NUM); diff --git a/components/esp32/intr_alloc.c b/components/esp32/intr_alloc.c index b74c4f929..6256f6a8b 100644 --- a/components/esp32/intr_alloc.c +++ b/components/esp32/intr_alloc.c @@ -854,7 +854,7 @@ esp_err_t IRAM_ATTR esp_intr_disable(intr_handle_t handle) } -void IRAM_ATTR esp_intr_noniram_disable() +void IRAM_ATTR esp_intr_noniram_disable(void) { int oldint; int cpu=xPortGetCoreID(); @@ -873,7 +873,7 @@ void IRAM_ATTR esp_intr_noniram_disable() non_iram_int_disabled[cpu]=oldint&non_iram_int_mask[cpu]; } -void IRAM_ATTR esp_intr_noniram_enable() +void IRAM_ATTR esp_intr_noniram_enable(void) { int cpu=xPortGetCoreID(); int intmask=non_iram_int_disabled[cpu]; diff --git a/components/esp32/panic.c b/components/esp32/panic.c index e7ed6540e..4a104f029 100644 --- a/components/esp32/panic.c +++ b/components/esp32/panic.c @@ -139,7 +139,7 @@ esp_reset_reason_t __attribute__((weak)) esp_reset_reason_get_hint(void) static bool abort_called; -static __attribute__((noreturn)) inline void invoke_abort() +static __attribute__((noreturn)) inline void invoke_abort(void) { abort_called = true; #if CONFIG_ESP32_APPTRACE_ENABLE @@ -158,7 +158,7 @@ static __attribute__((noreturn)) inline void invoke_abort() } } -void abort() +void abort(void) { #if !CONFIG_ESP32_PANIC_SILENT_REBOOT ets_printf("abort() was called at PC 0x%08x on core %d\r\n", (intptr_t)__builtin_return_address(0) - 3, xPortGetCoreID()); @@ -189,12 +189,12 @@ static const char *edesc[] = { #define NUM_EDESCS (sizeof(edesc) / sizeof(char *)) static void commonErrorHandler(XtExcFrame *frame); -static inline void disableAllWdts(); +static inline void disableAllWdts(void); static void illegal_instruction_helper(XtExcFrame *frame); //The fact that we've panic'ed probably means the other CPU is now running wild, possibly //messing up the serial output, so we stall it here. -static void haltOtherCore() +static void haltOtherCore(void) { esp_cpu_stall( xPortGetCoreID() == 0 ? 1 : 0 ); } @@ -399,7 +399,7 @@ static void illegal_instruction_helper(XtExcFrame *frame) all watchdogs except the timer group 0 watchdog, and it reconfigures that to reset the chip after one second. */ -static void reconfigureAllWdts() +static void reconfigureAllWdts(void) { TIMERG0.wdt_wprotect = TIMG_WDT_WKEY_VALUE; TIMERG0.wdt_feed = 1; @@ -419,7 +419,7 @@ static void reconfigureAllWdts() /* This disables all the watchdogs for when we call the gdbstub. */ -static inline void disableAllWdts() +static inline void disableAllWdts(void) { TIMERG0.wdt_wprotect = TIMG_WDT_WKEY_VALUE; TIMERG0.wdt_config0.en = 0; @@ -429,9 +429,9 @@ static inline void disableAllWdts() TIMERG1.wdt_wprotect = 0; } -static void esp_panic_dig_reset() __attribute__((noreturn)); +static void esp_panic_dig_reset(void) __attribute__((noreturn)); -static void esp_panic_dig_reset() +static void esp_panic_dig_reset(void) { // make sure all the panic handler output is sent from UART FIFO uart_tx_wait_idle(CONFIG_ESP_CONSOLE_UART_NUM); diff --git a/components/esp32/pm_esp32.c b/components/esp32/pm_esp32.c index 746a1ca40..f1b29189a 100644 --- a/components/esp32/pm_esp32.c +++ b/components/esp32/pm_esp32.c @@ -145,9 +145,9 @@ static const char* s_mode_names[] = { static const char* TAG = "pm_esp32"; -static void update_ccompare(); +static void update_ccompare(void); static void do_switch(pm_mode_t new_mode); -static void leave_idle(); +static void leave_idle(void); static void on_freq_update(uint32_t old_ticks_per_us, uint32_t ticks_per_us); @@ -246,7 +246,7 @@ esp_err_t esp_pm_configure(const void* vconfig) return ESP_OK; } -static pm_mode_t IRAM_ATTR get_lowest_allowed_mode() +static pm_mode_t IRAM_ATTR get_lowest_allowed_mode(void) { /* TODO: optimize using ffs/clz */ if (s_mode_mask >= BIT(PM_MODE_CPU_MAX)) { @@ -418,7 +418,7 @@ static void IRAM_ATTR do_switch(pm_mode_t new_mode) * would happen without the frequency change. * Assumes that the new_frequency = old_frequency * s_ccount_mul / s_ccount_div. */ -static void IRAM_ATTR update_ccompare() +static void IRAM_ATTR update_ccompare(void) { uint32_t ccount = XTHAL_GET_CCOUNT(); uint32_t ccompare = XTHAL_GET_CCOMPARE(XT_TIMER_INDEX); @@ -432,7 +432,7 @@ static void IRAM_ATTR update_ccompare() } } -static void IRAM_ATTR leave_idle() +static void IRAM_ATTR leave_idle(void) { int core_id = xPortGetCoreID(); if (s_core_idle[core_id]) { @@ -442,7 +442,7 @@ static void IRAM_ATTR leave_idle() } } -void esp_pm_impl_idle_hook() +void esp_pm_impl_idle_hook(void) { int core_id = xPortGetCoreID(); uint32_t state = portENTER_CRITICAL_NESTED(); @@ -454,7 +454,7 @@ void esp_pm_impl_idle_hook() ESP_PM_TRACE_ENTER(IDLE, core_id); } -void IRAM_ATTR esp_pm_impl_isr_hook() +void IRAM_ATTR esp_pm_impl_isr_hook(void) { int core_id = xPortGetCoreID(); ESP_PM_TRACE_ENTER(ISR_HOOK, core_id); @@ -476,7 +476,7 @@ void IRAM_ATTR esp_pm_impl_isr_hook() ESP_PM_TRACE_EXIT(ISR_HOOK, core_id); } -void esp_pm_impl_waiti() +void esp_pm_impl_waiti(void) { #if CONFIG_FREERTOS_USE_TICKLESS_IDLE int core_id = xPortGetCoreID(); @@ -595,7 +595,7 @@ void esp_pm_impl_dump_stats(FILE* out) } #endif // WITH_PROFILING -void esp_pm_impl_init() +void esp_pm_impl_init(void) { #ifdef CONFIG_PM_TRACE esp_pm_trace_init(); diff --git a/components/esp32/pm_trace.c b/components/esp32/pm_trace.c index 02a636211..5cdb666d6 100644 --- a/components/esp32/pm_trace.c +++ b/components/esp32/pm_trace.c @@ -29,7 +29,7 @@ static const int DRAM_ATTR s_trace_io[] = { BIT(27), BIT(27), // ESP_PM_TRACE_SLEEP }; -void esp_pm_trace_init() +void esp_pm_trace_init(void) { for (size_t i = 0; i < sizeof(s_trace_io)/sizeof(s_trace_io[0]); ++i) { int io = __builtin_ffs(s_trace_io[i]); diff --git a/components/esp32/reset_reason.c b/components/esp32/reset_reason.c index 0b291b12c..a0667b6c1 100644 --- a/components/esp32/reset_reason.c +++ b/components/esp32/reset_reason.c @@ -17,7 +17,7 @@ #include "esp_private/system_internal.h" #include "soc/rtc_periph.h" -static void esp_reset_reason_clear_hint(); +static void esp_reset_reason_clear_hint(void); static esp_reset_reason_t s_reset_reason; @@ -119,7 +119,7 @@ esp_reset_reason_t IRAM_ATTR esp_reset_reason_get_hint(void) } return (esp_reset_reason_t) low; } -static void esp_reset_reason_clear_hint() +static void esp_reset_reason_clear_hint(void) { REG_WRITE(RTC_RESET_CAUSE_REG, 0); } diff --git a/components/esp32/sleep_modes.c b/components/esp32/sleep_modes.c index 04179d379..6e6011989 100644 --- a/components/esp32/sleep_modes.c +++ b/components/esp32/sleep_modes.c @@ -89,10 +89,10 @@ static _lock_t lock_rtc_memory_crc; static const char* TAG = "sleep"; -static uint32_t get_power_down_flags(); -static void ext0_wakeup_prepare(); -static void ext1_wakeup_prepare(); -static void timer_wakeup_prepare(); +static uint32_t get_power_down_flags(void); +static void ext0_wakeup_prepare(void); +static void ext1_wakeup_prepare(void); +static void timer_wakeup_prepare(void); /* Wake from deep sleep stub See esp_deepsleep.h esp_wake_deep_sleep() comments for details. @@ -148,14 +148,14 @@ void esp_deep_sleep(uint64_t time_in_us) esp_deep_sleep_start(); } -static void IRAM_ATTR flush_uarts() +static void IRAM_ATTR flush_uarts(void) { for (int i = 0; i < 3; ++i) { uart_tx_wait_idle(i); } } -static void IRAM_ATTR suspend_uarts() +static void IRAM_ATTR suspend_uarts(void) { for (int i = 0; i < 3; ++i) { REG_SET_BIT(UART_FLOW_CONF_REG(i), UART_FORCE_XOFF); @@ -165,7 +165,7 @@ static void IRAM_ATTR suspend_uarts() } } -static void IRAM_ATTR resume_uarts() +static void IRAM_ATTR resume_uarts(void) { for (int i = 0; i < 3; ++i) { REG_CLR_BIT(UART_FLOW_CONF_REG(i), UART_FORCE_XOFF); @@ -222,7 +222,7 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags) return result; } -void IRAM_ATTR esp_deep_sleep_start() +void IRAM_ATTR esp_deep_sleep_start(void) { // record current RTC time s_config.rtc_ticks_at_sleep_start = rtc_time_get(); @@ -277,7 +277,7 @@ static esp_err_t esp_light_sleep_inner(uint32_t pd_flags, return err; } -esp_err_t esp_light_sleep_start() +esp_err_t esp_light_sleep_start(void) { static portMUX_TYPE light_sleep_lock = portMUX_INITIALIZER_UNLOCKED; portENTER_CRITICAL(&light_sleep_lock); @@ -399,7 +399,7 @@ esp_err_t esp_sleep_disable_wakeup_source(esp_sleep_source_t source) return ESP_OK; } -esp_err_t esp_sleep_enable_ulp_wakeup() +esp_err_t esp_sleep_enable_ulp_wakeup(void) { #ifdef CONFIG_ESP32_RTC_EXT_CRYST_ADDIT_CURRENT return ESP_ERR_NOT_SUPPORTED; @@ -423,7 +423,7 @@ esp_err_t esp_sleep_enable_timer_wakeup(uint64_t time_in_us) return ESP_OK; } -static void timer_wakeup_prepare() +static void timer_wakeup_prepare(void) { uint32_t period = esp_clk_slowclk_cal_get(); int64_t sleep_duration = (int64_t) s_config.sleep_duration - (int64_t) s_config.sleep_time_adjustment; @@ -435,7 +435,7 @@ static void timer_wakeup_prepare() rtc_sleep_set_wakeup_time(s_config.rtc_ticks_at_sleep_start + rtc_count_delta); } -esp_err_t esp_sleep_enable_touchpad_wakeup() +esp_err_t esp_sleep_enable_touchpad_wakeup(void) { #ifdef CONFIG_ESP32_RTC_EXT_CRYST_ADDIT_CURRENT return ESP_ERR_NOT_SUPPORTED; @@ -448,7 +448,7 @@ esp_err_t esp_sleep_enable_touchpad_wakeup() return ESP_OK; } -touch_pad_t esp_sleep_get_touchpad_wakeup_status() +touch_pad_t esp_sleep_get_touchpad_wakeup_status(void) { if (esp_sleep_get_wakeup_cause() != ESP_SLEEP_WAKEUP_TOUCHPAD) { return TOUCH_PAD_MAX; @@ -477,7 +477,7 @@ esp_err_t esp_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level) return ESP_OK; } -static void ext0_wakeup_prepare() +static void ext0_wakeup_prepare(void) { int rtc_gpio_num = s_config.ext0_rtc_gpio_num; // Set GPIO to be used for wakeup @@ -520,7 +520,7 @@ esp_err_t esp_sleep_enable_ext1_wakeup(uint64_t mask, esp_sleep_ext1_wakeup_mode return ESP_OK; } -static void ext1_wakeup_prepare() +static void ext1_wakeup_prepare(void) { // Configure all RTC IOs selected as ext1 wakeup inputs uint32_t rtc_gpio_mask = s_config.ext1_rtc_gpio_mask; @@ -556,7 +556,7 @@ static void ext1_wakeup_prepare() s_config.ext1_trigger_mode, RTC_CNTL_EXT_WAKEUP1_LV_S); } -uint64_t esp_sleep_get_ext1_wakeup_status() +uint64_t esp_sleep_get_ext1_wakeup_status(void) { if (esp_sleep_get_wakeup_cause() != ESP_SLEEP_WAKEUP_EXT1) { return 0; @@ -577,7 +577,7 @@ uint64_t esp_sleep_get_ext1_wakeup_status() return gpio_mask; } -esp_err_t esp_sleep_enable_gpio_wakeup() +esp_err_t esp_sleep_enable_gpio_wakeup(void) { if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) { ESP_LOGE(TAG, "Conflicting wake-up triggers: touch / ULP"); @@ -600,7 +600,7 @@ esp_err_t esp_sleep_enable_uart_wakeup(int uart_num) return ESP_OK; } -esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause() +esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause(void) { if (rtc_get_reset_reason(0) != DEEPSLEEP_RESET && !s_light_sleep_wakeup) { return ESP_SLEEP_WAKEUP_UNDEFINED; @@ -636,7 +636,7 @@ esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain, return ESP_OK; } -static uint32_t get_power_down_flags() +static uint32_t get_power_down_flags(void) { // Where needed, convert AUTO options to ON. Later interpret AUTO as OFF. diff --git a/components/esp32/spiram.c b/components/esp32/spiram.c index fc4a9a619..37ae07e2c 100644 --- a/components/esp32/spiram.c +++ b/components/esp32/spiram.c @@ -69,12 +69,12 @@ static bool spiram_inited=false; //If no function in esp_himem.c is used, this function will be linked into the //binary instead of the one in esp_himem.c, automatically making sure no memory //is reserved if no himem function is used. -size_t __attribute__((weak)) esp_himem_reserved_area_size() { +size_t __attribute__((weak)) esp_himem_reserved_area_size(void) { return 0; } -static int spiram_size_usable_for_malloc() +static int spiram_size_usable_for_malloc(void) { int s=esp_spiram_get_size(); if (s>4*1024*1024) s=4*1024*1024; //we can map at most 4MiB @@ -87,7 +87,7 @@ static int spiram_size_usable_for_malloc() true when RAM seems OK, false when test fails. WARNING: Do not run this before the 2nd cpu has been initialized (in a two-core system) or after the heap allocator has taken ownership of the memory. */ -bool esp_spiram_test() +bool esp_spiram_test(void) { volatile int *spiram=(volatile int*)SOC_EXTRAM_DATA_LOW; size_t p; @@ -112,7 +112,7 @@ bool esp_spiram_test() } } -void IRAM_ATTR esp_spiram_init_cache() +void IRAM_ATTR esp_spiram_init_cache(void) { //Enable external RAM in MMU cache_sram_mmu_set( 0, 0, SOC_EXTRAM_DATA_LOW, 0, 32, 128 ); @@ -123,7 +123,7 @@ void IRAM_ATTR esp_spiram_init_cache() #endif } -esp_spiram_size_t esp_spiram_get_chip_size() +esp_spiram_size_t esp_spiram_get_chip_size(void) { if (!spiram_inited) { ESP_EARLY_LOGE(TAG, "SPI RAM not initialized"); @@ -142,7 +142,7 @@ esp_spiram_size_t esp_spiram_get_chip_size() } } -esp_err_t esp_spiram_init() +esp_err_t esp_spiram_init(void) { esp_err_t r; r = psram_enable(PSRAM_SPEED, PSRAM_MODE); @@ -174,7 +174,7 @@ esp_err_t esp_spiram_init() } -esp_err_t esp_spiram_add_to_heapalloc() +esp_err_t esp_spiram_add_to_heapalloc(void) { //Add entire external RAM region to heap allocator. Heap allocator knows the capabilities of this type of memory, so there's //no need to explicitly specify them. @@ -213,7 +213,7 @@ esp_err_t esp_spiram_reserve_dma_pool(size_t size) { return ESP_OK; } -size_t esp_spiram_get_size() +size_t esp_spiram_get_size(void) { psram_size_t size=esp_spiram_get_chip_size(); if (size==PSRAM_SIZE_16MBITS) return 2*1024*1024; @@ -228,7 +228,7 @@ size_t esp_spiram_get_size() Note that this routine assumes some unique mapping for the first 2 banks of the PSRAM memory range, as well as the 2 banks after the 2 MiB mark. */ -void IRAM_ATTR esp_spiram_writeback_cache() +void IRAM_ATTR esp_spiram_writeback_cache(void) { int x; volatile int i=0; @@ -289,7 +289,7 @@ void IRAM_ATTR esp_spiram_writeback_cache() * @return true SPI RAM has been initialized successfully * @return false SPI RAM hasn't been initialized or initialized failed */ -bool esp_spiram_is_initialized() +bool esp_spiram_is_initialized(void) { return spiram_inited; } diff --git a/components/esp32/spiram_psram.c b/components/esp32/spiram_psram.c index ee393618a..1ac19a97d 100644 --- a/components/esp32/spiram_psram.c +++ b/components/esp32/spiram_psram.c @@ -596,7 +596,7 @@ static void IRAM_ATTR psram_gpio_config(psram_io_t *psram_io, psram_cache_mode_t } } -psram_size_t psram_get_size() +psram_size_t psram_get_size(void) { if ((PSRAM_SIZE_ID(s_psram_id) == PSRAM_EID_SIZE_64MBITS) || PSRAM_IS_64MBIT_TRIAL(s_psram_id)) { return PSRAM_SIZE_64MBITS; diff --git a/components/esp32/spiram_psram.h b/components/esp32/spiram_psram.h index 5a5f147bf..14f06cb41 100644 --- a/components/esp32/spiram_psram.h +++ b/components/esp32/spiram_psram.h @@ -53,7 +53,7 @@ typedef enum { * - PSRAM_SIZE_MAX if psram not enabled or not valid * - PSRAM size */ -psram_size_t psram_get_size(); +psram_size_t psram_get_size(void); /** * @brief psram cache enable function diff --git a/components/esp32/system_api.c b/components/esp32/system_api.c index bd81a82db..570c0997a 100644 --- a/components/esp32/system_api.c +++ b/components/esp32/system_api.c @@ -46,7 +46,7 @@ static uint8_t base_mac_addr[6] = { 0 }; #define SHUTDOWN_HANDLERS_NO 2 static shutdown_handler_t shutdown_handlers[SHUTDOWN_HANDLERS_NO]; -void system_init() +void system_init(void) { } @@ -232,7 +232,7 @@ esp_err_t esp_unregister_shutdown_handler(shutdown_handler_t handler) return ESP_ERR_INVALID_STATE; } -void esp_restart_noos() __attribute__ ((noreturn)); +void esp_restart_noos(void) __attribute__ ((noreturn)); void IRAM_ATTR esp_restart(void) { @@ -253,7 +253,7 @@ void IRAM_ATTR esp_restart(void) * core are already stopped. Stalls other core, resets hardware, * triggers restart. */ -void IRAM_ATTR esp_restart_noos() +void IRAM_ATTR esp_restart_noos(void) { // Disable interrupts xt_ints_off(0xFFFFFFFF); diff --git a/components/esp32/task_wdt.c b/components/esp32/task_wdt.c index 86610be94..6675a1a98 100644 --- a/components/esp32/task_wdt.c +++ b/components/esp32/task_wdt.c @@ -104,7 +104,7 @@ static twdt_task_t *find_task_in_twdt_list(TaskHandle_t handle, bool *all_reset) * Resets the hardware timer and has_reset flags of each task on the list. * Called within critical */ -static void reset_hw_timer() +static void reset_hw_timer(void) { //All tasks have reset; time to reset the hardware timer. TIMERG0.wdt_wprotect=TIMG_WDT_WKEY_VALUE; @@ -229,7 +229,7 @@ esp_err_t esp_task_wdt_init(uint32_t timeout, bool panic) return ESP_OK; } -esp_err_t esp_task_wdt_deinit() +esp_err_t esp_task_wdt_deinit(void) { portENTER_CRITICAL(&twdt_spinlock); //TWDT must already be initialized @@ -297,7 +297,7 @@ esp_err_t esp_task_wdt_add(TaskHandle_t handle) return ESP_OK; } -esp_err_t esp_task_wdt_reset() +esp_err_t esp_task_wdt_reset(void) { portENTER_CRITICAL(&twdt_spinlock); //TWDT must already be initialized @@ -385,7 +385,7 @@ esp_err_t esp_task_wdt_status(TaskHandle_t handle) return ESP_ERR_NOT_FOUND; } -void esp_task_wdt_feed() +void esp_task_wdt_feed(void) { portENTER_CRITICAL(&twdt_spinlock); //Return immediately if TWDT has not been initialized diff --git a/components/esp32/test/test_4mpsram.c b/components/esp32/test/test_4mpsram.c index da173a19b..9e8688214 100644 --- a/components/esp32/test/test_4mpsram.c +++ b/components/esp32/test/test_4mpsram.c @@ -7,7 +7,7 @@ static const char TAG[] = "test_psram"; #ifdef CONFIG_ESP32_SPIRAM_SUPPORT -static void test_psram_content() +static void test_psram_content(void) { const int test_size = 2048; uint32_t *test_area = heap_caps_malloc(test_size, MALLOC_CAP_SPIRAM); diff --git a/components/esp32/test/test_ahb_arb.c b/components/esp32/test/test_ahb_arb.c index 185bbb3dd..a4a8f87fd 100644 --- a/components/esp32/test/test_ahb_arb.c +++ b/components/esp32/test/test_ahb_arb.c @@ -31,7 +31,7 @@ to copy bytes over from one memory location to another. DO NOT USE the i2s routi the point where they happened to do what I want. */ -static void lcdIfaceInit() +static void lcdIfaceInit(void) { DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN); DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST); @@ -99,7 +99,7 @@ static void lcdIfaceInit() static volatile lldesc_t dmaDesc[2]; -static void finishDma() +static void finishDma(void) { //No need to finish if no DMA transfer going on if (!(READ_PERI_REG(I2S_FIFO_CONF_REG(0))&I2S_DSCR_EN)) { diff --git a/components/esp32/test/test_esp_timer.c b/components/esp32/test/test_esp_timer.c index e3444503a..52265fb82 100644 --- a/components/esp32/test/test_esp_timer.c +++ b/components/esp32/test/test_esp_timer.c @@ -16,12 +16,12 @@ #define WITH_PROFILING 1 #endif -extern uint32_t esp_timer_impl_get_overflow_val(); +extern uint32_t esp_timer_impl_get_overflow_val(void); extern void esp_timer_impl_set_overflow_val(uint32_t overflow_val); static uint32_t s_old_overflow_val; -static void setup_overflow() +static void setup_overflow(void) { s_old_overflow_val = esp_timer_impl_get_overflow_val(); /* Overflow every 0.1 sec. @@ -31,7 +31,7 @@ static void setup_overflow() esp_timer_impl_set_overflow_val(8000000); } -static void teardown_overflow() +static void teardown_overflow(void) { esp_timer_impl_set_overflow_val(s_old_overflow_val); } @@ -409,7 +409,7 @@ TEST_CASE("esp_timer_get_time call takes less than 1us", "[esp_timer]") TEST_PERFORMANCE_LESS_THAN(ESP_TIMER_GET_TIME_PER_CALL, "%dns", ns_per_call); } -static int64_t IRAM_ATTR __attribute__((noinline)) get_clock_diff() +static int64_t IRAM_ATTR __attribute__((noinline)) get_clock_diff(void) { uint64_t hs_time = esp_timer_get_time(); uint64_t ref_time = ref_clock_get(); diff --git a/components/esp32/test/test_intr_alloc.c b/components/esp32/test/test_intr_alloc.c index 8255388e9..85654c1ae 100644 --- a/components/esp32/test/test_intr_alloc.c +++ b/components/esp32/test/test_intr_alloc.c @@ -144,7 +144,7 @@ void int_timer_handler(void *arg) { int_timer_ctr++; } -void local_timer_test() +void local_timer_test(void) { intr_handle_t ih; esp_err_t r; diff --git a/components/esp32/test/test_pm.c b/components/esp32/test/test_pm.c index cf031ab59..e74a214d7 100644 --- a/components/esp32/test/test_pm.c +++ b/components/esp32/test/test_pm.c @@ -58,7 +58,7 @@ TEST_CASE("Can switch frequency using esp_pm_configure", "[pm]") #if CONFIG_FREERTOS_USE_TICKLESS_IDLE -static void light_sleep_enable() +static void light_sleep_enable(void) { const esp_pm_config_esp32_t pm_config = { .max_cpu_freq = rtc_clk_cpu_freq_get(), @@ -68,7 +68,7 @@ static void light_sleep_enable() ESP_ERROR_CHECK( esp_pm_configure(&pm_config) ); } -static void light_sleep_disable() +static void light_sleep_disable(void) { const esp_pm_config_esp32_t pm_config = { .max_cpu_freq = rtc_clk_cpu_freq_get(), diff --git a/components/esp32/test/test_reset_reason.c b/components/esp32/test/test_reset_reason.c index 78d051358..da03e8c1e 100644 --- a/components/esp32/test/test_reset_reason.c +++ b/components/esp32/test/test_reset_reason.c @@ -24,7 +24,7 @@ static RTC_FAST_ATTR uint32_t s_rtc_force_fast_val; static RTC_SLOW_ATTR uint32_t s_rtc_force_slow_val; -static void setup_values() +static void setup_values(void) { s_noinit_val = CHECK_VALUE; s_rtc_noinit_val = CHECK_VALUE; @@ -44,14 +44,14 @@ TEST_CASE("reset reason ESP_RST_POWERON", "[reset][ignore]") TEST_ASSERT_EQUAL(ESP_RST_POWERON, esp_reset_reason()); } -static void do_deep_sleep() +static void do_deep_sleep(void) { setup_values(); esp_sleep_enable_timer_wakeup(10000); esp_deep_sleep_start(); } -static void check_reset_reason_deep_sleep() +static void check_reset_reason_deep_sleep(void) { TEST_ASSERT_EQUAL(ESP_RST_DEEPSLEEP, esp_reset_reason()); @@ -67,19 +67,19 @@ TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_DEEPSLEEP", "[reset_reason][rese do_deep_sleep, check_reset_reason_deep_sleep); -static void do_exception() +static void do_exception(void) { setup_values(); *(int*) (0x40000001) = 0; } -static void do_abort() +static void do_abort(void) { setup_values(); abort(); } -static void check_reset_reason_panic() +static void check_reset_reason_panic(void) { TEST_ASSERT_EQUAL(ESP_RST_PANIC, esp_reset_reason()); @@ -100,14 +100,14 @@ TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_PANIC after abort", "[reset_reas do_abort, check_reset_reason_panic); -static void do_restart() +static void do_restart(void) { setup_values(); esp_restart(); } #if portNUM_PROCESSORS > 1 -static void do_restart_from_app_cpu() +static void do_restart_from_app_cpu(void) { setup_values(); xTaskCreatePinnedToCore((TaskFunction_t) &do_restart, "restart", 2048, NULL, 5, NULL, 1); @@ -115,7 +115,7 @@ static void do_restart_from_app_cpu() } #endif -static void check_reset_reason_sw() +static void check_reset_reason_sw(void) { TEST_ASSERT_EQUAL(ESP_RST_SW, esp_reset_reason()); @@ -139,21 +139,21 @@ TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_SW after restart from APP CPU", #endif -static void do_int_wdt() +static void do_int_wdt(void) { setup_values(); portENTER_CRITICAL_NESTED(); while(1); } -static void do_int_wdt_hw() +static void do_int_wdt_hw(void) { setup_values(); XTOS_SET_INTLEVEL(XCHAL_NMILEVEL); while(1); } -static void check_reset_reason_int_wdt() +static void check_reset_reason_int_wdt(void) { TEST_ASSERT_EQUAL(ESP_RST_INT_WDT, esp_reset_reason()); TEST_ASSERT_EQUAL_HEX32(CHECK_VALUE, s_rtc_noinit_val); @@ -169,7 +169,7 @@ TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_INT_WDT after interrupt watchdog do_int_wdt_hw, check_reset_reason_int_wdt); -static void do_task_wdt() +static void do_task_wdt(void) { setup_values(); esp_task_wdt_init(1, true); @@ -177,7 +177,7 @@ static void do_task_wdt() while(1); } -static void check_reset_reason_task_wdt() +static void check_reset_reason_task_wdt(void) { TEST_ASSERT_EQUAL(ESP_RST_TASK_WDT, esp_reset_reason()); @@ -195,7 +195,7 @@ TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_TASK_WDT after task watchdog", do_task_wdt, check_reset_reason_task_wdt); -static void do_rtc_wdt() +static void do_rtc_wdt(void) { setup_values(); WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, RTC_CNTL_WDT_WKEY_VALUE); @@ -206,7 +206,7 @@ static void do_rtc_wdt() while(1); } -static void check_reset_reason_any_wdt() +static void check_reset_reason_any_wdt(void) { TEST_ASSERT_EQUAL(ESP_RST_WDT, esp_reset_reason()); TEST_ASSERT_EQUAL_HEX32(CHECK_VALUE, s_rtc_noinit_val); @@ -218,14 +218,14 @@ TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_WDT after RTC watchdog", check_reset_reason_any_wdt); -static void do_brownout() +static void do_brownout(void) { setup_values(); printf("Manual test: lower the supply voltage to cause brownout\n"); vTaskSuspend(NULL); } -static void check_reset_reason_brownout() +static void check_reset_reason_brownout(void) { TEST_ASSERT_EQUAL(ESP_RST_BROWNOUT, esp_reset_reason()); diff --git a/components/esp32/test/test_sleep.c b/components/esp32/test/test_sleep.c index 8712bdfd0..12e268e35 100644 --- a/components/esp32/test/test_sleep.c +++ b/components/esp32/test/test_sleep.c @@ -29,7 +29,7 @@ static void deep_sleep_task(void *arg) esp_deep_sleep_start(); } -static void do_deep_sleep_from_app_cpu() +static void do_deep_sleep_from_app_cpu(void) { xTaskCreatePinnedToCore(&deep_sleep_task, "ds", 2048, NULL, 5, NULL, 1); @@ -204,20 +204,20 @@ TEST_CASE("enter deep sleep on APP CPU and wake up using timer", "[deepsleep][re } #endif -static void do_deep_sleep() +static void do_deep_sleep(void) { esp_sleep_enable_timer_wakeup(100000); esp_deep_sleep_start(); } -static void check_sleep_reset_and_sleep() +static void check_sleep_reset_and_sleep(void) { TEST_ASSERT_EQUAL(ESP_RST_DEEPSLEEP, esp_reset_reason()); esp_sleep_enable_timer_wakeup(100000); esp_deep_sleep_start(); } -static void check_sleep_reset() +static void check_sleep_reset(void) { TEST_ASSERT_EQUAL(ESP_RST_DEEPSLEEP, esp_reset_reason()); } @@ -228,12 +228,12 @@ TEST_CASE_MULTIPLE_STAGES("enter deep sleep more than once", "[deepsleep][reset= check_sleep_reset_and_sleep, check_sleep_reset); -static void do_abort() +static void do_abort(void) { abort(); } -static void check_abort_reset_and_sleep() +static void check_abort_reset_and_sleep(void) { TEST_ASSERT_EQUAL(ESP_RST_PANIC, esp_reset_reason()); esp_sleep_enable_timer_wakeup(100000); @@ -247,20 +247,20 @@ TEST_CASE_MULTIPLE_STAGES("enter deep sleep after abort", "[deepsleep][reset=abo static RTC_DATA_ATTR uint32_t s_wake_stub_var; -static RTC_IRAM_ATTR void wake_stub() +static RTC_IRAM_ATTR void wake_stub(void) { esp_default_wake_deep_sleep(); s_wake_stub_var = (uint32_t) &wake_stub; } -static void prepare_wake_stub() +static void prepare_wake_stub(void) { esp_set_deep_sleep_wake_stub(&wake_stub); esp_sleep_enable_timer_wakeup(100000); esp_deep_sleep_start(); } -static void check_wake_stub() +static void check_wake_stub(void) { TEST_ASSERT_EQUAL(ESP_RST_DEEPSLEEP, esp_reset_reason()); TEST_ASSERT_EQUAL_HEX32((uint32_t) &wake_stub, s_wake_stub_var); @@ -336,7 +336,7 @@ static float get_time_ms(void) return fabs(dt); } -static uint32_t get_cause() +static uint32_t get_cause(void) { uint32_t wakeup_cause = REG_GET_FIELD(RTC_CNTL_WAKEUP_STATE_REG, \ RTC_CNTL_WAKEUP_CAUSE); diff --git a/components/esp32/test/test_stack_check.c b/components/esp32/test/test_stack_check.c index 0fa6c7bfe..abc36047b 100644 --- a/components/esp32/test/test_stack_check.c +++ b/components/esp32/test/test_stack_check.c @@ -2,7 +2,7 @@ #if CONFIG_COMPILER_STACK_CHECK -static void recur_and_smash() +static void recur_and_smash(void) { static int cnt; volatile uint8_t buf[50]; diff --git a/components/esp_adc_cal/esp_adc_cal.c b/components/esp_adc_cal/esp_adc_cal.c index f71c08637..75146b37c 100644 --- a/components/esp_adc_cal/esp_adc_cal.c +++ b/components/esp_adc_cal/esp_adc_cal.c @@ -110,13 +110,13 @@ static const uint32_t lut_adc2_high[LUT_POINTS] = {2657, 2698, 2738, 2774, 2807, 2971, 2996, 3020, 3043, 3067, 3092, 3116, 3139, 3162, 3185}; /* ----------------------- EFuse Access Functions --------------------------- */ -static bool check_efuse_vref() +static bool check_efuse_vref(void) { //Check if Vref is burned in eFuse return (REG_GET_FIELD(VREF_REG, EFUSE_RD_ADC_VREF) != 0) ? true : false; } -static bool check_efuse_tp() +static bool check_efuse_tp(void) { //Check if Two Point values are burned in eFuse if (CHECK_BLK3_FLAG && (REG_GET_FIELD(BLK3_RESERVED_REG, EFUSE_RD_BLK3_PART_RESERVE) == 0)) { @@ -150,7 +150,7 @@ static inline int decode_bits(uint32_t bits, uint32_t mask, bool is_twos_compl) return ret; } -static uint32_t read_efuse_vref() +static uint32_t read_efuse_vref(void) { //eFuse stores deviation from ideal reference voltage uint32_t ret = VREF_OFFSET; //Ideal vref diff --git a/components/esp_common/include/esp_int_wdt.h b/components/esp_common/include/esp_int_wdt.h index f581d939a..87cc23ec1 100644 --- a/components/esp_common/include/esp_int_wdt.h +++ b/components/esp_common/include/esp_int_wdt.h @@ -43,7 +43,7 @@ This uses the TIMERG1 WDT. * is enabled in menuconfig. * */ -void esp_int_wdt_init(); +void esp_int_wdt_init(void); /** * @brief Enable the interrupt watchdog on the current CPU. This is called @@ -51,7 +51,7 @@ void esp_int_wdt_init(); * in menuconfig. * */ -void esp_int_wdt_cpu_init(); +void esp_int_wdt_cpu_init(void); diff --git a/components/esp_common/include/esp_private/crosscore_int.h b/components/esp_common/include/esp_private/crosscore_int.h index 2f1c5b3be..d0e3cadc1 100644 --- a/components/esp_common/include/esp_private/crosscore_int.h +++ b/components/esp_common/include/esp_private/crosscore_int.h @@ -24,7 +24,7 @@ * called automatically by the startup code and should not * be called manually. */ -void esp_crosscore_int_init(); +void esp_crosscore_int_init(void); /** diff --git a/components/esp_common/include/esp_private/esp_timer_impl.h b/components/esp_common/include/esp_private/esp_timer_impl.h index adc98bc42..bee1d0756 100644 --- a/components/esp_common/include/esp_private/esp_timer_impl.h +++ b/components/esp_common/include/esp_private/esp_timer_impl.h @@ -38,7 +38,7 @@ esp_err_t esp_timer_impl_init(intr_handler_t alarm_handler); /** * @brief Deinitialize platform specific layer of esp_timer */ -void esp_timer_impl_deinit(); +void esp_timer_impl_deinit(void); /** * @brief Set up the timer interrupt to fire at a particular time @@ -73,7 +73,7 @@ void esp_timer_impl_advance(int64_t time_us); * @brief Get time, in microseconds, since esp_timer_impl_init was called * @return timestamp in microseconds */ -uint64_t esp_timer_impl_get_time(); +uint64_t esp_timer_impl_get_time(void); /** * @brief Get minimal timer period, in microseconds @@ -83,7 +83,7 @@ uint64_t esp_timer_impl_get_time(); * callback, preventing other tasks from running. * @return minimal period of periodic timer, in microseconds */ -uint64_t esp_timer_impl_get_min_period_us(); +uint64_t esp_timer_impl_get_min_period_us(void); /** * @brief obtain internal critical section used esp_timer implementation @@ -92,10 +92,10 @@ uint64_t esp_timer_impl_get_min_period_us(); * the calls. Should be treated in the same way as a spinlock. * Call esp_timer_impl_unlock to release the lock */ -void esp_timer_impl_lock(); +void esp_timer_impl_lock(void); /** * @brief counterpart of esp_timer_impl_lock */ -void esp_timer_impl_unlock(); +void esp_timer_impl_unlock(void); diff --git a/components/esp_common/include/esp_private/pm_impl.h b/components/esp_common/include/esp_private/pm_impl.h index 134e874e5..f0cf914f7 100644 --- a/components/esp_common/include/esp_private/pm_impl.h +++ b/components/esp_common/include/esp_private/pm_impl.h @@ -80,19 +80,19 @@ void esp_pm_impl_switch_mode(pm_mode_t mode, pm_mode_switch_t lock_or_unlock, pm /** * @brief Call once at startup to initialize pm implementation */ -void esp_pm_impl_init(); +void esp_pm_impl_init(void); /** * @brief Hook function for the idle task * Must be called from the IDLE task on each CPU before entering waiti state. */ -void esp_pm_impl_idle_hook(); +void esp_pm_impl_idle_hook(void); /** * @brief Hook function for the interrupt dispatcher * Must be called soon after entering the ISR */ -void esp_pm_impl_isr_hook(); +void esp_pm_impl_isr_hook(void); /** * @brief Dump the information about time spent in each of the pm modes. @@ -107,14 +107,14 @@ void esp_pm_impl_dump_stats(FILE* out); /** * @brief Hook function implementing `waiti` instruction, should be invoked from idle task context */ -void esp_pm_impl_waiti(); +void esp_pm_impl_waiti(void); #ifdef CONFIG_PM_PROFILING #define WITH_PROFILING #endif #ifdef WITH_PROFILING -static inline pm_time_t IRAM_ATTR pm_get_time() +static inline pm_time_t IRAM_ATTR pm_get_time(void) { return esp_timer_get_time(); } diff --git a/components/esp_common/include/esp_private/pm_trace.h b/components/esp_common/include/esp_private/pm_trace.h index d1cf7e336..24e671907 100644 --- a/components/esp_common/include/esp_private/pm_trace.h +++ b/components/esp_common/include/esp_private/pm_trace.h @@ -26,7 +26,7 @@ typedef enum { ESP_PM_TRACE_TYPE_MAX } esp_pm_trace_event_t; -void esp_pm_trace_init(); +void esp_pm_trace_init(void); void esp_pm_trace_enter(esp_pm_trace_event_t event, int core_id); void esp_pm_trace_exit(esp_pm_trace_event_t event, int core_id); diff --git a/components/esp_common/include/esp_private/system_internal.h b/components/esp_common/include/esp_private/system_internal.h index 5bda73fb7..e0d95d2f7 100644 --- a/components/esp_common/include/esp_private/system_internal.h +++ b/components/esp_common/include/esp_private/system_internal.h @@ -29,7 +29,7 @@ extern "C" { * This is an internal function called by esp_restart. It is called directly * by the panic handler and brownout detector interrupt. */ -void esp_restart_noos() __attribute__ ((noreturn)); +void esp_restart_noos(void) __attribute__ ((noreturn)); /** * @brief Internal function to set reset reason hint diff --git a/components/esp_common/include/esp_task_wdt.h b/components/esp_common/include/esp_task_wdt.h index 60b0e5e5c..554aa3497 100644 --- a/components/esp_common/include/esp_task_wdt.h +++ b/components/esp_common/include/esp_task_wdt.h @@ -56,7 +56,7 @@ esp_err_t esp_task_wdt_init(uint32_t timeout, bool panic); * - ESP_ERR_INVALID_STATE: Error, tasks are still subscribed to the TWDT * - ESP_ERR_NOT_FOUND: Error, TWDT has already been deinitialized */ -esp_err_t esp_task_wdt_deinit(); +esp_err_t esp_task_wdt_deinit(void); /** * @brief Subscribe a task to the Task Watchdog Timer (TWDT) @@ -102,7 +102,7 @@ esp_err_t esp_task_wdt_add(TaskHandle_t handle); * to the TWDT * - ESP_ERR_INVALID_STATE: Error, the TWDT has not been initialized yet */ -esp_err_t esp_task_wdt_reset(); +esp_err_t esp_task_wdt_reset(void); /** * @brief Unsubscribes a task from the Task Watchdog Timer (TWDT) @@ -155,7 +155,7 @@ esp_err_t esp_task_wdt_status(TaskHandle_t handle); * function, then proceed to reset the TWDT on subsequent calls of this * function. */ -void esp_task_wdt_feed() __attribute__ ((deprecated)); +void esp_task_wdt_feed(void) __attribute__ ((deprecated)); #ifdef __cplusplus diff --git a/components/esp_common/include/esp_timer.h b/components/esp_common/include/esp_timer.h index ff5c13ab4..769c9fe29 100644 --- a/components/esp_common/include/esp_timer.h +++ b/components/esp_common/include/esp_timer.h @@ -95,7 +95,7 @@ typedef struct { * - ESP_ERR_INVALID_STATE if already initialized * - other errors from interrupt allocator */ -esp_err_t esp_timer_init(); +esp_err_t esp_timer_init(void); /** * @brief De-initialize esp_timer library @@ -106,7 +106,7 @@ esp_err_t esp_timer_init(); * - ESP_OK on success * - ESP_ERR_INVALID_STATE if not yet initialized */ -esp_err_t esp_timer_deinit(); +esp_err_t esp_timer_deinit(void); /** * @brief Create an esp_timer instance @@ -187,14 +187,14 @@ esp_err_t esp_timer_delete(esp_timer_handle_t timer); * @return number of microseconds since esp_timer_init was called (this normally * happens early during application startup). */ -int64_t esp_timer_get_time(); +int64_t esp_timer_get_time(void); /** * @brief Get the timestamp when the next timeout is expected to occur * @return Timestamp of the nearest timer event, in microseconds. * The timebase is the same as for the values returned by esp_timer_get_time. */ -int64_t esp_timer_get_next_alarm(); +int64_t esp_timer_get_next_alarm(void); /** * @brief Dump the list of timers to a stream diff --git a/components/esp_common/src/dbg_stubs.c b/components/esp_common/src/dbg_stubs.c index 3def85c3f..e0389ce1d 100644 --- a/components/esp_common/src/dbg_stubs.c +++ b/components/esp_common/src/dbg_stubs.c @@ -69,7 +69,7 @@ static void esp_dbg_stubs_data_free(void *addr) ESP_LOGV(TAG, "%s EXIT %p", __func__, addr); } -void esp_dbg_stubs_init() +void esp_dbg_stubs_init(void) { s_dbg_stubs_ctl_data.tramp_addr = (uint32_t)s_stub_code_buf; s_dbg_stubs_ctl_data.min_stack_addr = (uint32_t)s_stub_min_stack; diff --git a/components/esp_common/src/esp_timer.c b/components/esp_common/src/esp_timer.c index 82a2d0b85..034f77fcc 100644 --- a/components/esp_common/src/esp_timer.c +++ b/components/esp_common/src/esp_timer.c @@ -60,12 +60,12 @@ struct esp_timer { LIST_ENTRY(esp_timer) list_entry; }; -static bool is_initialized(); +static bool is_initialized(void); static esp_err_t timer_insert(esp_timer_handle_t timer); static esp_err_t timer_remove(esp_timer_handle_t timer); static bool timer_armed(esp_timer_handle_t timer); -static void timer_list_lock(); -static void timer_list_unlock(); +static void timer_list_lock(void); +static void timer_list_unlock(void); #if WITH_PROFILING static void timer_insert_inactive(esp_timer_handle_t timer); @@ -247,12 +247,12 @@ static IRAM_ATTR bool timer_armed(esp_timer_handle_t timer) return timer->alarm > 0; } -static IRAM_ATTR void timer_list_lock() +static IRAM_ATTR void timer_list_lock(void) { portENTER_CRITICAL(&s_timer_lock); } -static IRAM_ATTR void timer_list_unlock() +static IRAM_ATTR void timer_list_unlock(void) { portEXIT_CRITICAL(&s_timer_lock); } @@ -323,7 +323,7 @@ static void IRAM_ATTR timer_alarm_handler(void* arg) } } -static IRAM_ATTR bool is_initialized() +static IRAM_ATTR bool is_initialized(void) { return s_timer_task != NULL; } @@ -474,7 +474,7 @@ esp_err_t esp_timer_dump(FILE* stream) return ESP_OK; } -int64_t IRAM_ATTR esp_timer_get_next_alarm() +int64_t IRAM_ATTR esp_timer_get_next_alarm(void) { int64_t next_alarm = INT64_MAX; timer_list_lock(); @@ -486,7 +486,7 @@ int64_t IRAM_ATTR esp_timer_get_next_alarm() return next_alarm; } -int64_t IRAM_ATTR esp_timer_get_time() +int64_t IRAM_ATTR esp_timer_get_time(void) { return (int64_t) esp_timer_impl_get_time(); } diff --git a/components/esp_common/src/freertos_hooks.c b/components/esp_common/src/freertos_hooks.c index d60411dc7..58c42b854 100644 --- a/components/esp_common/src/freertos_hooks.c +++ b/components/esp_common/src/freertos_hooks.c @@ -32,7 +32,7 @@ static portMUX_TYPE hooks_spinlock = portMUX_INITIALIZER_UNLOCKED; static esp_freertos_idle_cb_t idle_cb[portNUM_PROCESSORS][MAX_HOOKS]={0}; static esp_freertos_tick_cb_t tick_cb[portNUM_PROCESSORS][MAX_HOOKS]={0}; -void IRAM_ATTR esp_vApplicationTickHook() +void IRAM_ATTR esp_vApplicationTickHook(void) { int n; int core = xPortGetCoreID(); @@ -43,7 +43,7 @@ void IRAM_ATTR esp_vApplicationTickHook() } } -void esp_vApplicationIdleHook() +void esp_vApplicationIdleHook(void) { bool can_go_idle=true; int core = xPortGetCoreID(); diff --git a/components/esp_common/src/ipc.c b/components/esp_common/src/ipc.c index 927db9087..c68a48851 100644 --- a/components/esp_common/src/ipc.c +++ b/components/esp_common/src/ipc.c @@ -82,9 +82,9 @@ static void IRAM_ATTR ipc_task(void* arg) * woken up to execute the callback provided to esp_ipc_call_nonblocking or * esp_ipc_call_blocking. */ -static void esp_ipc_init() __attribute__((constructor)); +static void esp_ipc_init(void) __attribute__((constructor)); -static void esp_ipc_init() +static void esp_ipc_init(void) { s_ipc_mutex = xSemaphoreCreateMutex(); s_ipc_ack = xSemaphoreCreateBinary(); diff --git a/components/esp_event/default_event_loop.c b/components/esp_event/default_event_loop.c index 01418c72a..9b5b8e8b6 100644 --- a/components/esp_event/default_event_loop.c +++ b/components/esp_event/default_event_loop.c @@ -70,7 +70,7 @@ esp_err_t esp_event_isr_post(esp_event_base_t event_base, int32_t event_id, #endif -esp_err_t esp_event_loop_create_default() +esp_err_t esp_event_loop_create_default(void) { if (s_default_loop) { return ESP_ERR_INVALID_STATE; @@ -94,7 +94,7 @@ esp_err_t esp_event_loop_create_default() return ESP_OK; } -esp_err_t esp_event_loop_delete_default() +esp_err_t esp_event_loop_delete_default(void) { if (!s_default_loop) { return ESP_ERR_INVALID_STATE; diff --git a/components/esp_event/esp_event.c b/components/esp_event/esp_event.c index 99a3cf70b..557cfba0d 100644 --- a/components/esp_event/esp_event.c +++ b/components/esp_event/esp_event.c @@ -60,7 +60,7 @@ static portMUX_TYPE s_event_loops_spinlock = portMUX_INITIALIZER_UNLOCKED; #ifdef CONFIG_ESP_EVENT_LOOP_PROFILING -static int esp_event_dump_prepare() +static int esp_event_dump_prepare(void) { esp_event_loop_instance_t* loop_it; esp_event_loop_node_t *loop_node_it; diff --git a/components/esp_event/event_loop_legacy.c b/components/esp_event/event_loop_legacy.c index f5e737d20..3b80387bf 100644 --- a/components/esp_event/event_loop_legacy.c +++ b/components/esp_event/event_loop_legacy.c @@ -76,7 +76,7 @@ esp_err_t esp_event_loop_init(system_event_cb_t cb, void *ctx) return ESP_OK; } -esp_err_t esp_event_loop_deinit() +esp_err_t esp_event_loop_deinit(void) { if (!s_initialized) { ESP_LOGE(TAG, "system event loop not initialized"); diff --git a/components/esp_event/include/esp_event.h b/components/esp_event/include/esp_event.h index c78636415..8282122a0 100644 --- a/components/esp_event/include/esp_event.h +++ b/components/esp_event/include/esp_event.h @@ -74,7 +74,7 @@ esp_err_t esp_event_loop_delete(esp_event_loop_handle_t event_loop); * - ESP_FAIL: Failed to create task loop * - Others: Fail */ -esp_err_t esp_event_loop_create_default(); +esp_err_t esp_event_loop_create_default(void); /** * @brief Delete the default event loop @@ -83,7 +83,7 @@ esp_err_t esp_event_loop_create_default(); * - ESP_OK: Success * - Others: Fail */ -esp_err_t esp_event_loop_delete_default(); +esp_err_t esp_event_loop_delete_default(void); /** * @brief Dispatch events posted to an event loop. diff --git a/components/esp_event/include/esp_event_legacy.h b/components/esp_event/include/esp_event_legacy.h index 44e95546a..9509ce6a7 100644 --- a/components/esp_event/include/esp_event_legacy.h +++ b/components/esp_event/include/esp_event_legacy.h @@ -160,14 +160,14 @@ esp_err_t esp_event_process_default(system_event_t *event); * @note This API is part of the legacy event system. New code should use event library API in esp_event.h * */ -void esp_event_set_default_eth_handlers(); +void esp_event_set_default_eth_handlers(void); /** * @brief Install default event handlers for Wi-Fi interfaces (station and AP) * * @note This API is part of the legacy event system. New code should use event library API in esp_event.h */ -void esp_event_set_default_wifi_handlers(); +void esp_event_set_default_wifi_handlers(void); /** * @brief Application specified event callback function diff --git a/components/esp_event/private_include/esp_event_private.h b/components/esp_event/private_include/esp_event_private.h index 990d51872..d96f66e2d 100644 --- a/components/esp_event/private_include/esp_event_private.h +++ b/components/esp_event/private_include/esp_event_private.h @@ -45,7 +45,7 @@ bool esp_event_is_handler_registered(esp_event_loop_handle_t event_loop, esp_eve * - ESP_OK: Success * - Others: Fail */ -esp_err_t esp_event_loop_deinit(); +esp_err_t esp_event_loop_deinit(void); #ifdef __cplusplus } // extern "C" diff --git a/components/esp_event/test/test_event.c b/components/esp_event/test/test_event.c index 0efc2d492..6560bdc5f 100644 --- a/components/esp_event/test/test_event.c +++ b/components/esp_event/test/test_event.c @@ -103,7 +103,7 @@ enum { TEST_EVENT_BASE2_MAX }; -static BaseType_t test_event_get_core() +static BaseType_t test_event_get_core(void) { static int calls = 0; @@ -114,7 +114,7 @@ static BaseType_t test_event_get_core() } } -static esp_event_loop_args_t test_event_get_default_loop_args() +static esp_event_loop_args_t test_event_get_default_loop_args(void) { esp_event_loop_args_t loop_config = { .queue_size = CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE, @@ -263,13 +263,13 @@ static void test_post_from_handler_loop_task(void* args) } } -static void test_setup() +static void test_setup(void) { TEST_ASSERT_TRUE(TEST_CONFIG_TASKS_TO_SPAWN >= 2); TEST_ASSERT_EQUAL(ESP_OK, esp_event_loop_create_default()); } -static void test_teardown() +static void test_teardown(void) { TEST_ASSERT_EQUAL(ESP_OK, esp_event_loop_delete_default()); } diff --git a/components/esp_gdbstub/esp32/gdbstub_esp32.c b/components/esp_gdbstub/esp32/gdbstub_esp32.c index 3fe393a0d..98a6454ac 100644 --- a/components/esp_gdbstub/esp32/gdbstub_esp32.c +++ b/components/esp_gdbstub/esp32/gdbstub_esp32.c @@ -19,11 +19,11 @@ #define UART_NUM CONFIG_CONSOLE_UART_NUM -void esp_gdbstub_target_init() +void esp_gdbstub_target_init(void) { } -int esp_gdbstub_getchar() +int esp_gdbstub_getchar(void) { while (REG_GET_FIELD(UART_STATUS_REG(UART_NUM), UART_RXFIFO_CNT) == 0) { ; diff --git a/components/esp_gdbstub/private_include/esp_gdbstub_common.h b/components/esp_gdbstub/private_include/esp_gdbstub_common.h index 75674ff02..43c35dcab 100644 --- a/components/esp_gdbstub/private_include/esp_gdbstub_common.h +++ b/components/esp_gdbstub/private_include/esp_gdbstub_common.h @@ -98,13 +98,13 @@ void esp_gdbstub_tcb_to_regfile(TaskHandle_t tcb, esp_gdbstub_gdb_regfile_t *dst * Do target-specific initialization before gdbstub can start communicating. * This may involve, for example, configuring the UART. */ -void esp_gdbstub_target_init(); +void esp_gdbstub_target_init(void); /** * Receive a byte from the GDB client. Blocks until a byte is available. * @return received byte */ -int esp_gdbstub_getchar(); +int esp_gdbstub_getchar(void); /** * Send a byte to the GDB client @@ -123,7 +123,7 @@ int esp_gdbstub_readmem(intptr_t addr); /**** GDB packet related functions ****/ /** Begin a packet */ -void esp_gdbstub_send_start(); +void esp_gdbstub_send_start(void); /** Send a character as part of the packet */ void esp_gdbstub_send_char(char c); @@ -135,7 +135,7 @@ void esp_gdbstub_send_str(const char *s); void esp_gdbstub_send_hex(int val, int bits); /** Finish sending the packet */ -void esp_gdbstub_send_end(); +void esp_gdbstub_send_end(void); /** Send a packet with a string as content */ void esp_gdbstub_send_str_packet(const char* str); diff --git a/components/esp_gdbstub/src/gdbstub.c b/components/esp_gdbstub/src/gdbstub.c index 4d1f4cf54..fbb3d26bf 100644 --- a/components/esp_gdbstub/src/gdbstub.c +++ b/components/esp_gdbstub/src/gdbstub.c @@ -19,12 +19,12 @@ #ifdef CONFIG_ESP_GDBSTUB_SUPPORT_TASKS -static void init_task_info(); -static void find_paniced_task_index(); +static void init_task_info(void); +static void find_paniced_task_index(void); static int handle_task_commands(unsigned char *cmd, int len); #endif -static void send_reason(); +static void send_reason(void); static esp_gdbstub_scratch_t s_scratch; @@ -77,7 +77,7 @@ void esp_gdbstub_panic_handler(esp_gdbstub_frame_t *frame) } -static void send_reason() +static void send_reason(void) { esp_gdbstub_send_start(); esp_gdbstub_send_char('T'); @@ -162,7 +162,7 @@ int esp_gdbstub_handle_command(unsigned char *cmd, int len) #ifdef CONFIG_ESP_GDBSTUB_SUPPORT_TASKS -static void init_task_info() +static void init_task_info(void) { unsigned tcb_size; s_scratch.task_count = uxTaskGetSnapshotAll(s_scratch.tasks, GDBSTUB_TASKS_NUM, &tcb_size); @@ -178,7 +178,7 @@ static bool get_task_handle(size_t index, TaskHandle_t *handle) } /** Get the index of the task running on the current CPU, and save the result */ -static void find_paniced_task_index() +static void find_paniced_task_index(void) { TaskHandle_t cur_handle = xTaskGetCurrentTaskHandleForCPU(xPortGetCoreID()); TaskHandle_t handle; diff --git a/components/esp_gdbstub/src/packet.c b/components/esp_gdbstub/src/packet.c index 9bf0c5d5a..39e0c6883 100644 --- a/components/esp_gdbstub/src/packet.c +++ b/components/esp_gdbstub/src/packet.c @@ -21,7 +21,7 @@ static unsigned char s_cmd[GDBSTUB_CMD_BUFLEN]; static char s_chsum; // Send the start of a packet; reset checksum calculation. -void esp_gdbstub_send_start() +void esp_gdbstub_send_start(void) { s_chsum = 0; esp_gdbstub_putchar('$'); @@ -60,7 +60,7 @@ void esp_gdbstub_send_hex(int val, int bits) } // Finish sending a packet. -void esp_gdbstub_send_end() +void esp_gdbstub_send_end(void) { esp_gdbstub_putchar('#'); esp_gdbstub_send_hex(s_chsum, 8); diff --git a/components/esp_http_client/lib/http_header.c b/components/esp_http_client/lib/http_header.c index b771f6f6e..65d7aa0de 100644 --- a/components/esp_http_client/lib/http_header.c +++ b/components/esp_http_client/lib/http_header.c @@ -37,7 +37,7 @@ typedef struct http_header_item { STAILQ_HEAD(http_header, http_header_item); -http_header_handle_t http_header_init() +http_header_handle_t http_header_init(void) { http_header_handle_t header = calloc(1, sizeof(struct http_header)); HTTP_MEM_CHECK(TAG, header, return NULL); diff --git a/components/esp_http_client/lib/include/http_header.h b/components/esp_http_client/lib/include/http_header.h index 0a1537222..9d8ea3ad8 100644 --- a/components/esp_http_client/lib/include/http_header.h +++ b/components/esp_http_client/lib/include/http_header.h @@ -32,7 +32,7 @@ typedef struct http_header_item *http_header_item_handle_t; * - http_header_handle_t * - NULL if any errors */ -http_header_handle_t http_header_init(); +http_header_handle_t http_header_init(void); /** * @brief Cleanup and free all http header pairs diff --git a/components/esp_http_server/src/httpd_sess.c b/components/esp_http_server/src/httpd_sess.c index c56c22efa..8109475b4 100644 --- a/components/esp_http_server/src/httpd_sess.c +++ b/components/esp_http_server/src/httpd_sess.c @@ -199,7 +199,7 @@ static int fd_is_valid(int fd) return fcntl(fd, F_GETFD) != -1 || errno != EBADF; } -static inline uint64_t httpd_sess_get_lru_counter() +static inline uint64_t httpd_sess_get_lru_counter(void) { static uint64_t lru_counter = 0; return lru_counter++; diff --git a/components/esp_http_server/src/port/esp32/osal.h b/components/esp_http_server/src/port/esp32/osal.h index 84dfb8c27..f59c2bd31 100644 --- a/components/esp_http_server/src/port/esp32/osal.h +++ b/components/esp_http_server/src/port/esp32/osal.h @@ -43,7 +43,7 @@ static inline int httpd_os_thread_create(othread_t *thread, } /* Only self delete is supported */ -static inline void httpd_os_thread_delete() +static inline void httpd_os_thread_delete(void) { vTaskDelete(xTaskGetCurrentTaskHandle()); } @@ -53,7 +53,7 @@ static inline void httpd_os_thread_sleep(int msecs) vTaskDelay(msecs / portTICK_RATE_MS); } -static inline othread_t httpd_os_thread_handle() +static inline othread_t httpd_os_thread_handle(void) { return xTaskGetCurrentTaskHandle(); } diff --git a/components/esp_local_ctrl/include/esp_local_ctrl.h b/components/esp_local_ctrl/include/esp_local_ctrl.h index 53d062b10..9f4f89daa 100644 --- a/components/esp_local_ctrl/include/esp_local_ctrl.h +++ b/components/esp_local_ctrl/include/esp_local_ctrl.h @@ -183,12 +183,12 @@ typedef struct esp_local_ctrl_transport esp_local_ctrl_transport_t; /** * @brief Function for obtaining BLE transport mode */ -const esp_local_ctrl_transport_t *esp_local_ctrl_get_transport_ble(); +const esp_local_ctrl_transport_t *esp_local_ctrl_get_transport_ble(void); /** * @brief Function for obtaining HTTPD transport mode */ -const esp_local_ctrl_transport_t *esp_local_ctrl_get_transport_httpd(); +const esp_local_ctrl_transport_t *esp_local_ctrl_get_transport_httpd(void); #define ESP_LOCAL_CTRL_TRANSPORT_BLE esp_local_ctrl_get_transport_ble() #define ESP_LOCAL_CTRL_TRANSPORT_HTTPD esp_local_ctrl_get_transport_httpd() diff --git a/components/esp_ringbuf/test/test_ringbuf.c b/components/esp_ringbuf/test/test_ringbuf.c index 376b119a7..62ca3c9b1 100644 --- a/components/esp_ringbuf/test/test_ringbuf.c +++ b/components/esp_ringbuf/test/test_ringbuf.c @@ -395,7 +395,7 @@ static void ringbuffer_isr(void *arg) } } -static void setup_timer() +static void setup_timer(void) { //Setup timer for ISR int timer_group = TIMER_GROUP; @@ -416,7 +416,7 @@ static void setup_timer() timer_isr_register(timer_group, timer_idx, ringbuffer_isr, NULL, 0, &ringbuffer_isr_handle); //Set ISR handler } -static void cleanup_timer() +static void cleanup_timer(void) { timer_disable_intr(TIMER_GROUP, TIMER_NUMBER); esp_intr_free(ringbuffer_isr_handle); @@ -570,7 +570,7 @@ static void rec_task(void *args) vTaskDelete(NULL); } -static void setup() +static void setup(void) { ets_printf("Size of test data: %d\n", CONT_DATA_LEN); tx_done = xSemaphoreCreateBinary(); //Semaphore to indicate send is done for a particular iteration @@ -579,7 +579,7 @@ static void setup() srand(SRAND_SEED); //Seed RNG } -static void cleanup() +static void cleanup(void) { //Cleanup vSemaphoreDelete(tx_done); @@ -669,7 +669,7 @@ TEST_CASE("Test static ring buffer SMP", "[esp_ringbuf]") /* -------------------------- Test ring buffer IRAM ------------------------- */ -static IRAM_ATTR __attribute__((noinline)) bool iram_ringbuf_test() +static IRAM_ATTR __attribute__((noinline)) bool iram_ringbuf_test(void) { bool result = true; diff --git a/components/esp_rom/include/esp32/rom/tbconsole.h b/components/esp_rom/include/esp32/rom/tbconsole.h index 891c2732a..d6ca069cc 100644 --- a/components/esp_rom/include/esp32/rom/tbconsole.h +++ b/components/esp_rom/include/esp32/rom/tbconsole.h @@ -18,7 +18,7 @@ extern "C" { #endif -void start_tb_console(); +void start_tb_console(void); #ifdef __cplusplus } diff --git a/components/esp_websocket_client/esp_websocket_client.c b/components/esp_websocket_client/esp_websocket_client.c index a066c288c..cc77267d0 100644 --- a/components/esp_websocket_client/esp_websocket_client.c +++ b/components/esp_websocket_client/esp_websocket_client.c @@ -92,7 +92,7 @@ struct esp_websocket_client { int buffer_size; }; -static uint64_t _tick_get_ms() +static uint64_t _tick_get_ms(void) { return esp_timer_get_time()/1000; } diff --git a/components/esp_wifi/include/esp_phy_init.h b/components/esp_wifi/include/esp_phy_init.h index 6783ff54b..7f06bcb2e 100644 --- a/components/esp_wifi/include/esp_phy_init.h +++ b/components/esp_wifi/include/esp_phy_init.h @@ -103,7 +103,7 @@ typedef enum{ * * @return pointer to PHY init data structure */ -const esp_phy_init_data_t* esp_phy_get_init_data(); +const esp_phy_init_data_t* esp_phy_get_init_data(void); /** * @brief Release PHY init data diff --git a/components/esp_wifi/include/phy.h b/components/esp_wifi/include/phy.h index 37066d00f..1ee3f37dc 100644 --- a/components/esp_wifi/include/phy.h +++ b/components/esp_wifi/include/phy.h @@ -44,7 +44,7 @@ int register_chipv7_phy(const esp_phy_init_data_t* init_data, esp_phy_calibratio * @brief Get the format version of calibration data used by PHY library. * @return Format version number, OR'ed with BIT(16) if PHY is in WIFI only mode. */ -uint32_t phy_get_rf_cal_version(); +uint32_t phy_get_rf_cal_version(void); /** * @brief Set RF/BB for only WIFI mode or coexist(WIFI & BT) mode diff --git a/components/esp_wifi/src/phy_init.c b/components/esp_wifi/src/phy_init.c index b36b5754f..ae8da2f5d 100644 --- a/components/esp_wifi/src/phy_init.c +++ b/components/esp_wifi/src/phy_init.c @@ -376,7 +376,7 @@ esp_err_t esp_modem_sleep_deregister(modem_sleep_module_t module) #if CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION #include "esp_partition.h" -const esp_phy_init_data_t* esp_phy_get_init_data() +const esp_phy_init_data_t* esp_phy_get_init_data(void) { const esp_partition_t* partition = esp_partition_find_first( ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_PHY, NULL); @@ -416,7 +416,7 @@ void esp_phy_release_init_data(const esp_phy_init_data_t* init_data) // phy_init_data.h will declare static 'phy_init_data' variable initialized with default init data -const esp_phy_init_data_t* esp_phy_get_init_data() +const esp_phy_init_data_t* esp_phy_get_init_data(void) { ESP_LOGD(TAG, "loading PHY init data from application binary"); return &phy_init_data; diff --git a/components/esp_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index 6564acc90..5082a77e4 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -39,7 +39,7 @@ wifi_mac_time_update_cb_t s_wifi_mac_time_update_cb = NULL; static const char* TAG = "wifi_init"; -static void __attribute__((constructor)) s_set_default_wifi_log_level() +static void __attribute__((constructor)) s_set_default_wifi_log_level(void) { /* WiFi libraries aren't compiled to know CONFIG_LOG_DEFAULT_LEVEL, so set it at runtime startup. Done here not in esp_wifi_init() to allow @@ -49,7 +49,7 @@ static void __attribute__((constructor)) s_set_default_wifi_log_level() esp_log_level_set("mesh", CONFIG_LOG_DEFAULT_LEVEL); } -static void esp_wifi_set_debug_log() +static void esp_wifi_set_debug_log(void) { /* set WiFi log level and module */ #if CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE diff --git a/components/esp_wifi/test/test_phy_rtc.c b/components/esp_wifi/test/test_phy_rtc.c index 950659924..133a62c35 100644 --- a/components/esp_wifi/test/test_phy_rtc.c +++ b/components/esp_wifi/test/test_phy_rtc.c @@ -15,8 +15,8 @@ //Function just extern, need not test extern void bt_bb_init_cmplx(void); -extern void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu(); -extern void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu(); +extern void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu(void); +extern void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu(void); //Functions in librtc.a called by WIFI or Blutooth directly in ISR extern void bt_bb_init_cmplx_reg(void); diff --git a/components/espcoredump/include/esp_core_dump.h b/components/espcoredump/include/esp_core_dump.h index e19b45c98..0e8020086 100644 --- a/components/espcoredump/include/esp_core_dump.h +++ b/components/espcoredump/include/esp_core_dump.h @@ -27,7 +27,7 @@ * * @note Should be called at system startup. */ -void esp_core_dump_init(); +void esp_core_dump_init(void); /** * @brief Saves core dump to flash. diff --git a/components/espcoredump/include_core_dump/esp_core_dump_priv.h b/components/espcoredump/include_core_dump/esp_core_dump_priv.h index a13dd1707..59568e004 100644 --- a/components/espcoredump/include_core_dump/esp_core_dump_priv.h +++ b/components/espcoredump/include_core_dump/esp_core_dump_priv.h @@ -82,7 +82,7 @@ typedef struct _core_dump_task_header_t #if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH // Core dump flash init function -void esp_core_dump_flash_init(); +void esp_core_dump_flash_init(void); #endif diff --git a/components/espcoredump/src/core_dump_common.c b/components/espcoredump/src/core_dump_common.c index bbd3e29ce..056f3417b 100644 --- a/components/espcoredump/src/core_dump_common.c +++ b/components/espcoredump/src/core_dump_common.c @@ -153,7 +153,7 @@ inline void esp_core_dump_write(void *frame, core_dump_write_config_t *write_cfg #endif -void esp_core_dump_init() +void esp_core_dump_init(void) { #if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH esp_core_dump_flash_init(); diff --git a/components/espcoredump/src/core_dump_flash.c b/components/espcoredump/src/core_dump_flash.c index dd48d5ba8..9c2ac7876 100644 --- a/components/espcoredump/src/core_dump_flash.c +++ b/components/espcoredump/src/core_dump_flash.c @@ -50,7 +50,7 @@ static inline core_dump_crc_t esp_core_dump_calc_flash_config_crc(void) return crc32_le(0, (uint8_t const *)&s_core_flash_config.partition, sizeof(s_core_flash_config.partition)); } -void esp_core_dump_flash_init() +void esp_core_dump_flash_init(void) { const esp_partition_t *core_part; diff --git a/components/espcoredump/src/core_dump_uart.c b/components/espcoredump/src/core_dump_uart.c index d3afbe5d0..2a2aa2d5f 100644 --- a/components/espcoredump/src/core_dump_uart.c +++ b/components/espcoredump/src/core_dump_uart.c @@ -81,7 +81,7 @@ static esp_err_t esp_core_dump_uart_write_data(void *priv, void * data, uint32_t return err; } -static int esp_core_dump_uart_get_char() { +static int esp_core_dump_uart_get_char(void) { int i; uint32_t reg = (READ_PERI_REG(UART_STATUS_REG(0)) >> UART_RXFIFO_CNT_S) & UART_RXFIFO_CNT; if (reg) { diff --git a/components/espcoredump/test/test_core_dump.c b/components/espcoredump/test/test_core_dump.c index 024d2301d..ad6758b67 100644 --- a/components/espcoredump/test/test_core_dump.c +++ b/components/espcoredump/test/test_core_dump.c @@ -20,7 +20,7 @@ volatile unsigned long crash_flags = TCI_UNALIGN_PTR; -void bad_ptr_func() +void bad_ptr_func(void) { unsigned long *ptr = (unsigned long *)0; volatile int cnt = 0; @@ -47,7 +47,7 @@ void bad_ptr_task(void *pvParameter) fflush(stdout); } -void recur_func() +void recur_func(void) { static int rec_cnt; unsigned short *ptr = (unsigned short *)0x5; diff --git a/components/fatfs/test/test_fatfs_rawflash.c b/components/fatfs/test/test_fatfs_rawflash.c index 66412451a..ca949e1ab 100644 --- a/components/fatfs/test/test_fatfs_rawflash.c +++ b/components/fatfs/test/test_fatfs_rawflash.c @@ -60,7 +60,7 @@ static void test_setup(size_t max_files) TEST_ESP_OK(esp_vfs_fat_rawflash_mount("/spiflash", "flash_test", &mount_config)); } -static void test_teardown() +static void test_teardown(void) { TEST_ESP_OK(esp_vfs_fat_rawflash_unmount("/spiflash","flash_test")); } diff --git a/components/fatfs/test/test_fatfs_spiflash.c b/components/fatfs/test/test_fatfs_spiflash.c index f848c31ca..64dbe4ff0 100644 --- a/components/fatfs/test/test_fatfs_spiflash.c +++ b/components/fatfs/test/test_fatfs_spiflash.c @@ -32,7 +32,7 @@ static wl_handle_t s_test_wl_handle; -static void test_setup() +static void test_setup(void) { esp_vfs_fat_sdmmc_mount_config_t mount_config = { .format_if_mount_failed = true, @@ -42,7 +42,7 @@ static void test_setup() TEST_ESP_OK(esp_vfs_fat_spiflash_mount("/spiflash", NULL, &mount_config, &s_test_wl_handle)); } -static void test_teardown() +static void test_teardown(void) { TEST_ESP_OK(esp_vfs_fat_spiflash_unmount("/spiflash", s_test_wl_handle)); } diff --git a/components/fatfs/vfs/esp_vfs_fat.h b/components/fatfs/vfs/esp_vfs_fat.h index a2a05951e..d3f9caa68 100644 --- a/components/fatfs/vfs/esp_vfs_fat.h +++ b/components/fatfs/vfs/esp_vfs_fat.h @@ -63,7 +63,7 @@ esp_err_t esp_vfs_fat_register(const char* base_path, const char* fat_drive, * - ESP_OK on success * - ESP_ERR_INVALID_STATE if FATFS is not registered in VFS */ -esp_err_t esp_vfs_fat_unregister() __attribute__((deprecated)); +esp_err_t esp_vfs_fat_unregister(void) __attribute__((deprecated)); /** * @brief Un-register FATFS from VFS @@ -160,7 +160,7 @@ esp_err_t esp_vfs_fat_sdmmc_mount(const char* base_path, * - ESP_OK on success * - ESP_ERR_INVALID_STATE if esp_vfs_fat_sdmmc_mount hasn't been called */ -esp_err_t esp_vfs_fat_sdmmc_unmount(); +esp_err_t esp_vfs_fat_sdmmc_unmount(void); /** * @brief Convenience function to initialize FAT filesystem in SPI flash and register it in VFS diff --git a/components/fatfs/vfs/vfs_fat.c b/components/fatfs/vfs/vfs_fat.c index 511be8c56..e4be41516 100644 --- a/components/fatfs/vfs/vfs_fat.c +++ b/components/fatfs/vfs/vfs_fat.c @@ -104,7 +104,7 @@ static size_t find_context_index_by_path(const char* base_path) return FF_VOLUMES; } -static size_t find_unused_context_index() +static size_t find_unused_context_index(void) { for(size_t i=0; istart(); // Disables flash cache diff --git a/components/libsodium/test/test_sodium.c b/components/libsodium/test/test_sodium.c index 7a9f096da..5c2e26b23 100644 --- a/components/libsodium/test/test_sodium.c +++ b/components/libsodium/test/test_sodium.c @@ -9,7 +9,7 @@ internal filesystem storage. */ -extern int aead_chacha20poly1305_xmain(); +extern int aead_chacha20poly1305_xmain(void); TEST_CASE("aead_chacha20poly1305 test vectors", "[libsodium]") { @@ -17,7 +17,7 @@ TEST_CASE("aead_chacha20poly1305 test vectors", "[libsodium]") TEST_ASSERT_EQUAL(0, aead_chacha20poly1305_xmain()); } -extern int chacha20_xmain(); +extern int chacha20_xmain(void); TEST_CASE("chacha20 test vectors", "[libsodium]") { @@ -25,8 +25,8 @@ TEST_CASE("chacha20 test vectors", "[libsodium]") TEST_ASSERT_EQUAL(0, chacha20_xmain()); } -extern int box_xmain(); -extern int box2_xmain(); +extern int box_xmain(void); +extern int box2_xmain(void); TEST_CASE("box tests", "[libsodium]") { @@ -37,7 +37,7 @@ TEST_CASE("box tests", "[libsodium]") TEST_ASSERT_EQUAL(0, box2_xmain()); } -extern int ed25519_convert_xmain(); +extern int ed25519_convert_xmain(void); TEST_CASE("ed25519_convert tests", "[libsodium]") { @@ -45,7 +45,7 @@ TEST_CASE("ed25519_convert tests", "[libsodium]") TEST_ASSERT_EQUAL(0, ed25519_convert_xmain() ); } -extern int sign_xmain(); +extern int sign_xmain(void); TEST_CASE("sign tests", "[libsodium]") { @@ -53,7 +53,7 @@ TEST_CASE("sign tests", "[libsodium]") TEST_ASSERT_EQUAL(0, sign_xmain() ); } -extern int hash_xmain(); +extern int hash_xmain(void); TEST_CASE("hash tests", "[libsodium]") { diff --git a/components/log/log.c b/components/log/log.c index c59469cc0..fbbdf2406 100644 --- a/components/log/log.c +++ b/components/log/log.c @@ -104,7 +104,7 @@ static inline void add_to_cache(const char* tag, esp_log_level_t level); static void heap_bubble_down(int index); static inline void heap_swap(int i, int j); static inline bool should_output(esp_log_level_t level_for_message, esp_log_level_t level_for_tag); -static inline void clear_log_level_list(); +static inline void clear_log_level_list(void); vprintf_like_t esp_log_set_vprintf(vprintf_like_t func) { @@ -172,7 +172,7 @@ void esp_log_level_set(const char* tag, esp_log_level_t level) xSemaphoreGive(s_log_mutex); } -void clear_log_level_list() +void clear_log_level_list(void) { uncached_tag_entry_t *it; while((it = SLIST_FIRST(&s_log_tags)) != NULL) { @@ -325,14 +325,14 @@ static inline void heap_swap(int i, int j) //as a workaround before the interface for this variable extern uint32_t g_ticks_per_us_pro; -uint32_t ATTR esp_log_early_timestamp() +uint32_t ATTR esp_log_early_timestamp(void) { return xthal_get_ccount() / (g_ticks_per_us_pro * 1000); } #ifndef BOOTLOADER_BUILD -uint32_t IRAM_ATTR esp_log_timestamp() +uint32_t IRAM_ATTR esp_log_timestamp(void) { if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) { return esp_log_early_timestamp(); @@ -346,7 +346,7 @@ uint32_t IRAM_ATTR esp_log_timestamp() #else -uint32_t esp_log_timestamp() __attribute__((alias("esp_log_early_timestamp"))); +uint32_t esp_log_timestamp(void) __attribute__((alias("esp_log_early_timestamp"))); #endif //BOOTLOADER_BUILD diff --git a/components/lwip/apps/dhcpserver/dhcpserver.c b/components/lwip/apps/dhcpserver/dhcpserver.c index df6a2af02..48adc3b98 100644 --- a/components/lwip/apps/dhcpserver/dhcpserver.c +++ b/components/lwip/apps/dhcpserver/dhcpserver.c @@ -1322,7 +1322,7 @@ dhcps_dns_setserver(const ip_addr_t *dnsserver) * Returns : ip4_addr_t *******************************************************************************/ ip4_addr_t -dhcps_dns_getserver() +dhcps_dns_getserver(void) { return dns_server; } diff --git a/components/lwip/include/apps/dhcpserver/dhcpserver.h b/components/lwip/include/apps/dhcpserver/dhcpserver.h index a6ad51d99..1aef8aaca 100644 --- a/components/lwip/include/apps/dhcpserver/dhcpserver.h +++ b/components/lwip/include/apps/dhcpserver/dhcpserver.h @@ -88,7 +88,7 @@ void *dhcps_option_info(u8_t op_id, u32_t opt_len); void dhcps_set_option_info(u8_t op_id, void *opt_info, u32_t opt_len); bool dhcp_search_ip_on_mac(u8_t *mac, ip4_addr_t *ip); void dhcps_dns_setserver(const ip_addr_t *dnsserver); -ip4_addr_t dhcps_dns_getserver(); +ip4_addr_t dhcps_dns_getserver(void); void dhcps_set_new_lease_cb(dhcps_cb_t cb); #endif diff --git a/components/lwip/port/esp32/include/arch/vfs_lwip.h b/components/lwip/port/esp32/include/arch/vfs_lwip.h index 1957304b9..8a037c6ff 100644 --- a/components/lwip/port/esp32/include/arch/vfs_lwip.h +++ b/components/lwip/port/esp32/include/arch/vfs_lwip.h @@ -16,7 +16,7 @@ extern "C" { #endif -void esp_vfs_lwip_sockets_register(); +void esp_vfs_lwip_sockets_register(void); #ifdef __cplusplus } diff --git a/components/lwip/port/esp32/vfs_lwip.c b/components/lwip/port/esp32/vfs_lwip.c index ffd3e79e1..9ef74784c 100644 --- a/components/lwip/port/esp32/vfs_lwip.c +++ b/components/lwip/port/esp32/vfs_lwip.c @@ -39,7 +39,7 @@ static void lwip_stop_socket_select_isr(void *sem, BaseType_t *woken) } } -static void *lwip_get_socket_select_semaphore() +static void *lwip_get_socket_select_semaphore(void) { /* Calling this from the same process as select() will ensure that the semaphore won't be allocated from * ISR (lwip_stop_socket_select_isr). @@ -57,7 +57,7 @@ static int lwip_ioctl_r_wrapper(int fd, int cmd, va_list args) return lwip_ioctl(fd, cmd, va_arg(args, void *)); } -void esp_vfs_lwip_sockets_register() +void esp_vfs_lwip_sockets_register(void) { esp_vfs_t vfs = { .flags = ESP_VFS_FLAG_DEFAULT, diff --git a/components/lwip/test_afl_host/dhcp_di.h b/components/lwip/test_afl_host/dhcp_di.h index c37a3e1b6..2f3b2cc55 100644 --- a/components/lwip/test_afl_host/dhcp_di.h +++ b/components/lwip/test_afl_host/dhcp_di.h @@ -23,7 +23,7 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_a void (*dhcp_test_static_dhcp_recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) = NULL; -void dhcp_test_init_di() +void dhcp_test_init_di(void) { dhcp_test_static_dhcp_recv = dhcp_recv; } diff --git a/components/lwip/test_afl_host/dhcpserver_di.h b/components/lwip/test_afl_host/dhcpserver_di.h index 48cce58f6..a05a88578 100644 --- a/components/lwip/test_afl_host/dhcpserver_di.h +++ b/components/lwip/test_afl_host/dhcpserver_di.h @@ -13,7 +13,7 @@ static void handle_dhcp(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip void (*dhcp_test_static_handle_hdcp)(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) = NULL; -void dhcp_test_init_di() +void dhcp_test_init_di(void) { dhcp_test_static_handle_hdcp = handle_dhcp; } diff --git a/components/lwip/test_afl_host/dns_di.h b/components/lwip/test_afl_host/dns_di.h index 0479f36a8..a02b464aa 100644 --- a/components/lwip/test_afl_host/dns_di.h +++ b/components/lwip/test_afl_host/dns_di.h @@ -35,7 +35,7 @@ static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr void (*dns_test_static_dns_recv)(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) = NULL; err_t (*dns_test_static_dns_enqueue)(const char *name, size_t hostnamelen, dns_found_callback found, void *callback_arg, u8_t dns_addrtype) = NULL; -void dns_test_init_di() +void dns_test_init_di(void) { dns_test_static_dns_recv = dns_recv; dns_test_static_dns_enqueue = dns_enqueue; diff --git a/components/lwip/test_afl_host/test_dhcp_client.c b/components/lwip/test_afl_host/test_dhcp_client.c index fee5d01b1..681189ea0 100644 --- a/components/lwip/test_afl_host/test_dhcp_client.c +++ b/components/lwip/test_afl_host/test_dhcp_client.c @@ -22,7 +22,7 @@ ip4_addr_t server_ip; // // Dependency injected test functions void dhcp_test_dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); -void dhcp_test_init_di(); +void dhcp_test_init_di(void); // // Test starts here diff --git a/components/lwip/test_afl_host/test_dhcp_server.c b/components/lwip/test_afl_host/test_dhcp_server.c index e19cf28e7..dc8995280 100644 --- a/components/lwip/test_afl_host/test_dhcp_server.c +++ b/components/lwip/test_afl_host/test_dhcp_server.c @@ -14,7 +14,7 @@ void dhcp_test_dhcps_cb (u8_t client_ip[4]) {} // Dependency injected static function to pass the packet into parser void dhcp_test_handle_dhcp(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); -void dhcp_test_init_di(); +void dhcp_test_init_di(void); // // Test starts here diff --git a/components/lwip/test_afl_host/test_dns.c b/components/lwip/test_afl_host/test_dns.c index 1e9a58815..df74d7d86 100644 --- a/components/lwip/test_afl_host/test_dns.c +++ b/components/lwip/test_afl_host/test_dns.c @@ -21,7 +21,7 @@ ip4_addr_t server_ip; void dns_test_dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); void dns_test_inject_port_and_txid(int port, int txid); -void dns_test_init_di(); +void dns_test_init_di(void); err_t dns_test_dns_enqueue(const char *name, size_t hostnamelen, dns_found_callback found, void *callback_arg, u8_t dns_addrtype); // diff --git a/components/mbedtls/port/esp_bignum.c b/components/mbedtls/port/esp_bignum.c index 50e1d9f36..09bb774b9 100644 --- a/components/mbedtls/port/esp_bignum.c +++ b/components/mbedtls/port/esp_bignum.c @@ -73,7 +73,7 @@ static IRAM_ATTR void rsa_complete_isr(void *arg) } } -static void rsa_isr_initialise() +static void rsa_isr_initialise(void) { if (op_complete_sem == NULL) { op_complete_sem = xSemaphoreCreateBinary(); diff --git a/components/mbedtls/test/test_apb_dport_access.c b/components/mbedtls/test/test_apb_dport_access.c index 392effc91..07203ac1e 100644 --- a/components/mbedtls/test/test_apb_dport_access.c +++ b/components/mbedtls/test/test_apb_dport_access.c @@ -17,7 +17,7 @@ static void apb_access_loop_task(void *ignore); static volatile bool apb_access_corrupt; static TaskHandle_t apb_task_handle; -void start_apb_access_loop() +void start_apb_access_loop(void) { apb_access_corrupt = false; xTaskCreatePinnedToCore(apb_access_loop_task, "accessAPB", 2048, NULL, @@ -25,7 +25,7 @@ void start_apb_access_loop() &apb_task_handle, !UNITY_FREERTOS_CPU); } -void verify_apb_access_loop() +void verify_apb_access_loop(void) { vTaskDelete(apb_task_handle); apb_task_handle = NULL; @@ -45,11 +45,11 @@ static void apb_access_loop_task(void *ignore) #else /*CONFIG_FREERTOS_UNICORE */ -void start_apb_access_loop() +void start_apb_access_loop(void) { } -void verify_apb_access_loop() +void verify_apb_access_loop(void) { } diff --git a/components/mbedtls/test/test_apb_dport_access.h b/components/mbedtls/test/test_apb_dport_access.h index a974c2d42..8f30e0465 100644 --- a/components/mbedtls/test/test_apb_dport_access.h +++ b/components/mbedtls/test/test_apb_dport_access.h @@ -10,9 +10,9 @@ Does nothing in unicore mode. */ -void start_apb_access_loop(); +void start_apb_access_loop(void); /* verify_apb_access_loop() kills the task started by start_apb_access_loop() and verifies that none of the APB reads were corrupted by unsafe DPORT reads. */ -void verify_apb_access_loop(); +void verify_apb_access_loop(void); diff --git a/components/mdns/include/mdns.h b/components/mdns/include/mdns.h index 4370969d7..a30534640 100644 --- a/components/mdns/include/mdns.h +++ b/components/mdns/include/mdns.h @@ -85,13 +85,13 @@ typedef struct mdns_result_s { * - ESP_ERR_NO_MEM on memory error * - ESP_FAIL when failed to start mdns task */ -esp_err_t mdns_init(); +esp_err_t mdns_init(void); /** * @brief Stop and free mDNS server * */ -void mdns_free(); +void mdns_free(void); /** * @brief Set the hostname for mDNS server @@ -235,7 +235,7 @@ esp_err_t mdns_service_txt_item_remove(const char * service_type, const char * p * - ESP_OK success * - ESP_ERR_INVALID_ARG Parameter error */ -esp_err_t mdns_service_remove_all(); +esp_err_t mdns_service_remove_all(void); /** * @brief Query mDNS for host or service diff --git a/components/mdns/include/mdns_console.h b/components/mdns/include/mdns_console.h index 5c8b0b5a4..059e03de5 100644 --- a/components/mdns/include/mdns_console.h +++ b/components/mdns/include/mdns_console.h @@ -17,6 +17,6 @@ /** * @brief Register MDNS functions with the console component */ -void mdns_console_register(); +void mdns_console_register(void); #endif /* _MDNS_CONSOLE_H_ */ diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 92909e2de..7331353d2 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -32,7 +32,7 @@ static const char *TAG = "MDNS"; static volatile TaskHandle_t _mdns_service_task_handle = NULL; static SemaphoreHandle_t _mdns_service_semaphore = NULL; -static void _mdns_search_finish_done(); +static void _mdns_search_finish_done(void); static mdns_search_once_t * _mdns_search_find_from(mdns_search_once_t * search, mdns_name_t * name, uint16_t type, tcpip_adapter_if_t tcpip_if, mdns_ip_protocol_t ip_protocol); static void _mdns_search_result_add_ip(mdns_search_once_t * search, const char * hostname, ip_addr_t * ip, tcpip_adapter_if_t tcpip_if, mdns_ip_protocol_t ip_protocol); static void _mdns_search_result_add_srv(mdns_search_once_t * search, const char * hostname, uint16_t port, tcpip_adapter_if_t tcpip_if, mdns_ip_protocol_t ip_protocol); @@ -1010,7 +1010,7 @@ static void _mdns_schedule_tx_packet(mdns_tx_packet_t * packet, uint32_t ms_afte /** * @brief free all packets scheduled for sending */ -static void _mdns_clear_tx_queue_head() +static void _mdns_clear_tx_queue_head(void) { mdns_tx_packet_t * q; while (_mdns_server->tx_queue_head) { @@ -1699,7 +1699,7 @@ static void _mdns_send_final_bye(bool include_ip) /** * @brief Stop the responder on all services without instance */ -static void _mdns_send_bye_all_pcbs_no_instance() +static void _mdns_send_bye_all_pcbs_no_instance(void) { size_t srv_count = 0; mdns_srv_item_t * a = _mdns_server->services; @@ -1727,7 +1727,7 @@ static void _mdns_send_bye_all_pcbs_no_instance() /** * @brief Restart the responder on all services without instance */ -static void _mdns_restart_all_pcbs_no_instance() +static void _mdns_restart_all_pcbs_no_instance(void) { size_t srv_count = 0; mdns_srv_item_t * a = _mdns_server->services; @@ -1755,7 +1755,7 @@ static void _mdns_restart_all_pcbs_no_instance() /** * @brief Restart the responder on all active PCBs */ -static void _mdns_restart_all_pcbs() +static void _mdns_restart_all_pcbs(void) { _mdns_clear_tx_queue_head(); size_t srv_count = 0; @@ -3209,7 +3209,7 @@ static void _mdns_search_add(mdns_search_once_t * search) /** * @brief Called from parser to finish any searches that have reached maximum results */ -static void _mdns_search_finish_done() +static void _mdns_search_finish_done(void) { mdns_search_once_t * search = _mdns_server->search_once; mdns_search_once_t * s = NULL; @@ -3931,7 +3931,7 @@ static esp_err_t _mdns_send_search_action(mdns_action_type_t type, mdns_search_o * if it is scheduled to be transmitted, then pushes the packet to action queue to be handled. * */ -static void _mdns_scheduler_run() +static void _mdns_scheduler_run(void) { MDNS_SERVICE_LOCK(); mdns_tx_packet_t * p = _mdns_server->tx_queue_head; @@ -3966,7 +3966,7 @@ static void _mdns_scheduler_run() /** * @brief Called from timer task to run active searches */ -static void _mdns_search_run() +static void _mdns_search_run(void) { MDNS_SERVICE_LOCK(); mdns_search_once_t * s = _mdns_server->search_once; @@ -4025,7 +4025,7 @@ static void _mdns_timer_cb(void * arg) _mdns_search_run(); } -static esp_err_t _mdns_start_timer(){ +static esp_err_t _mdns_start_timer(void){ esp_timer_create_args_t timer_conf = { .callback = _mdns_timer_cb, .arg = NULL, @@ -4039,7 +4039,7 @@ static esp_err_t _mdns_start_timer(){ return esp_timer_start_periodic(_mdns_server->timer_handle, MDNS_TIMER_PERIOD_US); } -static esp_err_t _mdns_stop_timer(){ +static esp_err_t _mdns_stop_timer(void){ esp_err_t err = ESP_OK; if (_mdns_server->timer_handle) { err = esp_timer_stop(_mdns_server->timer_handle); @@ -4058,7 +4058,7 @@ static esp_err_t _mdns_stop_timer(){ * - ESP_OK on success * - ESP_FAIL on error */ -static esp_err_t _mdns_service_task_start() +static esp_err_t _mdns_service_task_start(void) { if (!_mdns_service_semaphore) { _mdns_service_semaphore = xSemaphoreCreateMutex(); @@ -4091,7 +4091,7 @@ static esp_err_t _mdns_service_task_start() * @return * - ESP_OK */ -static esp_err_t _mdns_service_task_stop() +static esp_err_t _mdns_service_task_stop(void) { _mdns_stop_timer(); if (_mdns_service_task_handle) { @@ -4146,7 +4146,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, } } -esp_err_t mdns_init() +esp_err_t mdns_init(void) { esp_err_t err = ESP_OK; @@ -4222,7 +4222,7 @@ free_server: return err; } -void mdns_free() +void mdns_free(void) { uint8_t i, j; if (!_mdns_server) { @@ -4571,7 +4571,7 @@ esp_err_t mdns_service_remove(const char * service, const char * proto) return ESP_OK; } -esp_err_t mdns_service_remove_all() +esp_err_t mdns_service_remove_all(void) { if (!_mdns_server) { return ESP_ERR_INVALID_ARG; diff --git a/components/mdns/mdns_console.c b/components/mdns/mdns_console.c index 17bffa55b..adbbf0b8f 100644 --- a/components/mdns/mdns_console.c +++ b/components/mdns/mdns_console.c @@ -99,7 +99,7 @@ static int cmd_mdns_query_a(int argc, char** argv) return 0; } -static void register_mdns_query_a() +static void register_mdns_query_a(void) { mdns_query_a_args.hostname = arg_str1(NULL, NULL, "", "Hostname that is searched for"); mdns_query_a_args.timeout = arg_int0("t", "timeout", "", "Timeout for this query"); @@ -156,7 +156,7 @@ static int cmd_mdns_query_aaaa(int argc, char** argv) return 0; } -static void register_mdns_query_aaaa() +static void register_mdns_query_aaaa(void) { mdns_query_a_args.hostname = arg_str1(NULL, NULL, "", "Hostname that is searched for"); mdns_query_a_args.timeout = arg_int0("t", "timeout", "", "Timeout for this query"); @@ -215,7 +215,7 @@ static int cmd_mdns_query_srv(int argc, char** argv) return 0; } -static void register_mdns_query_srv() +static void register_mdns_query_srv(void) { mdns_query_srv_args.instance = arg_str1(NULL, NULL, "", "Instance to search for"); mdns_query_srv_args.service = arg_str1(NULL, NULL, "", "Service to search for (ex. _http, _smb, etc.)"); @@ -277,7 +277,7 @@ static int cmd_mdns_query_txt(int argc, char** argv) return 0; } -static void register_mdns_query_txt() +static void register_mdns_query_txt(void) { mdns_query_txt_args.instance = arg_str1(NULL, NULL, "", "Instance to search for"); mdns_query_txt_args.service = arg_str1(NULL, NULL, "", "Service to search for (ex. _http, _smb, etc.)"); @@ -343,7 +343,7 @@ static int cmd_mdns_query_ptr(int argc, char** argv) return 0; } -static void register_mdns_query_ptr() +static void register_mdns_query_ptr(void) { mdns_query_ptr_args.service = arg_str1(NULL, NULL, "", "Service to search for (ex. _http, _smb, etc.)"); mdns_query_ptr_args.proto = arg_str1(NULL, NULL, "", "Protocol to search for (_tcp, _udp, etc.)"); @@ -412,7 +412,7 @@ static int cmd_mdns_query_ip(int argc, char** argv) return 0; } -static void register_mdns_query_ip() +static void register_mdns_query_ip(void) { mdns_query_ip_args.hostname = arg_str1(NULL, NULL, "", "Hostname that is searched for"); mdns_query_ip_args.timeout = arg_int0("t", "timeout", "", "Timeout for this query"); @@ -479,7 +479,7 @@ static int cmd_mdns_query_svc(int argc, char** argv) return 0; } -static void register_mdns_query_svc() +static void register_mdns_query_svc(void) { mdns_query_svc_args.instance = arg_str1(NULL, NULL, "", "Instance to search for"); mdns_query_svc_args.service = arg_str1(NULL, NULL, "", "Service to search for (ex. _http, _smb, etc.)"); @@ -528,7 +528,7 @@ static int cmd_mdns_init(int argc, char** argv) return 0; } -static void register_mdns_init() +static void register_mdns_init(void) { mdns_init_args.hostname = arg_str0("h", "hostname", "", "Hostname that the server will advertise"); mdns_init_args.instance = arg_str0("i", "instance", "", "Default instance name for services"); @@ -551,7 +551,7 @@ static int cmd_mdns_free(int argc, char** argv) return 0; } -static void register_mdns_free() +static void register_mdns_free(void) { const esp_console_cmd_t cmd_free = { .command = "mdns_free", @@ -586,7 +586,7 @@ static int cmd_mdns_set_hostname(int argc, char** argv) return 0; } -static void register_mdns_set_hostname() +static void register_mdns_set_hostname(void) { mdns_set_hostname_args.hostname = arg_str1(NULL, NULL, "", "Hostname that the server will advertise"); mdns_set_hostname_args.end = arg_end(2); @@ -624,7 +624,7 @@ static int cmd_mdns_set_instance(int argc, char** argv) return 0; } -static void register_mdns_set_instance() +static void register_mdns_set_instance(void) { mdns_set_instance_args.instance = arg_str1(NULL, NULL, "", "Default instance name for services"); mdns_set_instance_args.end = arg_end(2); @@ -733,7 +733,7 @@ static int cmd_mdns_service_add(int argc, char** argv) return 0; } -static void register_mdns_service_add() +static void register_mdns_service_add(void) { mdns_add_args.service = arg_str1(NULL, NULL, "", "MDNS Service"); mdns_add_args.proto = arg_str1(NULL, NULL, "", "IP Protocol"); @@ -776,7 +776,7 @@ static int cmd_mdns_service_remove(int argc, char** argv) return 0; } -static void register_mdns_service_remove() +static void register_mdns_service_remove(void) { mdns_remove_args.service = arg_str1(NULL, NULL, "", "MDNS Service"); mdns_remove_args.proto = arg_str1(NULL, NULL, "", "IP Protocol"); @@ -817,7 +817,7 @@ static int cmd_mdns_service_instance_set(int argc, char** argv) return 0; } -static void register_mdns_service_instance_set() +static void register_mdns_service_instance_set(void) { mdns_service_instance_set_args.service = arg_str1(NULL, NULL, "", "MDNS Service"); mdns_service_instance_set_args.proto = arg_str1(NULL, NULL, "", "IP Protocol"); @@ -858,7 +858,7 @@ static int cmd_mdns_service_port_set(int argc, char** argv) { return 0; } -static void register_mdns_service_port_set() +static void register_mdns_service_port_set(void) { mdns_service_port_set_args.service = arg_str1(NULL, NULL, "", "MDNS Service"); mdns_service_port_set_args.proto = arg_str1(NULL, NULL, "", "IP Protocol"); @@ -910,7 +910,7 @@ static int cmd_mdns_service_txt_replace(int argc, char** argv) return 0; } -static void register_mdns_service_txt_replace() +static void register_mdns_service_txt_replace(void) { mdns_txt_replace_args.service = arg_str1(NULL, NULL, "", "MDNS Service"); mdns_txt_replace_args.proto = arg_str1(NULL, NULL, "", "IP Protocol"); @@ -953,7 +953,7 @@ static int cmd_mdns_service_txt_set(int argc, char** argv) return 0; } -static void register_mdns_service_txt_set() +static void register_mdns_service_txt_set(void) { mdns_txt_set_args.service = arg_str1(NULL, NULL, "", "MDNS Service"); mdns_txt_set_args.proto = arg_str1(NULL, NULL, "", "IP Protocol"); @@ -996,7 +996,7 @@ static int cmd_mdns_service_txt_remove(int argc, char** argv) return 0; } -static void register_mdns_service_txt_remove() +static void register_mdns_service_txt_remove(void) { mdns_txt_remove_args.service = arg_str1(NULL, NULL, "", "MDNS Service"); mdns_txt_remove_args.proto = arg_str1(NULL, NULL, "", "IP Protocol"); @@ -1020,7 +1020,7 @@ static int cmd_mdns_service_remove_all(int argc, char** argv) return 0; } -static void register_mdns_service_remove_all() +static void register_mdns_service_remove_all(void) { const esp_console_cmd_t cmd_free = { .command = "mdns_service_remove_all", @@ -1033,7 +1033,7 @@ static void register_mdns_service_remove_all() ESP_ERROR_CHECK( esp_console_cmd_register(&cmd_free) ); } -void mdns_console_register() +void mdns_console_register(void) { register_mdns_init(); register_mdns_free(); diff --git a/components/mdns/mdns_networking.c b/components/mdns/mdns_networking.c index bb3400f0a..ac69b093d 100644 --- a/components/mdns/mdns_networking.c +++ b/components/mdns/mdns_networking.c @@ -23,7 +23,7 @@ static void _udp_recv(void *arg, struct udp_pcb *upcb, struct pbuf *pb, const ip /** * @brief Low level UDP PCB Initialize */ -static esp_err_t _udp_pcb_main_init() +static esp_err_t _udp_pcb_main_init(void) { if(_pcb_main) { return ESP_OK; @@ -47,7 +47,7 @@ static esp_err_t _udp_pcb_main_init() /** * @brief Low level UDP PCB Free */ -static void _udp_pcb_main_deinit() +static void _udp_pcb_main_deinit(void) { if(_pcb_main){ udp_recv(_pcb_main, NULL, NULL); @@ -177,7 +177,7 @@ static void _udp_recv(void *arg, struct udp_pcb *upcb, struct pbuf *pb, const ip /** * @brief Check if any of the interfaces is up */ -static bool _udp_pcb_is_in_use(){ +static bool _udp_pcb_is_in_use(void){ int i, p; for (i=0; isize); } -extern "C" esp_err_t nvs_flash_erase() +extern "C" esp_err_t nvs_flash_erase(void) { return nvs_flash_erase_partition(NVS_DEFAULT_PART_NAME); } diff --git a/components/openssl/include/internal/ssl_x509.h b/components/openssl/include/internal/ssl_x509.h index 877c4fbb7..e58439724 100644 --- a/components/openssl/include/internal/ssl_x509.h +++ b/components/openssl/include/internal/ssl_x509.h @@ -159,7 +159,7 @@ BIO *BIO_new(void * method); /** * @brief get the memory BIO method function */ -void *BIO_s_mem(); +void *BIO_s_mem(void); /** * @brief free a BIO object diff --git a/components/openssl/library/ssl_x509.c b/components/openssl/library/ssl_x509.c index 0b49bb8fe..91c2a64ef 100644 --- a/components/openssl/library/ssl_x509.c +++ b/components/openssl/library/ssl_x509.c @@ -409,7 +409,7 @@ failed: /** * @brief get the memory BIO method function */ -void *BIO_s_mem() { +void *BIO_s_mem(void) { return NULL; } diff --git a/components/protocomm/include/common/protocomm.h b/components/protocomm/include/common/protocomm.h index cb11a0b13..b5c57992c 100644 --- a/components/protocomm/include/common/protocomm.h +++ b/components/protocomm/include/common/protocomm.h @@ -52,7 +52,7 @@ typedef struct protocomm protocomm_t; * - protocomm_t* : On success * - NULL : No memory for allocating new instance */ -protocomm_t *protocomm_new(); +protocomm_t *protocomm_new(void); /** * @brief Delete a protocomm instance diff --git a/components/protocomm/src/common/protocomm.c b/components/protocomm/src/common/protocomm.c index e55ad7b89..683e36090 100644 --- a/components/protocomm/src/common/protocomm.c +++ b/components/protocomm/src/common/protocomm.c @@ -26,7 +26,7 @@ static const char *TAG = "protocomm"; -protocomm_t *protocomm_new() +protocomm_t *protocomm_new(void) { protocomm_t *pc; diff --git a/components/protocomm/src/simple_ble/simple_ble.c b/components/protocomm/src/simple_ble/simple_ble.c index ff57b9595..e4f2a8f8d 100644 --- a/components/protocomm/src/simple_ble/simple_ble.c +++ b/components/protocomm/src/simple_ble/simple_ble.c @@ -178,7 +178,7 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_ } } -simple_ble_cfg_t *simple_ble_init() +simple_ble_cfg_t *simple_ble_init(void) { simple_ble_cfg_t *ble_cfg_p = (simple_ble_cfg_t *) malloc(sizeof(simple_ble_cfg_t)); if (ble_cfg_p == NULL) { @@ -188,7 +188,7 @@ simple_ble_cfg_t *simple_ble_init() return ble_cfg_p; } -esp_err_t simple_ble_deinit() +esp_err_t simple_ble_deinit(void) { free(g_ble_cfg_p->gatt_db); free(g_ble_cfg_p); @@ -262,7 +262,7 @@ esp_err_t simple_ble_start(simple_ble_cfg_t *cfg) return ESP_OK; } -esp_err_t simple_ble_stop() +esp_err_t simple_ble_stop(void) { esp_err_t err; ESP_LOGD(TAG, "Free mem at start of simple_ble_stop %d", esp_get_free_heap_size()); diff --git a/components/protocomm/src/simple_ble/simple_ble.h b/components/protocomm/src/simple_ble/simple_ble.h index d4f927b61..46f37f6d4 100644 --- a/components/protocomm/src/simple_ble/simple_ble.h +++ b/components/protocomm/src/simple_ble/simple_ble.h @@ -67,7 +67,7 @@ typedef struct { * * @return simple_ble_cfg_t* Pointer to configuration structure */ -simple_ble_cfg_t *simple_ble_init(); +simple_ble_cfg_t *simple_ble_init(void); /** Deallocates memory * @@ -75,7 +75,7 @@ simple_ble_cfg_t *simple_ble_init(); * * @return ESP_OK */ -esp_err_t simple_ble_deinit(); +esp_err_t simple_ble_deinit(void); /** Starts BLE service * @@ -97,7 +97,7 @@ esp_err_t simple_ble_start(simple_ble_cfg_t *cfg); * * @return ESP_OK on success, and appropriate error code for failure */ -esp_err_t simple_ble_stop(); +esp_err_t simple_ble_stop(void); /** Convert handle to 128 bit UUID of characteristic * diff --git a/components/pthread/include/esp_pthread.h b/components/pthread/include/esp_pthread.h index 76f45a32a..6d24d3ea9 100644 --- a/components/pthread/include/esp_pthread.h +++ b/components/pthread/include/esp_pthread.h @@ -41,7 +41,7 @@ typedef struct { * @return * A default configuration structure. */ -esp_pthread_cfg_t esp_pthread_get_default_config(); +esp_pthread_cfg_t esp_pthread_get_default_config(void); /** * @brief Configure parameters for creating pthread diff --git a/components/pthread/pthread.c b/components/pthread/pthread.c index ce0c064ce..40caf9e12 100644 --- a/components/pthread/pthread.c +++ b/components/pthread/pthread.c @@ -168,12 +168,12 @@ esp_err_t esp_pthread_get_cfg(esp_pthread_cfg_t *p) return ESP_ERR_NOT_FOUND; } -static int get_default_pthread_core() +static int get_default_pthread_core(void) { return CONFIG_PTHREAD_TASK_CORE_DEFAULT == -1 ? tskNO_AFFINITY : CONFIG_PTHREAD_TASK_CORE_DEFAULT; } -esp_pthread_cfg_t esp_pthread_get_default_config() +esp_pthread_cfg_t esp_pthread_get_default_config(void) { esp_pthread_cfg_t cfg = { .stack_size = CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT, @@ -822,6 +822,6 @@ int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) } /* Hook function to force linking this file */ -void pthread_include_pthread_impl() +void pthread_include_pthread_impl(void) { } diff --git a/components/pthread/pthread_cond_var.c b/components/pthread/pthread_cond_var.c index 8db28ae5e..bb3a883c4 100644 --- a/components/pthread/pthread_cond_var.c +++ b/components/pthread/pthread_cond_var.c @@ -200,6 +200,6 @@ int pthread_cond_destroy(pthread_cond_t *cv) } /* Hook function to force linking this file */ -void pthread_include_pthread_cond_var_impl() +void pthread_include_pthread_cond_var_impl(void) { } diff --git a/components/pthread/pthread_internal.h b/components/pthread/pthread_internal.h index 6ed2fe45e..a4e4cfd55 100644 --- a/components/pthread/pthread_internal.h +++ b/components/pthread/pthread_internal.h @@ -13,4 +13,4 @@ // limitations under the License. #pragma once -void pthread_internal_local_storage_destructor_callback(); +void pthread_internal_local_storage_destructor_callback(void); diff --git a/components/pthread/pthread_local_storage.c b/components/pthread/pthread_local_storage.c index ecf252e4c..557276847 100644 --- a/components/pthread/pthread_local_storage.c +++ b/components/pthread/pthread_local_storage.c @@ -166,7 +166,7 @@ void __wrap_vPortCleanUpTCB(void *tcb) #endif /* this function called from pthread_task_func for "early" cleanup of TLS in a pthread */ -void pthread_internal_local_storage_destructor_callback() +void pthread_internal_local_storage_destructor_callback(void) { void *tls = pvTaskGetThreadLocalStoragePointer(NULL, PTHREAD_TLS_INDEX); if (tls != NULL) { @@ -257,6 +257,6 @@ int pthread_setspecific(pthread_key_t key, const void *value) } /* Hook function to force linking this file */ -void pthread_include_pthread_local_storage_impl() +void pthread_include_pthread_local_storage_impl(void) { } diff --git a/components/sdmmc/test/test_sd.c b/components/sdmmc/test/test_sd.c index b1b418c95..29ce04a28 100644 --- a/components/sdmmc/test/test_sd.c +++ b/components/sdmmc/test/test_sd.c @@ -48,7 +48,7 @@ #define CD_WP_TEST_GPIO 18 -static void sd_test_board_power_on() +static void sd_test_board_power_on(void) { gpio_set_direction(SD_TEST_BOARD_VSEL_GPIO, GPIO_MODE_OUTPUT); gpio_set_level(SD_TEST_BOARD_VSEL_GPIO, SD_TEST_BOARD_VSEL_3V3); @@ -59,7 +59,7 @@ static void sd_test_board_power_on() usleep(SD_TEST_BOARD_PWR_ON_DELAY_MS * 1000); } -static void sd_test_board_power_off() +static void sd_test_board_power_off(void) { gpio_set_level(SD_TEST_BOARD_VSEL_EN_GPIO, 0); gpio_set_direction(SD_TEST_BOARD_VSEL_GPIO, GPIO_MODE_INPUT); diff --git a/components/sdmmc/test/test_sdio.c b/components/sdmmc/test/test_sdio.c index 56213d713..0e5be1d6f 100644 --- a/components/sdmmc/test/test_sdio.c +++ b/components/sdmmc/test/test_sdio.c @@ -126,7 +126,7 @@ static esp_err_t slave_slc_reg_write(sdmmc_card_t* card, uint32_t addr, uint32_t } /** Reset and put slave into download mode */ -static void reset_slave() +static void reset_slave(void) { const int pin_en = 18; const int pin_io0 = 19; diff --git a/components/soc/esp32/cpu_util.c b/components/soc/esp32/cpu_util.c index 83ae830b9..ed2c6361e 100644 --- a/components/soc/esp32/cpu_util.c +++ b/components/soc/esp32/cpu_util.c @@ -50,7 +50,7 @@ void IRAM_ATTR esp_cpu_reset(int cpu_id) cpu_id == 0 ? RTC_CNTL_SW_PROCPU_RST_M : RTC_CNTL_SW_APPCPU_RST_M); } -bool IRAM_ATTR esp_cpu_in_ocd_debug_mode() +bool IRAM_ATTR esp_cpu_in_ocd_debug_mode(void) { #if CONFIG_ESP32_DEBUG_OCDAWARE int dcr; diff --git a/components/soc/esp32/include/soc/cpu.h b/components/soc/esp32/include/soc/cpu.h index 190786a43..57ccd6e17 100644 --- a/components/soc/esp32/include/soc/cpu.h +++ b/components/soc/esp32/include/soc/cpu.h @@ -30,7 +30,7 @@ /** @brief Read current stack pointer address * */ -static inline void *get_sp() +static inline void *get_sp(void) { void *sp; asm volatile ("mov %0, sp;" : "=r" (sp)); @@ -52,7 +52,7 @@ static inline void cpu_write_itlb(unsigned vpn, unsigned attr) asm volatile ("witlb %1, %0; isync\n" :: "r" (vpn), "r" (attr)); } -static inline void cpu_init_memctl() +static inline void cpu_init_memctl(void) { #if XCHAL_ERRATUM_572 uint32_t memctl = XCHAL_CACHE_MEMCTL_DEFAULT; @@ -71,7 +71,7 @@ static inline void cpu_init_memctl() * 15 — no access, raise exception */ -static inline void cpu_configure_region_protection() +static inline void cpu_configure_region_protection(void) { const uint32_t pages_to_protect[] = {0x00000000, 0x80000000, 0xa0000000, 0xc0000000, 0xe0000000}; for (int i = 0; i < sizeof(pages_to_protect)/sizeof(pages_to_protect[0]); ++i) { @@ -108,7 +108,7 @@ void esp_cpu_reset(int cpu_id); * @note If "Make exception and panic handlers JTAG/OCD aware" * is disabled, this function always returns false. */ -bool esp_cpu_in_ocd_debug_mode(); +bool esp_cpu_in_ocd_debug_mode(void); /** * @brief Convert the PC register value to its true address diff --git a/components/soc/esp32/include/soc/rtc.h b/components/soc/esp32/include/soc/rtc.h index 4dd0db6e2..22d3601d3 100644 --- a/components/soc/esp32/include/soc/rtc.h +++ b/components/soc/esp32/include/soc/rtc.h @@ -176,7 +176,7 @@ void rtc_clk_init(rtc_clk_config_t cfg); * * @return XTAL frequency, one of rtc_xtal_freq_t */ -rtc_xtal_freq_t rtc_clk_xtal_freq_get(); +rtc_xtal_freq_t rtc_clk_xtal_freq_get(void); /** * @brief Update XTAL frequency @@ -197,13 +197,13 @@ void rtc_clk_32k_enable(bool en); /** * @brief Configure 32 kHz XTAL oscillator to accept external clock signal */ -void rtc_clk_32k_enable_external(); +void rtc_clk_32k_enable_external(void); /** * @brief Get the state of 32k XTAL oscillator * @return true if 32k XTAL oscillator has been enabled */ -bool rtc_clk_32k_enabled(); +bool rtc_clk_32k_enabled(void); /** * @brief Enable 32k oscillator, configuring it for fast startup time. @@ -239,13 +239,13 @@ void rtc_clk_8m_enable(bool clk_8m_en, bool d256_en); * @brief Get the state of 8 MHz internal oscillator * @return true if the oscillator is enabled */ -bool rtc_clk_8m_enabled(); +bool rtc_clk_8m_enabled(void); /** * @brief Get the state of /256 divider which is applied to 8MHz clock * @return true if the divided output is enabled */ -bool rtc_clk_8md256_enabled(); +bool rtc_clk_8md256_enabled(void); /** * @brief Enable or disable APLL @@ -276,7 +276,7 @@ void rtc_clk_slow_freq_set(rtc_slow_freq_t slow_freq); * @brief Get the RTC_SLOW_CLK source * @return currently selected clock source (one of rtc_slow_freq_t values) */ -rtc_slow_freq_t rtc_clk_slow_freq_get(); +rtc_slow_freq_t rtc_clk_slow_freq_get(void); /** * @brief Get the approximate frequency of RTC_SLOW_CLK, in Hz @@ -290,7 +290,7 @@ rtc_slow_freq_t rtc_clk_slow_freq_get(); * * @return RTC_SLOW_CLK frequency, in Hz */ -uint32_t rtc_clk_slow_freq_get_hz(); +uint32_t rtc_clk_slow_freq_get_hz(void); /** * @brief Select source for RTC_FAST_CLK @@ -302,7 +302,7 @@ void rtc_clk_fast_freq_set(rtc_fast_freq_t fast_freq); * @brief Get the RTC_FAST_CLK source * @return currently selected clock source (one of rtc_fast_freq_t values) */ -rtc_fast_freq_t rtc_clk_fast_freq_get(); +rtc_fast_freq_t rtc_clk_fast_freq_get(void); /** * @brief Switch CPU frequency @@ -355,7 +355,7 @@ void rtc_clk_cpu_freq_set_fast(rtc_cpu_freq_t cpu_freq) __attribute__((deprecate * * @return CPU frequency (one of rtc_cpu_freq_t values) */ -rtc_cpu_freq_t rtc_clk_cpu_freq_get() __attribute__((deprecated)); +rtc_cpu_freq_t rtc_clk_cpu_freq_get(void) __attribute__((deprecated)); /** * @brief Get corresponding frequency value for rtc_cpu_freq_t enum value @@ -444,7 +444,7 @@ uint32_t rtc_clk_cpu_freq_value(rtc_cpu_freq_t cpu_freq) __attribute__((depreca * rtc_clk_cpu_freq_set_config when a switch to XTAL is needed. * Assumes that XTAL frequency has been determined — don't call in startup code. */ - void rtc_clk_cpu_freq_set_xtal(); + void rtc_clk_cpu_freq_set_xtal(void); /** @@ -465,7 +465,7 @@ void rtc_clk_apb_freq_update(uint32_t apb_freq); * @brief Get the current stored APB frequency. * @return The APB frequency value as last set via rtc_clk_apb_freq_update(), in Hz. */ -uint32_t rtc_clk_apb_freq_get(); +uint32_t rtc_clk_apb_freq_get(void); #define RTC_CLK_CAL_FRACT 19 //!< Number of fractional bits in values returned by rtc_clk_cal @@ -522,7 +522,7 @@ uint64_t rtc_time_slowclk_to_us(uint64_t rtc_cycles, uint32_t period); * * @return current value of RTC counter */ -uint64_t rtc_time_get(); +uint64_t rtc_time_get(void); /** * @brief Busy loop until next RTC_SLOW_CLK cycle @@ -531,7 +531,7 @@ uint64_t rtc_time_get(); * In some cases (e.g. when RTC_SLOW_CLK cycle is very close), it may return * one RTC_SLOW_CLK cycle later. */ -void rtc_clk_wait_for_slow_cycle(); +void rtc_clk_wait_for_slow_cycle(void); /** * @brief sleep configuration for rtc_sleep_init function @@ -710,7 +710,7 @@ typedef struct rtc_vddsdio_config_s { * Otherwise, use default values and the level of MTDI bootstrapping pin. * @return currently used VDDSDIO configuration */ -rtc_vddsdio_config_t rtc_vddsdio_get_config(); +rtc_vddsdio_config_t rtc_vddsdio_get_config(void); /** * Set new VDDSDIO configuration using RTC registers. diff --git a/components/soc/esp32/rtc_clk.c b/components/soc/esp32/rtc_clk.c index 80a749b22..42640b32f 100644 --- a/components/soc/esp32/rtc_clk.c +++ b/components/soc/esp32/rtc_clk.c @@ -100,9 +100,9 @@ #define RTC_PLL_FREQ_320M 320 #define RTC_PLL_FREQ_480M 480 -static void rtc_clk_cpu_freq_to_8m(); -static void rtc_clk_bbpll_disable(); -static void rtc_clk_bbpll_enable(); +static void rtc_clk_cpu_freq_to_8m(void); +static void rtc_clk_bbpll_disable(void); +static void rtc_clk_bbpll_enable(void); static void rtc_clk_cpu_freq_to_pll_mhz(int cpu_freq_mhz); static bool rtc_clk_cpu_freq_from_mhz_internal(int mhz, rtc_cpu_freq_t* out_val); @@ -161,7 +161,7 @@ void rtc_clk_32k_enable(bool enable) } } -void rtc_clk_32k_enable_external() +void rtc_clk_32k_enable_external(void) { rtc_clk_32k_enable_common(XTAL_32K_EXT_DAC_VAL, XTAL_32K_EXT_DRES_VAL, XTAL_32K_EXT_DBIAS_VAL); } @@ -201,7 +201,7 @@ void rtc_clk_32k_bootstrap(uint32_t cycle) XTAL_32K_BOOTSTRAP_DRES_VAL, XTAL_32K_BOOTSTRAP_DBIAS_VAL); } -bool rtc_clk_32k_enabled() +bool rtc_clk_32k_enabled(void) { return GET_PERI_REG_MASK(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_XPD_XTAL_32K) != 0; } @@ -224,12 +224,12 @@ void rtc_clk_8m_enable(bool clk_8m_en, bool d256_en) } } -bool rtc_clk_8m_enabled() +bool rtc_clk_8m_enabled(void) { return GET_PERI_REG_MASK(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_ENB_CK8M) == 0; } -bool rtc_clk_8md256_enabled() +bool rtc_clk_8md256_enabled(void) { return GET_PERI_REG_MASK(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_ENB_CK8M_DIV) == 0; } @@ -284,12 +284,12 @@ void rtc_clk_slow_freq_set(rtc_slow_freq_t slow_freq) ets_delay_us(DELAY_SLOW_CLK_SWITCH); } -rtc_slow_freq_t rtc_clk_slow_freq_get() +rtc_slow_freq_t rtc_clk_slow_freq_get(void) { return REG_GET_FIELD(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_ANA_CLK_RTC_SEL); } -uint32_t rtc_clk_slow_freq_get_hz() +uint32_t rtc_clk_slow_freq_get_hz(void) { switch(rtc_clk_slow_freq_get()) { case RTC_SLOW_FREQ_RTC: return RTC_SLOW_CLK_FREQ_150K; @@ -305,7 +305,7 @@ void rtc_clk_fast_freq_set(rtc_fast_freq_t fast_freq) ets_delay_us(DELAY_FAST_CLK_SWITCH); } -rtc_fast_freq_t rtc_clk_fast_freq_get() +rtc_fast_freq_t rtc_clk_fast_freq_get(void) { return REG_GET_FIELD(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_FAST_CLK_RTC_SEL); } @@ -435,7 +435,7 @@ void rtc_clk_cpu_freq_to_xtal(int freq, int div) } } -static void rtc_clk_cpu_freq_to_8m() +static void rtc_clk_cpu_freq_to_8m(void) { ets_update_cpu_frequency(8); REG_SET_FIELD(RTC_CNTL_REG, RTC_CNTL_DIG_DBIAS_WAK, DIG_DBIAS_XTAL); @@ -444,7 +444,7 @@ static void rtc_clk_cpu_freq_to_8m() rtc_clk_apb_freq_update(RTC_FAST_CLK_FREQ_8M); } -static void rtc_clk_bbpll_disable() +static void rtc_clk_bbpll_disable(void) { SET_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_BB_I2C_FORCE_PD | RTC_CNTL_BBPLL_FORCE_PD | @@ -459,7 +459,7 @@ static void rtc_clk_bbpll_disable() } } -static void rtc_clk_bbpll_enable() +static void rtc_clk_bbpll_enable(void) { CLEAR_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_BIAS_I2C_FORCE_PD | RTC_CNTL_BB_I2C_FORCE_PD | @@ -516,7 +516,7 @@ void rtc_clk_cpu_freq_set_fast(rtc_cpu_freq_t cpu_freq) rtc_clk_cpu_freq_set_config_fast(&config); } -void rtc_clk_cpu_freq_set_xtal() +void rtc_clk_cpu_freq_set_xtal(void) { int freq_mhz = (int) rtc_clk_xtal_freq_get(); @@ -525,7 +525,7 @@ void rtc_clk_cpu_freq_set_xtal() rtc_clk_bbpll_disable(); } -rtc_cpu_freq_t rtc_clk_cpu_freq_get() +rtc_cpu_freq_t rtc_clk_cpu_freq_get(void) { rtc_cpu_freq_config_t config; rtc_clk_cpu_freq_get_config(&config); @@ -766,7 +766,7 @@ void rtc_clk_cpu_freq_set_config_fast(const rtc_cpu_freq_config_t* config) } } -rtc_xtal_freq_t rtc_clk_xtal_freq_get() +rtc_xtal_freq_t rtc_clk_xtal_freq_get(void) { /* We may have already written XTAL value into RTC_XTAL_FREQ_REG */ uint32_t xtal_freq_reg = READ_PERI_REG(RTC_XTAL_FREQ_REG); @@ -790,7 +790,7 @@ void rtc_clk_apb_freq_update(uint32_t apb_freq) WRITE_PERI_REG(RTC_APB_FREQ_REG, clk_val_to_reg_val(apb_freq >> 12)); } -uint32_t rtc_clk_apb_freq_get() +uint32_t rtc_clk_apb_freq_get(void) { uint32_t freq_hz = reg_val_to_clk_val(READ_PERI_REG(RTC_APB_FREQ_REG)) << 12; // round to the nearest MHz @@ -802,4 +802,4 @@ uint32_t rtc_clk_apb_freq_get() /* Name used in libphy.a:phy_chip_v7.o * TODO: update the library to use rtc_clk_xtal_freq_get */ -rtc_xtal_freq_t rtc_get_xtal() __attribute__((alias("rtc_clk_xtal_freq_get"))); +rtc_xtal_freq_t rtc_get_xtal(void) __attribute__((alias("rtc_clk_xtal_freq_get"))); diff --git a/components/soc/esp32/rtc_clk_init.c b/components/soc/esp32/rtc_clk_init.c index a675d53f3..d1f128ffa 100644 --- a/components/soc/esp32/rtc_clk_init.c +++ b/components/soc/esp32/rtc_clk_init.c @@ -36,7 +36,7 @@ */ #define XTAL_FREQ_EST_CYCLES 10 -static rtc_xtal_freq_t rtc_clk_xtal_freq_estimate(); +static rtc_xtal_freq_t rtc_clk_xtal_freq_estimate(void); static const char* TAG = "rtc_clk_init"; @@ -140,7 +140,7 @@ void rtc_clk_init(rtc_clk_config_t cfg) rtc_clk_slow_freq_set(cfg.slow_freq); } -static rtc_xtal_freq_t rtc_clk_xtal_freq_estimate() +static rtc_xtal_freq_t rtc_clk_xtal_freq_estimate(void) { /* Enable 8M/256 clock if needed */ const bool clk_8m_enabled = rtc_clk_8m_enabled(); diff --git a/components/soc/esp32/rtc_init.c b/components/soc/esp32/rtc_init.c index e0cd4ba4a..942b9409a 100644 --- a/components/soc/esp32/rtc_init.c +++ b/components/soc/esp32/rtc_init.c @@ -97,7 +97,7 @@ void rtc_init(rtc_config_t cfg) } } -rtc_vddsdio_config_t rtc_vddsdio_get_config() +rtc_vddsdio_config_t rtc_vddsdio_get_config(void) { rtc_vddsdio_config_t result; uint32_t sdio_conf_reg = REG_READ(RTC_CNTL_SDIO_CONF_REG); diff --git a/components/soc/esp32/rtc_pm.c b/components/soc/esp32/rtc_pm.c index f951ee107..47baedf95 100644 --- a/components/soc/esp32/rtc_pm.c +++ b/components/soc/esp32/rtc_pm.c @@ -29,14 +29,14 @@ typedef enum{ /* These MAC-related functions are defined in the closed source part of * RTC library */ -extern void pm_mac_init(); -extern int pm_check_mac_idle(); -extern void pm_mac_deinit(); +extern void pm_mac_init(void); +extern int pm_check_mac_idle(void); +extern void pm_mac_deinit(void); /* This sleep-related function is called from the closed source part of RTC * library. */ -pm_sw_reject_t pm_set_sleep_mode(pm_sleep_mode_t sleep_mode, void(*pmac_save_params)()) +pm_sw_reject_t pm_set_sleep_mode(pm_sleep_mode_t sleep_mode, void(*pmac_save_params)(void)) { (void) pmac_save_params; /* unused */ diff --git a/components/soc/esp32/rtc_time.c b/components/soc/esp32/rtc_time.c index e64477564..a7dfdb248 100644 --- a/components/soc/esp32/rtc_time.c +++ b/components/soc/esp32/rtc_time.c @@ -140,7 +140,7 @@ uint64_t rtc_time_slowclk_to_us(uint64_t rtc_cycles, uint32_t period) return (rtc_cycles * period) >> RTC_CLK_CAL_FRACT; } -uint64_t rtc_time_get() +uint64_t rtc_time_get(void) { SET_PERI_REG_MASK(RTC_CNTL_TIME_UPDATE_REG, RTC_CNTL_TIME_UPDATE); while (GET_PERI_REG_MASK(RTC_CNTL_TIME_UPDATE_REG, RTC_CNTL_TIME_VALID) == 0) { @@ -152,7 +152,7 @@ uint64_t rtc_time_get() return t; } -void rtc_clk_wait_for_slow_cycle() +void rtc_clk_wait_for_slow_cycle(void) { REG_CLR_BIT(TIMG_RTCCALICFG_REG(0), TIMG_RTC_CALI_START_CYCLING | TIMG_RTC_CALI_START); REG_CLR_BIT(TIMG_RTCCALICFG_REG(0), TIMG_RTC_CALI_RDY); diff --git a/components/soc/esp32/rtc_wdt.c b/components/soc/esp32/rtc_wdt.c index 1b01ce304..facf8d444 100644 --- a/components/soc/esp32/rtc_wdt.c +++ b/components/soc/esp32/rtc_wdt.c @@ -16,34 +16,34 @@ #include "soc/rtc.h" -bool rtc_wdt_get_protect_status() +bool rtc_wdt_get_protect_status(void) { return READ_PERI_REG(RTC_CNTL_WDTWPROTECT_REG) != RTC_CNTL_WDT_WKEY_VALUE; } -void rtc_wdt_protect_off() +void rtc_wdt_protect_off(void) { WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, RTC_CNTL_WDT_WKEY_VALUE); } -void rtc_wdt_protect_on() +void rtc_wdt_protect_on(void) { WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, 0); } -void rtc_wdt_enable() +void rtc_wdt_enable(void) { REG_SET_BIT(RTC_CNTL_WDTFEED_REG, RTC_CNTL_WDT_FEED); SET_PERI_REG_MASK(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_EN | RTC_CNTL_WDT_PAUSE_IN_SLP); } -void rtc_wdt_flashboot_mode_enable() +void rtc_wdt_flashboot_mode_enable(void) { REG_SET_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_FLASHBOOT_MOD_EN); } -void rtc_wdt_disable() +void rtc_wdt_disable(void) { bool protect = rtc_wdt_get_protect_status(); if (protect) { @@ -61,7 +61,7 @@ void rtc_wdt_disable() } } -void rtc_wdt_feed() +void rtc_wdt_feed(void) { bool protect = rtc_wdt_get_protect_status(); if (protect) { @@ -145,7 +145,7 @@ esp_err_t rtc_wdt_set_length_of_reset_signal(rtc_wdt_reset_sig_t reset_src, rtc_ return ESP_OK; } -bool rtc_wdt_is_on() +bool rtc_wdt_is_on(void) { return (REG_GET_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_EN) != 0) || (REG_GET_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_FLASHBOOT_MOD_EN) != 0); } diff --git a/components/soc/esp32/test/test_rtc_clk.c b/components/soc/esp32/test/test_rtc_clk.c index 698303558..1c21a1af1 100644 --- a/components/soc/esp32/test/test_rtc_clk.c +++ b/components/soc/esp32/test/test_rtc_clk.c @@ -141,7 +141,7 @@ TEST_CASE("Test fast switching between PLL and XTAL", "[rtc_clk]") #define COUNT_TEST 3 #define TIMEOUT_TEST_MS (5 + CONFIG_ESP32_RTC_CLK_CAL_CYCLES / 16) -void stop_rtc_external_quartz(){ +void stop_rtc_external_quartz(void){ const uint8_t pin_32 = 32; const uint8_t pin_33 = 33; const uint8_t mask_32 = (1 << (pin_32 - 32)); diff --git a/components/soc/include/soc/rtc_wdt.h b/components/soc/include/soc/rtc_wdt.h index aae54530a..0ed2c9a7b 100644 --- a/components/soc/include/soc/rtc_wdt.h +++ b/components/soc/include/soc/rtc_wdt.h @@ -99,22 +99,22 @@ typedef enum { * @return * - True if the protect of RTC_WDT is set */ -bool rtc_wdt_get_protect_status(); +bool rtc_wdt_get_protect_status(void); /** * @brief Set protect of rtc_wdt. */ -void rtc_wdt_protect_on(); +void rtc_wdt_protect_on(void); /** * @brief Reset protect of rtc_wdt. */ -void rtc_wdt_protect_off(); +void rtc_wdt_protect_off(void); /** * @brief Enable rtc_wdt. */ -void rtc_wdt_enable(); +void rtc_wdt_enable(void); /** * @brief Enable the flash boot protection procedure for WDT. @@ -123,19 +123,19 @@ void rtc_wdt_enable(); * This function was added to be compatibility with the old bootloaders. * This mode is disabled in bootloader or using rtc_wdt_disable() function. */ -void rtc_wdt_flashboot_mode_enable(); +void rtc_wdt_flashboot_mode_enable(void); /** * @brief Disable rtc_wdt. */ -void rtc_wdt_disable(); +void rtc_wdt_disable(void); /** * @brief Reset counter rtc_wdt. * * It returns to stage 0 and its expiry counter restarts from 0. */ -void rtc_wdt_feed(); +void rtc_wdt_feed(void); /** * @brief Set time for required stage. @@ -191,7 +191,7 @@ esp_err_t rtc_wdt_set_length_of_reset_signal(rtc_wdt_reset_sig_t reset_src, rtc_ * @return * - True rtc_wdt is enabled */ -bool rtc_wdt_is_on(); +bool rtc_wdt_is_on(void); #ifdef __cplusplus } diff --git a/components/soc/include/soc/soc_memory_layout.h b/components/soc/include/soc/soc_memory_layout.h index de7c449d5..15556fcde 100644 --- a/components/soc/include/soc/soc_memory_layout.h +++ b/components/soc/include/soc/soc_memory_layout.h @@ -138,7 +138,7 @@ size_t soc_get_available_memory_regions(soc_memory_region_t *regions); * returned by soc_get_available_memory_regions(). Used to size the * array passed to that function. */ -size_t soc_get_available_memory_region_max_count(); +size_t soc_get_available_memory_region_max_count(void); inline static bool IRAM_ATTR esp_ptr_dma_capable(const void *p) { diff --git a/components/soc/src/memory_layout_utils.c b/components/soc/src/memory_layout_utils.c index b43865fd6..29f752b9d 100644 --- a/components/soc/src/memory_layout_utils.c +++ b/components/soc/src/memory_layout_utils.c @@ -34,14 +34,14 @@ extern int _data_start, _static_data_end, _iram_start, _iram_end; /* static DRAM & IRAM chunks */ static const size_t EXTRA_RESERVED_REGIONS = 2; -static size_t s_get_num_reserved_regions() +static size_t s_get_num_reserved_regions(void) { return ( ( &soc_reserved_memory_region_end - &soc_reserved_memory_region_start ) + EXTRA_RESERVED_REGIONS ); } -size_t soc_get_available_memory_region_max_count() +size_t soc_get_available_memory_region_max_count(void) { /* Worst-case: each reserved memory region splits an available region in two, so the maximum possible number of regions diff --git a/components/spi_flash/cache_utils.c b/components/spi_flash/cache_utils.c index b27b968ad..25f937d74 100644 --- a/components/spi_flash/cache_utils.c +++ b/components/spi_flash/cache_utils.c @@ -45,18 +45,18 @@ static volatile bool s_flash_op_complete = false; static volatile int s_flash_op_cpu = -1; #endif -void spi_flash_init_lock() +void spi_flash_init_lock(void) { s_flash_op_mutex = xSemaphoreCreateRecursiveMutex(); assert(s_flash_op_mutex != NULL); } -void spi_flash_op_lock() +void spi_flash_op_lock(void) { xSemaphoreTakeRecursive(s_flash_op_mutex, portMAX_DELAY); } -void spi_flash_op_unlock() +void spi_flash_op_unlock(void) { xSemaphoreGiveRecursive(s_flash_op_mutex); } @@ -90,7 +90,7 @@ void IRAM_ATTR spi_flash_op_block_func(void* arg) xTaskResumeAll(); } -void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu() +void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu(void) { spi_flash_op_lock(); @@ -141,7 +141,7 @@ void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu() spi_flash_disable_cache(other_cpuid, &s_flash_op_cache_state[other_cpuid]); } -void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu() +void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu(void) { const uint32_t cpuid = xPortGetCoreID(); const uint32_t other_cpuid = (cpuid == 0) ? 1 : 0; @@ -178,7 +178,7 @@ void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu() spi_flash_op_unlock(); } -void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu_no_os() +void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu_no_os(void) { const uint32_t cpuid = xPortGetCoreID(); const uint32_t other_cpuid = (cpuid == 0) ? 1 : 0; @@ -191,7 +191,7 @@ void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu_no_os() spi_flash_disable_cache(cpuid, &s_flash_op_cache_state[cpuid]); } -void IRAM_ATTR spi_flash_enable_interrupts_caches_no_os() +void IRAM_ATTR spi_flash_enable_interrupts_caches_no_os(void) { const uint32_t cpuid = xPortGetCoreID(); @@ -203,36 +203,36 @@ void IRAM_ATTR spi_flash_enable_interrupts_caches_no_os() #else // CONFIG_FREERTOS_UNICORE -void spi_flash_init_lock() +void spi_flash_init_lock(void) { } -void spi_flash_op_lock() +void spi_flash_op_lock(void) { vTaskSuspendAll(); } -void spi_flash_op_unlock() +void spi_flash_op_unlock(void) { xTaskResumeAll(); } -void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu() +void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu(void) { spi_flash_op_lock(); esp_intr_noniram_disable(); spi_flash_disable_cache(0, &s_flash_op_cache_state[0]); } -void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu() +void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu(void) { spi_flash_restore_cache(0, s_flash_op_cache_state[0]); esp_intr_noniram_enable(); spi_flash_op_unlock(); } -void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu_no_os() +void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu_no_os(void) { // Kill interrupts that aren't located in IRAM esp_intr_noniram_disable(); @@ -240,7 +240,7 @@ void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu_no_os() spi_flash_disable_cache(0, &s_flash_op_cache_state[0]); } -void IRAM_ATTR spi_flash_enable_interrupts_caches_no_os() +void IRAM_ATTR spi_flash_enable_interrupts_caches_no_os(void) { // Re-enable cache on this CPU spi_flash_restore_cache(0, s_flash_op_cache_state[0]); @@ -291,7 +291,7 @@ static void IRAM_ATTR spi_flash_restore_cache(uint32_t cpuid, uint32_t saved_sta } -IRAM_ATTR bool spi_flash_cache_enabled() +IRAM_ATTR bool spi_flash_cache_enabled(void) { bool result = (DPORT_REG_GET_BIT(DPORT_PRO_CACHE_CTRL_REG, DPORT_PRO_CACHE_ENABLE) != 0); #if portNUM_PROCESSORS == 2 diff --git a/components/spi_flash/cache_utils.h b/components/spi_flash/cache_utils.h index d482c4da7..9b272009f 100644 --- a/components/spi_flash/cache_utils.h +++ b/components/spi_flash/cache_utils.h @@ -23,30 +23,30 @@ */ // Init mutex protecting access to spi_flash_* APIs -void spi_flash_init_lock(); +void spi_flash_init_lock(void); // Take mutex protecting access to spi_flash_* APIs -void spi_flash_op_lock(); +void spi_flash_op_lock(void); // Release said mutex -void spi_flash_op_unlock(); +void spi_flash_op_unlock(void); // Suspend the scheduler on both CPUs, disable cache. // Contrary to its name this doesn't do anything with interrupts, yet. // Interrupt disabling capability will be added once we implement // interrupt allocation API. -void spi_flash_disable_interrupts_caches_and_other_cpu(); +void spi_flash_disable_interrupts_caches_and_other_cpu(void); // Enable cache, enable interrupts (to be added in future), resume scheduler -void spi_flash_enable_interrupts_caches_and_other_cpu(); +void spi_flash_enable_interrupts_caches_and_other_cpu(void); // Disables non-IRAM interrupt handlers on current CPU and caches on both CPUs. // This function is implied to be called when other CPU is not running or running code from IRAM. -void spi_flash_disable_interrupts_caches_and_other_cpu_no_os(); +void spi_flash_disable_interrupts_caches_and_other_cpu_no_os(void); // Enable cache, enable interrupts on current CPU. // This function is implied to be called when other CPU is not running or running code from IRAM. -void spi_flash_enable_interrupts_caches_no_os(); +void spi_flash_enable_interrupts_caches_no_os(void); // Flushes cache if address range has corresponding valid cache mappings // Recommended to use post flash program operation (erase or write) diff --git a/components/spi_flash/esp_flash_api.c b/components/spi_flash/esp_flash_api.c index 1ce52e47b..f064bcbdb 100644 --- a/components/spi_flash/esp_flash_api.c +++ b/components/spi_flash/esp_flash_api.c @@ -664,7 +664,7 @@ esp_err_t spi_flash_read(size_t src, void *dstv, size_t size) return spi_flash_translate_rc(err); } -esp_err_t spi_flash_unlock() +esp_err_t spi_flash_unlock(void) { esp_err_t err = esp_flash_set_chip_write_protect(NULL, false); return spi_flash_translate_rc(err); diff --git a/components/spi_flash/esp_flash_spi_init.c b/components/spi_flash/esp_flash_spi_init.c index ecd566686..c554f4a29 100644 --- a/components/spi_flash/esp_flash_spi_init.c +++ b/components/spi_flash/esp_flash_spi_init.c @@ -174,7 +174,7 @@ static DRAM_ATTR esp_flash_t default_chip = { esp_flash_t *esp_flash_default_chip = NULL; -esp_err_t esp_flash_init_default_chip() +esp_err_t esp_flash_init_default_chip(void) { memspi_host_config_t cfg = ESP_FLASH_HOST_CONFIG_DEFAULT(); //the host is already initialized, only do init for the data and load it to the host @@ -200,7 +200,7 @@ esp_err_t esp_flash_init_default_chip() return ESP_OK; } -esp_err_t esp_flash_app_init() +esp_err_t esp_flash_app_init(void) { return esp_flash_init_os_functions(&default_chip, 0); } diff --git a/components/spi_flash/flash_mmap.c b/components/spi_flash/flash_mmap.c index 76e2d025c..4af801292 100644 --- a/components/spi_flash/flash_mmap.c +++ b/components/spi_flash/flash_mmap.c @@ -62,7 +62,7 @@ static uint8_t s_mmap_page_refcnt[REGIONS_COUNT * PAGES_PER_REGION] = {0}; static uint32_t s_mmap_last_handle = 0; -static void IRAM_ATTR spi_flash_mmap_init() +static void IRAM_ATTR spi_flash_mmap_init(void) { if (s_mmap_page_refcnt[0] != 0) { return; /* mmap data already initialised */ @@ -268,7 +268,7 @@ void IRAM_ATTR spi_flash_munmap(spi_flash_mmap_handle_t handle) free(it); } -static void IRAM_ATTR NOINLINE_ATTR spi_flash_protected_mmap_init() +static void IRAM_ATTR NOINLINE_ATTR spi_flash_protected_mmap_init(void) { spi_flash_disable_interrupts_caches_and_other_cpu(); spi_flash_mmap_init(); @@ -284,7 +284,7 @@ static uint32_t IRAM_ATTR NOINLINE_ATTR spi_flash_protected_read_mmu_entry(int i return value; } -void spi_flash_mmap_dump() +void spi_flash_mmap_dump(void) { spi_flash_protected_mmap_init(); diff --git a/components/spi_flash/flash_ops.c b/components/spi_flash/flash_ops.c index 1b06447b1..41405c8d0 100644 --- a/components/spi_flash/flash_ops.c +++ b/components/spi_flash/flash_ops.c @@ -123,7 +123,7 @@ static __attribute__((unused)) bool is_safe_write_address(size_t addr, size_t si } -void spi_flash_init() +void spi_flash_init(void) { spi_flash_init_lock(); #if CONFIG_SPI_FLASH_ENABLE_COUNTERS @@ -136,38 +136,38 @@ void IRAM_ATTR spi_flash_guard_set(const spi_flash_guard_funcs_t *funcs) s_flash_guard_ops = funcs; } -const spi_flash_guard_funcs_t *IRAM_ATTR spi_flash_guard_get() +const spi_flash_guard_funcs_t *IRAM_ATTR spi_flash_guard_get(void) { return s_flash_guard_ops; } -size_t IRAM_ATTR spi_flash_get_chip_size() +size_t IRAM_ATTR spi_flash_get_chip_size(void) { return g_rom_flashchip.chip_size; } -static inline void IRAM_ATTR spi_flash_guard_start() +static inline void IRAM_ATTR spi_flash_guard_start(void) { if (s_flash_guard_ops && s_flash_guard_ops->start) { s_flash_guard_ops->start(); } } -static inline void IRAM_ATTR spi_flash_guard_end() +static inline void IRAM_ATTR spi_flash_guard_end(void) { if (s_flash_guard_ops && s_flash_guard_ops->end) { s_flash_guard_ops->end(); } } -static inline void IRAM_ATTR spi_flash_guard_op_lock() +static inline void IRAM_ATTR spi_flash_guard_op_lock(void) { if (s_flash_guard_ops && s_flash_guard_ops->op_lock) { s_flash_guard_ops->op_lock(); } } -static inline void IRAM_ATTR spi_flash_guard_op_unlock() +static inline void IRAM_ATTR spi_flash_guard_op_unlock(void) { if (s_flash_guard_ops && s_flash_guard_ops->op_unlock) { s_flash_guard_ops->op_unlock(); @@ -175,7 +175,7 @@ static inline void IRAM_ATTR spi_flash_guard_op_unlock() } #ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL -static esp_rom_spiflash_result_t IRAM_ATTR spi_flash_unlock() +static esp_rom_spiflash_result_t IRAM_ATTR spi_flash_unlock(void) { static bool unlocked = false; if (!unlocked) { @@ -190,7 +190,7 @@ static esp_rom_spiflash_result_t IRAM_ATTR spi_flash_unlock() return ESP_ROM_SPIFLASH_RESULT_OK; } #else -static esp_rom_spiflash_result_t IRAM_ATTR spi_flash_unlock() +static esp_rom_spiflash_result_t IRAM_ATTR spi_flash_unlock(void) { esp_err_t err = esp_flash_set_chip_write_protect(NULL, false); if (err != ESP_OK) { @@ -677,17 +677,17 @@ static inline void dump_counter(spi_flash_counter_t *counter, const char *name) counter->count, counter->time, counter->bytes); } -const spi_flash_counters_t *spi_flash_get_counters() +const spi_flash_counters_t *spi_flash_get_counters(void) { return &s_flash_stats; } -void spi_flash_reset_counters() +void spi_flash_reset_counters(void) { memset(&s_flash_stats, 0, sizeof(s_flash_stats)); } -void spi_flash_dump_counters() +void spi_flash_dump_counters(void) { dump_counter(&s_flash_stats.read, "read "); dump_counter(&s_flash_stats.write, "write"); diff --git a/components/spi_flash/include/esp_flash.h b/components/spi_flash/include/esp_flash.h index 86737f791..efcfccc24 100644 --- a/components/spi_flash/include/esp_flash.h +++ b/components/spi_flash/include/esp_flash.h @@ -271,7 +271,7 @@ extern esp_flash_t *esp_flash_default_chip; * * Called by OS startup code. You do not need to call this in your own applications. */ -esp_err_t esp_flash_init_default_chip(); +esp_err_t esp_flash_init_default_chip(void); /** * Enable OS-level SPI flash protections in IDF @@ -280,7 +280,7 @@ esp_err_t esp_flash_init_default_chip(); * * @return ESP_OK if success, otherwise failed. See return value of ``esp_flash_init_os_functions``. */ -esp_err_t esp_flash_app_init(); +esp_err_t esp_flash_app_init(void); /** * Enable OS-level SPI flash for a specific chip. diff --git a/components/spi_flash/include/esp_spi_flash.h b/components/spi_flash/include/esp_spi_flash.h index 795142f4a..33bdc4d83 100644 --- a/components/spi_flash/include/esp_spi_flash.h +++ b/components/spi_flash/include/esp_spi_flash.h @@ -41,7 +41,7 @@ extern "C" { * no need to call it from application code. * */ -void spi_flash_init(); +void spi_flash_init(void); /** * @brief Get flash chip size, as set in binary image header @@ -50,7 +50,7 @@ void spi_flash_init(); * * @return size of flash chip, in bytes */ -size_t spi_flash_get_chip_size(); +size_t spi_flash_get_chip_size(void); /** * @brief Erase the Flash sector. @@ -238,7 +238,7 @@ void spi_flash_munmap(spi_flash_mmap_handle_t handle); * of pages allocated to each handle. It also lists all non-zero entries of * MMU table and corresponding reference counts. */ -void spi_flash_mmap_dump(); +void spi_flash_mmap_dump(void); /** * @brief get free pages number which can be mmap @@ -293,7 +293,7 @@ const void *spi_flash_phys2cache(size_t phys_offs, spi_flash_mmap_memory_t memor * * @return true if both CPUs have flash cache enabled, false otherwise. */ -bool spi_flash_cache_enabled(); +bool spi_flash_cache_enabled(void); /** * @brief SPI flash critical section enter function. @@ -374,7 +374,7 @@ void spi_flash_guard_set(const spi_flash_guard_funcs_t* funcs); * @return The guard functions that were set via spi_flash_guard_set(). These functions * can be called if implementing custom low-level SPI flash operations. */ -const spi_flash_guard_funcs_t *spi_flash_guard_get(); +const spi_flash_guard_funcs_t *spi_flash_guard_get(void); /** * @brief Default OS-aware flash access guard functions @@ -409,12 +409,12 @@ typedef struct { /** * @brief Reset SPI flash operation counters */ -void spi_flash_reset_counters(); +void spi_flash_reset_counters(void); /** * @brief Print SPI flash operation counters */ -void spi_flash_dump_counters(); +void spi_flash_dump_counters(void); /** * @brief Return current SPI flash operation counters @@ -422,7 +422,7 @@ void spi_flash_dump_counters(); * @return pointer to the spi_flash_counters_t structure holding values * of the operation counters */ -const spi_flash_counters_t* spi_flash_get_counters(); +const spi_flash_counters_t* spi_flash_get_counters(void); #endif //CONFIG_SPI_FLASH_ENABLE_COUNTERS diff --git a/components/spi_flash/partition.c b/components/spi_flash/partition.c index f31705c81..14de32c9f 100644 --- a/components/spi_flash/partition.c +++ b/components/spi_flash/partition.c @@ -54,7 +54,7 @@ typedef struct esp_partition_iterator_opaque_ { static esp_partition_iterator_opaque_t* iterator_create(esp_partition_type_t type, esp_partition_subtype_t subtype, const char* label); -static esp_err_t load_partitions(); +static esp_err_t load_partitions(void); static SLIST_HEAD(partition_list_head_, partition_list_item_) s_partition_list = @@ -146,7 +146,7 @@ static esp_partition_iterator_opaque_t* iterator_create(esp_partition_type_t typ // Create linked list of partition_list_item_t structures. // This function is called only once, with s_partition_list_lock taken. -static esp_err_t load_partitions() +static esp_err_t load_partitions(void) { const uint32_t* ptr; spi_flash_mmap_handle_t handle; diff --git a/components/spi_flash/sim/flash_mock.cpp b/components/spi_flash/sim/flash_mock.cpp index 1a275d518..b089e22dc 100644 --- a/components/spi_flash/sim/flash_mock.cpp +++ b/components/spi_flash/sim/flash_mock.cpp @@ -65,7 +65,7 @@ extern "C" void spi_flash_munmap(spi_flash_mmap_handle_t handle) return; } -extern "C" int spi_flash_get_total_erase_cycles() +extern "C" int spi_flash_get_total_erase_cycles(void) { return spiflash.get_total_erase_cycles(); } diff --git a/components/spi_flash/sim/flash_mock_util.c b/components/spi_flash/sim/flash_mock_util.c index a22b2854c..770600e64 100644 --- a/components/spi_flash/sim/flash_mock_util.c +++ b/components/spi_flash/sim/flash_mock_util.c @@ -16,42 +16,42 @@ bool spi_flash_check_and_flush_cache(size_t start_addr, size_t length) return true; } -esp_rom_spiflash_result_t esp_rom_spiflash_unlock() +esp_rom_spiflash_result_t esp_rom_spiflash_unlock(void) { return ESP_ROM_SPIFLASH_RESULT_OK; } -void spi_flash_init_lock() +void spi_flash_init_lock(void) { return; } -void spi_flash_op_lock() +void spi_flash_op_lock(void) { return; } -void spi_flash_op_unlock() +void spi_flash_op_unlock(void) { return; } -void spi_flash_disable_interrupts_caches_and_other_cpu() +void spi_flash_disable_interrupts_caches_and_other_cpu(void) { return; } -void spi_flash_enable_interrupts_caches_and_other_cpu() +void spi_flash_enable_interrupts_caches_and_other_cpu(void) { return; } -void spi_flash_disable_interrupts_caches_and_other_cpu_no_os() +void spi_flash_disable_interrupts_caches_and_other_cpu_no_os(void) { return; } -void spi_flash_enable_interrupts_caches_no_os() +void spi_flash_enable_interrupts_caches_no_os(void) { return; } diff --git a/components/spi_flash/sim/stubs/log/log.c b/components/spi_flash/sim/stubs/log/log.c index 5d606d357..4c8dc7802 100644 --- a/components/spi_flash/sim/stubs/log/log.c +++ b/components/spi_flash/sim/stubs/log/log.c @@ -15,7 +15,7 @@ void esp_log_write(esp_log_level_t level, va_end(arg); } -uint32_t esp_log_timestamp() +uint32_t esp_log_timestamp(void) { return 0; } diff --git a/components/spi_flash/spi_flash_rom_patch.c b/components/spi_flash/spi_flash_rom_patch.c index adf62fa57..af3d5d47d 100644 --- a/components/spi_flash/spi_flash_rom_patch.c +++ b/components/spi_flash/spi_flash_rom_patch.c @@ -53,7 +53,7 @@ esp_rom_spiflash_result_t esp_rom_spiflash_wait_idle(esp_rom_spiflash_chip_t *sp about interrupts, CPU coordination, flash mapping. However some of the functions in esp_spi_flash.c call it. */ -esp_rom_spiflash_result_t esp_rom_spiflash_unlock() +esp_rom_spiflash_result_t esp_rom_spiflash_unlock(void) { uint32_t status; @@ -349,7 +349,7 @@ static void spi_cache_mode_switch(uint32_t modebit) } -esp_rom_spiflash_result_t esp_rom_spiflash_lock() +esp_rom_spiflash_result_t esp_rom_spiflash_lock(void) { uint32_t status; @@ -401,7 +401,7 @@ esp_rom_spiflash_result_t esp_rom_spiflash_config_readmode(esp_rom_spiflash_read return ESP_ROM_SPIFLASH_RESULT_OK; } -esp_rom_spiflash_result_t esp_rom_spiflash_erase_chip() +esp_rom_spiflash_result_t esp_rom_spiflash_erase_chip(void) { if ( ESP_ROM_SPIFLASH_RESULT_OK != esp_rom_spiflash_enable_write(&g_rom_spiflash_chip)) { return ESP_ROM_SPIFLASH_RESULT_ERR; diff --git a/components/spi_flash/test/test_esp_flash.c b/components/spi_flash/test/test_esp_flash.c index bf1384545..49d144c9c 100644 --- a/components/spi_flash/test/test_esp_flash.c +++ b/components/spi_flash/test/test_esp_flash.c @@ -147,7 +147,7 @@ static void setup_new_chip(esp_flash_read_mode_t io_mode, esp_flash_speed_t spee TEST_ESP_OK(err); } -void teardown_test_chip() +void teardown_test_chip(void) { spi_bus_remove_flash_device(test_chip); test_chip = NULL; diff --git a/components/spi_flash/test/test_flash_encryption.c b/components/spi_flash/test/test_flash_encryption.c index 16579930c..ea647f336 100644 --- a/components/spi_flash/test/test_flash_encryption.c +++ b/components/spi_flash/test/test_flash_encryption.c @@ -14,7 +14,7 @@ static void verify_erased_flash(size_t offset, size_t length); static size_t start; -static void setup_tests() +static void setup_tests(void) { if (start == 0) { const esp_partition_t *part = get_test_data_partition(); diff --git a/components/spi_flash/test/test_mmap.c b/components/spi_flash/test/test_mmap.c index fe14a8be0..52a5be1f3 100644 --- a/components/spi_flash/test/test_mmap.c +++ b/components/spi_flash/test/test_mmap.c @@ -21,7 +21,7 @@ static uint32_t end; static spi_flash_mmap_handle_t handle1, handle2, handle3; -static void setup_mmap_tests() +static void setup_mmap_tests(void) { if (start == 0) { const esp_partition_t *part = get_test_data_partition(); diff --git a/components/spi_flash/test/test_read_write.c b/components/spi_flash/test/test_read_write.c index febe95bf8..e780b6e2f 100644 --- a/components/spi_flash/test/test_read_write.c +++ b/components/spi_flash/test/test_read_write.c @@ -31,7 +31,7 @@ /* Base offset in flash for tests. */ static size_t start; -static void setup_tests() +static void setup_tests(void) { if (start == 0) { const esp_partition_t *part = get_test_data_partition(); diff --git a/components/spiffs/test/test_spiffs.c b/components/spiffs/test/test_spiffs.c index b5dc129e3..34a2de874 100644 --- a/components/spiffs/test/test_spiffs.c +++ b/components/spiffs/test/test_spiffs.c @@ -448,7 +448,7 @@ void test_spiffs_concurrent(const char* filename_prefix) } -static void test_setup() +static void test_setup(void) { esp_vfs_spiffs_conf_t conf = { .base_path = "/spiffs", @@ -460,7 +460,7 @@ static void test_setup() TEST_ESP_OK(esp_vfs_spiffs_register(&conf)); } -static void test_teardown() +static void test_teardown(void) { TEST_ESP_OK(esp_vfs_spiffs_unregister(spiffs_test_partition_label)); } diff --git a/components/tcp_transport/include/esp_transport.h b/components/tcp_transport/include/esp_transport.h index 9dd7ff449..39e694f05 100644 --- a/components/tcp_transport/include/esp_transport.h +++ b/components/tcp_transport/include/esp_transport.h @@ -40,7 +40,7 @@ typedef struct esp_tls_last_error* esp_tls_error_handle_t; * * @return A handle can hold all transports */ -esp_transport_list_handle_t esp_transport_list_init(); +esp_transport_list_handle_t esp_transport_list_init(void); /** * @brief Cleanup and free all transports, include itself, @@ -93,7 +93,7 @@ esp_transport_handle_t esp_transport_list_get_transport(esp_transport_list_handl * * @return The transport handle */ -esp_transport_handle_t esp_transport_init(); +esp_transport_handle_t esp_transport_init(void); /** * @brief Cleanup and free memory the transport diff --git a/components/tcp_transport/include/esp_transport_ssl.h b/components/tcp_transport/include/esp_transport_ssl.h index 0f83c1d6e..330b68518 100644 --- a/components/tcp_transport/include/esp_transport_ssl.h +++ b/components/tcp_transport/include/esp_transport_ssl.h @@ -27,7 +27,7 @@ extern "C" { * * @return the allocated esp_transport_handle_t, or NULL if the handle can not be allocated */ -esp_transport_handle_t esp_transport_ssl_init(); +esp_transport_handle_t esp_transport_ssl_init(void); /** * @brief Set SSL certificate data (as PEM format). diff --git a/components/tcp_transport/include/esp_transport_tcp.h b/components/tcp_transport/include/esp_transport_tcp.h index 57ad45330..7a283fe9d 100644 --- a/components/tcp_transport/include/esp_transport_tcp.h +++ b/components/tcp_transport/include/esp_transport_tcp.h @@ -26,7 +26,7 @@ extern "C" { * * @return the allocated esp_transport_handle_t, or NULL if the handle can not be allocated */ -esp_transport_handle_t esp_transport_tcp_init(); +esp_transport_handle_t esp_transport_tcp_init(void); #ifdef __cplusplus diff --git a/components/tcp_transport/transport.c b/components/tcp_transport/transport.c index b48acf908..d5bc57bb4 100644 --- a/components/tcp_transport/transport.c +++ b/components/tcp_transport/transport.c @@ -70,7 +70,7 @@ static esp_transport_handle_t esp_transport_get_default_parent(esp_transport_han return t; } -esp_transport_list_handle_t esp_transport_list_init() +esp_transport_list_handle_t esp_transport_list_init(void) { esp_transport_list_handle_t transport = calloc(1, sizeof(esp_transport_internal_t)); ESP_TRANSPORT_MEM_CHECK(TAG, transport, return NULL); @@ -131,7 +131,7 @@ esp_err_t esp_transport_list_clean(esp_transport_list_handle_t h) return ESP_OK; } -esp_transport_handle_t esp_transport_init() +esp_transport_handle_t esp_transport_init(void) { esp_transport_handle_t t = calloc(1, sizeof(struct esp_transport_item_t)); ESP_TRANSPORT_MEM_CHECK(TAG, t, return NULL); diff --git a/components/tcp_transport/transport_ssl.c b/components/tcp_transport/transport_ssl.c index 1651a2f87..e05802930 100644 --- a/components/tcp_transport/transport_ssl.c +++ b/components/tcp_transport/transport_ssl.c @@ -204,7 +204,7 @@ void esp_transport_ssl_skip_common_name_check(esp_transport_handle_t t) } } -esp_transport_handle_t esp_transport_ssl_init() +esp_transport_handle_t esp_transport_ssl_init(void) { esp_transport_handle_t t = esp_transport_init(); transport_ssl_t *ssl = calloc(1, sizeof(transport_ssl_t)); diff --git a/components/tcp_transport/transport_tcp.c b/components/tcp_transport/transport_tcp.c index ff6925b2d..6de1d2237 100644 --- a/components/tcp_transport/transport_tcp.c +++ b/components/tcp_transport/transport_tcp.c @@ -153,7 +153,7 @@ static esp_err_t tcp_destroy(esp_transport_handle_t t) return 0; } -esp_transport_handle_t esp_transport_tcp_init() +esp_transport_handle_t esp_transport_tcp_init(void) { esp_transport_handle_t t = esp_transport_init(); transport_tcp_t *tcp = calloc(1, sizeof(transport_tcp_t)); diff --git a/components/tcpip_adapter/event_handlers.c b/components/tcpip_adapter/event_handlers.c index d22d18a05..5e3717c56 100644 --- a/components/tcpip_adapter/event_handlers.c +++ b/components/tcpip_adapter/event_handlers.c @@ -198,7 +198,7 @@ static void handle_sta_disconnected(void *arg, esp_event_base_t base, int32_t ev } -esp_err_t tcpip_adapter_set_default_wifi_handlers() +esp_err_t tcpip_adapter_set_default_wifi_handlers(void) { esp_err_t err; err = esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_START, handle_sta_start, NULL); @@ -248,7 +248,7 @@ fail: return err; } -esp_err_t tcpip_adapter_clear_default_wifi_handlers() +esp_err_t tcpip_adapter_clear_default_wifi_handlers(void) { esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_START, handle_sta_start); esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_STOP, handle_sta_stop); @@ -262,7 +262,7 @@ esp_err_t tcpip_adapter_clear_default_wifi_handlers() return ESP_OK; } -esp_err_t tcpip_adapter_set_default_eth_handlers() +esp_err_t tcpip_adapter_set_default_eth_handlers(void) { esp_err_t err; err = esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_START, handle_eth_start, NULL); @@ -297,7 +297,7 @@ fail: return err; } -esp_err_t tcpip_adapter_clear_default_eth_handlers() +esp_err_t tcpip_adapter_clear_default_eth_handlers(void) { esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_START, handle_eth_start); esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_STOP, handle_eth_stop); diff --git a/components/tcpip_adapter/include/tcpip_adapter.h b/components/tcpip_adapter/include/tcpip_adapter.h index 4c0a4af4f..f880511f7 100644 --- a/components/tcpip_adapter/include/tcpip_adapter.h +++ b/components/tcpip_adapter/include/tcpip_adapter.h @@ -714,7 +714,7 @@ esp_err_t tcpip_adapter_test_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_inf * - ESP_OK on success * - one of the errors from esp_event on failure */ -esp_err_t tcpip_adapter_set_default_eth_handlers(); +esp_err_t tcpip_adapter_set_default_eth_handlers(void); /** * @brief Uninstall default event handlers for Ethernet interface @@ -722,7 +722,7 @@ esp_err_t tcpip_adapter_set_default_eth_handlers(); * - ESP_OK on success * - one of the errors from esp_event on failure */ -esp_err_t tcpip_adapter_clear_default_eth_handlers(); +esp_err_t tcpip_adapter_clear_default_eth_handlers(void); /** * @brief Install default event handlers for Wi-Fi interfaces (station and AP) @@ -730,7 +730,7 @@ esp_err_t tcpip_adapter_clear_default_eth_handlers(); * - ESP_OK on success * - one of the errors from esp_event on failure */ -esp_err_t tcpip_adapter_set_default_wifi_handlers(); +esp_err_t tcpip_adapter_set_default_wifi_handlers(void); /** * @brief Uninstall default event handlers for Wi-Fi interfaces (station and AP) @@ -738,7 +738,7 @@ esp_err_t tcpip_adapter_set_default_wifi_handlers(); * - ESP_OK on success * - one of the errors from esp_event on failure */ -esp_err_t tcpip_adapter_clear_default_wifi_handlers(); +esp_err_t tcpip_adapter_clear_default_wifi_handlers(void); /** * @brief Search nefit index through netif interface diff --git a/components/unity/include/unity_test_runner.h b/components/unity/include/unity_test_runner.h index 8f41eb83d..a9a1fae49 100644 --- a/components/unity/include/unity_test_runner.h +++ b/components/unity/include/unity_test_runner.h @@ -168,7 +168,7 @@ void unity_run_test_by_name(const char *name); void unity_run_tests_by_tag(const char *tag, bool invert); -void unity_run_all_tests(); +void unity_run_all_tests(void); -void unity_run_menu(); +void unity_run_menu(void); diff --git a/components/unity/unity_port_esp32.c b/components/unity/unity_port_esp32.c index 9c1370007..2517cd94c 100644 --- a/components/unity/unity_port_esp32.c +++ b/components/unity/unity_port_esp32.c @@ -31,7 +31,7 @@ void unity_putc(int c) } } -void unity_flush() +void unity_flush(void) { uart_tx_wait_idle(CONFIG_ESP_CONSOLE_UART_NUM); } diff --git a/components/unity/unity_runner.c b/components/unity/unity_runner.c index e88840d2f..3c07b250f 100644 --- a/components/unity/unity_runner.c +++ b/components/unity/unity_runner.c @@ -178,7 +178,7 @@ void unity_run_test_by_name(const char *name) } } -void unity_run_all_tests() +void unity_run_all_tests(void) { for (const test_desc_t *test = s_unity_tests_first; test != NULL; test = test->next) { unity_run_single_test(test); @@ -265,7 +265,7 @@ static int get_test_count(void) return test_counter; } -void unity_run_menu() +void unity_run_menu(void) { UNITY_PRINT_EOL(); UNITY_PRINT_EOL(); diff --git a/components/vfs/include/esp_vfs_dev.h b/components/vfs/include/esp_vfs_dev.h index b330b4c56..95daaa61f 100644 --- a/components/vfs/include/esp_vfs_dev.h +++ b/components/vfs/include/esp_vfs_dev.h @@ -34,7 +34,7 @@ typedef enum { * * This function is called from startup code to enable serial output */ -void esp_vfs_dev_uart_register(); +void esp_vfs_dev_uart_register(void); /** * @brief Set the line endings expected to be received on UART diff --git a/components/vfs/test/test_vfs_access.c b/components/vfs/test/test_vfs_access.c index 02e7d56f8..ed691f998 100644 --- a/components/vfs/test/test_vfs_access.c +++ b/components/vfs/test/test_vfs_access.c @@ -58,7 +58,7 @@ TEST_CASE("Can use access() for UART", "[vfs]") uart_driver_delete(UART_NUM_2); } -static inline void test_spi_flash_setup() +static inline void test_spi_flash_setup(void) { esp_vfs_fat_sdmmc_mount_config_t mount_config = { .format_if_mount_failed = true, @@ -68,7 +68,7 @@ static inline void test_spi_flash_setup() TEST_ESP_OK(esp_vfs_fat_spiflash_mount("/spiflash", NULL, &mount_config, &test_wl_handle)); } -static inline void test_spi_flash_teardown() +static inline void test_spi_flash_teardown(void) { TEST_ESP_OK(esp_vfs_fat_spiflash_unmount("/spiflash", test_wl_handle)); } diff --git a/components/vfs/test/test_vfs_select.c b/components/vfs/test/test_vfs_select.c index c8ff500da..bea17242e 100644 --- a/components/vfs/test/test_vfs_select.c +++ b/components/vfs/test/test_vfs_select.c @@ -33,7 +33,7 @@ typedef struct { static const char message[] = "Hello world!"; -static int open_dummy_socket() +static int open_dummy_socket(void) { const struct addrinfo hints = { .ai_family = AF_INET, @@ -51,7 +51,7 @@ static int open_dummy_socket() return dummy_socket_fd; } -static int socket_init() +static int socket_init(void) { const struct addrinfo hints = { .ai_family = AF_INET, @@ -83,7 +83,7 @@ static int socket_init() return socket_fd; } -static void uart1_init() +static void uart1_init(void) { uart_config_t uart_config = { .baud_rate = 115200, diff --git a/components/vfs/test/test_vfs_uart.c b/components/vfs/test/test_vfs_uart.c index 5c3d3f1d6..262eb4f08 100644 --- a/components/vfs/test/test_vfs_uart.c +++ b/components/vfs/test/test_vfs_uart.c @@ -39,7 +39,7 @@ static void fwrite_str_loopback(const char* str, size_t size) UART0.conf0.loopback = 0; } -static void flush_stdin_stdout() +static void flush_stdin_stdout(void) { vTaskDelay(10 / portTICK_PERIOD_MS); char *bitbucket = (char*) 0x3f000000; diff --git a/components/vfs/vfs.c b/components/vfs/vfs.c index 0fc5aead3..c604b0973 100644 --- a/components/vfs/vfs.c +++ b/components/vfs/vfs.c @@ -1249,7 +1249,7 @@ int esp_vfs_poll(struct pollfd *fds, nfds_t nfds, int timeout) return ret; } -void vfs_include_syscalls_impl() +void vfs_include_syscalls_impl(void) { // Linker hook function, exists to make the linker examine this fine } diff --git a/components/vfs/vfs_uart.c b/components/vfs/vfs_uart.c index 5cb179a4a..d996e9eeb 100644 --- a/components/vfs/vfs_uart.c +++ b/components/vfs/vfs_uart.c @@ -123,7 +123,7 @@ static fd_set *_writefds_orig = NULL; static fd_set *_errorfds_orig = NULL; -static void uart_end_select(); +static void uart_end_select(void); static int uart_open(const char * path, int flags, int mode) @@ -432,7 +432,7 @@ static esp_err_t uart_start_select(int nfds, fd_set *readfds, fd_set *writefds, return ESP_OK; } -static void uart_end_select() +static void uart_end_select(void) { portENTER_CRITICAL(uart_get_selectlock()); for (int i = 0; i < UART_NUM; ++i) { @@ -915,7 +915,7 @@ static int uart_tcflush(int fd, int select) } #endif // CONFIG_VFS_SUPPORT_TERMIOS -void esp_vfs_dev_uart_register() +void esp_vfs_dev_uart_register(void) { esp_vfs_t vfs = { .flags = ESP_VFS_FLAG_DEFAULT, diff --git a/components/wpa_supplicant/src/esp_supplicant/esp_wpa_main.c b/components/wpa_supplicant/src/esp_supplicant/esp_wpa_main.c index d565cd1cb..6f37b1850 100644 --- a/components/wpa_supplicant/src/esp_supplicant/esp_wpa_main.c +++ b/components/wpa_supplicant/src/esp_supplicant/esp_wpa_main.c @@ -71,7 +71,7 @@ void wpa_deauthenticate(u8 reason_code) esp_wifi_deauthenticate_internal(reason_code); } -void wpa_config_profile() +void wpa_config_profile(void) { if (esp_wifi_sta_prof_is_wpa_internal()) { wpa_set_profile(WPA_PROTO_WPA, esp_wifi_sta_get_prof_authmode_internal()); @@ -102,7 +102,7 @@ void wpa_config_assoc_ie(u8 proto, u8 *assoc_buf, u32 assoc_wpa_ie_len) } } -void wpa_neg_complete() +void wpa_neg_complete(void) { esp_wifi_auth_done_internal(); } diff --git a/examples/bluetooth/ble_ancs/main/ble_ancs_demo.c b/examples/bluetooth/ble_ancs/main/ble_ancs_demo.c index 294a8a106..4dc89b83a 100644 --- a/examples/bluetooth/ble_ancs/main/ble_ancs_demo.c +++ b/examples/bluetooth/ble_ancs/main/ble_ancs_demo.c @@ -596,7 +596,7 @@ void init_timer(void) ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer)); } -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c index fca661d2c..7c1ca1c0b 100644 --- a/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c +++ b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c @@ -615,7 +615,7 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ } while (0); } -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/bluetooth/bluedroid/ble/ble_eddystone/main/esp_eddystone_demo.c b/examples/bluetooth/bluedroid/ble/ble_eddystone/main/esp_eddystone_demo.c index 525bcd2ae..f41ebf6c1 100644 --- a/examples/bluetooth/bluedroid/ble/ble_eddystone/main/esp_eddystone_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_eddystone/main/esp_eddystone_demo.c @@ -160,7 +160,7 @@ void esp_eddystone_init(void) esp_eddystone_appRegister(); } -void app_main() +void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)); diff --git a/examples/bluetooth/bluedroid/ble/ble_hid_device_demo/main/ble_hidd_demo_main.c b/examples/bluetooth/bluedroid/ble/ble_hid_device_demo/main/ble_hidd_demo_main.c index e26fa38d9..b7584735a 100644 --- a/examples/bluetooth/bluedroid/ble/ble_hid_device_demo/main/ble_hidd_demo_main.c +++ b/examples/bluetooth/bluedroid/ble/ble_hid_device_demo/main/ble_hidd_demo_main.c @@ -183,7 +183,7 @@ void hid_demo_task(void *pvParameters) } -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/bluetooth/bluedroid/ble/ble_ibeacon/main/ibeacon_demo.c b/examples/bluetooth/bluedroid/ble/ble_ibeacon/main/ibeacon_demo.c index dcad4dd4a..7aa8ae26d 100644 --- a/examples/bluetooth/bluedroid/ble/ble_ibeacon/main/ibeacon_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_ibeacon/main/ibeacon_demo.c @@ -163,7 +163,7 @@ void ble_ibeacon_init(void) ble_ibeacon_appRegister(); } -void app_main() +void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)); diff --git a/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c b/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c index ae3da8e1c..f1a91e9bd 100644 --- a/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c @@ -604,7 +604,7 @@ static void spp_uart_init(void) xTaskCreate(uart_task, "uTask", 2048, (void*)UART_NUM_0, 8, NULL); } -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c b/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c index 999b047e7..f1eaba16b 100644 --- a/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c @@ -648,7 +648,7 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ } while (0); } -void app_main() +void app_main(void) { esp_err_t ret; esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); diff --git a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c index b0ca2daa9..6ae2cee93 100644 --- a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c +++ b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c @@ -510,7 +510,7 @@ static void throughput_client_task(void *param) } } -void app_main() +void app_main(void) { // Initialize NVS. esp_err_t ret = nvs_flash_init(); diff --git a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c index 3467104f3..b8a8f621c 100644 --- a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c +++ b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c @@ -640,7 +640,7 @@ void throughput_server_task(void *param) } } -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/bluetooth/bluedroid/ble/blufi/main/blufi_example_main.c b/examples/bluetooth/bluedroid/ble/blufi/main/blufi_example_main.c index 4106dd24e..bd3b86e21 100644 --- a/examples/bluetooth/bluedroid/ble/blufi/main/blufi_example_main.c +++ b/examples/bluetooth/bluedroid/ble/blufi/main/blufi_example_main.c @@ -375,7 +375,7 @@ static void example_gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_ } } -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c b/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c index 2bd779836..e53d85d33 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c @@ -436,7 +436,7 @@ static void esp_gattc_cb(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp } while (0); } -void app_main() +void app_main(void) { // Initialize NVS. esp_err_t ret = nvs_flash_init(); diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c index fa9e8914b..365fb40d8 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c @@ -509,7 +509,7 @@ static void esp_gattc_cb(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp } while (0); } -void app_main() +void app_main(void) { // Initialize NVS. esp_err_t ret = nvs_flash_init(); diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c index a7c80182f..6cbfb7182 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c @@ -497,7 +497,7 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ } while (0); } -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c b/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c index 6770d8f86..ea140e8cc 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c @@ -671,7 +671,7 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ } while (0); } -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c b/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c index e58357865..b6a9abffa 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c @@ -512,7 +512,7 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ } while (0); } -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c b/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c index b6499a766..175c0f98e 100644 --- a/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c +++ b/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c @@ -883,7 +883,7 @@ static void esp_gattc_cb(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp } while (0); } -void app_main() +void app_main(void) { esp_err_t ret = nvs_flash_init(); if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { diff --git a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/main.c b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/main.c index adaf8ff43..c5a90f089 100644 --- a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/main.c @@ -42,7 +42,7 @@ enum { static void bt_av_hdl_stack_evt(uint16_t event, void *p_param); -void app_main() +void app_main(void) { /* Initialize NVS — it is used to store PHY calibration data */ esp_err_t err = nvs_flash_init(); diff --git a/examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/main.c b/examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/main.c index a3971f8cd..25f66c90f 100644 --- a/examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/a2dp_source/main/main.c @@ -107,7 +107,7 @@ static char *bda2str(esp_bd_addr_t bda, char *str, size_t size) return str; } -void app_main() +void app_main(void) { // Initialize NVS. esp_err_t ret = nvs_flash_init(); diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_discovery/main/bt_discovery.c b/examples/bluetooth/bluedroid/classic_bt/bt_discovery/main/bt_discovery.c index af753cb09..cb8a687f0 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_discovery/main/bt_discovery.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_discovery/main/bt_discovery.c @@ -269,7 +269,7 @@ void bt_app_gap_start_up(void) esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 10, 0); } -void app_main() +void app_main(void) { /* Initialize NVS — it is used to store PHY calibration data */ esp_err_t ret = nvs_flash_init(); diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/example_spp_acceptor_demo.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/example_spp_acceptor_demo.c index cf82c2724..c654d8616 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/example_spp_acceptor_demo.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_acceptor/main/example_spp_acceptor_demo.c @@ -154,7 +154,7 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param) return; } -void app_main() +void app_main(void) { esp_err_t ret = nvs_flash_init(); if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/example_spp_initiator_demo.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/example_spp_initiator_demo.c index cd4365996..39705a990 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/example_spp_initiator_demo.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/example_spp_initiator_demo.c @@ -235,7 +235,7 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa } } -void app_main() +void app_main(void) { for (int i = 0; i < SPP_DATA_LEN; ++i) { spp_data[i] = i; diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c index 092756b72..d24ea1053 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c @@ -159,7 +159,7 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param) return; } -void app_main() +void app_main(void) { esp_err_t ret = nvs_flash_init(); if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { diff --git a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c index fc34a8f02..9be627fe6 100644 --- a/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c +++ b/examples/bluetooth/bluedroid/classic_bt/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c @@ -223,7 +223,7 @@ static void esp_spp_stack_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param spp_task_work_dispatch(esp_spp_cb, event, param, sizeof(esp_spp_cb_param_t), NULL); } -void app_main() +void app_main(void) { for (int i = 0; i < SPP_DATA_LEN; ++i) { spp_data[i] = i; diff --git a/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c b/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c index 466a2ce8d..b69fada10 100644 --- a/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c +++ b/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c @@ -669,7 +669,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param) } } -void app_main() +void app_main(void) { /* Initialize NVS — it is used to store PHY calibration data */ esp_err_t err = nvs_flash_init(); diff --git a/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c b/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c index 3e4989372..00172ebd9 100644 --- a/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c +++ b/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c @@ -942,7 +942,7 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ } while (0); } -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/bluetooth/bluedroid/hci/controller_hci_uart/main/controller_hci_uart_demo.c b/examples/bluetooth/bluedroid/hci/controller_hci_uart/main/controller_hci_uart_demo.c index 0eb7ef778..6214dec13 100644 --- a/examples/bluetooth/bluedroid/hci/controller_hci_uart/main/controller_hci_uart_demo.c +++ b/examples/bluetooth/bluedroid/hci/controller_hci_uart/main/controller_hci_uart_demo.c @@ -31,7 +31,7 @@ static void uart_gpio_reset(void) #endif } -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/bluetooth/bluedroid/hci/controller_vhci_ble_adv/main/app_bt.c b/examples/bluetooth/bluedroid/hci/controller_vhci_ble_adv/main/app_bt.c index 0a67c3246..09f78064c 100644 --- a/examples/bluetooth/bluedroid/hci/controller_vhci_ble_adv/main/app_bt.c +++ b/examples/bluetooth/bluedroid/hci/controller_vhci_ble_adv/main/app_bt.c @@ -210,7 +210,7 @@ void bleAdvtTask(void *pvParameters) } } -void app_main() +void app_main(void) { /* Initialize NVS — it is used to store PHY calibration data */ esp_err_t ret = nvs_flash_init(); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.c index 5cf017bdc..b8d1775b3 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.c @@ -72,7 +72,7 @@ esp_ble_mesh_comp_t *ble_mesh_get_component(uint16_t model_id) return comp; } -void ble_mesh_node_init() +void ble_mesh_node_init(void) { uint16_t i; @@ -100,7 +100,7 @@ void ble_mesh_set_node_prestore_params(uint16_t netkey_index, uint16_t unicast_a xSemaphoreGive(ble_mesh_node_sema); } -void ble_mesh_node_statistics_get() +void ble_mesh_node_statistics_get(void) { xSemaphoreTake(ble_mesh_node_sema, portMAX_DELAY); ESP_LOGI(TAG, "statistics:%d,%d\n", ble_mesh_node_statistics.statistics, ble_mesh_node_statistics.package_num); @@ -156,7 +156,7 @@ int ble_mesh_node_statistics_init(uint16_t package_num) return 0; } -void ble_mesh_node_statistics_destroy() +void ble_mesh_node_statistics_destroy(void) { if (ble_mesh_node_statistics.package_index != NULL) { free(ble_mesh_node_statistics.package_index); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.h index 06c876fd6..d7feee5fe 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.h @@ -85,13 +85,13 @@ extern SemaphoreHandle_t ble_mesh_node_sema; } \ }while(0) \ -void ble_mesh_node_init(); +void ble_mesh_node_init(void); void ble_mesh_set_node_prestore_params(uint16_t netkey_index, uint16_t unicast_addr); esp_ble_mesh_model_t *ble_mesh_get_model(uint16_t model_id); esp_ble_mesh_comp_t *ble_mesh_get_component(uint16_t model_id); -void ble_mesh_node_statistics_get(); +void ble_mesh_node_statistics_get(void); int ble_mesh_node_statistics_accumultate(uint8_t *data, uint32_t value, uint16_t type); int ble_mesh_node_statistics_init(uint16_t package_num); -void ble_mesh_node_statistics_destroy(); +void ble_mesh_node_statistics_destroy(void); #endif //_BLE_MESH_ADAOTER_H_ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_decl.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_decl.h index 22ab3a7f5..2e983265d 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_decl.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_decl.h @@ -11,18 +11,18 @@ #include "esp_ble_mesh_defs.h" // Register system functions -void register_system(); +void register_system(void); // Register blutooth -void register_bluetooth(); +void register_bluetooth(void); // Register mesh node cmd -void ble_mesh_register_mesh_node(); +void ble_mesh_register_mesh_node(void); // Register mesh config server and generic server operation cmd -void ble_mesh_register_server(); +void ble_mesh_register_server(void); #if (CONFIG_BLE_MESH_CFG_CLI) // Register mesh config client operation cmd -void ble_mesh_register_configuration_client_model(); +void ble_mesh_register_configuration_client_model(void); #endif diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c index f1f963552..25857bc96 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c @@ -36,7 +36,7 @@ #define MOUNT_PATH "/data" #define HISTORY_PATH MOUNT_PATH "/history.txt" -static void initialize_filesystem() +static void initialize_filesystem(void) { static wl_handle_t wl_handle; const esp_vfs_fat_mount_config_t mount_config = { @@ -51,7 +51,7 @@ static void initialize_filesystem() } #endif // CONFIG_STORE_HISTORY -static void initialize_console() +static void initialize_console(void) { /* Disable buffering on stdin and stdout */ setvbuf(stdin, NULL, _IONBF, 0); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_system.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_system.c index cc8805dbf..88c0a6a0a 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_system.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_system.c @@ -28,11 +28,11 @@ #define CONFIG_ESPTOOLPY_PORT "Which is choosen by Users for CMake" #endif -static void register_free(); -static void register_restart(); -static void register_make(); +static void register_free(void); +static void register_restart(void); +static void register_make(void); -void register_system() +void register_system(void) { register_free(); register_restart(); @@ -47,7 +47,7 @@ static int restart(int argc, char **argv) esp_restart(); } -static void register_restart() +static void register_restart(void) { const esp_console_cmd_t cmd = { .command = "restart", @@ -66,7 +66,7 @@ static int free_mem(int argc, char **argv) return 0; } -static void register_free() +static void register_free(void) { const esp_console_cmd_t cmd = { .command = "free", @@ -169,7 +169,7 @@ R"(MONITOR return 0; } -static void register_make() +static void register_make(void) { const esp_console_cmd_t cmd = { .command = "make", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c index 919e69f77..6dc356cda 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c @@ -86,18 +86,18 @@ ble_mesh_node_status node_status = { SemaphoreHandle_t ble_mesh_node_sema; -void ble_mesh_register_node_cmd(); +void ble_mesh_register_node_cmd(void); // Register callback function void ble_mesh_prov_cb(esp_ble_mesh_prov_cb_event_t event, esp_ble_mesh_prov_cb_param_t *param); void ble_mesh_model_cb(esp_ble_mesh_model_cb_event_t event, esp_ble_mesh_model_cb_param_t *param); -void ble_mesh_register_mesh_node() +void ble_mesh_register_mesh_node(void) { ble_mesh_register_node_cmd(); } -int ble_mesh_register_node_cb() +int ble_mesh_register_node_cb(void) { ESP_LOGD(TAG, "enter %s\n", __func__); ble_mesh_node_init(); @@ -364,7 +364,7 @@ int ble_mesh_node_enable_bearer(int argc, char **argv) return err; } -int ble_mesh_node_reset() +int ble_mesh_node_reset(void) { esp_err_t err; ESP_LOGD(TAG, "enter %s\n", __func__); @@ -437,7 +437,7 @@ int ble_mesh_node_enter_network_auto(int argc, char **argv) return err; } -void ble_mesh_register_node_cmd() +void ble_mesh_register_node_cmd(void) { const esp_console_cmd_t register_cmd = { .command = "bmreg", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_server_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_server_cmd.c index e2ae583bf..6fcb41d4f 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_server_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_server_cmd.c @@ -18,7 +18,7 @@ #include "ble_mesh_console_lib.h" #include "ble_mesh_adapter.h" -void ble_mesh_register_server_operation(); +void ble_mesh_register_server_operation(void); typedef struct { struct arg_str *data; @@ -29,7 +29,7 @@ typedef struct { } ble_mesh_publish_message; ble_mesh_publish_message msg_publish; -void ble_mesh_register_server() +void ble_mesh_register_server(void) { ble_mesh_register_server_operation(); } @@ -63,7 +63,7 @@ int ble_mesh_module_publish_message(int argc, char **argv) return err; } -void ble_mesh_register_server_operation() +void ble_mesh_register_server_operation(void) { msg_publish.data = arg_str1("d", NULL, "", "message data"); msg_publish.opcode = arg_int1("o", NULL, "", "operation opcode"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c index e6b03ed59..0489388ec 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c @@ -18,21 +18,21 @@ #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" -void register_ble_address(); +void register_ble_address(void); -void register_bluetooth() +void register_bluetooth(void) { register_ble_address(); } -int bt_mac() +int bt_mac(void) { const uint8_t *mac = esp_bt_dev_get_address(); printf("+BTMAC:"MACSTR"\n", MAC2STR(mac)); return 0; } -void register_ble_address() +void register_ble_address(void) { const esp_console_cmd_t cmd = { .command = "btmac", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.c index 754b0115f..eded5787b 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.c @@ -77,7 +77,7 @@ esp_ble_mesh_comp_t *ble_mesh_get_component(uint16_t model_id) return comp; } -void ble_mesh_node_init() +void ble_mesh_node_init(void) { uint16_t i; @@ -129,7 +129,7 @@ void ble_mesh_create_send_data(char *data, uint16_t byte_num, uint16_t sequence_ } } -void ble_mesh_test_performance_client_model_get() +void ble_mesh_test_performance_client_model_get(void) { uint32_t i, j; uint32_t sum_time = 0; @@ -155,7 +155,7 @@ void ble_mesh_test_performance_client_model_get() xSemaphoreGive(ble_mesh_test_perf_sema); } -void ble_mesh_test_performance_client_model_get_received_percent() +void ble_mesh_test_performance_client_model_get_received_percent(void) { uint32_t i, j; uint32_t max_time = 1400; @@ -283,7 +283,7 @@ int ble_mesh_test_performance_client_model_init(uint16_t node_num, uint32_t test return 0; } -void ble_mesh_test_performance_client_model_destroy() +void ble_mesh_test_performance_client_model_destroy(void) { if (test_perf_statistics.time != NULL) { free(test_perf_statistics.time); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.h index bdc083a21..305026c1a 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.h @@ -106,18 +106,18 @@ extern SemaphoreHandle_t ble_mesh_test_perf_sema; } \ }while(0) \ -void ble_mesh_node_init(); +void ble_mesh_node_init(void); void ble_mesh_set_node_prestore_params(uint16_t netkey_index, uint16_t unicast_addr); esp_ble_mesh_model_t *ble_mesh_get_model(uint16_t model_id); esp_ble_mesh_comp_t *ble_mesh_get_component(uint16_t model_id); void ble_mesh_create_send_data(char *data, uint16_t byte_num, uint16_t sequence_num, uint32_t opcode); -void ble_mesh_test_performance_client_model_get(); -void ble_mesh_test_performance_client_model_get_received_percent(); +void ble_mesh_test_performance_client_model_get(void); +void ble_mesh_test_performance_client_model_get_received_percent(void); void ble_mesh_test_performance_client_model_accumulate_statistics(uint32_t value); int ble_mesh_test_performance_client_model_accumulate_time(uint16_t time, uint8_t *data, uint8_t ack_ttl, uint16_t length); int ble_mesh_test_performance_client_model_init(uint16_t node_num, uint32_t test_num, uint8_t ttl); -void ble_mesh_test_performance_client_model_destroy(); +void ble_mesh_test_performance_client_model_destroy(void); #endif //_BLE_MESH_ADAPTER_H_ \ No newline at end of file diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_decl.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_decl.h index 90e52a61d..3ba4f496d 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_decl.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_decl.h @@ -11,28 +11,28 @@ #include "esp_ble_mesh_defs.h" // Register system functions -void register_system(); +void register_system(void); // Register bluetooth -void register_bluetooth(); +void register_bluetooth(void); // Register mesh node cmd -void ble_mesh_register_mesh_node(); +void ble_mesh_register_mesh_node(void); // Register Test Perf client cmd -void ble_mesh_register_mesh_test_performance_client(); +void ble_mesh_register_mesh_test_performance_client(void); #if (CONFIG_BLE_MESH_CFG_CLI) // Register mesh config client operation cmd -void ble_mesh_register_configuration_client_model(); +void ble_mesh_register_configuration_client_model(void); #endif #if (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI) // Register mesh client operation cmd -void ble_mesh_register_gen_onoff_client(); +void ble_mesh_register_gen_onoff_client(void); #endif #if CONFIG_BLE_MESH_PROVISIONER // Regitster mesh provisioner cmd -void ble_mesh_register_mesh_provisioner(); +void ble_mesh_register_mesh_provisioner(void); #endif diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c index d9d4a9e4e..4618e14b5 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c @@ -39,7 +39,7 @@ #define MOUNT_PATH "/data" #define HISTORY_PATH MOUNT_PATH "/history.txt" -static void initialize_filesystem() +static void initialize_filesystem(void) { static wl_handle_t wl_handle; const esp_vfs_fat_mount_config_t mount_config = { @@ -54,7 +54,7 @@ static void initialize_filesystem() } #endif // CONFIG_STORE_HISTORY -static void initialize_console() +static void initialize_console(void) { /* Disable buffering on stdin and stdout */ setvbuf(stdin, NULL, _IONBF, 0); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_system.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_system.c index d3dc6c12f..de76b11ae 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_system.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_system.c @@ -24,11 +24,11 @@ #define CONFIG_ESPTOOLPY_PORT "Which is choosen by Users for CMake" #endif -static void register_free(); -static void register_restart(); -static void register_make(); +static void register_free(void); +static void register_restart(void); +static void register_make(void); -void register_system() +void register_system(void) { register_free(); register_restart(); @@ -43,7 +43,7 @@ static int restart(int argc, char **argv) esp_restart(); } -static void register_restart() +static void register_restart(void) { const esp_console_cmd_t cmd = { .command = "restart", @@ -62,7 +62,7 @@ static int free_mem(int argc, char **argv) return 0; } -static void register_free() +static void register_free(void) { const esp_console_cmd_t cmd = { .command = "free", @@ -165,7 +165,7 @@ R"(MONITOR return 0; } -static void register_make() +static void register_make(void) { const esp_console_cmd_t cmd = { .command = "make", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_cfg_client_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_cfg_client_cmd.c index 53a10d38d..59bae35ce 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_cfg_client_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_cfg_client_cmd.c @@ -33,11 +33,11 @@ typedef struct { } ble_mesh_client_get_set_state_t; ble_mesh_client_get_set_state_t configuration_client_model_operation; -void ble_mesh_register_configuration_client_model_command(); +void ble_mesh_register_configuration_client_model_command(void); void ble_mesh_configuration_client_model_cb(esp_ble_mesh_cfg_client_cb_event_t event, esp_ble_mesh_cfg_client_cb_param_t *param); -void ble_mesh_register_configuration_client_model() +void ble_mesh_register_configuration_client_model(void) { ble_mesh_register_configuration_client_model_command(); } @@ -362,7 +362,7 @@ int ble_mesh_configuration_client_model_operation(int argc, char **argv) } -void ble_mesh_register_configuration_client_model_command() +void ble_mesh_register_configuration_client_model_command(void) { configuration_client_model_operation.action_type = arg_str1("z", NULL, "", "action type"); configuration_client_model_operation.set_state = arg_str0("x", NULL, "", "set state"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_gen_onoff_client_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_gen_onoff_client_cmd.c index 6f34a1b27..f9caa8931 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_gen_onoff_client_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_gen_onoff_client_cmd.c @@ -32,11 +32,11 @@ typedef struct { } ble_mesh_gen_onoff_state_t; ble_mesh_gen_onoff_state_t gen_onoff_state; -void ble_mesh_register_gen_onoff_client_command(); +void ble_mesh_register_gen_onoff_client_command(void); void ble_mesh_generic_onoff_client_model_cb(esp_ble_mesh_generic_client_cb_event_t event, esp_ble_mesh_generic_client_cb_param_t *param); -void ble_mesh_register_gen_onoff_client() +void ble_mesh_register_gen_onoff_client(void) { ble_mesh_register_gen_onoff_client_command(); } @@ -152,7 +152,7 @@ int ble_mesh_generic_onoff_client_model(int argc, char **argv) return err; } -void ble_mesh_register_gen_onoff_client_command() +void ble_mesh_register_gen_onoff_client_command(void) { gen_onoff_state.action_type = arg_str1("z", NULL, "", "action type"); gen_onoff_state.opcode = arg_int0("o", NULL, "", "message opcode"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_test_perf_client_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_test_perf_client_cmd.c index e46efc8ec..b6b4c898f 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_test_perf_client_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_test_perf_client_cmd.c @@ -47,9 +47,9 @@ typedef struct { } ble_mesh_test_perf_client_model_statistics_t; ble_mesh_test_perf_client_model_statistics_t test_perf_client_model_statistics; -void ble_mesh_performance_client_model_command(); +void ble_mesh_performance_client_model_command(void); -void ble_mesh_register_mesh_test_performance_client() +void ble_mesh_register_mesh_test_performance_client(void) { ble_mesh_performance_client_model_command(); } @@ -177,7 +177,7 @@ int ble_mesh_test_performance_client_model_performance(int argc, char **argv) return 0; } -void ble_mesh_performance_client_model_command() +void ble_mesh_performance_client_model_command(void) { test_perf_client_model.action_type = arg_str1("z", NULL, "", "action type"); test_perf_client_model.playload_byte = arg_int0("p", NULL, "", "playload byte"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c index 0e0775aca..dc96f7907 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c @@ -65,18 +65,18 @@ ble_mesh_node_status node_status = { SemaphoreHandle_t ble_mesh_node_sema; -void ble_mesh_register_node_cmd(); +void ble_mesh_register_node_cmd(void); // Register callback function void ble_mesh_prov_cb(esp_ble_mesh_prov_cb_event_t event, esp_ble_mesh_prov_cb_param_t *param); void ble_mesh_model_cb(esp_ble_mesh_model_cb_event_t event, esp_ble_mesh_model_cb_param_t *param); -void ble_mesh_register_mesh_node() +void ble_mesh_register_mesh_node(void) { ble_mesh_register_node_cmd(); } -int ble_mesh_register_node_cb() +int ble_mesh_register_node_cb(void) { ESP_LOGD(TAG, "enter %s\n", __func__); ble_mesh_node_init(); @@ -405,7 +405,7 @@ int ble_mesh_provisioner_enable_bearer(int argc, char **argv) return err; } -void ble_mesh_register_node_cmd() +void ble_mesh_register_node_cmd(void) { const esp_console_cmd_t register_cmd = { .command = "bmreg", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c index 2df3ec5b7..4c95d45b2 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c @@ -80,12 +80,12 @@ typedef struct { } ble_mesh_provisioner_add_key_t; ble_mesh_provisioner_add_key_t provisioner_add_key; -void ble_mesh_regist_provisioner_cmd(); +void ble_mesh_regist_provisioner_cmd(void); void ble_mesh_prov_adv_cb(const esp_bd_addr_t addr, const esp_ble_addr_type_t addr_type, const uint8_t adv_type, const uint8_t *dev_uuid, uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer); -void ble_mesh_register_mesh_provisioner() +void ble_mesh_register_mesh_provisioner(void) { ble_mesh_regist_provisioner_cmd(); } @@ -101,7 +101,7 @@ void ble_mesh_prov_adv_cb(const esp_bd_addr_t addr, const esp_ble_addr_type_t ad ESP_LOGD(TAG, "exit %s\n", __func__); } -int ble_mesh_provisioner_register() +int ble_mesh_provisioner_register(void) { ESP_LOGD(TAG, "enter %s \n", __func__); // esp_ble_mesh_register_unprov_adv_pkt_callback(ble_mesh_prov_adv_cb); @@ -322,7 +322,7 @@ int ble_mesh_provision_bind_local_model(int argc, char **argv) return err; } -void ble_mesh_regist_provisioner_cmd() +void ble_mesh_regist_provisioner_cmd(void) { const esp_console_cmd_t prov_register = { .command = "bmpreg", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/register_bluetooth.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/register_bluetooth.c index 6b856c30f..129617e7e 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/register_bluetooth.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/register_bluetooth.c @@ -18,9 +18,9 @@ #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" -void register_ble_address(); +void register_ble_address(void); -void register_bluetooth() +void register_bluetooth(void) { register_ble_address(); } @@ -32,7 +32,7 @@ int bt_mac(int argc, char** argv) return 0; } -void register_ble_address() +void register_ble_address(void) { const esp_console_cmd_t cmd = { .command = "btmac", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/cmd_wifi.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/cmd_wifi.c index 8d258dc92..15ebcb21c 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/cmd_wifi.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/cmd_wifi.c @@ -389,7 +389,7 @@ static int heap_size(int argc, char **argv) return 0; } -void register_wifi() +void register_wifi(void) { sta_args.ssid = arg_str1(NULL, NULL, "", "SSID of AP"); sta_args.password = arg_str0(NULL, NULL, "", "password of AP"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/ble_mesh_demo_main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/ble_mesh_demo_main.c index cdb2635ad..b68253c38 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/ble_mesh_demo_main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/ble_mesh_demo_main.c @@ -829,7 +829,7 @@ static esp_err_t bluetooth_init(void) #define WIFI_CONNECTED_BIT BIT0 -static void initialize_console() +static void initialize_console(void) { /* Disable buffering on stdin and stdout */ setvbuf(stdin, NULL, _IONBF, 0); diff --git a/examples/bluetooth/nimble/blemesh/main/app_mesh.c b/examples/bluetooth/nimble/blemesh/main/app_mesh.c index 691019265..82dde7ec2 100644 --- a/examples/bluetooth/nimble/blemesh/main/app_mesh.c +++ b/examples/bluetooth/nimble/blemesh/main/app_mesh.c @@ -420,7 +420,7 @@ void blemesh_host_task(void *param) nimble_port_run(); } -void app_main() +void app_main(void) { /* Initialize NVS — it is used to store PHY calibration data */ esp_err_t ret = nvs_flash_init(); diff --git a/examples/bluetooth/nimble/bleprph/main/scli.c b/examples/bluetooth/nimble/bleprph/main/scli.c index d5a2fe955..ec47a104c 100644 --- a/examples/bluetooth/nimble/bleprph/main/scli.c +++ b/examples/bluetooth/nimble/bleprph/main/scli.c @@ -80,7 +80,7 @@ static esp_console_cmd_t cmds[] = { }, }; -static int ble_register_cli() +static int ble_register_cli(void) { int cmds_num = sizeof(cmds) / sizeof(esp_console_cmd_t); int i; @@ -144,7 +144,7 @@ static void scli_task(void *arg) vTaskDelete(NULL); } -int scli_init() +int scli_init(void) { /* Register CLI "key " to accept input from user during pairing */ ble_register_cli(); diff --git a/examples/build_system/cmake/idf_as_lib/main.c b/examples/build_system/cmake/idf_as_lib/main.c index 59f0aa0f5..9eb73f55e 100644 --- a/examples/build_system/cmake/idf_as_lib/main.c +++ b/examples/build_system/cmake/idf_as_lib/main.c @@ -12,7 +12,7 @@ #include "esp_system.h" #include "esp_spi_flash.h" -void app_main() +void app_main(void) { printf("Hello world!\n"); diff --git a/examples/build_system/cmake/idf_as_lib/stubs/esp32/cpu_start.c b/examples/build_system/cmake/idf_as_lib/stubs/esp32/cpu_start.c index 44eedcb42..4aa606c8a 100644 --- a/examples/build_system/cmake/idf_as_lib/stubs/esp32/cpu_start.c +++ b/examples/build_system/cmake/idf_as_lib/stubs/esp32/cpu_start.c @@ -1,10 +1,10 @@ #include #include -extern void app_main(); +extern void app_main(void); jmp_buf buf; -int main() +int main(void) { setjmp(buf); app_main(); diff --git a/examples/build_system/cmake/idf_as_lib/stubs/esp32/flash_ops.c b/examples/build_system/cmake/idf_as_lib/stubs/esp32/flash_ops.c index 175e84b6e..72d5b6e4b 100644 --- a/examples/build_system/cmake/idf_as_lib/stubs/esp32/flash_ops.c +++ b/examples/build_system/cmake/idf_as_lib/stubs/esp32/flash_ops.c @@ -1,6 +1,6 @@ #include "esp_spi_flash.h" -int spi_flash_get_chip_size() +int spi_flash_get_chip_size(void) { return (1024 * 1024 * 1024); } \ No newline at end of file diff --git a/examples/build_system/cmake/idf_as_lib/stubs/spi_flash/esp_spi_flash.h b/examples/build_system/cmake/idf_as_lib/stubs/spi_flash/esp_spi_flash.h index 544f3611b..4ca6ae940 100644 --- a/examples/build_system/cmake/idf_as_lib/stubs/spi_flash/esp_spi_flash.h +++ b/examples/build_system/cmake/idf_as_lib/stubs/spi_flash/esp_spi_flash.h @@ -2,4 +2,4 @@ #include -int spi_flash_get_chip_size(); \ No newline at end of file +int spi_flash_get_chip_size(void); \ No newline at end of file diff --git a/examples/common_components/protocol_examples_common/connect.c b/examples/common_components/protocol_examples_common/connect.c index 68895905a..8ee8aea9d 100644 --- a/examples/common_components/protocol_examples_common/connect.c +++ b/examples/common_components/protocol_examples_common/connect.c @@ -41,10 +41,10 @@ static ip6_addr_t s_ipv6_addr; static const char *TAG = "example_connect"; /* set up connection, Wi-Fi or Ethernet */ -static void start(); +static void start(void); /* tear down connection, release resources */ -static void stop(); +static void stop(void); static void on_got_ip(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) @@ -66,7 +66,7 @@ static void on_got_ipv6(void *arg, esp_event_base_t event_base, #endif // CONFIG_EXAMPLE_CONNECT_IPV6 -esp_err_t example_connect() +esp_err_t example_connect(void) { if (s_connect_event_group != NULL) { return ESP_ERR_INVALID_STATE; @@ -82,7 +82,7 @@ esp_err_t example_connect() return ESP_OK; } -esp_err_t example_disconnect() +esp_err_t example_disconnect(void) { if (s_connect_event_group == NULL) { return ESP_ERR_INVALID_STATE; @@ -114,7 +114,7 @@ static void on_wifi_connect(void *arg, esp_event_base_t event_base, #endif // CONFIG_EXAMPLE_CONNECT_IPV6 -static void start() +static void start(void) { wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK(esp_wifi_init(&cfg)); @@ -141,7 +141,7 @@ static void start() s_connection_name = CONFIG_EXAMPLE_WIFI_SSID; } -static void stop() +static void stop(void) { ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &on_wifi_disconnect)); ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, &on_got_ip)); @@ -178,7 +178,7 @@ static esp_eth_handle_t s_eth_handle = NULL; static esp_eth_mac_t *s_mac = NULL; static esp_eth_phy_t *s_phy = NULL; -static void start() +static void start(void) { ESP_ERROR_CHECK(tcpip_adapter_set_default_eth_handlers()); ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &on_got_ip, NULL)); @@ -229,7 +229,7 @@ static void start() s_connection_name = "Ethernet"; } -static void stop() +static void stop(void) { ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_ETH_GOT_IP, &on_got_ip)); #ifdef CONFIG_EXAMPLE_CONNECT_IPV6 diff --git a/examples/common_components/protocol_examples_common/include/protocol_examples_common.h b/examples/common_components/protocol_examples_common/include/protocol_examples_common.h index e250db14d..d4f6e1fbb 100644 --- a/examples/common_components/protocol_examples_common/include/protocol_examples_common.h +++ b/examples/common_components/protocol_examples_common/include/protocol_examples_common.h @@ -39,12 +39,12 @@ extern "C" { * * @return ESP_OK on successful connection */ -esp_err_t example_connect(); +esp_err_t example_connect(void); /** * Counterpart to example_connect, de-initializes Wi-Fi or Ethernet */ -esp_err_t example_disconnect(); +esp_err_t example_disconnect(void); /** * @brief Configure stdin and stdout to use blocking I/O @@ -52,7 +52,7 @@ esp_err_t example_disconnect(); * This helper function is used in ASIO examples. It wraps installing the * UART driver and configuring VFS layer to use UART driver for console I/O. */ -esp_err_t example_configure_stdin_stdout(); +esp_err_t example_configure_stdin_stdout(void); #ifdef __cplusplus } diff --git a/examples/common_components/protocol_examples_common/stdin_out.c b/examples/common_components/protocol_examples_common/stdin_out.c index cb2220db4..10cc2167f 100644 --- a/examples/common_components/protocol_examples_common/stdin_out.c +++ b/examples/common_components/protocol_examples_common/stdin_out.c @@ -13,7 +13,7 @@ #include "driver/uart.h" #include "sdkconfig.h" -esp_err_t example_configure_stdin_stdout() +esp_err_t example_configure_stdin_stdout(void) { // Initialize VFS & UART so we can use std::cout/cin setvbuf(stdin, NULL, _IONBF, 0); diff --git a/examples/ethernet/basic/main/ethernet_example_main.c b/examples/ethernet/basic/main/ethernet_example_main.c index ed794a32b..a58bab806 100644 --- a/examples/ethernet/basic/main/ethernet_example_main.c +++ b/examples/ethernet/basic/main/ethernet_example_main.c @@ -62,7 +62,7 @@ static void got_ip_event_handler(void *arg, esp_event_base_t event_base, ESP_LOGI(TAG, "~~~~~~~~~~~"); } -void app_main() +void app_main(void) { tcpip_adapter_init(); diff --git a/examples/ethernet/eth2ap/main/ethernet_example_main.c b/examples/ethernet/eth2ap/main/ethernet_example_main.c index 4796cd9a1..3b540fad0 100644 --- a/examples/ethernet/eth2ap/main/ethernet_example_main.c +++ b/examples/ethernet/eth2ap/main/ethernet_example_main.c @@ -226,7 +226,7 @@ static esp_err_t initialize_flow_control(void) return ESP_OK; } -void app_main() +void app_main(void) { esp_err_t ret = nvs_flash_init(); if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { diff --git a/examples/ethernet/iperf/main/cmd_ethernet.c b/examples/ethernet/iperf/main/cmd_ethernet.c index 832d049b0..d148b5a28 100644 --- a/examples/ethernet/iperf/main/cmd_ethernet.c +++ b/examples/ethernet/iperf/main/cmd_ethernet.c @@ -173,7 +173,7 @@ static void event_handler(void *arg, esp_event_base_t event_base, } } -void register_ethernet() +void register_ethernet(void) { eth_event_group = xEventGroupCreate(); tcpip_adapter_init(); diff --git a/examples/ethernet/iperf/main/cmd_ethernet.h b/examples/ethernet/iperf/main/cmd_ethernet.h index bd619c7ff..e99615151 100644 --- a/examples/ethernet/iperf/main/cmd_ethernet.h +++ b/examples/ethernet/iperf/main/cmd_ethernet.h @@ -13,7 +13,7 @@ extern "C" { #endif // Register Ethernet functions -void register_ethernet(); +void register_ethernet(void); #ifdef __cplusplus } diff --git a/examples/ethernet/iperf/main/ethernet_example_main.c b/examples/ethernet/iperf/main/ethernet_example_main.c index 1f0718fd0..0d881fa5d 100644 --- a/examples/ethernet/iperf/main/ethernet_example_main.c +++ b/examples/ethernet/iperf/main/ethernet_example_main.c @@ -29,7 +29,7 @@ static const char *TAG = "eth_example"; #define MOUNT_PATH "/data" #define HISTORY_PATH MOUNT_PATH "/history.txt" -static void initialize_filesystem() +static void initialize_filesystem(void) { static wl_handle_t wl_handle; const esp_vfs_fat_mount_config_t mount_config = { @@ -44,7 +44,7 @@ static void initialize_filesystem() } #endif // CONFIG_EXAMPLE_STORE_HISTORY -static void initialize_nvs() +static void initialize_nvs(void) { esp_err_t err = nvs_flash_init(); if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { @@ -54,7 +54,7 @@ static void initialize_nvs() ESP_ERROR_CHECK(err); } -static void initialize_console() +static void initialize_console(void) { /* Disable buffering on stdin */ setvbuf(stdin, NULL, _IONBF, 0); @@ -109,7 +109,7 @@ static void initialize_console() #endif } -void app_main() +void app_main(void) { initialize_nvs(); diff --git a/examples/get-started/blink/main/blink.c b/examples/get-started/blink/main/blink.c index 9c58645f9..610ac8514 100644 --- a/examples/get-started/blink/main/blink.c +++ b/examples/get-started/blink/main/blink.c @@ -17,7 +17,7 @@ */ #define BLINK_GPIO CONFIG_BLINK_GPIO -void app_main() +void app_main(void) { /* Configure the IOMUX register for pad BLINK_GPIO (some pads are muxed to GPIO on reset already, but some default to other diff --git a/examples/get-started/hello_world/main/hello_world_main.c b/examples/get-started/hello_world/main/hello_world_main.c index c17eb1b20..7bb54d2fd 100644 --- a/examples/get-started/hello_world/main/hello_world_main.c +++ b/examples/get-started/hello_world/main/hello_world_main.c @@ -13,7 +13,7 @@ #include "esp_spi_flash.h" -void app_main() +void app_main(void) { printf("Hello world!\n"); diff --git a/examples/peripherals/adc/main/adc1_example_main.c b/examples/peripherals/adc/main/adc1_example_main.c index 00de0ab8b..d0f20a6e6 100644 --- a/examples/peripherals/adc/main/adc1_example_main.c +++ b/examples/peripherals/adc/main/adc1_example_main.c @@ -22,7 +22,7 @@ static const adc_channel_t channel = ADC_CHANNEL_6; //GPIO34 if ADC1, GPIO14 static const adc_atten_t atten = ADC_ATTEN_DB_0; static const adc_unit_t unit = ADC_UNIT_1; -static void check_efuse() +static void check_efuse(void) { //Check TP is burned into eFuse if (esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP) == ESP_OK) { @@ -50,7 +50,7 @@ static void print_char_val_type(esp_adc_cal_value_t val_type) } } -void app_main() +void app_main(void) { //Check if Two Point or Vref are burned into eFuse check_efuse(); diff --git a/examples/peripherals/can/can_alert_and_recovery/main/can_alert_and_recovery_example_main.c b/examples/peripherals/can/can_alert_and_recovery/main/can_alert_and_recovery_example_main.c index fab6d4bb0..ea4ac360e 100644 --- a/examples/peripherals/can/can_alert_and_recovery/main/can_alert_and_recovery_example_main.c +++ b/examples/peripherals/can/can_alert_and_recovery/main/can_alert_and_recovery_example_main.c @@ -127,7 +127,7 @@ static void ctrl_task(void *arg) vTaskDelete(NULL); } -void app_main() +void app_main(void) { tx_task_sem = xSemaphoreCreateBinary(); ctrl_task_sem = xSemaphoreCreateBinary(); diff --git a/examples/peripherals/can/can_network/can_network_listen_only/main/can_network_example_listen_only_main.c b/examples/peripherals/can/can_network/can_network_listen_only/main/can_network_example_listen_only_main.c index 5309bbd0b..2bfc8281a 100644 --- a/examples/peripherals/can/can_network/can_network_listen_only/main/can_network_example_listen_only_main.c +++ b/examples/peripherals/can/can_network/can_network_listen_only/main/can_network_example_listen_only_main.c @@ -97,7 +97,7 @@ static void can_receive_task(void *arg) vTaskDelete(NULL); } -void app_main() +void app_main(void) { rx_sem = xSemaphoreCreateBinary(); xTaskCreatePinnedToCore(can_receive_task, "CAN_rx", 4096, NULL, RX_TASK_PRIO, NULL, tskNO_AFFINITY); diff --git a/examples/peripherals/can/can_network/can_network_master/main/can_network_example_master_main.c b/examples/peripherals/can/can_network/can_network_master/main/can_network_example_master_main.c index 7372e7f77..f744072d8 100644 --- a/examples/peripherals/can/can_network/can_network_master/main/can_network_example_master_main.c +++ b/examples/peripherals/can/can_network/can_network_master/main/can_network_example_master_main.c @@ -205,7 +205,7 @@ static void can_control_task(void *arg) vTaskDelete(NULL); } -void app_main() +void app_main(void) { //Create tasks, queues, and semaphores rx_task_queue = xQueueCreate(1, sizeof(rx_task_action_t)); diff --git a/examples/peripherals/can/can_network/can_network_slave/main/can_network_example_slave_main.c b/examples/peripherals/can/can_network/can_network_slave/main/can_network_example_slave_main.c index 7c4a793bd..17ad07b8b 100644 --- a/examples/peripherals/can/can_network/can_network_slave/main/can_network_example_slave_main.c +++ b/examples/peripherals/can/can_network/can_network_slave/main/can_network_example_slave_main.c @@ -225,7 +225,7 @@ static void can_control_task(void *arg) vTaskDelete(NULL); } -void app_main() +void app_main(void) { //Add short delay to allow master it to initialize first for (int i = 3; i > 0; i--) { diff --git a/examples/peripherals/can/can_self_test/main/can_self_test_example_main.c b/examples/peripherals/can/can_self_test/main/can_self_test_example_main.c index bb17722cc..e3a12522c 100644 --- a/examples/peripherals/can/can_self_test/main/can_self_test_example_main.c +++ b/examples/peripherals/can/can_self_test/main/can_self_test_example_main.c @@ -107,7 +107,7 @@ static void can_control_task(void *arg) vTaskDelete(NULL); } -void app_main() +void app_main(void) { //Create tasks and synchronization primitives tx_sem = xSemaphoreCreateBinary(); diff --git a/examples/peripherals/gpio/main/gpio_example_main.c b/examples/peripherals/gpio/main/gpio_example_main.c index b6e71339e..9609daf79 100644 --- a/examples/peripherals/gpio/main/gpio_example_main.c +++ b/examples/peripherals/gpio/main/gpio_example_main.c @@ -57,7 +57,7 @@ static void gpio_task_example(void* arg) } } -void app_main() +void app_main(void) { gpio_config_t io_conf; //disable interrupt diff --git a/examples/peripherals/i2c/i2c_self_test/main/i2c_example_main.c b/examples/peripherals/i2c/i2c_self_test/main/i2c_example_main.c index 9b108a9aa..7fe6e0ffc 100644 --- a/examples/peripherals/i2c/i2c_self_test/main/i2c_example_main.c +++ b/examples/peripherals/i2c/i2c_self_test/main/i2c_example_main.c @@ -141,7 +141,7 @@ static esp_err_t i2c_master_sensor_test(i2c_port_t i2c_num, uint8_t *data_h, uin /** * @brief i2c master initialization */ -static esp_err_t i2c_master_init() +static esp_err_t i2c_master_init(void) { int i2c_master_port = I2C_MASTER_NUM; i2c_config_t conf; @@ -160,7 +160,7 @@ static esp_err_t i2c_master_init() /** * @brief i2c slave initialization */ -static esp_err_t i2c_slave_init() +static esp_err_t i2c_slave_init(void) { int i2c_slave_port = I2C_SLAVE_NUM; i2c_config_t conf_slave; @@ -281,7 +281,7 @@ static void i2c_test_task(void *arg) vTaskDelete(NULL); } -void app_main() +void app_main(void) { print_mux = xSemaphoreCreateMutex(); ESP_ERROR_CHECK(i2c_slave_init()); diff --git a/examples/peripherals/i2c/i2c_tools/main/cmd_i2ctools.c b/examples/peripherals/i2c/i2c_tools/main/cmd_i2ctools.c index b9c87369c..1030f4387 100644 --- a/examples/peripherals/i2c/i2c_tools/main/cmd_i2ctools.c +++ b/examples/peripherals/i2c/i2c_tools/main/cmd_i2ctools.c @@ -48,7 +48,7 @@ static esp_err_t i2c_get_port(int port, i2c_port_t *i2c_port) return ESP_OK; } -static esp_err_t i2c_master_driver_initialize() +static esp_err_t i2c_master_driver_initialize(void) { i2c_config_t conf = { .mode = I2C_MODE_MASTER, diff --git a/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c b/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c index ea79a854d..0cffbafd6 100644 --- a/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c +++ b/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c @@ -29,7 +29,7 @@ static const char *TAG = "i2c-tools"; #define MOUNT_PATH "/data" #define HISTORY_PATH MOUNT_PATH "/history.txt" -static void initialize_filesystem() +static void initialize_filesystem(void) { static wl_handle_t wl_handle; const esp_vfs_fat_mount_config_t mount_config = { @@ -44,7 +44,7 @@ static void initialize_filesystem() } #endif // CONFIG_EXAMPLE_STORE_HISTORY -static void initialize_nvs() +static void initialize_nvs(void) { esp_err_t err = nvs_flash_init(); if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { @@ -54,7 +54,7 @@ static void initialize_nvs() ESP_ERROR_CHECK(err); } -static void initialize_console() +static void initialize_console(void) { /* Disable buffering on stdin */ setvbuf(stdin, NULL, _IONBF, 0); @@ -109,7 +109,7 @@ static void initialize_console() #endif } -void app_main() +void app_main(void) { initialize_nvs(); diff --git a/examples/peripherals/i2s/main/i2s_example_main.c b/examples/peripherals/i2s/main/i2s_example_main.c index 36bbabc18..04c90261d 100644 --- a/examples/peripherals/i2s/main/i2s_example_main.c +++ b/examples/peripherals/i2s/main/i2s_example_main.c @@ -77,7 +77,7 @@ static void setup_triangle_sine_waves(int bits) free(samples_data); } -void app_main() +void app_main(void) { //for 36Khz sample rates, we create 100Hz sine wave, every cycle need 36000/100 = 360 samples (4-bytes or 8-bytes each sample) //depend on bits_per_sample diff --git a/examples/peripherals/i2s_adc_dac/main/app_main.c b/examples/peripherals/i2s_adc_dac/main/app_main.c index 9d3018b4b..44bdea4ef 100644 --- a/examples/peripherals/i2s_adc_dac/main/app_main.c +++ b/examples/peripherals/i2s_adc_dac/main/app_main.c @@ -56,7 +56,7 @@ static const char* TAG = "ad/da"; /** * @brief I2S ADC/DAC mode init. */ -void example_i2s_init() +void example_i2s_init(void) { int i2s_num = EXAMPLE_I2S_NUM; i2s_config_t i2s_config = { @@ -81,7 +81,7 @@ void example_i2s_init() /* * @brief erase flash for recording */ -void example_erase_flash() +void example_erase_flash(void) { #if RECORD_IN_FLASH_EN printf("Erasing flash \n"); @@ -118,7 +118,7 @@ void example_disp_buf(uint8_t* buf, int length) /** * @brief Reset i2s clock and mode */ -void example_reset_play_mode() +void example_reset_play_mode(void) { i2s_set_clk(EXAMPLE_I2S_NUM, EXAMPLE_I2S_SAMPLE_RATE, EXAMPLE_I2S_SAMPLE_BITS, EXAMPLE_I2S_CHANNEL_NUM); } @@ -126,7 +126,7 @@ void example_reset_play_mode() /** * @brief Set i2s clock for example audio file */ -void example_set_file_play_mode() +void example_set_file_play_mode(void) { i2s_set_clk(EXAMPLE_I2S_NUM, 16000, EXAMPLE_I2S_SAMPLE_BITS, 1); } @@ -280,7 +280,7 @@ void adc_read_task(void* arg) } } -esp_err_t app_main() +esp_err_t app_main(void) { example_i2s_init(); esp_log_level_set("I2S", ESP_LOG_INFO); diff --git a/examples/peripherals/ledc/main/ledc_example_main.c b/examples/peripherals/ledc/main/ledc_example_main.c index d61e73fba..3a0cd5e97 100644 --- a/examples/peripherals/ledc/main/ledc_example_main.c +++ b/examples/peripherals/ledc/main/ledc_example_main.c @@ -51,7 +51,7 @@ #define LEDC_TEST_DUTY (4000) #define LEDC_TEST_FADE_TIME (3000) -void app_main() +void app_main(void) { int ch; diff --git a/examples/peripherals/mcpwm/mcpwm_basic_config/main/mcpwm_basic_config_example.c b/examples/peripherals/mcpwm/mcpwm_basic_config/main/mcpwm_basic_config_example.c index 7853c1490..ef750de1a 100644 --- a/examples/peripherals/mcpwm/mcpwm_basic_config/main/mcpwm_basic_config_example.c +++ b/examples/peripherals/mcpwm/mcpwm_basic_config/main/mcpwm_basic_config_example.c @@ -62,7 +62,7 @@ xQueueHandle cap_queue; static mcpwm_dev_t *MCPWM[2] = {&MCPWM0, &MCPWM1}; #endif -static void mcpwm_example_gpio_initialize() +static void mcpwm_example_gpio_initialize(void) { printf("initializing mcpwm gpio...\n"); #if MCPWM_GPIO_INIT @@ -167,7 +167,7 @@ static void disp_captured_signal(void *arg) /** * @brief this is ISR handler function, here we check for interrupt that triggers rising edge on CAP0 signal and according take action */ -static void IRAM_ATTR isr_handler() +static void IRAM_ATTR isr_handler(void) { uint32_t mcpwm_intr_status; capture evt; @@ -282,7 +282,7 @@ static void mcpwm_example_config(void *arg) vTaskDelete(NULL); } -void app_main() +void app_main(void) { printf("Testing MCPWM...\n"); cap_queue = xQueueCreate(1, sizeof(capture)); //comment if you don't want to use capture module diff --git a/examples/peripherals/mcpwm/mcpwm_bldc_control/main/mcpwm_bldc_control_hall_sensor_example.c b/examples/peripherals/mcpwm/mcpwm_bldc_control/main/mcpwm_bldc_control_hall_sensor_example.c index ecef139cc..c8bfe0001 100644 --- a/examples/peripherals/mcpwm/mcpwm_bldc_control/main/mcpwm_bldc_control_hall_sensor_example.c +++ b/examples/peripherals/mcpwm/mcpwm_bldc_control/main/mcpwm_bldc_control_hall_sensor_example.c @@ -58,7 +58,7 @@ xQueueHandle cap_queue; static mcpwm_dev_t *MCPWM[2] = {&MCPWM0, &MCPWM1}; -static void mcpwm_example_gpio_initialize() +static void mcpwm_example_gpio_initialize(void) { printf("initializing mcpwm bldc control gpio...\n"); #if MCPWM_GPIO_INIT @@ -162,7 +162,7 @@ static void disp_captured_signal(void *arg) /** * @brief this is ISR handler function, here we check for interrupt that triggers rising edge on CAP0 signal and according take action */ -static void IRAM_ATTR isr_handler() +static void IRAM_ATTR isr_handler(void) { uint32_t mcpwm_intr_status; capture evt; @@ -307,7 +307,7 @@ static void mcpwm_example_bldc_control(void *arg) } } -void app_main() +void app_main(void) { printf("Testing MCPWM BLDC Control...\n"); #if CHANGE_DUTY_CONTINUOUSLY diff --git a/examples/peripherals/mcpwm/mcpwm_brushed_dc_control/main/mcpwm_brushed_dc_control_example.c b/examples/peripherals/mcpwm/mcpwm_brushed_dc_control/main/mcpwm_brushed_dc_control_example.c index 2c721e77a..ee35fcc60 100644 --- a/examples/peripherals/mcpwm/mcpwm_brushed_dc_control/main/mcpwm_brushed_dc_control_example.c +++ b/examples/peripherals/mcpwm/mcpwm_brushed_dc_control/main/mcpwm_brushed_dc_control_example.c @@ -25,7 +25,7 @@ #define GPIO_PWM0A_OUT 15 //Set GPIO 15 as PWM0A #define GPIO_PWM0B_OUT 16 //Set GPIO 16 as PWM0B -static void mcpwm_example_gpio_initialize() +static void mcpwm_example_gpio_initialize(void) { printf("initializing mcpwm gpio...\n"); mcpwm_gpio_init(MCPWM_UNIT_0, MCPWM0A, GPIO_PWM0A_OUT); @@ -88,7 +88,7 @@ static void mcpwm_example_brushed_motor_control(void *arg) } } -void app_main() +void app_main(void) { printf("Testing brushed motor...\n"); xTaskCreate(mcpwm_example_brushed_motor_control, "mcpwm_examlpe_brushed_motor_control", 4096, NULL, 5, NULL); diff --git a/examples/peripherals/mcpwm/mcpwm_servo_control/main/mcpwm_servo_control_example.c b/examples/peripherals/mcpwm/mcpwm_servo_control/main/mcpwm_servo_control_example.c index 2a944e5da..88841f252 100644 --- a/examples/peripherals/mcpwm/mcpwm_servo_control/main/mcpwm_servo_control_example.c +++ b/examples/peripherals/mcpwm/mcpwm_servo_control/main/mcpwm_servo_control_example.c @@ -20,7 +20,7 @@ #define SERVO_MAX_PULSEWIDTH 2000 //Maximum pulse width in microsecond #define SERVO_MAX_DEGREE 90 //Maximum angle in degree upto which servo can rotate -static void mcpwm_example_gpio_initialize() +static void mcpwm_example_gpio_initialize(void) { printf("initializing mcpwm servo control gpio......\n"); mcpwm_gpio_init(MCPWM_UNIT_0, MCPWM0A, 18); //Set GPIO 18 as PWM0A, to which servo is connected @@ -70,7 +70,7 @@ void mcpwm_example_servo_control(void *arg) } } -void app_main() +void app_main(void) { printf("Testing servo motor.......\n"); xTaskCreate(mcpwm_example_servo_control, "mcpwm_example_servo_control", 4096, NULL, 5, NULL); diff --git a/examples/peripherals/pcnt/main/pcnt_example_main.c b/examples/peripherals/pcnt/main/pcnt_example_main.c index f734501fc..89a370363 100644 --- a/examples/peripherals/pcnt/main/pcnt_example_main.c +++ b/examples/peripherals/pcnt/main/pcnt_example_main.c @@ -167,7 +167,7 @@ static void pcnt_example_init(void) pcnt_counter_resume(PCNT_TEST_UNIT); } -void app_main() +void app_main(void) { /* Initialize LEDC to generate sample pulse signal */ ledc_init(); diff --git a/examples/peripherals/rmt_nec_tx_rx/main/infrared_nec_main.c b/examples/peripherals/rmt_nec_tx_rx/main/infrared_nec_main.c index cebffbcae..1dc28e5ac 100644 --- a/examples/peripherals/rmt_nec_tx_rx/main/infrared_nec_main.c +++ b/examples/peripherals/rmt_nec_tx_rx/main/infrared_nec_main.c @@ -235,7 +235,7 @@ static int nec_build_items(int channel, rmt_item32_t* item, int item_num, uint16 /* * @brief RMT transmitter initialization */ -static void nec_tx_init() +static void nec_tx_init(void) { rmt_config_t rmt_tx; rmt_tx.channel = RMT_TX_CHANNEL; @@ -257,7 +257,7 @@ static void nec_tx_init() /* * @brief RMT receiver initialization */ -static void nec_rx_init() +static void nec_rx_init(void) { rmt_config_t rmt_rx; rmt_rx.channel = RMT_RX_CHANNEL; @@ -276,7 +276,7 @@ static void nec_rx_init() * @brief RMT receiver demo, this task will print each received NEC data. * */ -static void rmt_example_nec_rx_task() +static void rmt_example_nec_rx_task(void) { int channel = RMT_RX_CHANNEL; nec_rx_init(); @@ -317,7 +317,7 @@ static void rmt_example_nec_rx_task() * @brief RMT transmitter demo, this task will periodically send NEC data. (100 * 32 bits each time.) * */ -static void rmt_example_nec_tx_task() +static void rmt_example_nec_tx_task(void) { vTaskDelay(10); nec_tx_init(); @@ -355,7 +355,7 @@ static void rmt_example_nec_tx_task() vTaskDelete(NULL); } -void app_main() +void app_main(void) { xTaskCreate(rmt_example_nec_rx_task, "rmt_nec_rx_task", 2048, NULL, 10, NULL); xTaskCreate(rmt_example_nec_tx_task, "rmt_nec_tx_task", 2048, NULL, 10, NULL); diff --git a/examples/peripherals/rmt_tx/main/rmt_tx_main.c b/examples/peripherals/rmt_tx/main/rmt_tx_main.c index ad6e4f6f6..c36672206 100644 --- a/examples/peripherals/rmt_tx/main/rmt_tx_main.c +++ b/examples/peripherals/rmt_tx/main/rmt_tx_main.c @@ -84,7 +84,7 @@ static void IRAM_ATTR u8_to_rmt(const void* src, rmt_item32_t* dest, size_t src_ /* * Initialize the RMT Tx channel */ -static void rmt_tx_int() +static void rmt_tx_int(void) { rmt_config_t config; config.rmt_mode = RMT_MODE_TX; diff --git a/examples/peripherals/sdio/host/main/app_main.c b/examples/peripherals/sdio/host/main/app_main.c index b0b62d15d..b12f18677 100644 --- a/examples/peripherals/sdio/host/main/app_main.c +++ b/examples/peripherals/sdio/host/main/app_main.c @@ -123,7 +123,7 @@ esp_err_t slave_reset(esp_slave_context_t *context) } #ifdef CONFIG_EXAMPLE_SDIO_OVER_SPI -static void gpio_d2_set_high() +static void gpio_d2_set_high(void) { gpio_config_t d2_config = { .pin_bit_mask = BIT(SDIO_SLAVE_SLOT1_IOMUX_PIN_NUM_D2), @@ -257,7 +257,7 @@ esp_err_t slave_init(esp_slave_context_t *context) } -void slave_power_on() +void slave_power_on(void) { #ifdef SLAVE_PWR_GPIO int level_active; @@ -410,7 +410,7 @@ void job_getint(esp_slave_context_t *context) slave_inform_job(context, JOB_SEND_INT); } -void app_main() +void app_main(void) { esp_slave_context_t context; esp_err_t err; diff --git a/examples/peripherals/sdio/slave/main/app_main.c b/examples/peripherals/sdio/slave/main/app_main.c index dd7a73a61..147f4aba4 100644 --- a/examples/peripherals/sdio/slave/main/app_main.c +++ b/examples/peripherals/sdio/slave/main/app_main.c @@ -85,7 +85,7 @@ static const char job_desc[][32] = { //reset counters of the slave hardware, and clean the receive buffer (normally they should be sent back to the host) -static esp_err_t slave_reset() +static esp_err_t slave_reset(void) { esp_err_t ret; sdio_slave_stop(); @@ -106,7 +106,7 @@ static esp_err_t slave_reset() } //sent interrupts to the host in turns -static esp_err_t task_hostint() +static esp_err_t task_hostint(void) { for(int i = 0; i < 8; i++) { ESP_LOGV(TAG, "send intr: %d", i); @@ -120,7 +120,7 @@ static esp_err_t task_hostint() //read the value in a specified register set by the host, and set other register according to this. //the host will read these registers later -static esp_err_t task_write_reg() +static esp_err_t task_write_reg(void) { //the host write REG1, the slave should write its registers according to value of REG1 uint8_t read = sdio_slave_read_reg(1); @@ -157,7 +157,7 @@ static void event_cb(uint8_t pos) DMA_ATTR uint8_t buffer[BUFFER_NUM][BUFFER_SIZE] = {}; //Main application -void app_main() +void app_main(void) { esp_err_t ret; diff --git a/examples/peripherals/sigmadelta/main/sigmadelta_example_main.c b/examples/peripherals/sigmadelta/main/sigmadelta_example_main.c index 38bf2c099..4dee4ad17 100644 --- a/examples/peripherals/sigmadelta/main/sigmadelta_example_main.c +++ b/examples/peripherals/sigmadelta/main/sigmadelta_example_main.c @@ -35,7 +35,7 @@ static void sigmadelta_example_init(void) * Perform the sigma-delta modulation test * by changing the duty of the output signal. */ -void app_main() +void app_main(void) { sigmadelta_example_init(); diff --git a/examples/peripherals/spi_master/main/pretty_effect.c b/examples/peripherals/spi_master/main/pretty_effect.c index 9cd58c066..56903a38c 100644 --- a/examples/peripherals/spi_master/main/pretty_effect.c +++ b/examples/peripherals/spi_master/main/pretty_effect.c @@ -55,7 +55,7 @@ void pretty_effect_calc_lines(uint16_t *dest, int line, int frame, int linect) } -esp_err_t pretty_effect_init() +esp_err_t pretty_effect_init(void) { return decode_image(&pixels); } diff --git a/examples/peripherals/spi_master/main/pretty_effect.h b/examples/peripherals/spi_master/main/pretty_effect.h index 7f54a3245..00f000c04 100644 --- a/examples/peripherals/spi_master/main/pretty_effect.h +++ b/examples/peripherals/spi_master/main/pretty_effect.h @@ -19,4 +19,4 @@ void pretty_effect_calc_lines(uint16_t *dest, int line, int frame, int linect); * * @return ESP_OK on success, an error from the jpeg decoder otherwise. */ -esp_err_t pretty_effect_init(); +esp_err_t pretty_effect_init(void); diff --git a/examples/peripherals/spi_master/main/spi_master_example_main.c b/examples/peripherals/spi_master/main/spi_master_example_main.c index 3d4d304ea..0e4cea345 100644 --- a/examples/peripherals/spi_master/main/spi_master_example_main.c +++ b/examples/peripherals/spi_master/main/spi_master_example_main.c @@ -386,7 +386,7 @@ static void display_pretty_colors(spi_device_handle_t spi) } } -void app_main() +void app_main(void) { esp_err_t ret; spi_device_handle_t spi; diff --git a/examples/peripherals/spi_slave/receiver/main/app_main.c b/examples/peripherals/spi_slave/receiver/main/app_main.c index 1a51c653a..3071e77d2 100644 --- a/examples/peripherals/spi_slave/receiver/main/app_main.c +++ b/examples/peripherals/spi_slave/receiver/main/app_main.c @@ -69,7 +69,7 @@ void my_post_trans_cb(spi_slave_transaction_t *trans) { } //Main application -void app_main() +void app_main(void) { int n=0; esp_err_t ret; diff --git a/examples/peripherals/spi_slave/sender/main/app_main.c b/examples/peripherals/spi_slave/sender/main/app_main.c index af7dc2275..66323dad5 100644 --- a/examples/peripherals/spi_slave/sender/main/app_main.c +++ b/examples/peripherals/spi_slave/sender/main/app_main.c @@ -81,7 +81,7 @@ static void IRAM_ATTR gpio_handshake_isr_handler(void* arg) } //Main application -void app_main() +void app_main(void) { esp_err_t ret; spi_device_handle_t handle; diff --git a/examples/peripherals/timer_group/main/timer_group_example_main.c b/examples/peripherals/timer_group/main/timer_group_example_main.c index 572e35e61..403f9c0a0 100644 --- a/examples/peripherals/timer_group/main/timer_group_example_main.c +++ b/examples/peripherals/timer_group/main/timer_group_example_main.c @@ -163,7 +163,7 @@ static void timer_example_evt_task(void *arg) /* * In this example, we will test hardware timer0 and timer1 of timer group0. */ -void app_main() +void app_main(void) { timer_queue = xQueueCreate(10, sizeof(timer_event_t)); example_tg0_timer_init(TIMER_0, TEST_WITHOUT_RELOAD, TIMER_INTERVAL0_SEC); diff --git a/examples/peripherals/touch_pad_interrupt/main/tp_interrupt_main.c b/examples/peripherals/touch_pad_interrupt/main/tp_interrupt_main.c index 1ed6bcabd..7b3f244ce 100644 --- a/examples/peripherals/touch_pad_interrupt/main/tp_interrupt_main.c +++ b/examples/peripherals/touch_pad_interrupt/main/tp_interrupt_main.c @@ -137,7 +137,7 @@ static void tp_example_rtc_intr(void * arg) /* * Before reading touch pad, we need to initialize the RTC IO. */ -static void tp_example_touch_pad_init() +static void tp_example_touch_pad_init(void) { for (int i = 0;i< TOUCH_PAD_MAX;i++) { //init RTC IO and mode for touch pad. @@ -145,7 +145,7 @@ static void tp_example_touch_pad_init() } } -void app_main() +void app_main(void) { // Initialize touch pad peripheral, it will start a timer to run a filter ESP_LOGI(TAG, "Initializing touch pad"); diff --git a/examples/peripherals/touch_pad_read/main/tp_read_main.c b/examples/peripherals/touch_pad_read/main/tp_read_main.c index 85334c900..3f442d7eb 100644 --- a/examples/peripherals/touch_pad_read/main/tp_read_main.c +++ b/examples/peripherals/touch_pad_read/main/tp_read_main.c @@ -45,14 +45,14 @@ static void tp_example_read_task(void *pvParameter) } } -static void tp_example_touch_pad_init() +static void tp_example_touch_pad_init(void) { for (int i = 0;i< TOUCH_PAD_MAX;i++) { touch_pad_config(i, TOUCH_THRESH_NO_USE); } } -void app_main() +void app_main(void) { // Initialize touch pad peripheral. // The default fsm mode is software trigger mode. diff --git a/examples/peripherals/uart/nmea0183_parser/main/nmea_parser_example_main.c b/examples/peripherals/uart/nmea0183_parser/main/nmea_parser_example_main.c index 3b7c98705..34154a541 100644 --- a/examples/peripherals/uart/nmea0183_parser/main/nmea_parser_example_main.c +++ b/examples/peripherals/uart/nmea0183_parser/main/nmea_parser_example_main.c @@ -52,7 +52,7 @@ static void gps_event_handler(void *event_handler_arg, esp_event_base_t event_ba } } -void app_main() +void app_main(void) { /* NMEA parser configuration */ nmea_parser_config_t config = NMEA_PARSER_CONFIG_DEFAULT(); diff --git a/examples/peripherals/uart/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c b/examples/peripherals/uart/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c index 1933b0621..f4f4eb18d 100644 --- a/examples/peripherals/uart/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c +++ b/examples/peripherals/uart/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c @@ -19,7 +19,7 @@ static const int RX_BUF_SIZE = 1024; #define TXD_PIN (GPIO_NUM_4) #define RXD_PIN (GPIO_NUM_5) -void init() { +void init(void) { const uart_config_t uart_config = { .baud_rate = 115200, .data_bits = UART_DATA_8_BITS, @@ -41,7 +41,7 @@ int sendData(const char* logName, const char* data) return txBytes; } -static void tx_task() +static void tx_task(void) { static const char *TX_TASK_TAG = "TX_TASK"; esp_log_level_set(TX_TASK_TAG, ESP_LOG_INFO); @@ -51,7 +51,7 @@ static void tx_task() } } -static void rx_task() +static void rx_task(void) { static const char *RX_TASK_TAG = "RX_TASK"; esp_log_level_set(RX_TASK_TAG, ESP_LOG_INFO); @@ -67,7 +67,7 @@ static void rx_task() free(data); } -void app_main() +void app_main(void) { init(); xTaskCreate(rx_task, "uart_rx_task", 1024*2, NULL, configMAX_PRIORITIES, NULL); diff --git a/examples/peripherals/uart/uart_echo/main/uart_echo_example_main.c b/examples/peripherals/uart/uart_echo/main/uart_echo_example_main.c index 50885eeee..6e6a77a74 100644 --- a/examples/peripherals/uart/uart_echo/main/uart_echo_example_main.c +++ b/examples/peripherals/uart/uart_echo/main/uart_echo_example_main.c @@ -31,7 +31,7 @@ #define BUF_SIZE (1024) -static void echo_task() +static void echo_task(void) { /* Configure parameters of an UART driver, * communication pins and install the driver */ @@ -57,7 +57,7 @@ static void echo_task() } } -void app_main() +void app_main(void) { xTaskCreate(echo_task, "uart_echo_task", 1024, NULL, 10, NULL); } diff --git a/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c b/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c index 22204b73f..c68c22edf 100644 --- a/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c +++ b/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c @@ -52,7 +52,7 @@ static const char *TAG = "RS485_ECHO_APP"; // An example of echo test with hardware flow control on UART -static void echo_task() +static void echo_task(void) { const int uart_num = ECHO_UART_PORT; uart_config_t uart_config = { @@ -118,7 +118,7 @@ static void echo_task() } } -void app_main() +void app_main(void) { //A uart read/write example without event queue; xTaskCreate(echo_task, "uart_echo_task", ECHO_TASK_STACK_SIZE, NULL, ECHO_TASK_PRIO, NULL); diff --git a/examples/peripherals/uart/uart_events/main/uart_events_example_main.c b/examples/peripherals/uart/uart_events/main/uart_events_example_main.c index 8c9f545cb..f749da0b1 100644 --- a/examples/peripherals/uart/uart_events/main/uart_events_example_main.c +++ b/examples/peripherals/uart/uart_events/main/uart_events_example_main.c @@ -117,7 +117,7 @@ static void uart_event_task(void *pvParameters) vTaskDelete(NULL); } -void app_main() +void app_main(void) { esp_log_level_set(TAG, ESP_LOG_INFO); diff --git a/examples/peripherals/uart/uart_select/main/uart_select_example_main.c b/examples/peripherals/uart/uart_select/main/uart_select_example_main.c index 717042f27..2c46a3d11 100644 --- a/examples/peripherals/uart/uart_select/main/uart_select_example_main.c +++ b/examples/peripherals/uart/uart_select/main/uart_select_example_main.c @@ -20,7 +20,7 @@ static const char* TAG = "uart_select_example"; -static void uart_select_task() +static void uart_select_task(void) { uart_config_t uart_config = { .baud_rate = 115200, @@ -87,7 +87,7 @@ static void uart_select_task() vTaskDelete(NULL); } -void app_main() +void app_main(void) { xTaskCreate(uart_select_task, "uart_select_task", 4*1024, NULL, 5, NULL); } diff --git a/examples/protocols/asio/chat_client/main/chat_client.cpp b/examples/protocols/asio/chat_client/main/chat_client.cpp index d4a111057..0b0f7097f 100644 --- a/examples/protocols/asio/chat_client/main/chat_client.cpp +++ b/examples/protocols/asio/chat_client/main/chat_client.cpp @@ -134,7 +134,7 @@ private: void read_line(char * line, int max_chars); -extern "C" void app_main() +extern "C" void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); diff --git a/examples/protocols/asio/chat_server/main/chat_server.cpp b/examples/protocols/asio/chat_server/main/chat_server.cpp index 56a447e05..c1838b53f 100644 --- a/examples/protocols/asio/chat_server/main/chat_server.cpp +++ b/examples/protocols/asio/chat_server/main/chat_server.cpp @@ -202,7 +202,7 @@ private: //---------------------------------------------------------------------- -extern "C" void app_main() +extern "C" void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); diff --git a/examples/protocols/asio/tcp_echo_server/main/echo_server.cpp b/examples/protocols/asio/tcp_echo_server/main/echo_server.cpp index 008ec6ed7..d1ed69e05 100644 --- a/examples/protocols/asio/tcp_echo_server/main/echo_server.cpp +++ b/examples/protocols/asio/tcp_echo_server/main/echo_server.cpp @@ -84,7 +84,7 @@ private: }; -extern "C" void app_main() +extern "C" void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); diff --git a/examples/protocols/asio/udp_echo_server/main/udp_echo_server.cpp b/examples/protocols/asio/udp_echo_server/main/udp_echo_server.cpp index 06ac3fec9..68adf4148 100644 --- a/examples/protocols/asio/udp_echo_server/main/udp_echo_server.cpp +++ b/examples/protocols/asio/udp_echo_server/main/udp_echo_server.cpp @@ -66,7 +66,7 @@ private: char data_[max_length]; }; -extern "C" void app_main() +extern "C" void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); diff --git a/examples/protocols/esp_http_client/main/esp_http_client_example.c b/examples/protocols/esp_http_client/main/esp_http_client_example.c index 6a642a73f..348471a61 100644 --- a/examples/protocols/esp_http_client/main/esp_http_client_example.c +++ b/examples/protocols/esp_http_client/main/esp_http_client_example.c @@ -76,7 +76,7 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt) return ESP_OK; } -static void http_rest_with_url() +static void http_rest_with_url(void) { esp_http_client_config_t config = { .url = "http://httpbin.org/get", @@ -160,7 +160,7 @@ static void http_rest_with_url() esp_http_client_cleanup(client); } -static void http_rest_with_hostname_path() +static void http_rest_with_hostname_path(void) { esp_http_client_config_t config = { .host = "httpbin.org", @@ -247,7 +247,7 @@ static void http_rest_with_hostname_path() } -static void http_auth_basic() +static void http_auth_basic(void) { esp_http_client_config_t config = { .url = "http://user:passwd@httpbin.org/basic-auth/user/passwd", @@ -267,7 +267,7 @@ static void http_auth_basic() esp_http_client_cleanup(client); } -static void http_auth_basic_redirect() +static void http_auth_basic_redirect(void) { esp_http_client_config_t config = { .url = "http://user:passwd@httpbin.org/basic-auth/user/passwd", @@ -286,7 +286,7 @@ static void http_auth_basic_redirect() esp_http_client_cleanup(client); } -static void http_auth_digest() +static void http_auth_digest(void) { esp_http_client_config_t config = { .url = "http://user:passwd@httpbin.org/digest-auth/auth/user/passwd/MD5/never", @@ -305,7 +305,7 @@ static void http_auth_digest() esp_http_client_cleanup(client); } -static void https_with_url() +static void https_with_url(void) { esp_http_client_config_t config = { .url = "https://www.howsmyssl.com", @@ -325,7 +325,7 @@ static void https_with_url() esp_http_client_cleanup(client); } -static void https_with_hostname_path() +static void https_with_hostname_path(void) { esp_http_client_config_t config = { .host = "www.howsmyssl.com", @@ -347,7 +347,7 @@ static void https_with_hostname_path() esp_http_client_cleanup(client); } -static void http_relative_redirect() +static void http_relative_redirect(void) { esp_http_client_config_t config = { .url = "http://httpbin.org/relative-redirect/3", @@ -366,7 +366,7 @@ static void http_relative_redirect() esp_http_client_cleanup(client); } -static void http_absolute_redirect() +static void http_absolute_redirect(void) { esp_http_client_config_t config = { .url = "http://httpbin.org/absolute-redirect/3", @@ -385,7 +385,7 @@ static void http_absolute_redirect() esp_http_client_cleanup(client); } -static void http_redirect_to_https() +static void http_redirect_to_https(void) { esp_http_client_config_t config = { .url = "http://httpbin.org/redirect-to?url=https%3A%2F%2Fwww.howsmyssl.com", @@ -405,7 +405,7 @@ static void http_redirect_to_https() } -static void http_download_chunk() +static void http_download_chunk(void) { esp_http_client_config_t config = { .url = "http://httpbin.org/stream-bytes/8912", @@ -424,7 +424,7 @@ static void http_download_chunk() esp_http_client_cleanup(client); } -static void http_perform_as_stream_reader() +static void http_perform_as_stream_reader(void) { char *buffer = malloc(MAX_HTTP_RECV_BUFFER + 1); if (buffer == NULL) { @@ -460,7 +460,7 @@ static void http_perform_as_stream_reader() free(buffer); } -static void https_async() +static void https_async(void) { esp_http_client_config_t config = { .url = "https://postman-echo.com/post", @@ -492,7 +492,7 @@ static void https_async() esp_http_client_cleanup(client); } -static void https_with_invalid_url() +static void https_with_invalid_url(void) { esp_http_client_config_t config = { .url = "https://not.existent.url", @@ -533,7 +533,7 @@ static void http_test_task(void *pvParameters) vTaskDelete(NULL); } -void app_main() +void app_main(void) { esp_err_t ret = nvs_flash_init(); if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { diff --git a/examples/protocols/esp_local_ctrl/main/app_main.c b/examples/protocols/esp_local_ctrl/main/app_main.c index d19feffda..a55090383 100644 --- a/examples/protocols/esp_local_ctrl/main/app_main.c +++ b/examples/protocols/esp_local_ctrl/main/app_main.c @@ -62,7 +62,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, } } -void wifi_init_sta() +void wifi_init_sta(void) { s_wifi_event_group = xEventGroupCreate(); @@ -95,7 +95,7 @@ void wifi_init_sta() * See local_ctrl_service.c for implementation */ extern void start_esp_local_ctrl_service(void); -void app_main() +void app_main(void) { //Initialize NVS esp_err_t ret = nvs_flash_init(); diff --git a/examples/protocols/http2_request/main/http2_request_example_main.c b/examples/protocols/http2_request/main/http2_request_example_main.c index 180b8b934..9b6bb739e 100644 --- a/examples/protocols/http2_request/main/http2_request_example_main.c +++ b/examples/protocols/http2_request/main/http2_request_example_main.c @@ -128,7 +128,7 @@ static void http2_task(void *args) vTaskDelete(NULL); } -void app_main() +void app_main(void) { ESP_ERROR_CHECK( nvs_flash_init() ); tcpip_adapter_init(); diff --git a/examples/protocols/http_request/main/http_request_example_main.c b/examples/protocols/http_request/main/http_request_example_main.c index 20f1b667f..5626ae796 100644 --- a/examples/protocols/http_request/main/http_request_example_main.c +++ b/examples/protocols/http_request/main/http_request_example_main.c @@ -119,7 +119,7 @@ static void http_get_task(void *pvParameters) } } -void app_main() +void app_main(void) { ESP_ERROR_CHECK( nvs_flash_init() ); tcpip_adapter_init(); diff --git a/examples/protocols/http_server/advanced_tests/main/main.c b/examples/protocols/http_server/advanced_tests/main/main.c index d203c4882..af9ae1a87 100644 --- a/examples/protocols/http_server/advanced_tests/main/main.c +++ b/examples/protocols/http_server/advanced_tests/main/main.c @@ -41,7 +41,7 @@ static void connect_handler(void* arg, esp_event_base_t event_base, } } -void app_main() +void app_main(void) { static httpd_handle_t server = NULL; diff --git a/examples/protocols/http_server/advanced_tests/main/tests.c b/examples/protocols/http_server/advanced_tests/main/tests.c index c41810e61..dd4a97315 100644 --- a/examples/protocols/http_server/advanced_tests/main/tests.c +++ b/examples/protocols/http_server/advanced_tests/main/tests.c @@ -270,7 +270,7 @@ static void register_basic_handlers(httpd_handle_t hd) ESP_LOGI(TAG, "Success"); } -static httpd_handle_t test_httpd_start() +static httpd_handle_t test_httpd_start(void) { pre_start_mem = esp_get_free_heap_size(); httpd_handle_t hd; @@ -299,7 +299,7 @@ static void test_httpd_stop(httpd_handle_t hd) ESP_LOGI(TAG, "HTTPD Stop: Current free memory: %d", post_stop_mem); } -httpd_handle_t start_tests() +httpd_handle_t start_tests(void) { httpd_handle_t hd = test_httpd_start(); if (hd) { diff --git a/examples/protocols/http_server/file_serving/main/main.c b/examples/protocols/http_server/file_serving/main/main.c index 8515f6133..421355da3 100644 --- a/examples/protocols/http_server/file_serving/main/main.c +++ b/examples/protocols/http_server/file_serving/main/main.c @@ -64,7 +64,7 @@ static esp_err_t init_spiffs(void) * file_server.c */ esp_err_t start_file_server(const char *base_path); -void app_main() +void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); diff --git a/examples/protocols/http_server/persistent_sockets/main/main.c b/examples/protocols/http_server/persistent_sockets/main/main.c index 3d551fe26..725de62e1 100644 --- a/examples/protocols/http_server/persistent_sockets/main/main.c +++ b/examples/protocols/http_server/persistent_sockets/main/main.c @@ -211,7 +211,7 @@ static void connect_handler(void* arg, esp_event_base_t event_base, } -void app_main() +void app_main(void) { static httpd_handle_t server = NULL; diff --git a/examples/protocols/http_server/restful_server/main/esp_rest_main.c b/examples/protocols/http_server/restful_server/main/esp_rest_main.c index dc885fa5b..ee13bfa35 100644 --- a/examples/protocols/http_server/restful_server/main/esp_rest_main.c +++ b/examples/protocols/http_server/restful_server/main/esp_rest_main.c @@ -121,7 +121,7 @@ esp_err_t init_fs(void) } #endif -void app_main() +void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); diff --git a/examples/protocols/http_server/simple/main/main.c b/examples/protocols/http_server/simple/main/main.c index 270c93941..d7bec4466 100644 --- a/examples/protocols/http_server/simple/main/main.c +++ b/examples/protocols/http_server/simple/main/main.c @@ -267,7 +267,7 @@ static void connect_handler(void* arg, esp_event_base_t event_base, } -void app_main() +void app_main(void) { static httpd_handle_t server = NULL; diff --git a/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c b/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c index 29c97e831..ce5823f60 100644 --- a/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c +++ b/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c @@ -271,7 +271,7 @@ static void https_get_task(void *pvParameters) } } -void app_main() +void app_main(void) { ESP_ERROR_CHECK( nvs_flash_init() ); tcpip_adapter_init(); diff --git a/examples/protocols/https_request/main/https_request_example_main.c b/examples/protocols/https_request/main/https_request_example_main.c index 742a4657e..4e07c128a 100644 --- a/examples/protocols/https_request/main/https_request_example_main.c +++ b/examples/protocols/https_request/main/https_request_example_main.c @@ -148,7 +148,7 @@ static void https_get_task(void *pvParameters) } } -void app_main() +void app_main(void) { ESP_ERROR_CHECK( nvs_flash_init() ); tcpip_adapter_init(); diff --git a/examples/protocols/https_server/main/main.c b/examples/protocols/https_server/main/main.c index 7cebabfb9..a71f44e59 100644 --- a/examples/protocols/https_server/main/main.c +++ b/examples/protocols/https_server/main/main.c @@ -98,7 +98,7 @@ static void connect_handler(void* arg, esp_event_base_t event_base, } } -void app_main() +void app_main(void) { static httpd_handle_t server = NULL; diff --git a/examples/protocols/mdns/main/mdns_example_main.c b/examples/protocols/mdns/main/mdns_example_main.c index 11bee313b..a406b74d1 100644 --- a/examples/protocols/mdns/main/mdns_example_main.c +++ b/examples/protocols/mdns/main/mdns_example_main.c @@ -27,7 +27,7 @@ #define EXAMPLE_BUTTON_GPIO 0 static const char *TAG = "mdns-test"; -static char* generate_hostname(); +static char* generate_hostname(void); static void initialise_mdns(void) { @@ -176,7 +176,7 @@ static void mdns_example_task(void *pvParameters) } } -void app_main() +void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); @@ -197,7 +197,7 @@ void app_main() /** Generate host name based on sdkconfig, optionally adding a portion of MAC address to it. * @return host name string allocated from the heap */ -static char* generate_hostname() +static char* generate_hostname(void) { #ifndef CONFIG_MDNS_ADD_MAC_TO_HOSTNAME return strdup(CONFIG_MDNS_HOSTNAME); diff --git a/examples/protocols/modbus_master/main/include/sense_modbus.h b/examples/protocols/modbus_master/main/include/sense_modbus.h index 9860c4057..4c13391da 100644 --- a/examples/protocols/modbus_master/main/include/sense_modbus.h +++ b/examples/protocols/modbus_master/main/include/sense_modbus.h @@ -47,7 +47,7 @@ typedef struct uint64_t timestamp; /*!< Time stamp of last access to parameter */ } characteristic_descriptor_t; -esp_err_t sense_modbus_init(); +esp_err_t sense_modbus_init(void); esp_err_t sense_modbus_get_characteristics(characteristic_descriptor_t** cid_table, uint16_t* table_size); esp_err_t sense_modbus_read_value(uint16_t cid, void* value); esp_err_t sense_modbus_send_value(uint16_t cid, void* value); diff --git a/examples/protocols/modbus_master/main/sense_main.c b/examples/protocols/modbus_master/main/sense_main.c index 00158336d..13d52a983 100644 --- a/examples/protocols/modbus_master/main/sense_main.c +++ b/examples/protocols/modbus_master/main/sense_main.c @@ -137,13 +137,13 @@ static void trigger_operation_task(void *arg) vTaskDelete(NULL); } -static void sense_device_init() +static void sense_device_init(void) { // Initialize and start Modbus controller sense_modbus_init(); } -void app_main() +void app_main(void) { esp_err_t result = ESP_OK; diff --git a/examples/protocols/modbus_master/main/sense_modbus.c b/examples/protocols/modbus_master/main/sense_modbus.c index f8b77539f..8d1ab3539 100644 --- a/examples/protocols/modbus_master/main/sense_modbus.c +++ b/examples/protocols/modbus_master/main/sense_modbus.c @@ -81,14 +81,14 @@ static void* sense_modbus_get_param_data(const mb_parameter_descriptor_t* param_ } // The helper function to get time stamp in microseconds -static uint64_t sense_modbus_get_time_stamp_us() +static uint64_t sense_modbus_get_time_stamp_us(void) { uint64_t time_stamp = esp_timer_get_time(); return time_stamp; } // Initialization of Modbus stack -esp_err_t sense_modbus_init() +esp_err_t sense_modbus_init(void) { mb_communication_info_t comm = { .port = MB_PORTNUM, diff --git a/examples/protocols/modbus_slave/main/freemodbus.c b/examples/protocols/modbus_slave/main/freemodbus.c index e29492c50..abca71999 100644 --- a/examples/protocols/modbus_slave/main/freemodbus.c +++ b/examples/protocols/modbus_slave/main/freemodbus.c @@ -35,7 +35,7 @@ static const char *TAG = "MODBUS_SLAVE_APP"; // Set register values into known state -static void setup_reg_data() +static void setup_reg_data(void) { // Define initial state of parameters discrete_reg_params.discrete_input1 = 1; @@ -64,7 +64,7 @@ static void setup_reg_data() // See deviceparams.h file for more information about assigned Modbus parameters. // These parameters can be accessed from main application and also can be changed // by external Modbus master host. -void app_main() +void app_main(void) { mb_param_info_t reg_info; // keeps the Modbus registers access information mb_communication_info_t comm_info; // Modbus communication parameters diff --git a/examples/protocols/mqtt/publish_test/main/publish_test.c b/examples/protocols/mqtt/publish_test/main/publish_test.c index 15cd2b09b..9183bbb8b 100644 --- a/examples/protocols/mqtt/publish_test/main/publish_test.c +++ b/examples/protocols/mqtt/publish_test/main/publish_test.c @@ -151,7 +151,7 @@ static void get_string(char *line, size_t size) } } -void app_main() +void app_main(void) { char line[256]; char pattern[32]; diff --git a/examples/protocols/mqtt/ssl/main/app_main.c b/examples/protocols/mqtt/ssl/main/app_main.c index e819c8fdc..fd0a49d7b 100644 --- a/examples/protocols/mqtt/ssl/main/app_main.c +++ b/examples/protocols/mqtt/ssl/main/app_main.c @@ -110,7 +110,7 @@ static void mqtt_app_start(void) esp_mqtt_client_start(client); } -void app_main() +void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); diff --git a/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c b/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c index 21c76ff44..5c6eab7ee 100644 --- a/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c +++ b/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c @@ -97,7 +97,7 @@ static void mqtt_app_start(void) esp_mqtt_client_start(client); } -void app_main() +void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); diff --git a/examples/protocols/mqtt/tcp/main/app_main.c b/examples/protocols/mqtt/tcp/main/app_main.c index 9e24a3770..7acd68536 100644 --- a/examples/protocols/mqtt/tcp/main/app_main.c +++ b/examples/protocols/mqtt/tcp/main/app_main.c @@ -123,7 +123,7 @@ static void mqtt_app_start(void) esp_mqtt_client_start(client); } -void app_main() +void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); diff --git a/examples/protocols/mqtt/ws/main/app_main.c b/examples/protocols/mqtt/ws/main/app_main.c index cb45759ef..cacea73e9 100644 --- a/examples/protocols/mqtt/ws/main/app_main.c +++ b/examples/protocols/mqtt/ws/main/app_main.c @@ -95,7 +95,7 @@ static void mqtt_app_start(void) esp_mqtt_client_start(client); } -void app_main() +void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); diff --git a/examples/protocols/mqtt/wss/main/app_main.c b/examples/protocols/mqtt/wss/main/app_main.c index dca752b99..a9de24455 100644 --- a/examples/protocols/mqtt/wss/main/app_main.c +++ b/examples/protocols/mqtt/wss/main/app_main.c @@ -105,7 +105,7 @@ static void mqtt_app_start(void) esp_mqtt_client_start(client); } -void app_main() +void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); diff --git a/examples/protocols/pppos_client/main/pppos_client_main.c b/examples/protocols/pppos_client/main/pppos_client_main.c index bd706f6fd..4f376ea68 100644 --- a/examples/protocols/pppos_client/main/pppos_client_main.c +++ b/examples/protocols/pppos_client/main/pppos_client_main.c @@ -179,7 +179,7 @@ static esp_err_t mqtt_event_handler(esp_mqtt_event_handle_t event) return ESP_OK; } -void app_main() +void app_main(void) { tcpip_adapter_init(); event_group = xEventGroupCreate(); diff --git a/examples/protocols/sntp/main/sntp_example_main.c b/examples/protocols/sntp/main/sntp_example_main.c index 157d26063..59d22d7fe 100644 --- a/examples/protocols/sntp/main/sntp_example_main.c +++ b/examples/protocols/sntp/main/sntp_example_main.c @@ -46,7 +46,7 @@ void time_sync_notification_cb(struct timeval *tv) ESP_LOGI(TAG, "Notification of a time synchronization event"); } -void app_main() +void app_main(void) { ++boot_count; ESP_LOGI(TAG, "Boot count: %d", boot_count); diff --git a/examples/protocols/sockets/tcp_client/main/tcp_client.c b/examples/protocols/sockets/tcp_client/main/tcp_client.c index 96657d798..5e98718df 100644 --- a/examples/protocols/sockets/tcp_client/main/tcp_client.c +++ b/examples/protocols/sockets/tcp_client/main/tcp_client.c @@ -109,7 +109,7 @@ static void tcp_client_task(void *pvParameters) vTaskDelete(NULL); } -void app_main() +void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); diff --git a/examples/protocols/sockets/tcp_server/main/tcp_server.c b/examples/protocols/sockets/tcp_server/main/tcp_server.c index 1e71096dc..062268ebd 100644 --- a/examples/protocols/sockets/tcp_server/main/tcp_server.c +++ b/examples/protocols/sockets/tcp_server/main/tcp_server.c @@ -128,7 +128,7 @@ static void tcp_server_task(void *pvParameters) vTaskDelete(NULL); } -void app_main() +void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); diff --git a/examples/protocols/sockets/udp_client/main/udp_client.c b/examples/protocols/sockets/udp_client/main/udp_client.c index 6639082a1..bb3175579 100644 --- a/examples/protocols/sockets/udp_client/main/udp_client.c +++ b/examples/protocols/sockets/udp_client/main/udp_client.c @@ -108,7 +108,7 @@ static void udp_client_task(void *pvParameters) vTaskDelete(NULL); } -void app_main() +void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); diff --git a/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c b/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c index bd2a4cbed..e20ce9fd3 100644 --- a/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c +++ b/examples/protocols/sockets/udp_multicast/main/udp_multicast_example_main.c @@ -107,7 +107,7 @@ static int socket_add_ipv4_multicast_group(int sock, bool assign_source_if) #endif /* CONFIG_EXAMPLE_IPV4 */ #ifdef CONFIG_EXAMPLE_IPV4_ONLY -static int create_multicast_ipv4_socket() +static int create_multicast_ipv4_socket(void) { struct sockaddr_in saddr = { 0 }; int sock = -1; @@ -167,7 +167,7 @@ err: #endif /* CONFIG_EXAMPLE_IPV4_ONLY */ #ifdef CONFIG_EXAMPLE_IPV6 -static int create_multicast_ipv6_socket() +static int create_multicast_ipv6_socket(void) { struct sockaddr_in6 saddr = { 0 }; int netif_index; @@ -481,7 +481,7 @@ static void mcast_example_task(void *pvParameters) } -void app_main() +void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); diff --git a/examples/protocols/sockets/udp_server/main/udp_server.c b/examples/protocols/sockets/udp_server/main/udp_server.c index ce8216832..262d2b213 100644 --- a/examples/protocols/sockets/udp_server/main/udp_server.c +++ b/examples/protocols/sockets/udp_server/main/udp_server.c @@ -109,7 +109,7 @@ static void udp_server_task(void *pvParameters) vTaskDelete(NULL); } -void app_main() +void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); tcpip_adapter_init(); diff --git a/examples/protocols/websocket/main/websocket_example.c b/examples/protocols/websocket/main/websocket_example.c index 120a5b4fd..6b64ef25d 100644 --- a/examples/protocols/websocket/main/websocket_example.c +++ b/examples/protocols/websocket/main/websocket_example.c @@ -80,7 +80,7 @@ static void websocket_app_start(void) esp_websocket_client_destroy(client); } -void app_main() +void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size()); diff --git a/examples/provisioning/ble_prov/main/app_main.c b/examples/provisioning/ble_prov/main/app_main.c index 6ce1184c2..1b96f5d12 100644 --- a/examples/provisioning/ble_prov/main/app_main.c +++ b/examples/provisioning/ble_prov/main/app_main.c @@ -25,7 +25,7 @@ static const char *TAG = "app"; -static void start_ble_provisioning(); +static void start_ble_provisioning(void); static void event_handler(void* arg, esp_event_base_t event_base, int event_id, void* event_data) @@ -76,7 +76,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, } } -static void wifi_init_sta() +static void wifi_init_sta(void) { /* Set our event handling */ ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, event_handler, NULL)); @@ -87,7 +87,7 @@ static void wifi_init_sta() ESP_ERROR_CHECK(esp_wifi_start()); } -static void start_ble_provisioning() +static void start_ble_provisioning(void) { /* Security version */ int security = 0; @@ -110,7 +110,7 @@ static void start_ble_provisioning() ESP_ERROR_CHECK(app_prov_start_ble_provisioning(security, pop)); } -void app_main() +void app_main(void) { /* Initialize networking stack */ tcpip_adapter_init(); diff --git a/examples/provisioning/console_prov/main/app_main.c b/examples/provisioning/console_prov/main/app_main.c index 35b3d575e..6d5ef3883 100644 --- a/examples/provisioning/console_prov/main/app_main.c +++ b/examples/provisioning/console_prov/main/app_main.c @@ -47,7 +47,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, } } -static void wifi_init_sta() +static void wifi_init_sta(void) { /* Set our event handling */ ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, event_handler, NULL)); @@ -58,7 +58,7 @@ static void wifi_init_sta() ESP_ERROR_CHECK(esp_wifi_start()); } -static void start_console_provisioning() +static void start_console_provisioning(void) { /* Security version */ int security = 0; @@ -81,7 +81,7 @@ static void start_console_provisioning() ESP_ERROR_CHECK(app_prov_start_console_provisioning(security, pop)); } -void app_main() +void app_main(void) { /* Initialize networking stack */ tcpip_adapter_init(); diff --git a/examples/provisioning/custom_config/main/app_main.c b/examples/provisioning/custom_config/main/app_main.c index 7b23c883c..072e7b5aa 100644 --- a/examples/provisioning/custom_config/main/app_main.c +++ b/examples/provisioning/custom_config/main/app_main.c @@ -47,7 +47,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, } } -static void wifi_init_sta() +static void wifi_init_sta(void) { /* Set our event handling */ ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, event_handler, NULL)); @@ -58,7 +58,7 @@ static void wifi_init_sta() ESP_ERROR_CHECK(esp_wifi_start()); } -static void start_softap_provisioning() +static void start_softap_provisioning(void) { /* Security version */ int security = 0; @@ -82,7 +82,7 @@ static void start_softap_provisioning() CONFIG_EXAMPLE_SSID, CONFIG_EXAMPLE_PASS, security, pop)); } -void app_main() +void app_main(void) { /* Initialize networking stack */ tcpip_adapter_init(); diff --git a/examples/provisioning/manager/main/app_main.c b/examples/provisioning/manager/main/app_main.c index 96634fa71..065b6f8fc 100644 --- a/examples/provisioning/manager/main/app_main.c +++ b/examples/provisioning/manager/main/app_main.c @@ -77,7 +77,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, } } -static void wifi_init_sta() +static void wifi_init_sta(void) { /* Start Wi-Fi in station mode */ ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); @@ -93,7 +93,7 @@ static void get_device_service_name(char *service_name, size_t max) ssid_prefix, eth_mac[3], eth_mac[4], eth_mac[5]); } -void app_main() +void app_main(void) { /* Initialize NVS partition */ esp_err_t ret = nvs_flash_init(); diff --git a/examples/provisioning/softap_prov/main/app_main.c b/examples/provisioning/softap_prov/main/app_main.c index a775f7a2f..8ee7ae679 100644 --- a/examples/provisioning/softap_prov/main/app_main.c +++ b/examples/provisioning/softap_prov/main/app_main.c @@ -47,7 +47,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, } } -static void wifi_init_sta() +static void wifi_init_sta(void) { /* Set our event handling */ ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, event_handler, NULL)); @@ -58,7 +58,7 @@ static void wifi_init_sta() ESP_ERROR_CHECK(esp_wifi_start()); } -static void start_softap_provisioning() +static void start_softap_provisioning(void) { /* Security version */ int security = 0; @@ -97,7 +97,7 @@ static void start_softap_provisioning() ssid, CONFIG_EXAMPLE_PASS, security, pop)); } -void app_main() +void app_main(void) { /* Initialize networking stack */ tcpip_adapter_init(); diff --git a/examples/security/flash_encryption/main/flash_encrypt_main.c b/examples/security/flash_encryption/main/flash_encrypt_main.c index 63fd480ba..73ab39afe 100644 --- a/examples/security/flash_encryption/main/flash_encrypt_main.c +++ b/examples/security/flash_encryption/main/flash_encrypt_main.c @@ -16,7 +16,7 @@ #include "esp_flash_encrypt.h" #include "esp_efuse_table.h" -void app_main() +void app_main(void) { uint32_t flash_crypt_cnt = 0; esp_flash_enc_mode_t mode; diff --git a/examples/storage/ext_flash_fatfs/main/ext_flash_fatfs_example_main.c b/examples/storage/ext_flash_fatfs/main/ext_flash_fatfs_example_main.c index c64fb76ad..e0698dccf 100644 --- a/examples/storage/ext_flash_fatfs/main/ext_flash_fatfs_example_main.c +++ b/examples/storage/ext_flash_fatfs/main/ext_flash_fatfs_example_main.c @@ -28,7 +28,7 @@ static wl_handle_t s_wl_handle = WL_INVALID_HANDLE; // Mount path for the partition const char *base_path = "/extflash"; -static esp_flash_t* example_init_ext_flash(); +static esp_flash_t* example_init_ext_flash(void); static const esp_partition_t* example_add_partition(esp_flash_t* ext_flash, const char* partition_label); static bool example_mount_fatfs(const char* partition_label); static void example_get_fatfs_usage(size_t* out_total_bytes, size_t* out_free_bytes); @@ -84,7 +84,7 @@ void app_main(void) ESP_LOGI(TAG, "Read from file: '%s'", line); } -static esp_flash_t* example_init_ext_flash() +static esp_flash_t* example_init_ext_flash(void) { const spi_bus_config_t bus_config = { .mosi_io_num = VSPI_IOMUX_PIN_NUM_MOSI, diff --git a/examples/storage/nvs_rw_blob/main/nvs_blob_example_main.c b/examples/storage/nvs_rw_blob/main/nvs_blob_example_main.c index f6b74766e..431752147 100644 --- a/examples/storage/nvs_rw_blob/main/nvs_blob_example_main.c +++ b/examples/storage/nvs_rw_blob/main/nvs_blob_example_main.c @@ -150,7 +150,7 @@ esp_err_t print_what_saved(void) } -void app_main() +void app_main(void) { esp_err_t err = nvs_flash_init(); if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { diff --git a/examples/storage/nvs_rw_value/main/nvs_value_example_main.c b/examples/storage/nvs_rw_value/main/nvs_value_example_main.c index 757eeeb30..47abd43a6 100644 --- a/examples/storage/nvs_rw_value/main/nvs_value_example_main.c +++ b/examples/storage/nvs_rw_value/main/nvs_value_example_main.c @@ -16,7 +16,7 @@ #include "nvs_flash.h" #include "nvs.h" -void app_main() +void app_main(void) { // Initialize NVS esp_err_t err = nvs_flash_init(); diff --git a/examples/storage/spiffsgen/main/spiffsgen_example_main.c b/examples/storage/spiffsgen/main/spiffsgen_example_main.c index fde74dcdc..5c67c47c5 100644 --- a/examples/storage/spiffsgen/main/spiffsgen_example_main.c +++ b/examples/storage/spiffsgen/main/spiffsgen_example_main.c @@ -18,7 +18,7 @@ static const char *TAG = "example"; -static void read_hello_txt() +static void read_hello_txt(void) { ESP_LOGI(TAG, "Reading hello.txt"); @@ -38,7 +38,7 @@ static void read_hello_txt() ESP_LOGI(TAG, "Read from hello.txt: %s", buf); } -static void compute_alice_txt_md5() +static void compute_alice_txt_md5(void) { ESP_LOGI(TAG, "Computing alice.txt MD5 hash"); diff --git a/examples/system/app_trace_to_host/main/app_trace_to_host_example_main.c b/examples/system/app_trace_to_host/main/app_trace_to_host_example_main.c index bedeeb35c..f2b382df9 100644 --- a/examples/system/app_trace_to_host/main/app_trace_to_host_example_main.c +++ b/examples/system/app_trace_to_host/main/app_trace_to_host_example_main.c @@ -85,7 +85,7 @@ static int adc1_sample_and_show(int sampling_period) * and logging results with application tracing to the host * as well as for comparison printing out sampling result to UART */ -void app_main() +void app_main(void) { ESP_LOGI(TAG, "Enabling ADC1 on channel 6 / GPIO34."); adc1_config_width(ADC_WIDTH_BIT_12); diff --git a/examples/system/base_mac_address/main/base_mac_address_example_main.c b/examples/system/base_mac_address/main/base_mac_address_example_main.c index c7a114bfe..7353ad76b 100644 --- a/examples/system/base_mac_address/main/base_mac_address_example_main.c +++ b/examples/system/base_mac_address/main/base_mac_address_example_main.c @@ -30,7 +30,7 @@ static esp_err_t external_storage_mac_get(uint8_t *mac) } #endif//CONFIG_BASE_MAC_STORED_OTHER_EXTERNAL_STORAGE -void app_main() +void app_main(void) { #if defined(CONFIG_BASE_MAC_STORED_EFUSE_BLK3) || defined(CONFIG_BASE_MAC_STORED_OTHER_EXTERNAL_STORAGE) uint8_t mac_addr[8] = {0}; diff --git a/examples/system/console/components/cmd_nvs/cmd_nvs.c b/examples/system/console/components/cmd_nvs/cmd_nvs.c index 21d128ecd..3878702eb 100644 --- a/examples/system/console/components/cmd_nvs/cmd_nvs.c +++ b/examples/system/console/components/cmd_nvs/cmd_nvs.c @@ -507,7 +507,7 @@ static int list_entries(int argc, char **argv) return list(part, name, type); } -void register_nvs() +void register_nvs(void) { set_args.key = arg_str1(NULL, NULL, "", "key of the value to be set"); set_args.type = arg_str1(NULL, NULL, "", ARG_TYPE_STR); diff --git a/examples/system/console/components/cmd_nvs/cmd_nvs.h b/examples/system/console/components/cmd_nvs/cmd_nvs.h index 6d0de50dc..d18c2b41f 100644 --- a/examples/system/console/components/cmd_nvs/cmd_nvs.h +++ b/examples/system/console/components/cmd_nvs/cmd_nvs.h @@ -13,7 +13,7 @@ extern "C" { #endif // Register NVS functions -void register_nvs(); +void register_nvs(void); #ifdef __cplusplus } diff --git a/examples/system/console/components/cmd_system/cmd_system.c b/examples/system/console/components/cmd_system/cmd_system.c index 50fe5ec09..caf8d70f2 100644 --- a/examples/system/console/components/cmd_system/cmd_system.c +++ b/examples/system/console/components/cmd_system/cmd_system.c @@ -30,17 +30,17 @@ static const char *TAG = "cmd_system"; -static void register_free(); -static void register_heap(); -static void register_version(); -static void register_restart(); -static void register_deep_sleep(); -static void register_light_sleep(); +static void register_free(void); +static void register_heap(void); +static void register_version(void); +static void register_restart(void); +static void register_deep_sleep(void); +static void register_light_sleep(void); #if WITH_TASKS_INFO -static void register_tasks(); +static void register_tasks(void); #endif -void register_system() +void register_system(void) { register_free(); register_heap(); @@ -72,7 +72,7 @@ static int get_version(int argc, char **argv) return 0; } -static void register_version() +static void register_version(void) { const esp_console_cmd_t cmd = { .command = "version", @@ -91,7 +91,7 @@ static int restart(int argc, char **argv) esp_restart(); } -static void register_restart() +static void register_restart(void) { const esp_console_cmd_t cmd = { .command = "restart", @@ -110,7 +110,7 @@ static int free_mem(int argc, char **argv) return 0; } -static void register_free() +static void register_free(void) { const esp_console_cmd_t cmd = { .command = "free", @@ -129,7 +129,7 @@ static int heap_size(int argc, char **argv) return 0; } -static void register_heap() +static void register_heap(void) { const esp_console_cmd_t heap_cmd = { .command = "heap", @@ -163,7 +163,7 @@ static int tasks_info(int argc, char **argv) return 0; } -static void register_tasks() +static void register_tasks(void) { const esp_console_cmd_t cmd = { .command = "tasks", @@ -221,7 +221,7 @@ static int deep_sleep(int argc, char **argv) esp_deep_sleep_start(); } -static void register_deep_sleep() +static void register_deep_sleep(void) { deep_sleep_args.wakeup_time = arg_int0("t", "time", "", "Wake up time, ms"); @@ -314,7 +314,7 @@ static int light_sleep(int argc, char **argv) return 0; } -static void register_light_sleep() +static void register_light_sleep(void) { light_sleep_args.wakeup_time = arg_int0("t", "time", "", "Wake up time, ms"); diff --git a/examples/system/console/components/cmd_system/cmd_system.h b/examples/system/console/components/cmd_system/cmd_system.h index be746a227..9af96a8ae 100644 --- a/examples/system/console/components/cmd_system/cmd_system.h +++ b/examples/system/console/components/cmd_system/cmd_system.h @@ -13,7 +13,7 @@ extern "C" { #endif // Register system functions -void register_system(); +void register_system(void); #ifdef __cplusplus } diff --git a/examples/system/console/main/cmd_wifi.c b/examples/system/console/main/cmd_wifi.c index eb2024dab..b9c24f0cd 100644 --- a/examples/system/console/main/cmd_wifi.c +++ b/examples/system/console/main/cmd_wifi.c @@ -109,7 +109,7 @@ static int connect(int argc, char **argv) return 0; } -void register_wifi() +void register_wifi(void) { join_args.timeout = arg_int0(NULL, "timeout", "", "Connection timeout, ms"); join_args.ssid = arg_str1(NULL, NULL, "", "SSID of AP"); diff --git a/examples/system/console/main/cmd_wifi.h b/examples/system/console/main/cmd_wifi.h index a1a1655e4..5259dd72f 100644 --- a/examples/system/console/main/cmd_wifi.h +++ b/examples/system/console/main/cmd_wifi.h @@ -13,7 +13,7 @@ extern "C" { #endif // Register WiFi functions -void register_wifi(); +void register_wifi(void); #ifdef __cplusplus } diff --git a/examples/system/console/main/console_example_main.c b/examples/system/console/main/console_example_main.c index e0e48b430..e89196c4b 100644 --- a/examples/system/console/main/console_example_main.c +++ b/examples/system/console/main/console_example_main.c @@ -32,7 +32,7 @@ static const char* TAG = "example"; #define MOUNT_PATH "/data" #define HISTORY_PATH MOUNT_PATH "/history.txt" -static void initialize_filesystem() +static void initialize_filesystem(void) { static wl_handle_t wl_handle; const esp_vfs_fat_mount_config_t mount_config = { @@ -47,7 +47,7 @@ static void initialize_filesystem() } #endif // CONFIG_STORE_HISTORY -static void initialize_nvs() +static void initialize_nvs(void) { esp_err_t err = nvs_flash_init(); if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { @@ -57,7 +57,7 @@ static void initialize_nvs() ESP_ERROR_CHECK(err); } -static void initialize_console() +static void initialize_console(void) { /* Disable buffering on stdin */ setvbuf(stdin, NULL, _IONBF, 0); @@ -115,7 +115,7 @@ static void initialize_console() #endif } -void app_main() +void app_main(void) { initialize_nvs(); diff --git a/examples/system/cpp_exceptions/main/exception_example_main.cpp b/examples/system/cpp_exceptions/main/exception_example_main.cpp index 24ada9de6..29045beb4 100644 --- a/examples/system/cpp_exceptions/main/exception_example_main.cpp +++ b/examples/system/cpp_exceptions/main/exception_example_main.cpp @@ -36,7 +36,7 @@ protected: }; /* Inside .cpp file, app_main function must be declared with C linkage */ -extern "C" void app_main() +extern "C" void app_main(void) { cout << "app_main starting" << endl; diff --git a/examples/system/cpp_pthread/main/cpp_pthread.cpp b/examples/system/cpp_pthread/main/cpp_pthread.cpp index 59b0870d0..d39ea91f3 100644 --- a/examples/system/cpp_pthread/main/cpp_pthread.cpp +++ b/examples/system/cpp_pthread/main/cpp_pthread.cpp @@ -82,7 +82,7 @@ esp_pthread_cfg_t create_config(const char *name, int core_id, int stack, int pr return cfg; } -extern "C" void app_main() +extern "C" void app_main(void) { // Create a thread using deafult values that can run on any core auto cfg = esp_pthread_get_default_config(); diff --git a/examples/system/deep_sleep/main/deep_sleep_example_main.c b/examples/system/deep_sleep/main/deep_sleep_example_main.c index 5843e64aa..22bfad4b5 100644 --- a/examples/system/deep_sleep/main/deep_sleep_example_main.c +++ b/examples/system/deep_sleep/main/deep_sleep_example_main.c @@ -45,7 +45,7 @@ _Static_assert(ULP_DATA_OFFSET < CONFIG_ESP32_ULP_COPROC_RESERVE_MEM/4 - 6, * The program monitors on-chip temperature sensor and wakes up the SoC when * the temperature goes lower or higher than certain thresholds. */ -static void start_ulp_temperature_monitoring(); +static void start_ulp_temperature_monitoring(void); /** * @brief Utility function which reads data written by ULP program @@ -76,7 +76,7 @@ static inline void ulp_data_write(size_t offset, uint16_t value) static void calibrate_touch_pad(touch_pad_t pad); #endif -void app_main() +void app_main(void) { struct timeval now; gettimeofday(&now, NULL); @@ -210,7 +210,7 @@ static void calibrate_touch_pad(touch_pad_t pad) #endif // CONFIG_ENABLE_TOUCH_WAKEUP #ifdef CONFIG_ENABLE_ULP_TEMPERATURE_WAKEUP -static void start_ulp_temperature_monitoring() +static void start_ulp_temperature_monitoring(void) { /* * This ULP program monitors the on-chip temperature sensor and wakes the chip up when diff --git a/examples/system/esp_timer/main/esp_timer_example_main.c b/examples/system/esp_timer/main/esp_timer_example_main.c index ab6a697c2..975042399 100644 --- a/examples/system/esp_timer/main/esp_timer_example_main.c +++ b/examples/system/esp_timer/main/esp_timer_example_main.c @@ -20,7 +20,7 @@ static void oneshot_timer_callback(void* arg); static const char* TAG = "example"; -void app_main() +void app_main(void) { /* Create two timers: * 1. a periodic timer which will run every 0.5s, and print a message diff --git a/examples/system/freertos/real_time_stats/main/main.c b/examples/system/freertos/real_time_stats/main/main.c index 96a199bfe..9b3b9ce87 100644 --- a/examples/system/freertos/real_time_stats/main/main.c +++ b/examples/system/freertos/real_time_stats/main/main.c @@ -165,7 +165,7 @@ static void stats_task(void *arg) } } -void app_main() +void app_main(void) { //Allow other core to finish initialization vTaskDelay(pdMS_TO_TICKS(100)); diff --git a/examples/system/gcov/main/gcov_example.c b/examples/system/gcov/main/gcov_example.c index e6d745768..5ded23b0d 100644 --- a/examples/system/gcov/main/gcov_example.c +++ b/examples/system/gcov/main/gcov_example.c @@ -52,7 +52,7 @@ static void blink_task(void *pvParameter) } } -void app_main() +void app_main(void) { xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL); } diff --git a/examples/system/himem/main/himem_test_main.c b/examples/system/himem/main/himem_test_main.c index 5a83482cc..955046b2d 100644 --- a/examples/system/himem/main/himem_test_main.c +++ b/examples/system/himem/main/himem_test_main.c @@ -87,7 +87,7 @@ static bool test_region(int check_size, int seed) } -void app_main() +void app_main(void) { size_t memcnt=esp_himem_get_phys_size(); size_t memfree=esp_himem_get_free_size(); diff --git a/examples/system/light_sleep/main/light_sleep_example_main.c b/examples/system/light_sleep/main/light_sleep_example_main.c index 36003c68f..8fb02b47b 100644 --- a/examples/system/light_sleep/main/light_sleep_example_main.c +++ b/examples/system/light_sleep/main/light_sleep_example_main.c @@ -27,7 +27,7 @@ /* "Boot" button on GPIO0 is active low */ #define BUTTON_WAKEUP_LEVEL_DEFAULT 0 -void app_main() +void app_main(void) { /* Configure the button GPIO as input, enable wakeup */ const int button_gpio_num = BUTTON_GPIO_NUM_DEFAULT; diff --git a/examples/system/network_tests/main/net_suite.c b/examples/system/network_tests/main/net_suite.c index 2fae24835..9b9dfe2d0 100644 --- a/examples/system/network_tests/main/net_suite.c +++ b/examples/system/network_tests/main/net_suite.c @@ -130,7 +130,7 @@ static size_t process_line(char* line, char* packet) return count; } -void app_main() +void app_main(void) { char packet[128]; diff --git a/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c b/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c index c2b01e144..0387e3e68 100644 --- a/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c +++ b/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c @@ -103,7 +103,7 @@ ota_end: } } -void app_main() +void app_main(void) { // Initialize NVS. esp_err_t err = nvs_flash_init(); diff --git a/examples/system/ota/native_ota_example/main/native_ota_example.c b/examples/system/ota/native_ota_example/main/native_ota_example.c index 638743892..fc42b7f3b 100644 --- a/examples/system/ota/native_ota_example/main/native_ota_example.c +++ b/examples/system/ota/native_ota_example/main/native_ota_example.c @@ -37,7 +37,7 @@ static void http_cleanup(esp_http_client_handle_t client) esp_http_client_cleanup(client); } -static void __attribute__((noreturn)) task_fatal_error() +static void __attribute__((noreturn)) task_fatal_error(void) { ESP_LOGE(TAG, "Exiting task due to fatal error..."); (void)vTaskDelete(NULL); @@ -219,7 +219,7 @@ static bool diagnostic(void) return diagnostic_is_ok; } -void app_main() +void app_main(void) { uint8_t sha_256[HASH_LEN] = { 0 }; esp_partition_t partition; diff --git a/examples/system/ota/otatool/main/otatool_main.c b/examples/system/ota/otatool/main/otatool_main.c index 50ea3f2ec..86b7a8204 100644 --- a/examples/system/ota/otatool/main/otatool_main.c +++ b/examples/system/ota/otatool/main/otatool_main.c @@ -13,7 +13,7 @@ static const char *TAG = "example"; -void app_main() +void app_main(void) { ESP_LOGI(TAG, "OTA Tool Example"); diff --git a/examples/system/ota/simple_ota_example/main/simple_ota_example.c b/examples/system/ota/simple_ota_example/main/simple_ota_example.c index 9d7c44e3a..9d0187f3b 100644 --- a/examples/system/ota/simple_ota_example/main/simple_ota_example.c +++ b/examples/system/ota/simple_ota_example/main/simple_ota_example.c @@ -95,7 +95,7 @@ void simple_ota_example_task(void *pvParameter) } } -void app_main() +void app_main(void) { // Initialize NVS. esp_err_t err = nvs_flash_init(); diff --git a/examples/system/select/main/select_example.c b/examples/system/select/main/select_example.c index 57daf8fd8..962902429 100644 --- a/examples/system/select/main/select_example.c +++ b/examples/system/select/main/select_example.c @@ -27,13 +27,13 @@ static const char* TAG = "uart_select_example"; static int uart_fd = -1; static int socket_fd = -1; -static void socket_deinit() +static void socket_deinit(void) { close(socket_fd); socket_fd = -1; } -static void socket_init() +static void socket_init(void) { const struct addrinfo hints = { .ai_family = AF_INET, @@ -81,7 +81,7 @@ static void socket_init() freeaddrinfo(res); } -static void uart1_deinit() +static void uart1_deinit(void) { close(uart_fd); uart_fd = -1; @@ -89,7 +89,7 @@ static void uart1_deinit() UART1.conf0.loopback = 0; } -static void uart1_init() +static void uart1_init(void) { uart_config_t uart_config = { .baud_rate = 115200, @@ -198,7 +198,7 @@ static void select_task(void *param) vTaskDelete(NULL); } -void app_main() +void app_main(void) { xTaskCreate(uart1_write_task, "uart1_write_task", 4*1024, NULL, 5, NULL); xTaskCreate(socket_write_task, "socket_write_task", 4*1024, NULL, 5, NULL); diff --git a/examples/system/sysview_tracing/main/sysview_tracing.c b/examples/system/sysview_tracing/main/sysview_tracing.c index c422d9e46..3436b4cbc 100644 --- a/examples/system/sysview_tracing/main/sysview_tracing.c +++ b/examples/system/sysview_tracing/main/sysview_tracing.c @@ -181,7 +181,7 @@ static void example_task(void *p) } } -void app_main() +void app_main(void) { static example_event_data_t event_data[portNUM_PROCESSORS] = { { diff --git a/examples/system/sysview_tracing_heap_log/main/sysview_heap_log.c b/examples/system/sysview_tracing_heap_log/main/sysview_heap_log.c index d34c93de6..9d38fcf70 100644 --- a/examples/system/sysview_tracing_heap_log/main/sysview_heap_log.c +++ b/examples/system/sysview_tracing_heap_log/main/sysview_heap_log.c @@ -57,7 +57,7 @@ static void alloc_task(void *p) while(1); } -void app_main() +void app_main(void) { // redirect log messages to the host using SystemView tracing module esp_log_set_vprintf(&esp_sysview_vprintf); diff --git a/examples/system/task_watchdog/main/task_watchdog_example_main.c b/examples/system/task_watchdog/main/task_watchdog_example_main.c index a5eed91ce..89bce16f0 100644 --- a/examples/system/task_watchdog/main/task_watchdog_example_main.c +++ b/examples/system/task_watchdog/main/task_watchdog_example_main.c @@ -42,7 +42,7 @@ void reset_task(void *arg) } } -void app_main() +void app_main(void) { printf("Initialize TWDT\n"); //Initialize or reinitialize TWDT diff --git a/examples/system/ulp/main/ulp_example_main.c b/examples/system/ulp/main/ulp_example_main.c index 6682294d5..fa6e1eead 100644 --- a/examples/system/ulp/main/ulp_example_main.c +++ b/examples/system/ulp/main/ulp_example_main.c @@ -22,10 +22,10 @@ extern const uint8_t ulp_main_bin_start[] asm("_binary_ulp_main_bin_start"); extern const uint8_t ulp_main_bin_end[] asm("_binary_ulp_main_bin_end"); -static void init_ulp_program(); -static void update_pulse_count(); +static void init_ulp_program(void); +static void update_pulse_count(void); -void app_main() +void app_main(void) { esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause(); if (cause != ESP_SLEEP_WAKEUP_ULP) { @@ -41,7 +41,7 @@ void app_main() esp_deep_sleep_start(); } -static void init_ulp_program() +static void init_ulp_program(void) { esp_err_t err = ulp_load_binary(0, ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t)); @@ -91,7 +91,7 @@ static void init_ulp_program() ESP_ERROR_CHECK(err); } -static void update_pulse_count() +static void update_pulse_count(void) { const char* namespace = "plusecnt"; const char* count_key = "count"; diff --git a/examples/system/ulp_adc/main/ulp_adc_example_main.c b/examples/system/ulp_adc/main/ulp_adc_example_main.c index 80f9fc1eb..c7be925ca 100644 --- a/examples/system/ulp_adc/main/ulp_adc_example_main.c +++ b/examples/system/ulp_adc/main/ulp_adc_example_main.c @@ -27,14 +27,14 @@ extern const uint8_t ulp_main_bin_end[] asm("_binary_ulp_main_bin_end"); /* This function is called once after power-on reset, to load ULP program into * RTC memory and configure the ADC. */ -static void init_ulp_program(); +static void init_ulp_program(void); /* This function is called every time before going into deep sleep. * It starts the ULP program and resets measurement counter. */ -static void start_ulp_program(); +static void start_ulp_program(void); -void app_main() +void app_main(void) { esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause(); if (cause != ESP_SLEEP_WAKEUP_ULP) { @@ -54,7 +54,7 @@ void app_main() esp_deep_sleep_start(); } -static void init_ulp_program() +static void init_ulp_program(void) { esp_err_t err = ulp_load_binary(0, ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t)); @@ -83,7 +83,7 @@ static void init_ulp_program() esp_deep_sleep_disable_rom_logging(); // suppress boot messages } -static void start_ulp_program() +static void start_ulp_program(void) { /* Reset sample counter */ ulp_sample_counter = 0; diff --git a/examples/system/unit_test/test/main/example_unit_test_test.c b/examples/system/unit_test/test/main/example_unit_test_test.c index a634ce8da..92f2f038a 100644 --- a/examples/system/unit_test/test/main/example_unit_test_test.c +++ b/examples/system/unit_test/test/main/example_unit_test_test.c @@ -13,7 +13,7 @@ static void print_banner(const char* text); -void app_main() +void app_main(void) { /* These are the different ways of running registered tests. * In practice, only one of them is usually needed. diff --git a/examples/wifi/espnow/main/espnow_example_main.c b/examples/wifi/espnow/main/espnow_example_main.c index 4d76a5bea..fbfde5780 100644 --- a/examples/wifi/espnow/main/espnow_example_main.c +++ b/examples/wifi/espnow/main/espnow_example_main.c @@ -361,7 +361,7 @@ static void example_espnow_deinit(example_espnow_send_param_t *send_param) esp_now_deinit(); } -void app_main() +void app_main(void) { // Initialize NVS esp_err_t ret = nvs_flash_init(); diff --git a/examples/wifi/getting_started/softAP/main/softap_example_main.c b/examples/wifi/getting_started/softAP/main/softap_example_main.c index 010289554..624e020ed 100644 --- a/examples/wifi/getting_started/softAP/main/softap_example_main.c +++ b/examples/wifi/getting_started/softAP/main/softap_example_main.c @@ -43,7 +43,7 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base, } } -void wifi_init_softap() +void wifi_init_softap(void) { tcpip_adapter_init(); ESP_ERROR_CHECK(esp_event_loop_create_default()); @@ -74,7 +74,7 @@ void wifi_init_softap() EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS); } -void app_main() +void app_main(void) { //Initialize NVS esp_err_t ret = nvs_flash_init(); diff --git a/examples/wifi/getting_started/station/main/station_example_main.c b/examples/wifi/getting_started/station/main/station_example_main.c index ae6101f2d..869b614ce 100644 --- a/examples/wifi/getting_started/station/main/station_example_main.c +++ b/examples/wifi/getting_started/station/main/station_example_main.c @@ -61,7 +61,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, } } -void wifi_init_sta() +void wifi_init_sta(void) { s_wifi_event_group = xEventGroupCreate(); @@ -90,7 +90,7 @@ void wifi_init_sta() EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS); } -void app_main() +void app_main(void) { //Initialize NVS esp_err_t ret = nvs_flash_init(); diff --git a/examples/wifi/iperf/main/cmd_wifi.c b/examples/wifi/iperf/main/cmd_wifi.c index a6fbdaa16..8bd3819a1 100644 --- a/examples/wifi/iperf/main/cmd_wifi.c +++ b/examples/wifi/iperf/main/cmd_wifi.c @@ -369,7 +369,7 @@ static int wifi_cmd_iperf(int argc, char** argv) return 0; } -void register_wifi() +void register_wifi(void) { sta_args.ssid = arg_str1(NULL, NULL, "", "SSID of AP"); sta_args.password = arg_str0(NULL, NULL, "", "password of AP"); diff --git a/examples/wifi/iperf/main/iperf_example_main.c b/examples/wifi/iperf/main/iperf_example_main.c index 797d74961..d3e2eb7c9 100644 --- a/examples/wifi/iperf/main/iperf_example_main.c +++ b/examples/wifi/iperf/main/iperf_example_main.c @@ -26,7 +26,7 @@ #define WIFI_CONNECTED_BIT BIT0 -static void initialize_console() +static void initialize_console(void) { /* Disable buffering on stdin */ setvbuf(stdin, NULL, _IONBF, 0); diff --git a/examples/wifi/power_save/main/power_save.c b/examples/wifi/power_save/main/power_save.c index 04f60cb66..c24dfdaa5 100644 --- a/examples/wifi/power_save/main/power_save.c +++ b/examples/wifi/power_save/main/power_save.c @@ -79,7 +79,7 @@ static void wifi_power_save(void) esp_wifi_set_ps(DEFAULT_PS_MODE); } -void app_main() +void app_main(void) { // Initialize NVS esp_err_t ret = nvs_flash_init(); diff --git a/examples/wifi/scan/main/scan.c b/examples/wifi/scan/main/scan.c index f5b0d29fd..0f54d8e3e 100644 --- a/examples/wifi/scan/main/scan.c +++ b/examples/wifi/scan/main/scan.c @@ -109,7 +109,7 @@ static void wifi_scan(void) ESP_ERROR_CHECK(esp_wifi_start()); } -void app_main() +void app_main(void) { // Initialize NVS esp_err_t ret = nvs_flash_init(); diff --git a/examples/wifi/simple_sniffer/main/cmd_sniffer.c b/examples/wifi/simple_sniffer/main/cmd_sniffer.c index e41f9941f..579a1c069 100644 --- a/examples/wifi/simple_sniffer/main/cmd_sniffer.c +++ b/examples/wifi/simple_sniffer/main/cmd_sniffer.c @@ -80,7 +80,7 @@ static uint32_t hash_func(const char *str, uint32_t max_num) return ret % max_num; } -static void create_wifi_filter_hashtable() +static void create_wifi_filter_hashtable(void) { char *wifi_filter_keys[SNIFFER_WLAN_FILTER_MAX] = {"mgmt", "data", "ctrl", "misc", "mpdu", "ampdu"}; uint32_t wifi_filter_values[SNIFFER_WLAN_FILTER_MAX] = {WIFI_PROMIS_FILTER_MASK_MGMT, WIFI_PROMIS_FILTER_MASK_DATA, @@ -372,7 +372,7 @@ static int do_sniffer_cmd(int argc, char **argv) return 0; } -void register_sniffer() +void register_sniffer(void) { sniffer_args.file = arg_str0("f", "file", "", "name of the file storing the packets in pcap format"); diff --git a/examples/wifi/simple_sniffer/main/cmd_sniffer.h b/examples/wifi/simple_sniffer/main/cmd_sniffer.h index c98f857d6..10d6f21f4 100644 --- a/examples/wifi/simple_sniffer/main/cmd_sniffer.h +++ b/examples/wifi/simple_sniffer/main/cmd_sniffer.h @@ -34,7 +34,7 @@ typedef enum { SNIFFER_WLAN_FILTER_MAX } sniffer_wlan_filter_t; -void register_sniffer(); +void register_sniffer(void); #ifdef __cplusplus } diff --git a/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c b/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c index 1b664b039..e1a78a42c 100644 --- a/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c +++ b/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c @@ -36,7 +36,7 @@ static const char *TAG = "example"; #if CONFIG_SNIFFER_STORE_HISTORY /* Initialize filesystem for command history store */ -static void initialize_filesystem() +static void initialize_filesystem(void) { static wl_handle_t wl_handle; const esp_vfs_fat_mount_config_t mount_config = { @@ -51,7 +51,7 @@ static void initialize_filesystem() } #endif -static void initialize_nvs() +static void initialize_nvs(void) { esp_err_t err = nvs_flash_init(); if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { @@ -62,7 +62,7 @@ static void initialize_nvs() } /* Initialize wifi with tcp/ip adapter */ -static void initialize_wifi() +static void initialize_wifi(void) { tcpip_adapter_init(); ESP_ERROR_CHECK(esp_event_loop_create_default()); @@ -73,7 +73,7 @@ static void initialize_wifi() } /* Initialize console component */ -static void initialize_console() +static void initialize_console(void) { /* Disable buffering on stdin */ setvbuf(stdin, NULL, _IONBF, 0); @@ -172,7 +172,7 @@ static int mount(int argc, char **argv) return 0; } -static void register_mount() +static void register_mount(void) { mount_args.device = arg_str1(NULL, NULL, "", "choose a proper device to mount/unmount"); mount_args.end = arg_end(1); @@ -204,7 +204,7 @@ static int unmount(int argc, char **argv) return 0; } -static void register_unmount() +static void register_unmount(void) { mount_args.device = arg_str1(NULL, NULL, "", "choose a proper device to mount/unmount"); mount_args.end = arg_end(1); diff --git a/examples/wifi/smart_config/main/smartconfig_main.c b/examples/wifi/smart_config/main/smartconfig_main.c index 0819f256d..65e7c5033 100644 --- a/examples/wifi/smart_config/main/smartconfig_main.c +++ b/examples/wifi/smart_config/main/smartconfig_main.c @@ -112,7 +112,7 @@ static void smartconfig_example_task(void * parm) } } -void app_main() +void app_main(void) { ESP_ERROR_CHECK( nvs_flash_init() ); initialise_wifi(); diff --git a/examples/wifi/wpa2_enterprise/main/wpa2_enterprise_main.c b/examples/wifi/wpa2_enterprise/main/wpa2_enterprise_main.c index 232065c4b..1cd210c66 100644 --- a/examples/wifi/wpa2_enterprise/main/wpa2_enterprise_main.c +++ b/examples/wifi/wpa2_enterprise/main/wpa2_enterprise_main.c @@ -143,7 +143,7 @@ static void wpa2_enterprise_example_task(void *pvParameters) } } -void app_main() +void app_main(void) { ESP_ERROR_CHECK( nvs_flash_init() ); initialise_wifi(); diff --git a/examples/wifi/wps/main/wps.c b/examples/wifi/wps/main/wps.c index 5ac103b7f..4e1af5d03 100644 --- a/examples/wifi/wps/main/wps.c +++ b/examples/wifi/wps/main/wps.c @@ -115,7 +115,7 @@ static void start_wps(void) ESP_ERROR_CHECK(esp_wifi_wps_start(0)); } -void app_main() +void app_main(void) { /* Initialize NVS — it is used to store PHY calibration data */ esp_err_t ret = nvs_flash_init(); diff --git a/tools/esp_app_trace/test/sysview/blink.c b/tools/esp_app_trace/test/sysview/blink.c index baa345be4..66fb4d31f 100644 --- a/tools/esp_app_trace/test/sysview/blink.c +++ b/tools/esp_app_trace/test/sysview/blink.c @@ -82,7 +82,7 @@ void blink_task(void *pvParameter) } } -void app_main() +void app_main(void) { xTaskCreatePinnedToCore(&blink_task, "blink_task", 2048, NULL, 5, NULL, 0); } diff --git a/tools/kconfig/nconf.gui.c b/tools/kconfig/nconf.gui.c index 8275f0e55..4c964e377 100644 --- a/tools/kconfig/nconf.gui.c +++ b/tools/kconfig/nconf.gui.c @@ -129,7 +129,7 @@ static void no_colors_theme(void) mkattrn(FUNCTION_TEXT, A_REVERSE); } -void set_colors() +void set_colors(void) { start_color(); use_default_colors(); diff --git a/tools/unit-test-app/components/test_utils/include/test_utils.h b/tools/unit-test-app/components/test_utils/include/test_utils.h index eb95f34f7..f9901bb9c 100644 --- a/tools/unit-test-app/components/test_utils/include/test_utils.h +++ b/tools/unit-test-app/components/test_utils/include/test_utils.h @@ -54,7 +54,7 @@ /* Return the 'flash_test' custom data partition (type 0x55) defined in the custom partition table. */ -const esp_partition_t *get_test_data_partition(); +const esp_partition_t *get_test_data_partition(void); /** * @brief Initialize reference clock @@ -62,26 +62,26 @@ const esp_partition_t *get_test_data_partition(); * Reference clock provides timestamps at constant 1 MHz frequency, even when * the APB frequency is changing. */ -void ref_clock_init(); +void ref_clock_init(void); /** * @brief Deinitialize reference clock */ -void ref_clock_deinit(); +void ref_clock_deinit(void); /** * @brief Get reference clock timestamp * @return number of microseconds since the reference clock was initialized */ -uint64_t ref_clock_get(); +uint64_t ref_clock_get(void); /** * @brief Entry point of the test application * * Starts Unity test runner in a separate task and returns. */ -void test_main(); +void test_main(void); /** * @brief Reset automatic leak checking which happens in unit tests. diff --git a/tools/unit-test-app/components/test_utils/ref_clock.c b/tools/unit-test-app/components/test_utils/ref_clock.c index c66ff28b9..afafd42b5 100644 --- a/tools/unit-test-app/components/test_utils/ref_clock.c +++ b/tools/unit-test-app/components/test_utils/ref_clock.c @@ -54,7 +54,7 @@ static intr_handle_t s_intr_handle; static portMUX_TYPE s_lock = portMUX_INITIALIZER_UNLOCKED; static volatile uint32_t s_milliseconds; -void ref_clock_init() +void ref_clock_init(void) { assert(s_intr_handle == NULL && "already initialized"); @@ -134,7 +134,7 @@ static void IRAM_ATTR pcnt_isr(void* arg) portEXIT_CRITICAL_ISR(&s_lock); } -void ref_clock_deinit() +void ref_clock_deinit(void) { assert(s_intr_handle && "deinit called without init"); @@ -153,7 +153,7 @@ void ref_clock_deinit() periph_module_disable(PERIPH_PCNT_MODULE); } -uint64_t ref_clock_get() +uint64_t ref_clock_get(void) { portENTER_CRITICAL(&s_lock); uint32_t microseconds = PCNT.cnt_unit[REF_CLOCK_PCNT_UNIT].cnt_val; diff --git a/tools/unit-test-app/components/test_utils/test_runner.c b/tools/unit-test-app/components/test_utils/test_runner.c index 33247904c..1f00a0168 100644 --- a/tools/unit-test-app/components/test_utils/test_runner.c +++ b/tools/unit-test-app/components/test_utils/test_runner.c @@ -37,7 +37,7 @@ static void unity_task(void *pvParameters) unity_run_menu(); /* Doesn't return */ } -void test_main() +void test_main(void) { // Note: if unpinning this task, change the way run times are calculated in // unity_port_esp32.c @@ -95,7 +95,7 @@ static void check_leak(size_t before_free, size_t after_free, const char *type) TEST_ASSERT_MESSAGE(leaked <= critical_leak_threshold, "The test leaked too much memory"); } -static bool leak_check_required() +static bool leak_check_required(void) { warn_leak_threshold = test_utils_get_leak_level(TYPE_LEAK_WARNING, COMP_LEAK_ALL); critical_leak_threshold = test_utils_get_leak_level(TYPE_LEAK_CRITICAL, COMP_LEAK_ALL); diff --git a/tools/unit-test-app/components/test_utils/test_utils.c b/tools/unit-test-app/components/test_utils/test_utils.c index fc16db9f0..9216a70fd 100644 --- a/tools/unit-test-app/components/test_utils/test_utils.c +++ b/tools/unit-test-app/components/test_utils/test_utils.c @@ -22,7 +22,7 @@ #include "tcpip_adapter.h" #include "lwip/sockets.h" -const esp_partition_t *get_test_data_partition() +const esp_partition_t *get_test_data_partition(void) { /* This finds "flash_test" partition defined in partition_table_unit_test_app.csv */ const esp_partition_t *result = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, @@ -31,7 +31,7 @@ const esp_partition_t *get_test_data_partition() return result; } -void test_case_uses_tcpip() +void test_case_uses_tcpip(void) { // Can be called more than once, does nothing on subsequent calls tcpip_adapter_init(); diff --git a/tools/unit-test-app/main/app_main.c b/tools/unit-test-app/main/app_main.c index 4385b3b0e..f9df657da 100644 --- a/tools/unit-test-app/main/app_main.c +++ b/tools/unit-test-app/main/app_main.c @@ -1,6 +1,6 @@ #include "test_utils.h" -void app_main() +void app_main(void) { test_main(); } diff --git a/tools/windows/tool_setup/cmdlinerunner/cmdlinerunner.c b/tools/windows/tool_setup/cmdlinerunner/cmdlinerunner.c index 0688ea430..c5ee95e3e 100644 --- a/tools/windows/tool_setup/cmdlinerunner/cmdlinerunner.c +++ b/tools/windows/tool_setup/cmdlinerunner/cmdlinerunner.c @@ -35,7 +35,7 @@ struct proc_instance_s { }; #ifdef WITH_DEBUG -static void print_last_error() +static void print_last_error(void) { DWORD dw; TCHAR errmsg[LINESIZE]; @@ -51,7 +51,7 @@ static void print_last_error() #define PRINT_LAST_ERROR() #endif -static proc_instance_t *proc_instance_allocate() +static proc_instance_t *proc_instance_allocate(void) { return (proc_instance_t*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(proc_instance_t)); } From 74a459dd3ddd8c203835d2a78cd07ff6d31dee69 Mon Sep 17 00:00:00 2001 From: Michael Zimmermann Date: Fri, 11 Jan 2019 09:43:11 +0100 Subject: [PATCH 09/36] make code conform to Wstrict-prototypes Merges https://github.com/espressif/esp-idf/pull/2937 --- components/bootloader_support/src/flash_qio_mode.c | 2 +- components/esp_common/include/esp_freertos_hooks.h | 4 ++-- components/vfs/include/esp_vfs.h | 4 ++-- components/xtensa/include/xtensa/xtruntime.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/bootloader_support/src/flash_qio_mode.c b/components/bootloader_support/src/flash_qio_mode.c index 06a8fcada..adf536893 100644 --- a/components/bootloader_support/src/flash_qio_mode.c +++ b/components/bootloader_support/src/flash_qio_mode.c @@ -39,7 +39,7 @@ static const char *TAG = "qio_mode"; -typedef unsigned (*read_status_fn_t)(); +typedef unsigned (*read_status_fn_t)(void); typedef void (*write_status_fn_t)(unsigned); typedef struct __attribute__((packed)) { diff --git a/components/esp_common/include/esp_freertos_hooks.h b/components/esp_common/include/esp_freertos_hooks.h index 5f24bc35a..47db07ce9 100644 --- a/components/esp_common/include/esp_freertos_hooks.h +++ b/components/esp_common/include/esp_freertos_hooks.h @@ -26,8 +26,8 @@ extern "C" /* Definitions for the tickhook and idlehook callbacks */ -typedef bool (*esp_freertos_idle_cb_t)(); -typedef void (*esp_freertos_tick_cb_t)(); +typedef bool (*esp_freertos_idle_cb_t)(void); +typedef void (*esp_freertos_tick_cb_t)(void); /** * @brief Register a callback to be called from the specified core's idle hook. diff --git a/components/vfs/include/esp_vfs.h b/components/vfs/include/esp_vfs.h index 4d9396c1c..e4eafb417 100644 --- a/components/vfs/include/esp_vfs.h +++ b/components/vfs/include/esp_vfs.h @@ -244,9 +244,9 @@ typedef struct /** stop_socket_select which can be called from ISR; set only for the socket driver */ void (*stop_socket_select_isr)(void *sem, BaseType_t *woken); /** end_select is called to stop the I/O multiplexing and deinitialize the environment created by start_select for the given VFS */ - void* (*get_socket_select_semaphore)(); + void* (*get_socket_select_semaphore)(void); /** get_socket_select_semaphore returns semaphore allocated in the socket driver; set only for the socket driver */ - void (*end_select)(); + void (*end_select)(void); } esp_vfs_t; diff --git a/components/xtensa/include/xtensa/xtruntime.h b/components/xtensa/include/xtensa/xtruntime.h index 9dae1f4b2..f4e1184ed 100644 --- a/components/xtensa/include/xtensa/xtruntime.h +++ b/components/xtensa/include/xtensa/xtruntime.h @@ -58,7 +58,7 @@ extern "C" { #ifdef __cplusplus typedef void (_xtos_handler_func)(...); #else -typedef void (_xtos_handler_func)(); +typedef void (_xtos_handler_func)(void); #endif typedef _xtos_handler_func *_xtos_handler; From e8191912c8348464f173423502c17410f2ad4fb7 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 19 Mar 2019 16:02:35 +0800 Subject: [PATCH 10/36] Add -Wstrict-prototypes check in CI --- tools/ci/build_examples.sh | 2 +- tools/ci/build_examples_cmake.sh | 2 +- tools/ci/config/build.yml | 23 ++++++++++++++++------- tools/ci/configure_ci_environment.sh | 5 ++++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tools/ci/build_examples.sh b/tools/ci/build_examples.sh index c300452e7..7393cb302 100755 --- a/tools/ci/build_examples.sh +++ b/tools/ci/build_examples.sh @@ -116,7 +116,7 @@ build_example () { pushd "example_builds/${ID}/${EXAMPLE_DIR_REL}" # be stricter in the CI build than the default IDF settings export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} - export EXTRA_CXXFLAGS=${EXTRA_CFLAGS} + export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS} # sdkconfig files are normally not checked into git, but may be present when # a developer runs this script locally diff --git a/tools/ci/build_examples_cmake.sh b/tools/ci/build_examples_cmake.sh index 6ec906b0d..da15bae72 100755 --- a/tools/ci/build_examples_cmake.sh +++ b/tools/ci/build_examples_cmake.sh @@ -111,7 +111,7 @@ build_example () { pushd "example_builds/${IDF_TARGET}/${ID}/${EXAMPLE_NAME}" # be stricter in the CI build than the default IDF settings export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} - export EXTRA_CXXFLAGS=${EXTRA_CFLAGS} + export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS} # sdkconfig files are normally not checked into git, but may be present when # a developer runs this script locally diff --git a/tools/ci/config/build.yml b/tools/ci/config/build.yml index c5dab206d..43bf40814 100644 --- a/tools/ci/config/build.yml +++ b/tools/ci/config/build.yml @@ -38,11 +38,13 @@ build_template_app: # Set the variable for 'esp-idf-template' testing - ESP_IDF_TEMPLATE_GIT=${ESP_IDF_TEMPLATE_GIT:-"https://github.com/espressif/esp-idf-template.git"} - git clone ${ESP_IDF_TEMPLATE_GIT} + # Try to use the same branch name for esp-idf-template that we're + # using on esp-idf. If it doesn't exist then just stick to the default branch - python $CHECKOUT_REF_SCRIPT esp-idf-template esp-idf-template - cd esp-idf-template - # Try to use the same branch name for esp-idf-template that we're - # using on esp-idf. If it doesn't exist then just stick to the default - # branch + - export PATH="$IDF_PATH/tools:$PATH" + - export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} + - export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS} - make defconfig # Test debug build (default) - make all V=1 @@ -51,10 +53,17 @@ build_template_app: - sed -i.bak -e's/CONFIG_OPTIMIZATION_LEVEL_DEBUG\=y/CONFIG_OPTIMIZATION_LEVEL_RELEASE=y/' sdkconfig - make all V=1 # Check if there are any stray printf/ets_printf references in WiFi libs - - cd ../components/esp_wifi/lib_esp32 + - pushd ../components/esp_wifi/lib_esp32 - test $(xtensa-esp32-elf-nm *.a | grep -w printf | wc -l) -eq 0 - test $(xtensa-esp32-elf-nm *.a | grep -w ets_printf | wc -l) -eq 0 - + - popd + # Repeat the build using CMake + - rm -rf build sdkconfig + # Debug build + - idf.py build + # Release build + - sed -i.bak -e's/CONFIG_OPTIMIZATION_LEVEL_DEBUG\=y/CONFIG_OPTIMIZATION_LEVEL_RELEASE=y/' sdkconfig + - idf.py build build_ssc: extends: .build_template @@ -81,7 +90,7 @@ build_esp_idf_tests_make: extends: .build_esp_idf_unit_test_template script: - export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} - - export EXTRA_CXXFLAGS=${EXTRA_CFLAGS} + - export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS} - cd $CI_PROJECT_DIR/tools/unit-test-app - MAKEFLAGS= make help # make sure kconfig tools are built in single process - make ut-clean-all-configs @@ -97,7 +106,7 @@ build_esp_idf_tests_cmake: script: - export PATH="$IDF_PATH/tools:$PATH" - export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} - - export EXTRA_CXXFLAGS=${EXTRA_CFLAGS} + - export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS} - cd $CI_PROJECT_DIR/tools/unit-test-app - idf.py ut-clean-all-configs - idf.py ut-build-all-configs diff --git a/tools/ci/configure_ci_environment.sh b/tools/ci/configure_ci_environment.sh index 9a664c1ce..d16e80500 100644 --- a/tools/ci/configure_ci_environment.sh +++ b/tools/ci/configure_ci_environment.sh @@ -15,4 +15,7 @@ DEBUG_SHELL=${DEBUG_SHELL:-"0"} # Compiler flags to thoroughly check the IDF code in some CI jobs # (Depends on default options '-Wno-error=XXX' used in the IDF build system) -export PEDANTIC_CFLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function" + +PEDANTIC_FLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function" +export PEDANTIC_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes" +export PEDANTIC_CXXFLAGS="${PEDANTIC_FLAGS}" From d4c098f5a93998e8fd0f46286f714c11a07929ee Mon Sep 17 00:00:00 2001 From: Michael Zimmermann Date: Fri, 11 Jan 2019 09:42:36 +0100 Subject: [PATCH 11/36] brownout: fix rtc_brownout_isr_handler signature Merges https://github.com/espressif/esp-idf/pull/2937 --- components/esp32/brownout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp32/brownout.c b/components/esp32/brownout.c index 89f821c50..c3db40271 100644 --- a/components/esp32/brownout.c +++ b/components/esp32/brownout.c @@ -31,7 +31,7 @@ #define BROWNOUT_DET_LVL 0 #endif //CONFIG_ESP32_BROWNOUT_DET_LVL -static void rtc_brownout_isr_handler(void) +static void rtc_brownout_isr_handler(void *arg) { /* Normally RTC ISR clears the interrupt flag after the application-supplied * handler returns. Since restart is called here, the flag needs to be From c2764f6fe85681cfaf5dbbe168295284f09c09cd Mon Sep 17 00:00:00 2001 From: Michael Zimmermann Date: Fri, 11 Jan 2019 09:40:34 +0100 Subject: [PATCH 12/36] mdns: mdns_service_remove_all doesn't take an argument Merges https://github.com/espressif/esp-idf/pull/2937 --- components/mdns/mdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 7331353d2..095651634 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -4228,7 +4228,7 @@ void mdns_free(void) if (!_mdns_server) { return; } - mdns_service_remove_all(_mdns_server); + mdns_service_remove_all(); _mdns_service_task_stop(); for (i=0; i Date: Wed, 31 Jul 2019 11:31:59 +0700 Subject: [PATCH 13/36] NimBLE: Update submodule to fix -Wstrict-prototypes warnings --- components/bt/host/nimble/nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index 7600a6f60..4839d84f6 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit 7600a6f60308c77fec755a024d51ab2fb7d11553 +Subproject commit 4839d84f61296b7d7479350ebb92908b0fdb1329 From 75c0066f93d054cdd16000c428aded6e119c78d7 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Tue, 30 Jul 2019 11:53:48 +0700 Subject: [PATCH 14/36] Fix remaining -Wstrict-prototypes warnings --- components/app_trace/app_trace.c | 4 ++-- components/app_update/test/test_switch_ota.c | 14 +++++++------- .../driver/test/param_test/include/param_test.h | 4 ++-- components/fatfs/vfs/vfs_fat_sdmmc.c | 2 +- .../include/freertos/deprecated_definitions.h | 8 ++++---- components/freertos/tasks.c | 2 +- .../test/test_freertos_backported_functions.c | 2 +- .../freertos/test/test_freertos_eventgroups.c | 2 +- .../freertos/test/test_freertos_task_notify.c | 2 +- components/unity/include/unity_test_runner.h | 6 +++--- components/wpa_supplicant/src/rsn_supp/wpa_i.h | 4 ++-- .../main/ble_mesh_register_node_cmd.c | 4 ++-- .../ble_mesh_node/main/register_bluetooth.c | 4 ++-- .../main/ble_mesh_register_node_cmd.c | 2 +- .../main/ble_mesh_register_provisioner_cmd.c | 2 +- .../main/mcpwm_bldc_control_hall_sensor_example.c | 2 +- .../rmt_nec_tx_rx/main/infrared_nec_main.c | 4 ++-- .../main/uart_async_rxtxtasks_main.c | 4 ++-- .../uart/uart_echo/main/uart_echo_example_main.c | 2 +- .../uart/uart_echo_rs485/main/rs485_example.c | 2 +- .../uart_select/main/uart_select_example_main.c | 2 +- examples/system/select/main/select_example.c | 2 +- 22 files changed, 40 insertions(+), 40 deletions(-) diff --git a/components/app_trace/app_trace.c b/components/app_trace/app_trace.c index c85ad6a2a..bc0d0c20b 100644 --- a/components/app_trace/app_trace.c +++ b/components/app_trace/app_trace.c @@ -379,10 +379,10 @@ static inline void esp_apptrace_log_unlock(void) #endif } -static inline esp_err_t esp_apptrace_lock_initialize(void) +static inline esp_err_t esp_apptrace_lock_initialize(esp_apptrace_lock_t *lock) { #if CONFIG_ESP32_APPTRACE_LOCK_ENABLE - esp_apptrace_lock_init(&s_trace_buf.lock); + esp_apptrace_lock_init(lock); #endif return ESP_OK; } diff --git a/components/app_update/test/test_switch_ota.c b/components/app_update/test/test_switch_ota.c index 232bfbc88..f0d056d9b 100644 --- a/components/app_update/test/test_switch_ota.c +++ b/components/app_update/test/test_switch_ota.c @@ -264,19 +264,19 @@ static void test_flow1(void) case 2: ESP_LOGI(TAG, "Factory"); TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_FACTORY, cur_app->subtype); - copy_current_app_to_next_part_and_reboot(cur_app); + copy_current_app_to_next_part_and_reboot(); break; case 3: ESP_LOGI(TAG, "OTA0"); TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_0, cur_app->subtype); mark_app_valid(); - copy_current_app_to_next_part_and_reboot(cur_app); + copy_current_app_to_next_part_and_reboot(); break; case 4: ESP_LOGI(TAG, "OTA1"); TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_1, cur_app->subtype); mark_app_valid(); - copy_current_app_to_next_part_and_reboot(cur_app); + copy_current_app_to_next_part_and_reboot(); break; case 5: ESP_LOGI(TAG, "OTA0"); @@ -307,7 +307,7 @@ static void test_flow2(void) case 2: ESP_LOGI(TAG, "Factory"); TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_FACTORY, cur_app->subtype); - copy_current_app_to_next_part_and_reboot(cur_app); + copy_current_app_to_next_part_and_reboot(); break; case 3: ESP_LOGI(TAG, "OTA0"); @@ -344,13 +344,13 @@ static void test_flow3(void) case 2: ESP_LOGI(TAG, "Factory"); TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_FACTORY, cur_app->subtype); - copy_current_app_to_next_part_and_reboot(cur_app); + copy_current_app_to_next_part_and_reboot(); break; case 3: ESP_LOGI(TAG, "OTA0"); TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_0, cur_app->subtype); mark_app_valid(); - copy_current_app_to_next_part_and_reboot(cur_app); + copy_current_app_to_next_part_and_reboot(); break; case 4: ESP_LOGI(TAG, "OTA1"); @@ -402,7 +402,7 @@ static void test_flow4(void) nvs_close(handle); nvs_flash_deinit(); - copy_current_app_to_next_part_and_reboot(cur_app); + copy_current_app_to_next_part_and_reboot(); break; case 3: ESP_LOGI(TAG, "OTA0"); diff --git a/components/driver/test/param_test/include/param_test.h b/components/driver/test/param_test/include/param_test.h index 879e2e5e9..e04a2bee6 100644 --- a/components/driver/test/param_test/include/param_test.h +++ b/components/driver/test/param_test/include/param_test.h @@ -159,6 +159,6 @@ void test_serializer(const param_group_t *param_group, const ptest_func_t* test_ * @param slave_func ``ptest_func_t`` to be executed by slave. */ #define TEST_MASTER_SLAVE(name, param_group, tag, master_func, slave_func) \ - static void PTEST_MASTER_NAME(name) () { test_serializer(&PGROUP_NAME(param_group), master_func); } \ - static void PTEST_SLAVE_NAME(name) () { test_serializer(&PGROUP_NAME(param_group), slave_func); } \ + static void PTEST_MASTER_NAME(name) (void) { test_serializer(&PGROUP_NAME(param_group), master_func); } \ + static void PTEST_SLAVE_NAME(name) (void) { test_serializer(&PGROUP_NAME(param_group), slave_func); } \ TEST_CASE_MULTIPLE_DEVICES("master slave test: "#name, tag, PTEST_MASTER_NAME(name), PTEST_SLAVE_NAME(name)) diff --git a/components/fatfs/vfs/vfs_fat_sdmmc.c b/components/fatfs/vfs/vfs_fat_sdmmc.c index ac1a37a7f..83cc0aee5 100644 --- a/components/fatfs/vfs/vfs_fat_sdmmc.c +++ b/components/fatfs/vfs/vfs_fat_sdmmc.c @@ -171,7 +171,7 @@ esp_err_t esp_vfs_fat_sdmmc_unmount(void) char drv[3] = {(char)('0' + s_pdrv), ':', 0}; f_mount(0, drv, 0); // release SD driver - esp_err_t (*host_deinit)() = s_card->host.deinit; + esp_err_t (*host_deinit)(void) = s_card->host.deinit; ff_diskio_unregister(s_pdrv); free(s_card); s_card = NULL; diff --git a/components/freertos/include/freertos/deprecated_definitions.h b/components/freertos/include/freertos/deprecated_definitions.h index fb031cdde..dc061f33f 100644 --- a/components/freertos/include/freertos/deprecated_definitions.h +++ b/components/freertos/include/freertos/deprecated_definitions.h @@ -82,12 +82,12 @@ projects should not use them. */ #ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); + typedef void ( __interrupt __far *pxISR )(void); #endif #ifdef OPEN_WATCOM_FLASH_LITE_186_PORT #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); + typedef void ( __interrupt __far *pxISR )(void); #endif #ifdef GCC_MEGA_AVR @@ -255,7 +255,7 @@ projects should not use them. */ FreeRTOSConfig.h when using the Borland compiler. */ #include "frconfig.h" #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); + typedef void ( __interrupt __far *pxISR )(void); #endif #ifdef BCC_FLASH_LITE_186_PORT @@ -263,7 +263,7 @@ projects should not use them. */ FreeRTOSConfig.h when using the Borland compiler. */ #include "frconfig.h" #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); + typedef void ( __interrupt __far *pxISR )(void); #endif #ifdef __GNUC__ diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index 8c4fd61a3..634e64e48 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -2149,7 +2149,7 @@ void vTaskSuspendAll( void ) #if ( portNUM_PROCESSORS > 1 ) - static BaseType_t xHaveReadyTasks() + static BaseType_t xHaveReadyTasks( void ) { for (int i = tskIDLE_PRIORITY + 1; i < configMAX_PRIORITIES; ++i) { diff --git a/components/freertos/test/test_freertos_backported_functions.c b/components/freertos/test/test_freertos_backported_functions.c index 5071ce1fe..f3fab9a8e 100644 --- a/components/freertos/test/test_freertos_backported_functions.c +++ b/components/freertos/test/test_freertos_backported_functions.c @@ -221,7 +221,7 @@ static void del_cb(int index, void *ptr) *((uint32_t *)ptr) = (TLSP_DEL_BASE << index); //Indicate deletion by setting task storage element to a unique value } -static void task_cb(void) +static void task_cb(void *arg) { int core = xPortGetCoreID(); for(int i = 0; i < NO_OF_TLSP; i++){ diff --git a/components/freertos/test/test_freertos_eventgroups.c b/components/freertos/test/test_freertos_eventgroups.c index c2672fe27..9b86f759f 100644 --- a/components/freertos/test/test_freertos_eventgroups.c +++ b/components/freertos/test/test_freertos_eventgroups.c @@ -135,7 +135,7 @@ static timer_isr_handle_t isr_handle; static bool test_set_bits; static bool test_clear_bits; -static void IRAM_ATTR event_group_isr(void) +static void IRAM_ATTR event_group_isr(void *arg) { portBASE_TYPE task_woken = pdFALSE; TIMERG0.int_clr_timers.t0 = 1; diff --git a/components/freertos/test/test_freertos_task_notify.c b/components/freertos/test/test_freertos_task_notify.c index fd230d162..8179cef9b 100644 --- a/components/freertos/test/test_freertos_task_notify.c +++ b/components/freertos/test/test_freertos_task_notify.c @@ -94,7 +94,7 @@ static void receiver_task (void* arg){ vTaskDelete(NULL); } -static void IRAM_ATTR sender_ISR (void) +static void IRAM_ATTR sender_ISR (void *arg) { int curcore = xPortGetCoreID(); if(curcore == 0){ //Clear timer interrupt diff --git a/components/unity/include/unity_test_runner.h b/components/unity/include/unity_test_runner.h index a9a1fae49..e9e46ebd4 100644 --- a/components/unity/include/unity_test_runner.h +++ b/components/unity/include/unity_test_runner.h @@ -84,7 +84,7 @@ void unity_testcase_register(test_desc_t* desc); #define TEST_CASE(name_, desc_) \ static void UNITY_TEST_UID(test_func_) (void); \ - static void __attribute__((constructor)) UNITY_TEST_UID(test_reg_helper_) () \ + static void __attribute__((constructor)) UNITY_TEST_UID(test_reg_helper_) (void) \ { \ static test_func test_fn_[] = {&UNITY_TEST_UID(test_func_)}; \ static test_desc_t UNITY_TEST_UID(test_desc_) = { \ @@ -115,7 +115,7 @@ void unity_testcase_register(test_desc_t* desc); #define TEST_CASE_MULTIPLE_STAGES(name_, desc_, ...) \ UNITY_TEST_FN_SET(__VA_ARGS__); \ - static void __attribute__((constructor)) UNITY_TEST_UID(test_reg_helper_) () \ + static void __attribute__((constructor)) UNITY_TEST_UID(test_reg_helper_) (void) \ { \ static test_desc_t UNITY_TEST_UID(test_desc_) = { \ .name = name_, \ @@ -140,7 +140,7 @@ void unity_testcase_register(test_desc_t* desc); #define TEST_CASE_MULTIPLE_DEVICES(name_, desc_, ...) \ UNITY_TEST_FN_SET(__VA_ARGS__); \ - static void __attribute__((constructor)) UNITY_TEST_UID(test_reg_helper_) () \ + static void __attribute__((constructor)) UNITY_TEST_UID(test_reg_helper_) (void) \ { \ static test_desc_t UNITY_TEST_UID(test_desc_) = { \ .name = name_, \ diff --git a/components/wpa_supplicant/src/rsn_supp/wpa_i.h b/components/wpa_supplicant/src/rsn_supp/wpa_i.h index 3a09eff1d..69fc1a5e3 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa_i.h +++ b/components/wpa_supplicant/src/rsn_supp/wpa_i.h @@ -81,7 +81,7 @@ struct wpa_sm { int (*get_ppkey) (uint8_t *ifx, int *alg, uint8_t *addr, int *key_idx, uint8_t *key, size_t key_len, int key_entry_valid); void (*wpa_deauthenticate)(u8 reason_code); - void (*wpa_neg_complete)(); + void (*wpa_neg_complete)(void); struct wpa_gtk_data gd; //used for calllback save param u16 key_info; //used for txcallback param u16 txcb_flags; @@ -145,7 +145,7 @@ typedef int (*WPA_GET_KEY) (u8 *ifx, int *alg, u8 *addt, int *keyidx, u8 *key, s typedef void (*WPA_DEAUTH_FUNC)(u8 reason_code); -typedef void (*WPA_NEG_COMPLETE)(); +typedef void (*WPA_NEG_COMPLETE)(void); void wpa_register(char * payload, WPA_SEND_FUNC snd_func, \ WPA_SET_ASSOC_IE set_assoc_ie_func, \ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c index 6dc356cda..375c224c6 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c @@ -97,7 +97,7 @@ void ble_mesh_register_mesh_node(void) ble_mesh_register_node_cmd(); } -int ble_mesh_register_node_cb(void) +int ble_mesh_register_node_cb(int argc, char** argv) { ESP_LOGD(TAG, "enter %s\n", __func__); ble_mesh_node_init(); @@ -364,7 +364,7 @@ int ble_mesh_node_enable_bearer(int argc, char **argv) return err; } -int ble_mesh_node_reset(void) +int ble_mesh_node_reset(int argc, char** argv) { esp_err_t err; ESP_LOGD(TAG, "enter %s\n", __func__); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c index 0489388ec..64358ba60 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c @@ -25,7 +25,7 @@ void register_bluetooth(void) register_ble_address(); } -int bt_mac(void) +int bt_mac(int argc, char** argv) { const uint8_t *mac = esp_bt_dev_get_address(); printf("+BTMAC:"MACSTR"\n", MAC2STR(mac)); @@ -38,7 +38,7 @@ void register_ble_address(void) .command = "btmac", .help = "get BT mac address", .hint = NULL, - .func = (esp_console_cmd_func_t)&bt_mac, + .func = &bt_mac, }; ESP_ERROR_CHECK(esp_console_cmd_register(&cmd)); } diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c index dc96f7907..b9bd565c4 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c @@ -76,7 +76,7 @@ void ble_mesh_register_mesh_node(void) ble_mesh_register_node_cmd(); } -int ble_mesh_register_node_cb(void) +int ble_mesh_register_node_cb(int argc, char** argv) { ESP_LOGD(TAG, "enter %s\n", __func__); ble_mesh_node_init(); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c index 4c95d45b2..6b74255d3 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c @@ -101,7 +101,7 @@ void ble_mesh_prov_adv_cb(const esp_bd_addr_t addr, const esp_ble_addr_type_t ad ESP_LOGD(TAG, "exit %s\n", __func__); } -int ble_mesh_provisioner_register(void) +int ble_mesh_provisioner_register(int argc, char** argv) { ESP_LOGD(TAG, "enter %s \n", __func__); // esp_ble_mesh_register_unprov_adv_pkt_callback(ble_mesh_prov_adv_cb); diff --git a/examples/peripherals/mcpwm/mcpwm_bldc_control/main/mcpwm_bldc_control_hall_sensor_example.c b/examples/peripherals/mcpwm/mcpwm_bldc_control/main/mcpwm_bldc_control_hall_sensor_example.c index c8bfe0001..6784b6399 100644 --- a/examples/peripherals/mcpwm/mcpwm_bldc_control/main/mcpwm_bldc_control_hall_sensor_example.c +++ b/examples/peripherals/mcpwm/mcpwm_bldc_control/main/mcpwm_bldc_control_hall_sensor_example.c @@ -162,7 +162,7 @@ static void disp_captured_signal(void *arg) /** * @brief this is ISR handler function, here we check for interrupt that triggers rising edge on CAP0 signal and according take action */ -static void IRAM_ATTR isr_handler(void) +static void IRAM_ATTR isr_handler(void *arg) { uint32_t mcpwm_intr_status; capture evt; diff --git a/examples/peripherals/rmt_nec_tx_rx/main/infrared_nec_main.c b/examples/peripherals/rmt_nec_tx_rx/main/infrared_nec_main.c index 1dc28e5ac..df5a6b08d 100644 --- a/examples/peripherals/rmt_nec_tx_rx/main/infrared_nec_main.c +++ b/examples/peripherals/rmt_nec_tx_rx/main/infrared_nec_main.c @@ -276,7 +276,7 @@ static void nec_rx_init(void) * @brief RMT receiver demo, this task will print each received NEC data. * */ -static void rmt_example_nec_rx_task(void) +static void rmt_example_nec_rx_task(void *arg) { int channel = RMT_RX_CHANNEL; nec_rx_init(); @@ -317,7 +317,7 @@ static void rmt_example_nec_rx_task(void) * @brief RMT transmitter demo, this task will periodically send NEC data. (100 * 32 bits each time.) * */ -static void rmt_example_nec_tx_task(void) +static void rmt_example_nec_tx_task(void *arg) { vTaskDelay(10); nec_tx_init(); diff --git a/examples/peripherals/uart/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c b/examples/peripherals/uart/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c index f4f4eb18d..3b4a5872e 100644 --- a/examples/peripherals/uart/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c +++ b/examples/peripherals/uart/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c @@ -41,7 +41,7 @@ int sendData(const char* logName, const char* data) return txBytes; } -static void tx_task(void) +static void tx_task(void *arg) { static const char *TX_TASK_TAG = "TX_TASK"; esp_log_level_set(TX_TASK_TAG, ESP_LOG_INFO); @@ -51,7 +51,7 @@ static void tx_task(void) } } -static void rx_task(void) +static void rx_task(void *arg) { static const char *RX_TASK_TAG = "RX_TASK"; esp_log_level_set(RX_TASK_TAG, ESP_LOG_INFO); diff --git a/examples/peripherals/uart/uart_echo/main/uart_echo_example_main.c b/examples/peripherals/uart/uart_echo/main/uart_echo_example_main.c index 6e6a77a74..c9b5dbc7b 100644 --- a/examples/peripherals/uart/uart_echo/main/uart_echo_example_main.c +++ b/examples/peripherals/uart/uart_echo/main/uart_echo_example_main.c @@ -31,7 +31,7 @@ #define BUF_SIZE (1024) -static void echo_task(void) +static void echo_task(void *arg) { /* Configure parameters of an UART driver, * communication pins and install the driver */ diff --git a/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c b/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c index c68c22edf..e2d53dac4 100644 --- a/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c +++ b/examples/peripherals/uart/uart_echo_rs485/main/rs485_example.c @@ -52,7 +52,7 @@ static const char *TAG = "RS485_ECHO_APP"; // An example of echo test with hardware flow control on UART -static void echo_task(void) +static void echo_task(void *arg) { const int uart_num = ECHO_UART_PORT; uart_config_t uart_config = { diff --git a/examples/peripherals/uart/uart_select/main/uart_select_example_main.c b/examples/peripherals/uart/uart_select/main/uart_select_example_main.c index 2c46a3d11..d7b3c8849 100644 --- a/examples/peripherals/uart/uart_select/main/uart_select_example_main.c +++ b/examples/peripherals/uart/uart_select/main/uart_select_example_main.c @@ -20,7 +20,7 @@ static const char* TAG = "uart_select_example"; -static void uart_select_task(void) +static void uart_select_task(void *arg) { uart_config_t uart_config = { .baud_rate = 115200, diff --git a/examples/system/select/main/select_example.c b/examples/system/select/main/select_example.c index 962902429..5da28c7dd 100644 --- a/examples/system/select/main/select_example.c +++ b/examples/system/select/main/select_example.c @@ -128,7 +128,7 @@ static void uart1_write_task(void *param) } } - uart1_deinit(uart_fd); + uart1_deinit(); vTaskDelete(NULL); } From 12403e39b43ead17e97336033407a74649c9fb5d Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Tue, 30 Jul 2019 21:26:43 +0700 Subject: [PATCH 15/36] tools: Fix the build examples script to run locally --- tools/ci/build_examples.sh | 5 ++++- tools/ci/build_examples_cmake.sh | 18 +++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tools/ci/build_examples.sh b/tools/ci/build_examples.sh index 7393cb302..9be1525b3 100755 --- a/tools/ci/build_examples.sh +++ b/tools/ci/build_examples.sh @@ -62,9 +62,12 @@ SDKCONFIG_DEFAULTS_CI=sdkconfig.ci EXAMPLE_PATHS=$( find ${IDF_PATH}/examples/ -type f -name Makefile | grep -v "/build_system/cmake/" | sort ) -if [ -z {CI_NODE_TOTAL} ] +if [ -z "${CI_NODE_TOTAL:-}" ] then START_NUM=0 + if [ "${1:-}" ]; then + START_NUM=$1 + fi END_NUM=999 else JOB_NUM=${CI_NODE_INDEX} diff --git a/tools/ci/build_examples_cmake.sh b/tools/ci/build_examples_cmake.sh index da15bae72..cc5f3adc0 100755 --- a/tools/ci/build_examples_cmake.sh +++ b/tools/ci/build_examples_cmake.sh @@ -52,7 +52,7 @@ set -o nounset # Exit if variable not set. echo "build_examples running in ${PWD} for target $IDF_TARGET" # only 0 or 1 arguments -[ $# -le 1 ] || die "Have to run as $(basename $0) []" +[ $# -le 1 ] || die "Have to run as $(basename $0) []" export BATCH_BUILD=1 export V=0 # only build verbose if there's an error @@ -67,22 +67,26 @@ touch ${LOG_SUSPECTED} SDKCONFIG_DEFAULTS_CI=sdkconfig.ci EXAMPLE_PATHS=$( get_supported_examples.sh $IDF_TARGET | sed "s#^#${IDF_PATH}\/examples\/#g" | awk '{print $0"/CmakeLists.txt"}' ) +NUM_OF_EXAMPLES=$( echo "${EXAMPLE_PATHS}" | wc -l ) +# just a plausibility check +[ ${NUM_OF_EXAMPLES} -lt 100 ] && die "NUM_OF_EXAMPLES is bad" + echo "All examples found for target $IDF_TARGET:" echo $EXAMPLE_PATHS +echo "Number of examples: $NUM_OF_EXAMPLES" -if [ -z {CI_NODE_TOTAL} ] +if [ -z "${CI_NODE_TOTAL:-}" ] then START_NUM=0 - END_NUM=999 + if [ "${1:-}" ]; then + START_NUM=$1 + fi + END_NUM=${NUM_OF_EXAMPLES} else JOB_NUM=${CI_NODE_INDEX} # count number of the jobs NUM_OF_JOBS=${CI_NODE_TOTAL} - # count number of examples - NUM_OF_EXAMPLES=$( echo "${EXAMPLE_PATHS}" | wc -l ) - [ ${NUM_OF_EXAMPLES} -lt 100 ] && die "NUM_OF_EXAMPLES is bad" - # separate intervals #57 / 5 == 12 NUM_OF_EX_PER_JOB=$(( (${NUM_OF_EXAMPLES} + ${NUM_OF_JOBS} - 1) / ${NUM_OF_JOBS} )) From ec94ee80f72aacd2c078e6ce13c5355a8cf6c461 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Thu, 1 Aug 2019 11:23:41 +0700 Subject: [PATCH 16/36] Fix a build issue with replacing init_spi_flash() in the host tests --- components/fatfs/test_fatfs_host/Makefile | 1 - components/fatfs/test_fatfs_host/test_fatfs.cpp | 4 ++-- components/fatfs/test_fatfs_host/test_utils.c | 7 ------- components/spi_flash/sim/flash_mock_util.c | 7 ------- .../sim/stubs/freertos/include/freertos/FreeRTOS.h | 4 ---- components/spiffs/test_spiffs_host/Makefile | 1 - components/spiffs/test_spiffs_host/test_spiffs.cpp | 6 +++--- components/spiffs/test_spiffs_host/test_utils.c | 7 ------- components/wear_levelling/test_wl_host/Makefile | 1 - components/wear_levelling/test_wl_host/test_utils.c | 7 ------- components/wear_levelling/test_wl_host/test_wl.cpp | 6 +++--- 11 files changed, 8 insertions(+), 43 deletions(-) delete mode 100644 components/fatfs/test_fatfs_host/test_utils.c delete mode 100644 components/spiffs/test_spiffs_host/test_utils.c delete mode 100644 components/wear_levelling/test_wl_host/test_utils.c diff --git a/components/fatfs/test_fatfs_host/Makefile b/components/fatfs/test_fatfs_host/Makefile index 4c43e16aa..3d17e5ac1 100644 --- a/components/fatfs/test_fatfs_host/Makefile +++ b/components/fatfs/test_fatfs_host/Makefile @@ -81,7 +81,6 @@ $(foreach cxxfile, $(CPPFILES), $(eval $(call COMPILE_CPP, $(cxxfile)))) TEST_SOURCE_FILES = \ test_fatfs.cpp \ main.cpp \ - test_utils.c TEST_OBJ_FILES = $(filter %.o, $(TEST_SOURCE_FILES:.cpp=.o) $(TEST_SOURCE_FILES:.c=.o)) diff --git a/components/fatfs/test_fatfs_host/test_fatfs.cpp b/components/fatfs/test_fatfs_host/test_fatfs.cpp index fcbbe5594..d1f7119e6 100644 --- a/components/fatfs/test_fatfs_host/test_fatfs.cpp +++ b/components/fatfs/test_fatfs_host/test_fatfs.cpp @@ -9,11 +9,11 @@ #include "catch.hpp" -extern "C" void init_spi_flash(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin); +extern "C" void _spi_flash_init(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin); TEST_CASE("create volume, open file, write and read back data", "[fatfs]") { - init_spi_flash(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin"); + _spi_flash_init(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin"); FRESULT fr_result; BYTE pdrv; diff --git a/components/fatfs/test_fatfs_host/test_utils.c b/components/fatfs/test_fatfs_host/test_utils.c deleted file mode 100644 index 3e4b05758..000000000 --- a/components/fatfs/test_fatfs_host/test_utils.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "esp_spi_flash.h" -#include "esp_partition.h" - -void init_spi_flash(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin) -{ - spi_flash_init(chip_size, block_size, sector_size, page_size, partition_bin); -} diff --git a/components/spi_flash/sim/flash_mock_util.c b/components/spi_flash/sim/flash_mock_util.c index 770600e64..2db51c58a 100644 --- a/components/spi_flash/sim/flash_mock_util.c +++ b/components/spi_flash/sim/flash_mock_util.c @@ -4,13 +4,6 @@ #include "esp_err.h" #include "esp32/rom/spi_flash.h" -extern void _spi_flash_init(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin); - -void spi_flash_init(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin) -{ - _spi_flash_init(chip_size, block_size, sector_size, page_size, partition_bin); -} - bool spi_flash_check_and_flush_cache(size_t start_addr, size_t length) { return true; diff --git a/components/spi_flash/sim/stubs/freertos/include/freertos/FreeRTOS.h b/components/spi_flash/sim/stubs/freertos/include/freertos/FreeRTOS.h index 9abd0dd8b..5bafa772d 100644 --- a/components/spi_flash/sim/stubs/freertos/include/freertos/FreeRTOS.h +++ b/components/spi_flash/sim/stubs/freertos/include/freertos/FreeRTOS.h @@ -2,7 +2,3 @@ #include "projdefs.h" #include "semphr.h" - -// Avoid redefinition compile error. Put here since this is included -// in flash_ops.c. -#define spi_flash_init() overriden_spi_flash_init() diff --git a/components/spiffs/test_spiffs_host/Makefile b/components/spiffs/test_spiffs_host/Makefile index 4d016f7b4..15b327acf 100644 --- a/components/spiffs/test_spiffs_host/Makefile +++ b/components/spiffs/test_spiffs_host/Makefile @@ -79,7 +79,6 @@ $(foreach cxxfile, $(CPPFILES), $(eval $(call COMPILE_CPP, $(cxxfile)))) TEST_SOURCE_FILES = \ test_spiffs.cpp \ main.cpp \ - test_utils.c TEST_OBJ_FILES = $(filter %.o, $(TEST_SOURCE_FILES:.cpp=.o) $(TEST_SOURCE_FILES:.c=.o)) diff --git a/components/spiffs/test_spiffs_host/test_spiffs.cpp b/components/spiffs/test_spiffs_host/test_spiffs.cpp index a523f06a7..868ce4580 100644 --- a/components/spiffs/test_spiffs_host/test_spiffs.cpp +++ b/components/spiffs/test_spiffs_host/test_spiffs.cpp @@ -12,7 +12,7 @@ #include "catch.hpp" -extern "C" void init_spi_flash(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin); +extern "C" void _spi_flash_init(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin); static void init_spiffs(spiffs *fs, uint32_t max_files) { @@ -152,7 +152,7 @@ static void check_spiffs_files(spiffs *fs, const char *base_path, char* cur_path TEST_CASE("format disk, open file, write and read file", "[spiffs]") { - init_spi_flash(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin"); + _spi_flash_init(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin"); spiffs fs; s32_t spiffs_res; @@ -204,7 +204,7 @@ TEST_CASE("format disk, open file, write and read file", "[spiffs]") TEST_CASE("can read spiffs image", "[spiffs]") { - init_spi_flash(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin"); + _spi_flash_init(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin"); spiffs fs; s32_t spiffs_res; diff --git a/components/spiffs/test_spiffs_host/test_utils.c b/components/spiffs/test_spiffs_host/test_utils.c deleted file mode 100644 index 3e4b05758..000000000 --- a/components/spiffs/test_spiffs_host/test_utils.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "esp_spi_flash.h" -#include "esp_partition.h" - -void init_spi_flash(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin) -{ - spi_flash_init(chip_size, block_size, sector_size, page_size, partition_bin); -} diff --git a/components/wear_levelling/test_wl_host/Makefile b/components/wear_levelling/test_wl_host/Makefile index 5d94990cc..40e517445 100644 --- a/components/wear_levelling/test_wl_host/Makefile +++ b/components/wear_levelling/test_wl_host/Makefile @@ -80,7 +80,6 @@ $(foreach cxxfile, $(CPPFILES), $(eval $(call COMPILE_CPP, $(cxxfile)))) TEST_SOURCE_FILES = \ test_wl.cpp \ main.cpp \ - test_utils.c TEST_OBJ_FILES = $(filter %.o, $(TEST_SOURCE_FILES:.cpp=.o) $(TEST_SOURCE_FILES:.c=.o)) diff --git a/components/wear_levelling/test_wl_host/test_utils.c b/components/wear_levelling/test_wl_host/test_utils.c deleted file mode 100644 index 3e4b05758..000000000 --- a/components/wear_levelling/test_wl_host/test_utils.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "esp_spi_flash.h" -#include "esp_partition.h" - -void init_spi_flash(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin) -{ - spi_flash_init(chip_size, block_size, sector_size, page_size, partition_bin); -} diff --git a/components/wear_levelling/test_wl_host/test_wl.cpp b/components/wear_levelling/test_wl_host/test_wl.cpp index 258902439..32993876c 100644 --- a/components/wear_levelling/test_wl_host/test_wl.cpp +++ b/components/wear_levelling/test_wl_host/test_wl.cpp @@ -12,14 +12,14 @@ #include "sdkconfig.h" -extern "C" void init_spi_flash(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin); +extern "C" void _spi_flash_init(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin); extern SpiFlash spiflash; #define TEST_COUNT_MAX 100 TEST_CASE("write and read back data", "[wear_levelling]") { - init_spi_flash(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin"); + _spi_flash_init(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin"); esp_err_t result; wl_handle_t wl_handle; @@ -92,7 +92,7 @@ TEST_CASE("write and read back data", "[wear_levelling]") TEST_CASE("power down test", "[wear_levelling]") { - init_spi_flash(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin"); + _spi_flash_init(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin"); esp_err_t result; wl_handle_t wl_handle; From e639d5cb84fb9aa92a40375dd370145e2e784568 Mon Sep 17 00:00:00 2001 From: RevoluPowered Date: Sun, 16 Jun 2019 15:15:48 +0100 Subject: [PATCH 17/36] CMake: Added git ignore for cache files generated by cmake Merges https://github.com/espressif/esp-idf/pull/3639 --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 48ee2b0f1..dedb5745d 100644 --- a/.gitignore +++ b/.gitignore @@ -63,8 +63,12 @@ test_multi_heap_host # VS Code Settings .vscode/ +# Clion IDE CMake build & config +.idea/ +cmake-build-*/ + # Results for the checking of the Python coding style flake8_output.txt -# ESP-IDF library +# ESP-IDF default build directory name build From 017a60a69da670d998c7b7b803041b27a1916bd2 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 1 Aug 2019 11:27:32 +0800 Subject: [PATCH 18/36] fix the wrong comment in esp_wifi_types.h --- components/esp_wifi/lib_esp32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_wifi/lib_esp32 b/components/esp_wifi/lib_esp32 index 57e1fd11f..2e3638146 160000 --- a/components/esp_wifi/lib_esp32 +++ b/components/esp_wifi/lib_esp32 @@ -1 +1 @@ -Subproject commit 57e1fd11f2f2e17c39ce9612e5fd87d687bcf133 +Subproject commit 2e3638146130970f9eec473f39817921d42320d7 From 9f9d8767991193651526fc552dc603cfd2f815bd Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Fri, 2 Aug 2019 10:22:20 +0800 Subject: [PATCH 19/36] wifi: fix wifi bugs for authmode and multi ssid --- components/esp_wifi/lib_esp32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_wifi/lib_esp32 b/components/esp_wifi/lib_esp32 index 2e3638146..8e2ed075d 160000 --- a/components/esp_wifi/lib_esp32 +++ b/components/esp_wifi/lib_esp32 @@ -1 +1 @@ -Subproject commit 2e3638146130970f9eec473f39817921d42320d7 +Subproject commit 8e2ed075db7f4d5f942b5ea354070d6273c01638 From 02e5266778a11caeff893d6dd675f9f03aa3692e Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Fri, 2 Aug 2019 10:22:46 +0800 Subject: [PATCH 20/36] modify WIFI_CONN_0101 case for wrong authmode of AP --- .../idf_test/integration_test/TC_IT_WIFI_CONN.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/idf_test/integration_test/TC_IT_WIFI_CONN.yml b/components/idf_test/integration_test/TC_IT_WIFI_CONN.yml index 7086310cd..7195a32cc 100644 --- a/components/idf_test/integration_test/TC_IT_WIFI_CONN.yml +++ b/components/idf_test/integration_test/TC_IT_WIFI_CONN.yml @@ -28,20 +28,20 @@ test cases: - - SSC SSC2 sta -C -s -p - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - SSC SSC1 ap -S -s -p -t 1 - - - R SSC1 C +SAP:OK + - - R SSC1 C +SAP:ERROR - - SSC SSC2 sta -D - - R SSC2 C +QAP:OK - - SSC SSC2 sta -S - - R SSC2 RE "\+SCAN:%%s,.+,0,\d+"%%() C +SCANDONE - - - SSC SSC1 ap -S -s -p -t 5 - - - R SSC1 C +SAP:OK + - - SSC SSC1 ap -S -s -p -t 6 + - - R SSC1 C +SAP:ERROR - - SSC SSC2 sta -S - - R SSC2 RE "\+SCAN:%%s,.+,0,\d+"%%() C +SCANDONE execution time: 0.0 expected result: "1.target1 set AP,open, \n2.target 2 jap succeed\n3.target1 set AP,wpa_psk \n4.target 2 jap succeed\n5.target1 set AP, wpa2_psk \n6.target 2 jap succeed\n7.target1 set AP,wap_wpa2_psk\n8.target 2 jap succeed\n9.target1 set - AP,加密方式为t 1\n10.target 2 上查询到target_ssid\n11.target1 set AP,加密方式为t 5\n12.target + AP,加密方式为t 1\n10.target 2 上查询到target_ssid\n11.target1 set AP,加密方式为t 6\n12.target 2 上查询到target_ssid" initial condition: T2_1 level: Integration @@ -50,7 +50,7 @@ test cases: 和pwd,加密方式 wpa_psk \n4.target2 jap target1\n5.target1下设置ssid 和pwd,加密方式 wpa2_psk \n6.target 2 jap target1\n7.target1下设置ssid 和pwd,加密方式 wap_wpa2_psk\n8.target2 jap target1\n9.target1下设置ssid 和pwd,加密方式 wep \n10.target2上查询target_ssid\n11.target1下设置ssid - 和pwd,加密方式 t 5 错误的加密方式\n12.target2上查询 target_ssid" + 和pwd,加密方式 t 6 错误的加密方式\n12.target2上查询 target_ssid" sub module: WIFI Connect summary: station SAP+JAP test, different encryption test environment: SSC_T2_5 From 73624e856066b069cfd81a8a3ca65540ee080bf2 Mon Sep 17 00:00:00 2001 From: Henning Fleddermann Date: Mon, 15 Jul 2019 17:51:25 +0200 Subject: [PATCH 21/36] modify comments on esp_tls_cfg, to clarify that other formats besides PEM (such as DER) might be used as well depending on mbedtls-support Signed-off-by: David Cermak --- components/esp-tls/esp_tls.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/components/esp-tls/esp_tls.h b/components/esp-tls/esp_tls.h index 1c2f785ea..ebdffa49e 100644 --- a/components/esp-tls/esp_tls.h +++ b/components/esp-tls/esp_tls.h @@ -90,22 +90,28 @@ typedef struct esp_tls_cfg { - where 'h2' is the protocol name */ const unsigned char *cacert_pem_buf; /*!< Certificate Authority's certificate in a buffer. - This buffer should be NULL terminated */ + Format may be PEM or DER, depending on mbedtls-support + This buffer should be NULL terminated in case of PEM */ unsigned int cacert_pem_bytes; /*!< Size of Certificate Authority certificate - pointed to by cacert_pem_buf */ + pointed to by cacert_pem_buf + (including NULL-terminator in case of PEM format) */ const unsigned char *clientcert_pem_buf;/*!< Client certificate in a buffer - This buffer should be NULL terminated */ + Format may be PEM or DER, depending on mbedtls-support + This buffer should be NULL terminated in case of PEM */ unsigned int clientcert_pem_bytes; /*!< Size of client certificate pointed to by - clientcert_pem_buf */ + clientcert_pem_buf + (including NULL-terminator in case of PEM format) */ const unsigned char *clientkey_pem_buf; /*!< Client key in a buffer - This buffer should be NULL terminated */ + Format may be PEM or DER, depending on mbedtls-support + This buffer should be NULL terminated in case of PEM */ unsigned int clientkey_pem_bytes; /*!< Size of client key pointed to by - clientkey_pem_buf */ + clientkey_pem_buf + (including NULL-terminator in case of PEM format) */ const unsigned char *clientkey_password;/*!< Client key decryption password string */ From 546b6254335435cc01ce26cded765855af8c4144 Mon Sep 17 00:00:00 2001 From: Henning Fleddermann Date: Mon, 15 Jul 2019 17:53:39 +0200 Subject: [PATCH 22/36] add _der variants for esp_transport_ssl_set_(client_cert|client_key|cert_data) Signed-off-by: David Cermak Merges https://github.com/espressif/esp-idf/pull/3783 --- .../tcp_transport/include/esp_transport_ssl.h | 33 +++++++++++++++++++ components/tcp_transport/transport_ssl.c | 27 +++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/components/tcp_transport/include/esp_transport_ssl.h b/components/tcp_transport/include/esp_transport_ssl.h index 0f83c1d6e..3e2bfb42d 100644 --- a/components/tcp_transport/include/esp_transport_ssl.h +++ b/components/tcp_transport/include/esp_transport_ssl.h @@ -40,6 +40,17 @@ esp_transport_handle_t esp_transport_ssl_init(); */ void esp_transport_ssl_set_cert_data(esp_transport_handle_t t, const char *data, int len); +/** + * @brief Set SSL certificate data (as DER format). + * Note that, this function stores the pointer to data, rather than making a copy. + * So this data must remain valid until after the connection is cleaned up + * + * @param t ssl transport + * @param[in] data The der data + * @param[in] len The length + */ +void esp_transport_ssl_set_cert_data_der(esp_transport_handle_t t, const char *data, int len); + /** * @brief Enable global CA store for SSL connection * @@ -58,6 +69,17 @@ void esp_transport_ssl_enable_global_ca_store(esp_transport_handle_t t); */ void esp_transport_ssl_set_client_cert_data(esp_transport_handle_t t, const char *data, int len); +/** + * @brief Set SSL client certificate data for mutual authentication (as DER format). + * Note that, this function stores the pointer to data, rather than making a copy. + * So this data must remain valid until after the connection is cleaned up + * + * @param t ssl transport + * @param[in] data The der data + * @param[in] len The length + */ +void esp_transport_ssl_set_client_cert_data_der(esp_transport_handle_t t, const char *data, int len); + /** * @brief Set SSL client key data for mutual authentication (as PEM format). * Note that, this function stores the pointer to data, rather than making a copy. @@ -69,6 +91,17 @@ void esp_transport_ssl_set_client_cert_data(esp_transport_handle_t t, const char */ void esp_transport_ssl_set_client_key_data(esp_transport_handle_t t, const char *data, int len); +/** + * @brief Set SSL client key data for mutual authentication (as DER format). + * Note that, this function stores the pointer to data, rather than making a copy. + * So this data must remain valid until after the connection is cleaned up + * + * @param t ssl transport + * @param[in] data The der data + * @param[in] len The length + */ +void esp_transport_ssl_set_client_key_data_der(esp_transport_handle_t t, const char *data, int len); + /** * @brief Skip validation of certificate's common name field * diff --git a/components/tcp_transport/transport_ssl.c b/components/tcp_transport/transport_ssl.c index 1651a2f87..b8a2e7281 100644 --- a/components/tcp_transport/transport_ssl.c +++ b/components/tcp_transport/transport_ssl.c @@ -178,6 +178,15 @@ void esp_transport_ssl_set_cert_data(esp_transport_handle_t t, const char *data, } } +void esp_transport_ssl_set_cert_data_der(esp_transport_handle_t t, const char *data, int len) +{ + transport_ssl_t *ssl = esp_transport_get_context_data(t); + if (t && ssl) { + ssl->cfg.cacert_pem_buf = (void *)data; + ssl->cfg.cacert_pem_bytes = len; + } +} + void esp_transport_ssl_set_client_cert_data(esp_transport_handle_t t, const char *data, int len) { transport_ssl_t *ssl = esp_transport_get_context_data(t); @@ -187,6 +196,15 @@ void esp_transport_ssl_set_client_cert_data(esp_transport_handle_t t, const char } } +void esp_transport_ssl_set_client_cert_data_der(esp_transport_handle_t t, const char *data, int len) +{ + transport_ssl_t *ssl = esp_transport_get_context_data(t); + if (t && ssl) { + ssl->cfg.clientcert_pem_buf = (void *)data; + ssl->cfg.clientcert_pem_bytes = len; + } +} + void esp_transport_ssl_set_client_key_data(esp_transport_handle_t t, const char *data, int len) { transport_ssl_t *ssl = esp_transport_get_context_data(t); @@ -196,6 +214,15 @@ void esp_transport_ssl_set_client_key_data(esp_transport_handle_t t, const char } } +void esp_transport_ssl_set_client_key_data_der(esp_transport_handle_t t, const char *data, int len) +{ + transport_ssl_t *ssl = esp_transport_get_context_data(t); + if (t && ssl) { + ssl->cfg.clientkey_pem_buf = (void *)data; + ssl->cfg.clientkey_pem_bytes = len; + } +} + void esp_transport_ssl_skip_common_name_check(esp_transport_handle_t t) { transport_ssl_t *ssl = esp_transport_get_context_data(t); From 25dd5e39afba5f66fe571ed235270b3972223679 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 2 Aug 2019 09:20:02 +0200 Subject: [PATCH 23/36] esp-tls: Naming variables refering to certificates and keys in a neutral way to suggest that both PEM and DER format could be used, added comments descibing important details about using these formats --- components/esp-tls/esp_tls.c | 34 ++++----- components/esp-tls/esp_tls.h | 74 +++++++++++++++---- .../esp_https_server/src/https_server.c | 26 +++---- components/tcp_transport/transport_ssl.c | 12 +-- .../main/https_request_example_main.c | 4 +- 5 files changed, 98 insertions(+), 52 deletions(-) diff --git a/components/esp-tls/esp_tls.c b/components/esp-tls/esp_tls.c index 65cd789f3..e2d33cb0e 100644 --- a/components/esp-tls/esp_tls.c +++ b/components/esp-tls/esp_tls.c @@ -339,8 +339,8 @@ static esp_err_t set_server_config(esp_tls_cfg_server_t *cfg, esp_tls_t *tls) } #endif - if (cfg->cacert_pem_buf != NULL) { - esp_ret = set_ca_cert(tls, cfg->cacert_pem_buf, cfg->cacert_pem_bytes); + if (cfg->cacert_buf != NULL) { + esp_ret = set_ca_cert(tls, cfg->cacert_buf, cfg->cacert_bytes); if (esp_ret != ESP_OK) { return esp_ret; } @@ -348,14 +348,14 @@ static esp_err_t set_server_config(esp_tls_cfg_server_t *cfg, esp_tls_t *tls) mbedtls_ssl_conf_authmode(&tls->conf, MBEDTLS_SSL_VERIFY_NONE); } - if (cfg->servercert_pem_buf != NULL && cfg->serverkey_pem_buf != NULL) { + if (cfg->servercert_buf != NULL && cfg->serverkey_buf != NULL) { esp_tls_pki_t pki = { .public_cert = &tls->servercert, .pk_key = &tls->serverkey, - .publiccert_pem_buf = cfg->servercert_pem_buf, - .publiccert_pem_bytes = cfg->servercert_pem_bytes, - .privkey_pem_buf = cfg->serverkey_pem_buf, - .privkey_pem_bytes = cfg->serverkey_pem_bytes, + .publiccert_pem_buf = cfg->servercert_buf, + .publiccert_pem_bytes = cfg->servercert_bytes, + .privkey_pem_buf = cfg->serverkey_buf, + .privkey_pem_bytes = cfg->serverkey_bytes, .privkey_password = cfg->serverkey_password, .privkey_password_len = cfg->serverkey_password_len, }; @@ -421,8 +421,8 @@ static esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls if (esp_ret != ESP_OK) { return esp_ret; } - } else if (cfg->cacert_pem_buf != NULL) { - esp_err_t esp_ret = set_ca_cert(tls, cfg->cacert_pem_buf, cfg->cacert_pem_bytes); + } else if (cfg->cacert_buf != NULL) { + esp_err_t esp_ret = set_ca_cert(tls, cfg->cacert_buf, cfg->cacert_bytes); if (esp_ret != ESP_OK) { return esp_ret; } @@ -430,14 +430,14 @@ static esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls mbedtls_ssl_conf_authmode(&tls->conf, MBEDTLS_SSL_VERIFY_NONE); } - if (cfg->clientcert_pem_buf != NULL && cfg->clientkey_pem_buf != NULL) { + if (cfg->clientcert_buf != NULL && cfg->clientkey_buf != NULL) { esp_tls_pki_t pki = { .public_cert = &tls->clientcert, .pk_key = &tls->clientkey, - .publiccert_pem_buf = cfg->clientcert_pem_buf, - .publiccert_pem_bytes = cfg->clientcert_pem_bytes, - .privkey_pem_buf = cfg->clientkey_pem_buf, - .privkey_pem_bytes = cfg->clientkey_pem_bytes, + .publiccert_pem_buf = cfg->clientcert_buf, + .publiccert_pem_bytes = cfg->clientcert_bytes, + .privkey_pem_buf = cfg->clientkey_buf, + .privkey_pem_bytes = cfg->clientkey_bytes, .privkey_password = cfg->clientkey_password, .privkey_password_len = cfg->clientkey_password_len, }; @@ -446,8 +446,8 @@ static esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls ESP_LOGE(TAG, "Failed to set server pki context"); return esp_ret; } - } else if (cfg->clientcert_pem_buf != NULL || cfg->clientkey_pem_buf != NULL) { - ESP_LOGE(TAG, "You have to provide both clientcert_pem_buf and clientkey_pem_buf for mutual authentication"); + } else if (cfg->clientcert_buf != NULL || cfg->clientkey_buf != NULL) { + ESP_LOGE(TAG, "You have to provide both clientcert_buf and clientkey_buf for mutual authentication"); return ESP_ERR_INVALID_STATE; } return ESP_OK; @@ -628,7 +628,7 @@ static int esp_tls_low_level_conn(const char *hostname, int hostlen, int port, c ESP_LOGE(TAG, "mbedtls_ssl_handshake returned -0x%x", -ret); ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ERR_TYPE_MBEDTLS, -ret); ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ERR_TYPE_ESP, ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED); - if (cfg->cacert_pem_buf != NULL || cfg->use_global_ca_store == true) { + if (cfg->cacert_buf != NULL || cfg->use_global_ca_store == true) { /* This is to check whether handshake failed due to invalid certificate*/ verify_certificate(tls); } diff --git a/components/esp-tls/esp_tls.h b/components/esp-tls/esp_tls.h index ebdffa49e..ee7fe49de 100644 --- a/components/esp-tls/esp_tls.h +++ b/components/esp-tls/esp_tls.h @@ -78,6 +78,16 @@ typedef enum esp_tls_role { /** * @brief ESP-TLS configuration parameters + * + * @note Note about format of certificates: + * - This structure includes certificates of a Certificate Authority, of client or server as well + * as private keys, which may be of PEM or DER format. In case of PEM format, the buffer must be + * NULL terminated (with NULL character included in certificate size). + * - Certificate Authority's certificate may be a chain of certificates in case of PEM format, + * but could be only one certificate in case of DER format + * - Variables names of certificates and private key buffers and sizes are defined as unions providing + * backward compatibility for legacy *_pem_buf and *_pem_bytes names which suggested only PEM format + * was supported. It is encouraged to use generic names such as cacert_buf and cacert_bytes. */ typedef struct esp_tls_cfg { const char **alpn_protos; /*!< Application protocols required for HTTP2. @@ -89,29 +99,47 @@ typedef struct esp_tls_cfg { const char **alpn_protos = { "h2", NULL }; - where 'h2' is the protocol name */ - const unsigned char *cacert_pem_buf; /*!< Certificate Authority's certificate in a buffer. + union { + const unsigned char *cacert_buf; /*!< Certificate Authority's certificate in a buffer. Format may be PEM or DER, depending on mbedtls-support This buffer should be NULL terminated in case of PEM */ - - unsigned int cacert_pem_bytes; /*!< Size of Certificate Authority certificate - pointed to by cacert_pem_buf + const unsigned char *cacert_pem_buf; /*!< CA certificate buffer legacy name */ + }; + + union { + unsigned int cacert_bytes; /*!< Size of Certificate Authority certificate + pointed to by cacert_buf (including NULL-terminator in case of PEM format) */ + unsigned int cacert_pem_bytes; /*!< Size of Certificate Authority certificate legacy name */ + }; - const unsigned char *clientcert_pem_buf;/*!< Client certificate in a buffer + union { + const unsigned char *clientcert_buf; /*!< Client certificate in a buffer Format may be PEM or DER, depending on mbedtls-support This buffer should be NULL terminated in case of PEM */ + const unsigned char *clientcert_pem_buf; /*!< Client certificate legacy name */ + }; - unsigned int clientcert_pem_bytes; /*!< Size of client certificate pointed to by + union { + unsigned int clientcert_bytes; /*!< Size of client certificate pointed to by clientcert_pem_buf (including NULL-terminator in case of PEM format) */ + unsigned int clientcert_pem_bytes; /*!< Size of client certificate legacy name */ + }; - const unsigned char *clientkey_pem_buf; /*!< Client key in a buffer + union { + const unsigned char *clientkey_buf; /*!< Client key in a buffer Format may be PEM or DER, depending on mbedtls-support This buffer should be NULL terminated in case of PEM */ + const unsigned char *clientkey_pem_buf; /*!< Client key legacy name */ + }; - unsigned int clientkey_pem_bytes; /*!< Size of client key pointed to by + union { + unsigned int clientkey_bytes; /*!< Size of client key pointed to by clientkey_pem_buf (including NULL-terminator in case of PEM format) */ + unsigned int clientkey_pem_bytes; /*!< Size of client key legacy name */ + }; const unsigned char *clientkey_password;/*!< Client key decryption password string */ @@ -144,23 +172,41 @@ typedef struct esp_tls_cfg_server { const char **alpn_protos = { "h2", NULL }; - where 'h2' is the protocol name */ - const unsigned char *cacert_pem_buf; /*!< Client CA certificate in a buffer. + union { + const unsigned char *cacert_buf; /*!< Client CA certificate in a buffer. This buffer should be NULL terminated */ + const unsigned char *cacert_pem_buf; /*!< Client CA certificate legacy name */ + }; - unsigned int cacert_pem_bytes; /*!< Size of client CA certificate + union { + unsigned int cacert_bytes; /*!< Size of client CA certificate pointed to by cacert_pem_buf */ + unsigned int cacert_pem_bytes; /*!< Size of client CA certificate legacy name */ + }; - const unsigned char *servercert_pem_buf; /*!< Server certificate in a buffer + union { + const unsigned char *servercert_buf; /*!< Server certificate in a buffer This buffer should be NULL terminated */ + const unsigned char *servercert_pem_buf; /*!< Server certificate legacy name */ + }; - unsigned int servercert_pem_bytes; /*!< Size of server certificate pointed to by + union { + unsigned int servercert_bytes; /*!< Size of server certificate pointed to by servercert_pem_buf */ + unsigned int servercert_pem_bytes; /*!< Size of server certificate legacy name */ + }; - const unsigned char *serverkey_pem_buf; /*!< Server key in a buffer + union { + const unsigned char *serverkey_buf; /*!< Server key in a buffer This buffer should be NULL terminated */ + const unsigned char *serverkey_pem_buf; /*!< Server key legacy name */ + }; - unsigned int serverkey_pem_bytes; /*!< Size of server key pointed to by + union { + unsigned int serverkey_bytes; /*!< Size of server key pointed to by serverkey_pem_buf */ + unsigned int serverkey_pem_bytes; /*!< Size of server key legacy name */ + }; const unsigned char *serverkey_password; /*!< Server key decryption password string */ diff --git a/components/esp_https_server/src/https_server.c b/components/esp_https_server/src/https_server.c index f012ffec8..47c2abcb0 100644 --- a/components/esp_https_server/src/https_server.c +++ b/components/esp_https_server/src/https_server.c @@ -135,11 +135,11 @@ static void free_secure_context(void *ctx) assert(ctx != NULL); esp_tls_cfg_server_t *cfg = (esp_tls_cfg_server_t *)ctx; ESP_LOGI(TAG, "Server shuts down, releasing SSL context"); - if (cfg->servercert_pem_buf) { - free((void *)cfg->servercert_pem_buf); + if (cfg->servercert_buf) { + free((void *)cfg->servercert_buf); } - if (cfg->serverkey_pem_buf) { - free((void *)cfg->serverkey_pem_buf); + if (cfg->serverkey_buf) { + free((void *)cfg->serverkey_buf); } free(cfg); } @@ -150,22 +150,22 @@ static esp_tls_cfg_server_t *create_secure_context(const struct httpd_ssl_config if (!cfg) { return NULL; } - cfg->servercert_pem_buf = (unsigned char *)malloc(config->cacert_len); - if (!cfg->servercert_pem_buf) { + cfg->servercert_buf = (unsigned char *)malloc(config->cacert_len); + if (!cfg->servercert_buf) { free(cfg); return NULL; } - memcpy((char *)cfg->servercert_pem_buf, config->cacert_pem, config->cacert_len); - cfg->servercert_pem_bytes = config->cacert_len; + memcpy((char *)cfg->servercert_buf, config->cacert_pem, config->cacert_len); + cfg->servercert_bytes = config->cacert_len; - cfg->serverkey_pem_buf = (unsigned char *)malloc(config->prvtkey_len); - if (!cfg->serverkey_pem_buf) { - free((void *)cfg->servercert_pem_buf); + cfg->serverkey_buf = (unsigned char *)malloc(config->prvtkey_len); + if (!cfg->serverkey_buf) { + free((void *)cfg->servercert_buf); free(cfg); return NULL; } - memcpy((char *)cfg->serverkey_pem_buf, config->prvtkey_pem, config->prvtkey_len); - cfg->serverkey_pem_bytes = config->prvtkey_len; + memcpy((char *)cfg->serverkey_buf, config->prvtkey_pem, config->prvtkey_len); + cfg->serverkey_bytes = config->prvtkey_len; return cfg; } diff --git a/components/tcp_transport/transport_ssl.c b/components/tcp_transport/transport_ssl.c index b8a2e7281..b576d1a48 100644 --- a/components/tcp_transport/transport_ssl.c +++ b/components/tcp_transport/transport_ssl.c @@ -182,8 +182,8 @@ void esp_transport_ssl_set_cert_data_der(esp_transport_handle_t t, const char *d { transport_ssl_t *ssl = esp_transport_get_context_data(t); if (t && ssl) { - ssl->cfg.cacert_pem_buf = (void *)data; - ssl->cfg.cacert_pem_bytes = len; + ssl->cfg.cacert_buf = (void *)data; + ssl->cfg.cacert_bytes = len; } } @@ -200,8 +200,8 @@ void esp_transport_ssl_set_client_cert_data_der(esp_transport_handle_t t, const { transport_ssl_t *ssl = esp_transport_get_context_data(t); if (t && ssl) { - ssl->cfg.clientcert_pem_buf = (void *)data; - ssl->cfg.clientcert_pem_bytes = len; + ssl->cfg.clientcert_buf = (void *)data; + ssl->cfg.clientcert_bytes = len; } } @@ -218,8 +218,8 @@ void esp_transport_ssl_set_client_key_data_der(esp_transport_handle_t t, const c { transport_ssl_t *ssl = esp_transport_get_context_data(t); if (t && ssl) { - ssl->cfg.clientkey_pem_buf = (void *)data; - ssl->cfg.clientkey_pem_bytes = len; + ssl->cfg.clientkey_buf = (void *)data; + ssl->cfg.clientkey_bytes = len; } } diff --git a/examples/protocols/https_request/main/https_request_example_main.c b/examples/protocols/https_request/main/https_request_example_main.c index 742a4657e..0cd31ec21 100644 --- a/examples/protocols/https_request/main/https_request_example_main.c +++ b/examples/protocols/https_request/main/https_request_example_main.c @@ -75,8 +75,8 @@ static void https_get_task(void *pvParameters) while(1) { esp_tls_cfg_t cfg = { - .cacert_pem_buf = server_root_cert_pem_start, - .cacert_pem_bytes = server_root_cert_pem_end - server_root_cert_pem_start, + .cacert_buf = server_root_cert_pem_start, + .cacert_bytes = server_root_cert_pem_end - server_root_cert_pem_start, }; struct esp_tls *tls = esp_tls_conn_http_new(WEB_URL, &cfg); From d163b9e6150ce8409aaba9cb80ba4e58419de178 Mon Sep 17 00:00:00 2001 From: Krzysztof Date: Fri, 2 Aug 2019 17:09:33 +0800 Subject: [PATCH 24/36] Fix broken links in 'Getting Started' gudes --- docs/en/get-started/linux-setup-scratch.rst | 2 +- docs/en/get-started/windows-setup-scratch.rst | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/en/get-started/linux-setup-scratch.rst b/docs/en/get-started/linux-setup-scratch.rst index a96992c06..56e590c54 100644 --- a/docs/en/get-started/linux-setup-scratch.rst +++ b/docs/en/get-started/linux-setup-scratch.rst @@ -66,7 +66,7 @@ Build the toolchain:: ./ct-ng build chmod -R u+w builds/xtensa-esp32-elf -Toolchain will be built in ``~/esp/crosstool-NG/builds/xtensa-esp32-elf``. Follow `instructions for standard setup `_ to add the toolchain to your ``PATH``. +Toolchain will be built in ``~/esp/crosstool-NG/builds/xtensa-esp32-elf``. Follow :ref:`instructions for standard setup ` to add the toolchain to your ``PATH``. Next Steps diff --git a/docs/en/get-started/windows-setup-scratch.rst b/docs/en/get-started/windows-setup-scratch.rst index d0bef754d..3e35f916e 100644 --- a/docs/en/get-started/windows-setup-scratch.rst +++ b/docs/en/get-started/windows-setup-scratch.rst @@ -56,9 +56,9 @@ Ninja build .. note:: Ninja currently only provides binaries for 64-bit Windows. It is possible to use CMake and ``idf.py`` with other build tools, such as mingw-make, on 32-bit windows. However this is currently undocumented. -Download the ninja_ latest stable Windows release from the (`download page `_). +Download the ninja_ latest stable Windows release from the (`download page `_). -The Ninja for Windows download is a .zip file containing a single ``ninja.exe`` file which needs to be unzipped to a directory which is then `added to your Path `_ (or you can choose a directory which is already on your Path). +The Ninja for Windows download is a .zip file containing a single ``ninja.exe`` file which needs to be unzipped to a directory which is then :ref:`added to your Path ` (or you can choose a directory which is already on your Path). Python 2.x @@ -77,7 +77,7 @@ MConf for IDF Download the configuration tool mconf-idf from the `kconfig-frontends releases page `_. This is the ``mconf`` configuration tool with some minor customizations for ESP-IDF. -This tool will also need to be unzipped to a directory which is then `added to your Path `_. +This tool will also need to be unzipped to a directory which is then :ref:`added to your Path `. Toolchain Setup =============== @@ -90,7 +90,7 @@ Download the precompiled Windows toolchain: Unzip the zip file to ``C:\Program Files`` (or some other location). The zip file contains a single directory ``xtensa-esp32-elf``. -Next, the ``bin`` subdirectory of this directory must be `added to your Path `_. For example, the directory to add may be ``C:\Program Files\xtensa-esp32-elf\bin``. +Next, the ``bin`` subdirectory of this directory must be :ref:`added to your Path `. For example, the directory to add may be ``C:\Program Files\xtensa-esp32-elf\bin``. .. note:: If you already have the MSYS2 environment (for use with the "GNU Make" build system) installed, you can skip the separate download and add the directory ``C:\msys32\opt\xtensa-esp32-elf\bin`` to the Path instead, as the toolchain is included in the MSYS2 environment. @@ -114,6 +114,7 @@ Next Steps To carry on with development environment setup, proceed to :ref:`get-started-get-esp-idf`. .. _ninja: https://ninja-build.org/ +.. _ninja-dl: https://github.com/ninja-build/ninja/releases .. _Python: https://www.python.org/downloads/windows/ .. _MSYS2: https://msys2.github.io/ .. _Stable version: https://docs.espressif.com/projects/esp-idf/en/stable/ From 164fd5ad2984a0be2ad49720f5ac7b9e95a6aa69 Mon Sep 17 00:00:00 2001 From: Krzysztof Date: Fri, 2 Aug 2019 17:58:08 +0800 Subject: [PATCH 25/36] More link corrections --- docs/en/get-started/windows-setup-scratch.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/en/get-started/windows-setup-scratch.rst b/docs/en/get-started/windows-setup-scratch.rst index 3e35f916e..1c59b9648 100644 --- a/docs/en/get-started/windows-setup-scratch.rst +++ b/docs/en/get-started/windows-setup-scratch.rst @@ -75,7 +75,7 @@ Once Python is installed, open a Windows Command Prompt from the Start menu and MConf for IDF ^^^^^^^^^^^^^ -Download the configuration tool mconf-idf from the `kconfig-frontends releases page `_. This is the ``mconf`` configuration tool with some minor customizations for ESP-IDF. +Download the configuration tool mconf-idf from the `kconfig-frontends releases page`_. This is the ``mconf`` configuration tool with some minor customizations for ESP-IDF. This tool will also need to be unzipped to a directory which is then :ref:`added to your Path `. @@ -113,9 +113,11 @@ Next Steps To carry on with development environment setup, proceed to :ref:`get-started-get-esp-idf`. +.. _CMake: https://cmake.org/download/ .. _ninja: https://ninja-build.org/ .. _ninja-dl: https://github.com/ninja-build/ninja/releases .. _Python: https://www.python.org/downloads/windows/ .. _MSYS2: https://msys2.github.io/ +.. _kconfig-frontends releases page: https://github.com/espressif/kconfig-frontends/releases .. _Stable version: https://docs.espressif.com/projects/esp-idf/en/stable/ From 146f120f794532b4fdd3709fc4e870c46c06c0a4 Mon Sep 17 00:00:00 2001 From: Hrishikesh Dhayagude Date: Fri, 2 Aug 2019 18:01:58 +0800 Subject: [PATCH 26/36] examples/bluetooth: Move the demos to the appropriate locations --- .../bluetooth/{ => bluedroid/ble}/ble_ancs/CMakeLists.txt | 0 examples/bluetooth/{ => bluedroid/ble}/ble_ancs/Makefile | 0 examples/bluetooth/{ => bluedroid/ble}/ble_ancs/README.md | 0 .../{ => bluedroid/ble}/ble_ancs/main/CMakeLists.txt | 0 .../bluetooth/{ => bluedroid/ble}/ble_ancs/main/ble_ancs.c | 0 .../bluetooth/{ => bluedroid/ble}/ble_ancs/main/ble_ancs.h | 0 .../{ => bluedroid/ble}/ble_ancs/main/ble_ancs_demo.c | 0 .../bluetooth/{ => bluedroid/ble}/ble_ancs/main/component.mk | 0 .../bluetooth/{ => bluedroid/ble}/ble_ancs/sdkconfig.defaults | 0 .../{ => bluedroid/ble}/ble_compatibility_test/README.md | 4 ++-- 10 files changed, 2 insertions(+), 2 deletions(-) rename examples/bluetooth/{ => bluedroid/ble}/ble_ancs/CMakeLists.txt (100%) rename examples/bluetooth/{ => bluedroid/ble}/ble_ancs/Makefile (100%) rename examples/bluetooth/{ => bluedroid/ble}/ble_ancs/README.md (100%) rename examples/bluetooth/{ => bluedroid/ble}/ble_ancs/main/CMakeLists.txt (100%) rename examples/bluetooth/{ => bluedroid/ble}/ble_ancs/main/ble_ancs.c (100%) rename examples/bluetooth/{ => bluedroid/ble}/ble_ancs/main/ble_ancs.h (100%) rename examples/bluetooth/{ => bluedroid/ble}/ble_ancs/main/ble_ancs_demo.c (100%) rename examples/bluetooth/{ => bluedroid/ble}/ble_ancs/main/component.mk (100%) rename examples/bluetooth/{ => bluedroid/ble}/ble_ancs/sdkconfig.defaults (100%) rename examples/bluetooth/{ => bluedroid/ble}/ble_compatibility_test/README.md (68%) diff --git a/examples/bluetooth/ble_ancs/CMakeLists.txt b/examples/bluetooth/bluedroid/ble/ble_ancs/CMakeLists.txt similarity index 100% rename from examples/bluetooth/ble_ancs/CMakeLists.txt rename to examples/bluetooth/bluedroid/ble/ble_ancs/CMakeLists.txt diff --git a/examples/bluetooth/ble_ancs/Makefile b/examples/bluetooth/bluedroid/ble/ble_ancs/Makefile similarity index 100% rename from examples/bluetooth/ble_ancs/Makefile rename to examples/bluetooth/bluedroid/ble/ble_ancs/Makefile diff --git a/examples/bluetooth/ble_ancs/README.md b/examples/bluetooth/bluedroid/ble/ble_ancs/README.md similarity index 100% rename from examples/bluetooth/ble_ancs/README.md rename to examples/bluetooth/bluedroid/ble/ble_ancs/README.md diff --git a/examples/bluetooth/ble_ancs/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble/ble_ancs/main/CMakeLists.txt similarity index 100% rename from examples/bluetooth/ble_ancs/main/CMakeLists.txt rename to examples/bluetooth/bluedroid/ble/ble_ancs/main/CMakeLists.txt diff --git a/examples/bluetooth/ble_ancs/main/ble_ancs.c b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs.c similarity index 100% rename from examples/bluetooth/ble_ancs/main/ble_ancs.c rename to examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs.c diff --git a/examples/bluetooth/ble_ancs/main/ble_ancs.h b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs.h similarity index 100% rename from examples/bluetooth/ble_ancs/main/ble_ancs.h rename to examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs.h diff --git a/examples/bluetooth/ble_ancs/main/ble_ancs_demo.c b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c similarity index 100% rename from examples/bluetooth/ble_ancs/main/ble_ancs_demo.c rename to examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c diff --git a/examples/bluetooth/ble_ancs/main/component.mk b/examples/bluetooth/bluedroid/ble/ble_ancs/main/component.mk similarity index 100% rename from examples/bluetooth/ble_ancs/main/component.mk rename to examples/bluetooth/bluedroid/ble/ble_ancs/main/component.mk diff --git a/examples/bluetooth/ble_ancs/sdkconfig.defaults b/examples/bluetooth/bluedroid/ble/ble_ancs/sdkconfig.defaults similarity index 100% rename from examples/bluetooth/ble_ancs/sdkconfig.defaults rename to examples/bluetooth/bluedroid/ble/ble_ancs/sdkconfig.defaults diff --git a/examples/bluetooth/ble_compatibility_test/README.md b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/README.md similarity index 68% rename from examples/bluetooth/ble_compatibility_test/README.md rename to examples/bluetooth/bluedroid/ble/ble_compatibility_test/README.md index 928a4b6a7..3102fc5e5 100644 --- a/examples/bluetooth/ble_compatibility_test/README.md +++ b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/README.md @@ -7,10 +7,10 @@ This demo is to test the compatibility of Bluetooth and mobile phones. * IDF version: 7c29a39d6f9f2dfbefc49d34d34e9267afc7200d -* [Test case](https://github.com/espressif/esp-idf/blob/master/examples/bluetooth/ble_compatibility_test/ble_compatibility_test_case.md) +* [Test case](https://github.com/espressif/esp-idf/blob/master/examples/bluetooth/bluedroid/ble/ble_compatibility_test/ble_compatibility_test_case.md) * Test APK: LightBlue V1.1.3 -* [Test report](https://github.com/espressif/esp-idf/blob/master/examples/bluetooth/ble_compatibility_test/esp_ble_compatibility_test_report.md) +* [Test report](https://github.com/espressif/esp-idf/blob/master/examples/bluetooth/bluedroid/ble/ble_compatibility_test/esp_ble_compatibility_test_report.md) From e7dba7d7bc6218eea440dfe6f55592b8c21f6083 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Fri, 2 Aug 2019 09:01:20 +0530 Subject: [PATCH 27/36] examples: change default build instructions in docs to CMake --- examples/README.md | 4 ++-- examples/bluetooth/bluedroid/ble/ble_spp_client/README.md | 2 +- .../bluetooth/bluedroid/classic_bt/a2dp_sink/README.md | 2 +- .../ble_mesh_fast_prov_server/tutorial/EspBleMesh.md | 4 ++-- examples/bluetooth/esp_ble_mesh/ble_mesh_node/README.md | 4 ++-- .../tutorial/Ble_Mesh_Node_Example_Walkthrough.md | 8 ++++---- .../tutorial/ble_mesh_wifi_coexist.md | 6 +++--- examples/bluetooth/nimble/blecent/README.md | 4 ++-- examples/bluetooth/nimble/blehr/README.md | 4 ++-- examples/bluetooth/nimble/blemesh/README.md | 4 ++-- examples/bluetooth/nimble/bleprph/README.md | 4 ++-- examples/ethernet/basic/README.md | 4 ++-- examples/ethernet/iperf/README.md | 4 ++-- examples/peripherals/adc/README.md | 6 +++--- examples/peripherals/adc2/README.md | 6 +++--- examples/peripherals/i2s/README.md | 6 +++--- examples/peripherals/i2s_adc_dac/README.md | 6 +++--- examples/peripherals/ledc/README.md | 6 +++--- examples/peripherals/pcnt/README.md | 6 +++--- examples/peripherals/rmt_nec_tx_rx/README.md | 6 +++--- examples/peripherals/rmt_tx/README.md | 6 +++--- examples/peripherals/sigmadelta/README.md | 4 ++-- examples/peripherals/uart/uart_async_rxtxtasks/README.md | 6 +++--- examples/peripherals/uart/uart_echo/README.md | 6 +++--- examples/peripherals/uart/uart_echo_rs485/README.md | 6 +++--- examples/peripherals/uart/uart_events/README.md | 6 +++--- examples/peripherals/uart/uart_select/README.md | 6 +++--- examples/protocols/asio/chat_client/README.md | 2 +- examples/protocols/coap_client/README.md | 4 ++-- examples/protocols/coap_server/README.md | 4 ++-- examples/protocols/esp_local_ctrl/README.md | 2 +- examples/protocols/esp_local_ctrl/main/app_main.c | 2 +- examples/protocols/http_server/file_serving/README.md | 2 +- examples/protocols/mdns/README.md | 2 +- examples/protocols/modbus_master/README.md | 4 ++-- examples/protocols/modbus_slave/README.md | 4 ++-- examples/protocols/mqtt/publish_test/README.md | 2 +- examples/protocols/mqtt/ssl/README.md | 2 +- examples/protocols/mqtt/ssl_mutual_auth/README.md | 2 +- examples/protocols/mqtt/tcp/README.md | 4 ++-- examples/protocols/mqtt/ws/README.md | 2 +- examples/protocols/mqtt/wss/README.md | 2 +- examples/protocols/sockets/README.md | 4 ++-- examples/protocols/sockets/tcp_client/README.md | 4 ++-- examples/protocols/sockets/tcp_server/README.md | 4 ++-- examples/protocols/sockets/udp_client/README.md | 4 ++-- examples/protocols/sockets/udp_server/README.md | 4 ++-- examples/provisioning/ble_prov/README.md | 6 +++--- examples/provisioning/console_prov/README.md | 6 +++--- examples/provisioning/custom_config/README.md | 6 +++--- examples/provisioning/manager/README.md | 4 ++-- examples/provisioning/softap_prov/README.md | 6 +++--- examples/security/flash_encryption/README.md | 8 ++++---- examples/storage/spiffsgen/README.md | 8 ++++---- examples/storage/spiffsgen/main/CMakeLists.txt | 2 +- examples/system/freertos/real_time_stats/README.md | 4 ++-- examples/system/himem/README.md | 4 ++-- examples/system/network_tests/README.md | 5 ++--- examples/wifi/espnow/README.md | 4 ++-- examples/wifi/getting_started/softAP/README.md | 4 ++-- examples/wifi/getting_started/station/README.md | 4 ++-- examples/wifi/power_save/main/power_save.c | 2 +- examples/wifi/smart_config/README.md | 4 ++-- 63 files changed, 136 insertions(+), 137 deletions(-) diff --git a/examples/README.md b/examples/README.md index e5b4a0c4f..9728c3216 100644 --- a/examples/README.md +++ b/examples/README.md @@ -26,8 +26,8 @@ Building an example is the same as building any other project: * Follow the Getting Started instructions which include building the "Hello World" example. * Change into the directory of the new example you'd like to build. * Run `idf.py menuconfig` to open the project configuration menu. Most examples have a project-specific "Example Configuration" section here (for example, to set the WiFi SSID & password to use). -* `make` to build the example. -* Follow the printed instructions to flash, or run `idf.py flash`. +* `idf.py build` to build the example. +* Follow the printed instructions to flash, or run `idf.py -p PORT flash`. # Copying Examples diff --git a/examples/bluetooth/bluedroid/ble/ble_spp_client/README.md b/examples/bluetooth/bluedroid/ble/ble_spp_client/README.md index afae60f76..a38473126 100644 --- a/examples/bluetooth/bluedroid/ble/ble_spp_client/README.md +++ b/examples/bluetooth/bluedroid/ble/ble_spp_client/README.md @@ -81,7 +81,7 @@ Build each project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/README.md b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/README.md index 7d0889ecc..cd57b59d7 100644 --- a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/README.md +++ b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/README.md @@ -40,7 +40,7 @@ idf.py menuconfig Build the project and flash it to the board, then run monitor tool to view serial output. ``` -idf.py flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/ble_mesh_fast_prov_server/tutorial/EspBleMesh.md b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/ble_mesh_fast_prov_server/tutorial/EspBleMesh.md index 0d087ce2d..8039d6672 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/ble_mesh_fast_prov_server/tutorial/EspBleMesh.md +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/ble_mesh_fast_prov_server/tutorial/EspBleMesh.md @@ -16,7 +16,7 @@ A video of this demo can be seen > 1. Please flash the [`ble_mesh_fast_prov_server`](https://glab.espressif.cn/ble_mesh/esp-ble-mesh-v0.6/tree/ble_mesh_release/esp-ble-mesh-v0.6/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/ble_mesh_fast_prov_server) to your boards first; > 2. To have a better understanding of the performance of the BLE Mesh network, we recommend that at least 3 devices should be added in your network. > 3. We recommend that you solder LED indicators if your development board does not come with lights. -> 4. Please check the type of board and LED pin definition enabled in `Example BLE Mesh Config` by running `make menuconfig` +> 4. Please check the type of board and LED pin definition enabled in `Example BLE Mesh Config` by running `idf.py menuconfig` ![Board](images/device.png) @@ -30,7 +30,7 @@ examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/ble_mesh_fast_prov_serve ![Checkenvironment](images/picture1.png) -4. Run `make -j4 flash` to compile codes and flash the codes to the device. +4. Run `idf.py -p PORT flash` to compile codes and flash the codes to the device. ![compiledcode](images/picture2.png) diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/README.md b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/README.md index c84d2dfd0..85b2147ee 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/README.md +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/README.md @@ -8,9 +8,9 @@ This demo shows how BLE Mesh device can be set up as a node with the following f - **Configuration Server model**: The role of this model is mainly to configure Provisioner device’s AppKey and set up its relay function, TTL size, subscription, etc. - **OnOff Server model**: This model implements the most basic function of turning the lights on and off. -The default purpose of this demo is to enable the advertising function with 20-ms non-connectable interval in BLE 5.0. You can disable this function through menuconfig: `make menuconfig --> Example Configuration --> This option facilitates sending with 20ms non-connectable interval...` +The default purpose of this demo is to enable the advertising function with 20-ms non-connectable interval in BLE 5.0. You can disable this function through menuconfig: `idf.py menuconfig --> Example Configuration --> This option facilitates sending with 20ms non-connectable interval...` For a better demonstration effect, an RGB LED can be soldered onto the ESP32-DevKitC board, by connecting their corresponding GPIO pins are GPIO\_NUM\_25, GPIO\_NUM\_26, GPIO\_NUM\_27. Then you need to select the following option in menuconfig: - `make menuconfig --> Example Configuration --> Board selection for BLE Mesh --> ESP-WROOM-32` + `idf.py menuconfig --> Example Configuration --> Board selection for BLE Mesh --> ESP-WROOM-32` Please check the [tutorial](tutorial/Ble_Mesh_Node_Example_Walkthrough.md) for more information about this example. diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/tutorial/Ble_Mesh_Node_Example_Walkthrough.md b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/tutorial/Ble_Mesh_Node_Example_Walkthrough.md index 877659004..cdde9bfdb 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/tutorial/Ble_Mesh_Node_Example_Walkthrough.md +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/tutorial/Ble_Mesh_Node_Example_Walkthrough.md @@ -27,9 +27,9 @@ $ tree examples/bluetooth/esp_ble_mesh/ble_mesh/ble_mesh_node ├── README.md /* Quick start guide */ ├── build ├── main /* Stores the `.c` and `.h` application code files for this demo */ -├── sdkconfig /* Current parameters of `make menuconfig` */ -├── sdkconfig.defaults /* Default parameters of `make menuconfig` */ -├── sdkconfig.old /* Previously saved parameters of `make menuconfig` */ +├── sdkconfig /* Current parameters of `idf.py menuconfig` */ +├── sdkconfig.defaults /* Default parameters of `idf.py menuconfig` */ +├── sdkconfig.old /* Previously saved parameters of `idf.py menuconfig` */ └── tutorial /* More in-depth information about the demo */ ``` @@ -381,7 +381,7 @@ These variables should be set to `0` for this demo, as it uses the most basic au To be functional across different applications, the BLE Mesh menuconfig is specifically designed to offer a variety of configuration options, which can be helpful in tailoring your own configuration. -The list of configuration options in BLE Mesh menuconfig is stored in `Component config` ---> `[]Bluetooth Mesh support` and can be accessed with the command `make menuconfig`. This configuration option list is shown below. +The list of configuration options in BLE Mesh menuconfig is stored in `Component config` ---> `[]Bluetooth Mesh support` and can be accessed with the command `idf.py menuconfig`. This configuration option list is shown below. ``` —— Bluetooth Mesh support diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/tutorial/ble_mesh_wifi_coexist.md b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/tutorial/ble_mesh_wifi_coexist.md index e60446ca7..2acdb4764 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/tutorial/ble_mesh_wifi_coexist.md +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/tutorial/ble_mesh_wifi_coexist.md @@ -40,9 +40,9 @@ $ tree examples/bluetooth/esp_ble_mesh/ble_mesh/ble_mesh_wifi_coexist ├── Makefile /* Compiling parameters for the demo */ ├── README.md /* Quick start guide */ ├── build -├── sdkconfig /* Current parameters of `make menuconfig` */ -├── sdkconfig.defaults /* Default parameters of `make menuconfig` */ -├── sdkconfig.old /* Previously saved parameters of `make menuconfig` */ +├── sdkconfig /* Current parameters of `idf.py menuconfig` */ +├── sdkconfig.defaults /* Default parameters of `idf.py menuconfig` */ +├── sdkconfig.old /* Previously saved parameters of `idf.py menuconfig` */ └── tutorial /* More in-depth information about the demo */ ``` diff --git a/examples/bluetooth/nimble/blecent/README.md b/examples/bluetooth/nimble/blecent/README.md index 4b531f978..7724aba48 100644 --- a/examples/bluetooth/nimble/blecent/README.md +++ b/examples/bluetooth/nimble/blecent/README.md @@ -32,7 +32,7 @@ Note : ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -42,7 +42,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/bluetooth/nimble/blehr/README.md b/examples/bluetooth/nimble/blehr/README.md index af4b0581f..067769dcc 100644 --- a/examples/bluetooth/nimble/blehr/README.md +++ b/examples/bluetooth/nimble/blehr/README.md @@ -23,7 +23,7 @@ Note : ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -33,7 +33,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/bluetooth/nimble/blemesh/README.md b/examples/bluetooth/nimble/blemesh/README.md index 0f991b599..9c44bbb25 100644 --- a/examples/bluetooth/nimble/blemesh/README.md +++ b/examples/bluetooth/nimble/blemesh/README.md @@ -20,7 +20,7 @@ To test this demo, any BLE mesh provisioner app can be used. ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -32,7 +32,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/bluetooth/nimble/bleprph/README.md b/examples/bluetooth/nimble/bleprph/README.md index 6f0d96e8a..b518c81f8 100644 --- a/examples/bluetooth/nimble/bleprph/README.md +++ b/examples/bluetooth/nimble/bleprph/README.md @@ -24,7 +24,7 @@ Note : ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -38,7 +38,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/ethernet/basic/README.md b/examples/ethernet/basic/README.md index 57f4b472c..8f5552dcf 100644 --- a/examples/ethernet/basic/README.md +++ b/examples/ethernet/basic/README.md @@ -21,7 +21,7 @@ To run this example, it's recommended that you have an official ESP32 Ethernet d ### Project configuration in menuconfig -Enter `make menuconfig` if you are using GNU Make based build system or enter `idf.py menuconfig` if you' are using CMake based build system. +Enter `idf.py menuconfig` if you are using GNU Make based build system or enter `idf.py menuconfig` if you' are using CMake based build system. 1. In the `Example Configuration` menu: * Choose the kind of Ethernet this example will run on under `Ethernet Type`. @@ -59,7 +59,7 @@ Enter `make menuconfig` if you are using GNU Make based build system or enter `i ### Build and Flash -Enter `make -j4 flash monitor` if you are using GNU Make based build system or enter `idf.py build flash monitor` if you' are using CMake based build system. +Enter `idf.py -p PORT flash monitor` if you are using GNU Make based build system or enter `idf.py build flash monitor` if you' are using CMake based build system. (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/ethernet/iperf/README.md b/examples/ethernet/iperf/README.md index c75e90096..b33bab61d 100644 --- a/examples/ethernet/iperf/README.md +++ b/examples/ethernet/iperf/README.md @@ -25,7 +25,7 @@ To run this example, it's recommended that you have an official ESP32 Ethernet d ### Project configuration in menuconfig -Enter `make menuconfig` if you are using GNU Make based build system or enter `idf.py menuconfig` if you' are using CMake based build system. +Enter `idf.py menuconfig` if you are using GNU Make based build system or enter `idf.py menuconfig` if you' are using CMake based build system. 1. In the `Example Configuration` menu: * Enable storing history commands in flash under `Store command history in flash`. @@ -63,7 +63,7 @@ Enter `make menuconfig` if you are using GNU Make based build system or enter `i ### Build and Flash -Enter `make -j4 flash monitor` if you are using GNU Make based build system or enter `idf.py build flash monitor` if you' are using CMake based build system. +Enter `idf.py -p PORT flash monitor` if you are using GNU Make based build system or enter `idf.py build flash monitor` if you' are using CMake based build system. (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/peripherals/adc/README.md b/examples/peripherals/adc/README.md index 47f58c94b..b392e9957 100644 --- a/examples/peripherals/adc/README.md +++ b/examples/peripherals/adc/README.md @@ -16,7 +16,7 @@ In this example, we use `ADC_UNIT_1` by default, we need to connect a voltage so ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -26,7 +26,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -48,7 +48,7 @@ Raw: 18 Voltage: 79mV * program upload failure - * Hardware connection is not correct: run `idf.py monitor`, and reboot your board to see if there are any output logs. + * Hardware connection is not correct: run `idf.py -p PORT monitor`, and reboot your board to see if there are any output logs. * The baud rate for downloading is too high: lower your baud rate in the `menuconfig` menu, and try again. For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. diff --git a/examples/peripherals/adc2/README.md b/examples/peripherals/adc2/README.md index 32b94f68e..3130072b5 100644 --- a/examples/peripherals/adc2/README.md +++ b/examples/peripherals/adc2/README.md @@ -16,7 +16,7 @@ We use ADC1_CHANNEL_7 (GPIO27) and DAC_CHANNEL_1 (GPIO25) by default, you need t ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -27,7 +27,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -59,7 +59,7 @@ start conversion. * program upload failure - * Hardware connection is not correct: run `idf.py monitor`, and reboot your board to see if there are any output logs. + * Hardware connection is not correct: run `idf.py -p PORT monitor`, and reboot your board to see if there are any output logs. * The baud rate for downloading is too high: lower your baud rate in the `menuconfig` menu, and try again. For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. diff --git a/examples/peripherals/i2s/README.md b/examples/peripherals/i2s/README.md index a02f3e5e6..11c881dfa 100644 --- a/examples/peripherals/i2s/README.md +++ b/examples/peripherals/i2s/README.md @@ -14,7 +14,7 @@ In this example, we generate a 100Hz triangle and sine wave and send it out from ### Configure the Project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -24,7 +24,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -61,7 +61,7 @@ If you have a logic analyzer, you can use a logic analyzer to grab online data. * Program upload failure - * Hardware connection is not correct: run `idf.py monitor`, and reboot your board to see if there are any output logs. + * Hardware connection is not correct: run `idf.py -p PORT monitor`, and reboot your board to see if there are any output logs. * The baud rate for downloading is too high: lower your baud rate in the `menuconfig` menu, and try again. For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. diff --git a/examples/peripherals/i2s_adc_dac/README.md b/examples/peripherals/i2s_adc_dac/README.md index 7d43ef845..c3c85b6c7 100644 --- a/examples/peripherals/i2s_adc_dac/README.md +++ b/examples/peripherals/i2s_adc_dac/README.md @@ -35,7 +35,7 @@ The following is the hardware connection: ### Configure the Project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options, the flash size should be set to 4 MB. @@ -48,7 +48,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -85,7 +85,7 @@ I2S: PLL_D2: Req RATE: 16000, real rate: 1004.000, BITS: 16, CLKM: 83, BCK: 60, * Program upload failure - * Hardware connection is not correct: run `idf.py monitor`, and reboot your board to see if there are any output logs. + * Hardware connection is not correct: run `idf.py -p PORT monitor`, and reboot your board to see if there are any output logs. * The baud rate for downloading is too high: lower your baud rate in the `menuconfig` menu, and try again. For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. diff --git a/examples/peripherals/ledc/README.md b/examples/peripherals/ledc/README.md index c66fa19dd..542d0b376 100644 --- a/examples/peripherals/ledc/README.md +++ b/examples/peripherals/ledc/README.md @@ -23,7 +23,7 @@ Connect four LEDs to the following LEDC channels / individual GPIOs: ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -33,7 +33,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -63,7 +63,7 @@ you can also see the following output log on the serial monitor: * Programming fail - * Hardware connection is not correct: run `idf.py monitor`, and reboot your board to see if there are any output logs. + * Hardware connection is not correct: run `idf.py -p PORT monitor`, and reboot your board to see if there are any output logs. * The baud rate for downloading is too high: lower your baud rate in the `menuconfig` menu, and try again. For any technical queries, please open an [issue] (https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. diff --git a/examples/peripherals/pcnt/README.md b/examples/peripherals/pcnt/README.md index 6e0beb6c0..84721c562 100644 --- a/examples/peripherals/pcnt/README.md +++ b/examples/peripherals/pcnt/README.md @@ -20,7 +20,7 @@ Pin connection: ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -30,7 +30,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -68,7 +68,7 @@ Current counter value :-1 * program upload failure - * Hardware connection is not correct: run `idf.py monitor`, and reboot your board to see if there are any output logs. + * Hardware connection is not correct: run `idf.py -p PORT monitor`, and reboot your board to see if there are any output logs. * The baud rate for downloading is too high: lower your baud rate in the `menuconfig` menu, and try again. For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. diff --git a/examples/peripherals/rmt_nec_tx_rx/README.md b/examples/peripherals/rmt_nec_tx_rx/README.md index 073859111..e5a15025d 100644 --- a/examples/peripherals/rmt_nec_tx_rx/README.md +++ b/examples/peripherals/rmt_nec_tx_rx/README.md @@ -25,7 +25,7 @@ The TX pin and RX pin can be modified in top of the main/infrared_nec_main.c fil ### Configure the Project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -35,7 +35,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -74,7 +74,7 @@ NEC: RMT RCV --- addr: 0xda25 cmd: 0xeb14 * Programming fail - * Hardware connection is not correct: run `idf.py monitor`, and reboot your board to see if there is any output logs. + * Hardware connection is not correct: run `idf.py -p PORT monitor`, and reboot your board to see if there is any output logs. * The baud rate for downloading is too high: lower your baud rate in the `menuconfig` menu, and try again. For any technical queries, please open an [issue] (https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. diff --git a/examples/peripherals/rmt_tx/README.md b/examples/peripherals/rmt_tx/README.md index 6b7f1ff17..cd32a7e2b 100644 --- a/examples/peripherals/rmt_tx/README.md +++ b/examples/peripherals/rmt_tx/README.md @@ -30,7 +30,7 @@ GPIO18 +----/\/\/\----+------|>|-----+ GND ### Configure the Project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -40,7 +40,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -61,7 +61,7 @@ RMT Tx: Sample transmission complete * Programming fail - * Hardware connection is not correct: run `idf.py monitor`, and reboot your board to see if there is any output logs. + * Hardware connection is not correct: run `idf.py -p PORT monitor`, and reboot your board to see if there is any output logs. * The baud rate for downloading is too high: lower your baud rate in the `menuconfig` menu, and try again. For any technical queries, please open an [issue] (https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. diff --git a/examples/peripherals/sigmadelta/README.md b/examples/peripherals/sigmadelta/README.md index 23af6cf8d..14e0dacfe 100644 --- a/examples/peripherals/sigmadelta/README.md +++ b/examples/peripherals/sigmadelta/README.md @@ -24,7 +24,7 @@ By default the GPIO output is 4. To change it, edit the line with `GPIO_NUM_4` i ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` Set serial port under Serial Flasher Options and save the configuration. @@ -35,7 +35,7 @@ Set serial port under Serial Flasher Options and save the configuration. Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/peripherals/uart/uart_async_rxtxtasks/README.md b/examples/peripherals/uart/uart_async_rxtxtasks/README.md index d103ccf54..3bc54d578 100644 --- a/examples/peripherals/uart/uart_async_rxtxtasks/README.md +++ b/examples/peripherals/uart/uart_async_rxtxtasks/README.md @@ -24,7 +24,7 @@ order to receive back the same data which were sent out. ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` or ``` @@ -38,11 +38,11 @@ idf.py menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` or ``` -idf.py flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/peripherals/uart/uart_echo/README.md b/examples/peripherals/uart/uart_echo/README.md index 797393a85..6da7c5c6e 100644 --- a/examples/peripherals/uart/uart_echo/README.md +++ b/examples/peripherals/uart/uart_echo/README.md @@ -36,7 +36,7 @@ UART1 driver to use the hardware flow control by setting `.flow_ctrl = UART_HW_F ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` or ``` @@ -50,11 +50,11 @@ idf.py menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` or ``` -idf.py flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/peripherals/uart/uart_echo_rs485/README.md b/examples/peripherals/uart/uart_echo_rs485/README.md index f2c23f7c9..97c3373ba 100644 --- a/examples/peripherals/uart/uart_echo_rs485/README.md +++ b/examples/peripherals/uart/uart_echo_rs485/README.md @@ -45,7 +45,7 @@ Connect USB to RS485 adapter to computer and connect its D+, D- output lines wit ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` or ``` @@ -56,11 +56,11 @@ idf.py menuconfig ### Build and Flash Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` or ``` -idf.py flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/peripherals/uart/uart_events/README.md b/examples/peripherals/uart/uart_events/README.md index 677ffe4b0..5cd3898e7 100644 --- a/examples/peripherals/uart/uart_events/README.md +++ b/examples/peripherals/uart/uart_events/README.md @@ -14,7 +14,7 @@ The example can be used with any ESP32 development board connected to a computer ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` or ``` @@ -28,11 +28,11 @@ idf.py menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` or ``` -idf.py flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/peripherals/uart/uart_select/README.md b/examples/peripherals/uart/uart_select/README.md index f02f6b7f4..ffe87895c 100644 --- a/examples/peripherals/uart/uart_select/README.md +++ b/examples/peripherals/uart/uart_select/README.md @@ -26,7 +26,7 @@ through UART. ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` or ``` @@ -40,11 +40,11 @@ idf.py menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` or ``` -idf.py flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/asio/chat_client/README.md b/examples/protocols/asio/chat_client/README.md index edc4c7189..bcc2bd4d5 100644 --- a/examples/protocols/asio/chat_client/README.md +++ b/examples/protocols/asio/chat_client/README.md @@ -6,7 +6,7 @@ Simple Asio chat client using WiFi STA or Ethernet. - Wi-Fi or Ethernet connection is established, and IP address is obtained. - Asio chat client connects to the corresponding server whose port number and IP are defined through the project configuration menu. -- Chat client receives all messages from other chat clients, also it sends message received from stdin using `idf.py monitor`. +- Chat client receives all messages from other chat clients, also it sends message received from stdin using `idf.py -p PORT monitor`. ## Running the example diff --git a/examples/protocols/coap_client/README.md b/examples/protocols/coap_client/README.md index d058e3c31..bc3159dbb 100644 --- a/examples/protocols/coap_client/README.md +++ b/examples/protocols/coap_client/README.md @@ -16,7 +16,7 @@ please refer to [RFC7252](https://www.rfc-editor.org/rfc/pdfrfc/rfc7252.txt.pdf) ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher config @@ -29,7 +29,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/coap_server/README.md b/examples/protocols/coap_server/README.md index 44366936d..cf00279a4 100644 --- a/examples/protocols/coap_server/README.md +++ b/examples/protocols/coap_server/README.md @@ -16,7 +16,7 @@ please refer to [RFC7252](https://www.rfc-editor.org/rfc/pdfrfc/rfc7252.txt.pdf) ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set default serial port under Serial Flasher config @@ -28,7 +28,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/esp_local_ctrl/README.md b/examples/protocols/esp_local_ctrl/README.md index 81abdea2e..b16b48547 100644 --- a/examples/protocols/esp_local_ctrl/README.md +++ b/examples/protocols/esp_local_ctrl/README.md @@ -4,7 +4,7 @@ This example creates a `esp_local_ctrl` service over HTTPS transport, for secure See the `esp_local_ctrl` component documentation for details. -Before using the example, run `make menuconfig` (or `idf.py menuconfig` if using CMake build system) to configure Wi-Fi or Ethernet. See "Establishing Wi-Fi or Ethernet Connection" section in [examples/protocols/README.md](../README.md) for more details. +Before using the example, run `idf.py menuconfig` (or `idf.py menuconfig` if using CMake build system) to configure Wi-Fi or Ethernet. See "Establishing Wi-Fi or Ethernet Connection" section in [examples/protocols/README.md](../README.md) for more details. ## Client Side Implementation diff --git a/examples/protocols/esp_local_ctrl/main/app_main.c b/examples/protocols/esp_local_ctrl/main/app_main.c index d19feffda..521be92b5 100644 --- a/examples/protocols/esp_local_ctrl/main/app_main.c +++ b/examples/protocols/esp_local_ctrl/main/app_main.c @@ -20,7 +20,7 @@ #include "lwip/err.h" #include "lwip/sys.h" -/* The examples use WiFi configuration that you can set via 'make menuconfig'. +/* The examples use WiFi configuration that you can set via 'idf.py menuconfig'. If you'd rather not, just change the below entries to strings with the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" diff --git a/examples/protocols/http_server/file_serving/README.md b/examples/protocols/http_server/file_serving/README.md index 475cd7b0c..e4a891dd4 100644 --- a/examples/protocols/http_server/file_serving/README.md +++ b/examples/protocols/http_server/file_serving/README.md @@ -27,7 +27,7 @@ File server implementation can be found under `main/file_server.c` which uses SP * In order to test the file server demo : 1. compile and burn the firmware `idf.py -p PORT flash` - 2. run `idf.py monitor` and note down the IP assigned to your ESP module. The default port is 80 + 2. run `idf.py -p PORT monitor` and note down the IP assigned to your ESP module. The default port is 80 3. test the example interactively on a web browser (assuming IP is 192.168.43.130): 1. open path `http://192.168.43.130/` or `http://192.168.43.130/index.html` to see an HTML web page with list of files on the server (initially empty) 2. use the file upload form on the webpage to select and upload a file to the server diff --git a/examples/protocols/mdns/README.md b/examples/protocols/mdns/README.md index 2392699b6..2b99f2d4c 100644 --- a/examples/protocols/mdns/README.md +++ b/examples/protocols/mdns/README.md @@ -24,7 +24,7 @@ Shows how to use mDNS to advertise lookup services and hosts Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` - Wait for WiFi to connect to your access point diff --git a/examples/protocols/modbus_master/README.md b/examples/protocols/modbus_master/README.md index bcd24b294..c700f4b29 100644 --- a/examples/protocols/modbus_master/README.md +++ b/examples/protocols/modbus_master/README.md @@ -72,7 +72,7 @@ ESP32 WROVER KIT 1 | | RS-485 side | | Exter ### Configure the application Configure the UART pins used for modbus communication using command and table below. ``` -make menuconfig +idf.py menuconfig ``` ``` @@ -98,7 +98,7 @@ Other option is to have the modbus_slave example flashed into ESP32 WROVER KIT b ### Build and flash software of master device Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/modbus_slave/README.md b/examples/protocols/modbus_slave/README.md index 6ef854836..6d671781f 100644 --- a/examples/protocols/modbus_slave/README.md +++ b/examples/protocols/modbus_slave/README.md @@ -30,7 +30,7 @@ ESP32 WROVER KIT 1 | | RS-485 side | | Modbus ### Configure the application Configure the UART pins used for modbus communication using command and table below. ``` -make menuconfig +idf.py menuconfig ``` ``` @@ -53,7 +53,7 @@ As an example the Modbus Poll application can be used with this example. ### Build and flash software Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/mqtt/publish_test/README.md b/examples/protocols/mqtt/publish_test/README.md index d3db83641..ee377d5a6 100644 --- a/examples/protocols/mqtt/publish_test/README.md +++ b/examples/protocols/mqtt/publish_test/README.md @@ -33,7 +33,7 @@ This example can be executed on any ESP32 board, the only required interface is Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/mqtt/ssl/README.md b/examples/protocols/mqtt/ssl/README.md index db711fdcf..e2693729d 100644 --- a/examples/protocols/mqtt/ssl/README.md +++ b/examples/protocols/mqtt/ssl/README.md @@ -33,7 +33,7 @@ with text operation. Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/mqtt/ssl_mutual_auth/README.md b/examples/protocols/mqtt/ssl_mutual_auth/README.md index bf5b57d70..0696a4e16 100644 --- a/examples/protocols/mqtt/ssl_mutual_auth/README.md +++ b/examples/protocols/mqtt/ssl_mutual_auth/README.md @@ -43,7 +43,7 @@ Please note, that the supplied files `client.crt` and `client.key` in the `main` Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/mqtt/tcp/README.md b/examples/protocols/mqtt/tcp/README.md index 7920a75e9..7fe788cd1 100644 --- a/examples/protocols/mqtt/tcp/README.md +++ b/examples/protocols/mqtt/tcp/README.md @@ -1,7 +1,7 @@ # ESP-MQTT sample application (See the README.md file in the upper level 'examples' directory for more information about examples.) -This example connects to the broker URI selected using `make menuconfig` (using mqtt tcp transport) and as a demonstration subscribes/unsubscribes and send a message on certain topic. +This example connects to the broker URI selected using `idf.py menuconfig` (using mqtt tcp transport) and as a demonstration subscribes/unsubscribes and send a message on certain topic. (Please note that the public broker is maintained by the community so may not be always available, for details please see this [disclaimer](https://iot.eclipse.org/getting-started/#sandboxes)) Note: If the URI equals `FROM_STDIN` then the broker address is read from stdin upon application startup (used for testing) @@ -25,7 +25,7 @@ This example can be executed on any ESP32 board, the only required interface is Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/mqtt/ws/README.md b/examples/protocols/mqtt/ws/README.md index d0eff6be2..c0526b073 100644 --- a/examples/protocols/mqtt/ws/README.md +++ b/examples/protocols/mqtt/ws/README.md @@ -24,7 +24,7 @@ This example can be executed on any ESP32 board, the only required interface is Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/mqtt/wss/README.md b/examples/protocols/mqtt/wss/README.md index 187797930..9851d5433 100644 --- a/examples/protocols/mqtt/wss/README.md +++ b/examples/protocols/mqtt/wss/README.md @@ -34,7 +34,7 @@ with text operation. Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/sockets/README.md b/examples/protocols/sockets/README.md index 9fbc850db..9d5241532 100644 --- a/examples/protocols/sockets/README.md +++ b/examples/protocols/sockets/README.md @@ -79,7 +79,7 @@ This example can be run on any commonly available ESP32 development board. ## Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -91,7 +91,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/sockets/tcp_client/README.md b/examples/protocols/sockets/tcp_client/README.md index 415dea814..af3348ed3 100644 --- a/examples/protocols/sockets/tcp_client/README.md +++ b/examples/protocols/sockets/tcp_client/README.md @@ -35,7 +35,7 @@ This example can be run on any commonly available ESP32 development board. ## Configure the project ``` -make menuconfig +idf.py menuconfig ``` Set following parameter under Serial Flasher Options: @@ -59,7 +59,7 @@ Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu. See " Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/sockets/tcp_server/README.md b/examples/protocols/sockets/tcp_server/README.md index ce47646c9..ca72ff01b 100644 --- a/examples/protocols/sockets/tcp_server/README.md +++ b/examples/protocols/sockets/tcp_server/README.md @@ -37,7 +37,7 @@ This example can be run on any commonly available ESP32 development board. ## Configure the project ``` -make menuconfig +idf.py menuconfig ``` Set following parameter under Serial Flasher Options: @@ -57,7 +57,7 @@ Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu. See " Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/sockets/udp_client/README.md b/examples/protocols/sockets/udp_client/README.md index 7232fb9f4..85bdaa830 100644 --- a/examples/protocols/sockets/udp_client/README.md +++ b/examples/protocols/sockets/udp_client/README.md @@ -45,7 +45,7 @@ This example can be run on any commonly available ESP32 development board. ## Configure the project ``` -make menuconfig +idf.py menuconfig ``` Set following parameter under Serial Flasher Options: @@ -70,7 +70,7 @@ Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu. See " Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/protocols/sockets/udp_server/README.md b/examples/protocols/sockets/udp_server/README.md index 3bf1fe370..bbfbd6032 100644 --- a/examples/protocols/sockets/udp_server/README.md +++ b/examples/protocols/sockets/udp_server/README.md @@ -47,7 +47,7 @@ This example can be run on any commonly available ESP32 development board. ## Configure the project ``` -make menuconfig +idf.py menuconfig ``` Set following parameter under Serial Flasher Options: @@ -67,7 +67,7 @@ Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu. See " Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/provisioning/ble_prov/README.md b/examples/provisioning/ble_prov/README.md index fa49ba8e4..1c871e657 100644 --- a/examples/provisioning/ble_prov/README.md +++ b/examples/provisioning/ble_prov/README.md @@ -47,7 +47,7 @@ There are various applications, specific to Windows and macOS platform which can ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -61,7 +61,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -140,7 +140,7 @@ It means the Wi-Fi credentials were already set by some other application flashe ``` make erase_flash -make -j4 flash monitor +idf.py -p PORT flash monitor ``` Or, enable `Reset Provisioning` option under `Example Configuration` under menuconfig. But this will erase the saved Wi-Fi credentials every time the device boots, so this is not the preferred solution. diff --git a/examples/provisioning/console_prov/README.md b/examples/provisioning/console_prov/README.md index 0732c5450..685fdf66c 100644 --- a/examples/provisioning/console_prov/README.md +++ b/examples/provisioning/console_prov/README.md @@ -30,7 +30,7 @@ To provision the device running this example, the `esp_prov.py` script needs to ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -44,7 +44,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -202,7 +202,7 @@ It means the Wi-Fi credentials were already set by some other application flashe ``` make erase_flash -make -j4 flash monitor +idf.py -p PORT flash monitor ``` Or, enable `Reset Provisioning` option under `Example Configuration` under menuconfig. But this will erase the saved Wi-Fi credentials every time the device boots, so this is not the preferred solution. diff --git a/examples/provisioning/custom_config/README.md b/examples/provisioning/custom_config/README.md index 82ed6ffe3..dba1854a6 100644 --- a/examples/provisioning/custom_config/README.md +++ b/examples/provisioning/custom_config/README.md @@ -29,7 +29,7 @@ To provision the device running this example, the `esp_prov.py` script needs to ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -45,7 +45,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -138,7 +138,7 @@ It means the Wi-Fi credentials were already set by some other application flashe ``` make erase_flash -make -j4 flash monitor +idf.py -p PORT flash monitor ``` Or, enable `Reset Provisioning` option under `Example Configuration` under menuconfig. But this will erase the saved Wi-Fi credentials every time the device boots, so this is not the preferred solution. diff --git a/examples/provisioning/manager/README.md b/examples/provisioning/manager/README.md index b59f83710..d514d7bde 100644 --- a/examples/provisioning/manager/README.md +++ b/examples/provisioning/manager/README.md @@ -47,7 +47,7 @@ There are various applications, specific to Windows and macOS platform which can ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -57,7 +57,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/provisioning/softap_prov/README.md b/examples/provisioning/softap_prov/README.md index 56d092dbf..086a18e63 100644 --- a/examples/provisioning/softap_prov/README.md +++ b/examples/provisioning/softap_prov/README.md @@ -42,7 +42,7 @@ To provision the device running this example, the `esp_prov.py` script needs to ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -58,7 +58,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -145,7 +145,7 @@ It means the Wi-Fi credentials were already set by some other application flashe ``` make erase_flash -make -j4 flash monitor +idf.py -p PORT flash monitor ``` Or, enable `Reset Provisioning` option under `Example Configuration` under menuconfig. But this will erase the saved Wi-Fi credentials every time the device boots, so this is not the preferred solution. diff --git a/examples/security/flash_encryption/README.md b/examples/security/flash_encryption/README.md index f65d1bb16..750ee2a7b 100644 --- a/examples/security/flash_encryption/README.md +++ b/examples/security/flash_encryption/README.md @@ -8,7 +8,7 @@ The example checks if the flash encryption feature is enabled/disabled and if en ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -24,7 +24,7 @@ make menuconfig When building the project and flashing it to the board FOR THE FIRST TIME after enabling flash encryption feature in menuconfig, run following command to program ESP32 and monitor the output ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) @@ -34,13 +34,13 @@ See the Getting Started Guide for full steps to configure and use ESP-IDF to bui When reprogramming the device subsequently use following command for encrypted write of new plaintext application ``` -make -j4 encrypted-app-flash monitor +idf.py encrypted-app-flash monitor ``` Please note above command programs only the app partition. In order to reprogram all partitions (bootloader, partition table and application) in encrypted form use ``` -make -j4 encrypted-flash monitor +idf.py encrypted-flash monitor ``` ## Example Output diff --git a/examples/storage/spiffsgen/README.md b/examples/storage/spiffsgen/README.md index 1176d343d..b1d34048b 100644 --- a/examples/storage/spiffsgen/README.md +++ b/examples/storage/spiffsgen/README.md @@ -4,7 +4,7 @@ This example demonstrates how to use the SPIFFS image generation tool [spiffsgen.py](../../../components/spiffs/spiffsgen.py) to automatically create a SPIFFS filesystem image from the contents of a host folder during build, with an option of -automatically flashing the created image on invocation of `idf.py flash`. +automatically flashing the created image on invocation of `idf.py -p PORT flash`. For more information, see description of `spiffsgen.py` on the ESP-IDF Programming Guide under API Reference > Storage > SPIFFS Filesystem. The following gives an overview of the example: @@ -14,10 +14,10 @@ The following gives an overview of the example: 2. The function `spiffs_create_partition_image` is used to specify that a SPIFFS image should be created during build for the `storage` partition. For CMake, it is called from [the main component's CMakeLists.txt](./main/CMakeLists.txt); for Make, from the [project Makefile](./Makefile). `FLASH_IN_PROJECT` specifies that the created image -should be flashed on invocation of `idf.py flash` together with app, bootloader, partition table, etc. +should be flashed on invocation of `idf.py -p PORT flash` together with app, bootloader, partition table, etc. For both build systems, the image is created on the example's build directory with the output filename `storage.bin`. -3. Upon invocation of `idf.py flash monitor`, application loads and +3. Upon invocation of `idf.py -p PORT flash monitor`, application loads and finds there is already a valid SPIFFS filesystem in the `storage` partition with files same as those in `spiffs_image` directory. The application is then able to read those files. @@ -34,7 +34,7 @@ make flash monitor or ```CMake # CMake -idf.py flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/storage/spiffsgen/main/CMakeLists.txt b/examples/storage/spiffsgen/main/CMakeLists.txt index 6153893c3..3c74aed1b 100644 --- a/examples/storage/spiffsgen/main/CMakeLists.txt +++ b/examples/storage/spiffsgen/main/CMakeLists.txt @@ -4,5 +4,5 @@ idf_component_register(SRCS "spiffsgen_example_main.c" # Create a SPIFFS image from the contents of the 'spiffs_image' directory # that fits the partition named 'storage'. FLASH_IN_PROJECT indicates that # the generated image should be flashed when the entire project is flashed to -# the target with 'idf.py flash'. +# the target with 'idf.py -p PORT flash'. spiffs_create_partition_image(storage ../spiffs_image FLASH_IN_PROJECT) diff --git a/examples/system/freertos/real_time_stats/README.md b/examples/system/freertos/real_time_stats/README.md index 1ee73a34f..51e49832e 100644 --- a/examples/system/freertos/real_time_stats/README.md +++ b/examples/system/freertos/real_time_stats/README.md @@ -15,7 +15,7 @@ This example should be able to run on any commonly available ESP32 development b ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -29,7 +29,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/system/himem/README.md b/examples/system/himem/README.md index 0bc8a624c..7eba56c40 100644 --- a/examples/system/himem/README.md +++ b/examples/system/himem/README.md @@ -29,7 +29,7 @@ a setup does not make much sense. ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -43,7 +43,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/system/network_tests/README.md b/examples/system/network_tests/README.md index c9aefd8d3..3c2581972 100644 --- a/examples/system/network_tests/README.md +++ b/examples/system/network_tests/README.md @@ -23,9 +23,8 @@ Note: TTCN3 engine works reliably only on Linux and Windows. ``` cd $IDF_PATH/examples/system/network_tests -make defconfig -make -j4 -make flash +idf.py build +idf.py -p PORT flash ``` ## Run test diff --git a/examples/wifi/espnow/README.md b/examples/wifi/espnow/README.md index 047cf85a4..5b375c99b 100644 --- a/examples/wifi/espnow/README.md +++ b/examples/wifi/espnow/README.md @@ -31,7 +31,7 @@ to make ESPNOW data more safe and more reliable. ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -53,7 +53,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/wifi/getting_started/softAP/README.md b/examples/wifi/getting_started/softAP/README.md index 8d831d29b..4b030e01c 100644 --- a/examples/wifi/getting_started/softAP/README.md +++ b/examples/wifi/getting_started/softAP/README.md @@ -8,7 +8,7 @@ ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -20,7 +20,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/wifi/getting_started/station/README.md b/examples/wifi/getting_started/station/README.md index 6666da534..e992df260 100644 --- a/examples/wifi/getting_started/station/README.md +++ b/examples/wifi/getting_started/station/README.md @@ -8,7 +8,7 @@ ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -20,7 +20,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) diff --git a/examples/wifi/power_save/main/power_save.c b/examples/wifi/power_save/main/power_save.c index 04f60cb66..efa7f41c5 100644 --- a/examples/wifi/power_save/main/power_save.c +++ b/examples/wifi/power_save/main/power_save.c @@ -20,7 +20,7 @@ #include "esp_pm.h" #include "nvs_flash.h" -/*set the ssid and password via "make menuconfig"*/ +/*set the ssid and password via "idf.py menuconfig"*/ #define DEFAULT_SSID CONFIG_EXAMPLE_WIFI_SSID #define DEFAULT_PWD CONFIG_EXAMPLE_WIFI_PASSWORD diff --git a/examples/wifi/smart_config/README.md b/examples/wifi/smart_config/README.md index 7f8ee90c7..c8bdbeb9e 100644 --- a/examples/wifi/smart_config/README.md +++ b/examples/wifi/smart_config/README.md @@ -13,7 +13,7 @@ Download ESPTOUCH APP from app store: ### Configure the project ``` -make menuconfig +idf.py menuconfig ``` * Set serial port under Serial Flasher Options. @@ -23,7 +23,7 @@ make menuconfig Build the project and flash it to the board, then run monitor tool to view serial output: ``` -make -j4 flash monitor +idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) From d4091f7cda3b17ba35a291396373a8142b972f7f Mon Sep 17 00:00:00 2001 From: Hrudaynath Dhabe Date: Fri, 2 Aug 2019 19:18:44 +0800 Subject: [PATCH 28/36] esp_http_client: Add support to check the binary length of the recieved stream and compare it with the size mentioned in the header. While downloading OTA firmware, if their is a Origin Respnse Timeout or the binary is only partially downloaded, OTA failure is observed. Checking binary size can also be helpful for simple http client applications. Closes https://github.com/espressif/esp-idf/issues/3004 --- components/esp_http_client/esp_http_client.c | 22 ++++++++++++++++++- .../esp_http_client/include/esp_http_client.h | 11 ++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/components/esp_http_client/esp_http_client.c b/components/esp_http_client/esp_http_client.c index 76f6eec01..2dab9da1a 100644 --- a/components/esp_http_client/esp_http_client.c +++ b/components/esp_http_client/esp_http_client.c @@ -775,6 +775,22 @@ static int esp_http_client_get_data(esp_http_client_handle_t client) return rlen; } +bool esp_http_client_is_complete_data_received(esp_http_client_handle_t client) +{ + if (client->response->is_chunked) { + if (!client->is_chunk_complete) { + ESP_LOGI(TAG, "Chunks were not completely read"); + return false; + } + } else { + if (client->response->data_process != client->response->content_length) { + ESP_LOGI(TAG, "Data processed %d != Data specified in content length %d", client->response->data_process, client->response->content_length); + return false; + } + } + return true; +} + int esp_http_client_read(esp_http_client_handle_t client, char *buffer, int len) { esp_http_buffer_t *res_buffer = client->response->buffer; @@ -798,7 +814,7 @@ int esp_http_client_read(esp_http_client_handle_t client, char *buffer, int len) } else { is_data_remain = client->response->data_process < client->response->content_length; } - ESP_LOGD(TAG, "is_data_remain=%d, is_chunked=%d", is_data_remain, client->response->is_chunked); + ESP_LOGD(TAG, "is_data_remain=%d, is_chunked=%d, content_length=%d", is_data_remain, client->response->is_chunked, client->response->content_length); if (!is_data_remain) { break; } @@ -806,10 +822,14 @@ int esp_http_client_read(esp_http_client_handle_t client, char *buffer, int len) if (byte_to_read > client->buffer_size_rx) { byte_to_read = client->buffer_size_rx; } + errno = 0; rlen = esp_transport_read(client->transport, res_buffer->data, byte_to_read, client->timeout_ms); ESP_LOGD(TAG, "need_read=%d, byte_to_read=%d, rlen=%d, ridx=%d", need_read, byte_to_read, rlen, ridx); if (rlen <= 0) { + if (errno != 0) { + ESP_LOGW(TAG, "esp_transport_read returned : %d and errno : %d ", rlen, errno); + } return ridx; } res_buffer->output_ptr = buffer + ridx; diff --git a/components/esp_http_client/include/esp_http_client.h b/components/esp_http_client/include/esp_http_client.h index cc97cc069..2021d6edd 100644 --- a/components/esp_http_client/include/esp_http_client.h +++ b/components/esp_http_client/include/esp_http_client.h @@ -445,6 +445,17 @@ esp_err_t esp_http_client_set_redirection(esp_http_client_handle_t client); */ void esp_http_client_add_auth(esp_http_client_handle_t client); +/** + * @brief Checks if entire data in the response has been read without any error. + * + * @param[in] client The esp_http_client handle + * + * @return + * - true + * - false + */ +bool esp_http_client_is_complete_data_received(esp_http_client_handle_t client); + #ifdef __cplusplus } #endif From a9dfae66ea2a35dc0de2bed350f0d86cf9f1cae7 Mon Sep 17 00:00:00 2001 From: Tian Hao Date: Sat, 27 Jul 2019 17:47:33 +0800 Subject: [PATCH 29/36] bugfix btdm sleep twice after wakeup request This problem may cause HCI send command timeout. When host call VHCI api to do btdm_wakeup_request, then controller wakeup process will be handled in ISR and controller task context. As host task priority is lower than controller task and ISR, it will cause an incorrect behavior that before VHCI take the rx_flow_on_semaphore, controller sleep again, then VHCI cannot take the semaphore and has to wait the automatic wakeup. --- components/bt/controller/bt.c | 17 +++++++++++++---- components/bt/controller/lib | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/components/bt/controller/bt.c b/components/bt/controller/bt.c index db19faea2..0453a102e 100644 --- a/components/bt/controller/bt.c +++ b/components/bt/controller/bt.c @@ -203,7 +203,8 @@ extern void btdm_controller_enable_sleep(bool enable); extern void btdm_controller_set_sleep_mode(uint8_t mode); extern uint8_t btdm_controller_get_sleep_mode(void); extern bool btdm_power_state_active(void); -extern void btdm_wakeup_request(void); +extern void btdm_wakeup_request(bool request_lock); +extern void btdm_wakeup_request_end(void); /* Low Power Clock */ extern bool btdm_lpclk_select_src(uint32_t sel); extern bool btdm_lpclk_set_div(uint32_t div); @@ -893,6 +894,8 @@ bool esp_vhci_host_check_send_available(void) void esp_vhci_host_send_packet(uint8_t *data, uint16_t len) { + bool do_wakeup_request = false; + if (!btdm_power_state_active()) { #if CONFIG_PM_ENABLE if (semphr_take_wrapper(s_pm_lock_sem, 0)) { @@ -900,9 +903,15 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len) } esp_timer_stop(s_btdm_slp_tmr); #endif - btdm_wakeup_request(); + do_wakeup_request = true; + btdm_wakeup_request(true); } + API_vhci_host_send_packet(data, len); + + if (do_wakeup_request) { + btdm_wakeup_request_end(); + } } esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback) @@ -1328,7 +1337,7 @@ esp_err_t esp_bt_controller_disable(void) if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) { btdm_controller_enable_sleep(false); if (!btdm_power_state_active()) { - btdm_wakeup_request(); + btdm_wakeup_request(false); } while (!btdm_power_state_active()) { ets_delay_us(1000); @@ -1466,7 +1475,7 @@ void esp_bt_controller_wakeup_request(void) return; } - btdm_wakeup_request(); + btdm_wakeup_request(false); } esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path) diff --git a/components/bt/controller/lib b/components/bt/controller/lib index cc2fd1177..717f0c6ec 160000 --- a/components/bt/controller/lib +++ b/components/bt/controller/lib @@ -1 +1 @@ -Subproject commit cc2fd1177d97f1a4b9e0d819035ddf52ba77079d +Subproject commit 717f0c6ec71a016a0b292acffeacf239d007b8ff From 26fc858ea4f6142d80eead64b743d3ef9eddb71b Mon Sep 17 00:00:00 2001 From: "Michael (XIAO Xufeng)" Date: Thu, 1 Aug 2019 13:54:31 +0800 Subject: [PATCH 30/36] spi_common: remove deprecated spi_common_periph_claim macros --- components/driver/include/driver/spi_common.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/components/driver/include/driver/spi_common.h b/components/driver/include/driver/spi_common.h index 8f7c97f3d..9c8bf7546 100644 --- a/components/driver/include/driver/spi_common.h +++ b/components/driver/include/driver/spi_common.h @@ -143,18 +143,6 @@ esp_err_t spi_bus_free(spi_host_device_t host); */ bool spicommon_periph_claim(spi_host_device_t host, const char* source); -// The macro is to keep the back-compatibility of IDF v3.2 and before -// In this way we can call spicommon_periph_claim with two arguments, or the host with the source set to the calling function name -// When two arguments (host, func) are given, __spicommon_periph_claim2 is called -// or if only one arguments (host) is given, __spicommon_periph_claim1 is called -#define spicommon_periph_claim(host...) __spicommon_periph_claim(host, 2, 1) -#define __spicommon_periph_claim(host, source, n, ...) __spicommon_periph_claim ## n(host, source) -#define __spicommon_periph_claim1(host, _) ({ \ - char* warning_str = "calling spicommon_periph_claim without source string is deprecated.";\ - spicommon_periph_claim(host, __FUNCTION__); }) - -#define __spicommon_periph_claim2(host, func) spicommon_periph_claim(host, func) - /** * @brief Check whether the spi periph is in use. * From 8d8ea6f698123fdc0464aa719f3e0c8f0fe1279a Mon Sep 17 00:00:00 2001 From: Wang Fang Date: Mon, 5 Aug 2019 21:25:15 +0800 Subject: [PATCH 31/36] Add Chinese translation for modules-and-boards.rst in hw-reference folder. Note: Also modify the table in en version --- docs/en/hw-reference/modules-and-boards.rst | 14 +- .../zh_CN/hw-reference/modules-and-boards.rst | 311 +++++++++++++++++- 2 files changed, 317 insertions(+), 8 deletions(-) diff --git a/docs/en/hw-reference/modules-and-boards.rst b/docs/en/hw-reference/modules-and-boards.rst index 838348e25..caacbc8e4 100644 --- a/docs/en/hw-reference/modules-and-boards.rst +++ b/docs/en/hw-reference/modules-and-boards.rst @@ -4,6 +4,8 @@ ESP32 Modules and Boards ************************ +:link_to_translation:`zh_CN:[中文]` + Espressif designs and manufactures different modules and development boards to help users evaluate the potential of the ESP32 family of chips. This document provides description of modules and development boards currently available from Espressif. @@ -22,8 +24,6 @@ This is a family of ESP32-based modules with some integrated key components, inc The key characteristics of these modules are summarized in the table below. Some additional details are covered in the following sections. =================== ============ =========== ========= ==== =============== - Key Components -------------------- ------------------------------------------ --------------- Module Chip Flash, MB PSRAM, MB Ant. Dimensions, mm =================== ============ =========== ========= ==== =============== ESP32-WROOM-32 ESP32-D0WDQ6 4 -- MIFA 18 × 25.5 × 3.1 @@ -133,7 +133,7 @@ This series consists of a few modifications of ESP32-WROOM-32x modules, which am For details, see the table in Section :ref:`esp-wroom-solo-wrover-modules` and `Espressif Products Ordering Information`_. * **ESP32-WROVER (PCB)** and **ESP32-WROVER (IPEX)** have PSRAM that operates at 1.8 V and supports up to 144 MHz clock rate. -* **ESP32-WROVER-B** and **ESP32-WROVER-IB** have PSRAM that operates at 3.3 V and can supports up to 133 MHz clock rate. +* **ESP32-WROVER-B** and **ESP32-WROVER-IB** have PSRAM that operates at 3.3 V and supports up to 133 MHz clock rate. The picture below shows an ESP32-WROVER module with a PCB antenna. @@ -179,7 +179,7 @@ Depending on the intended functionality, different development boards feature: - Access to different ESP32 GPIO pins. - Different interfaces: USB, JTAG. -- Different peripherals: touchpads, LCD screens, SD card slots, headers for camera modules, etc. +- Different peripherals: touchpads, LCD screens, SD card slots, female headers for camera modules, etc. .. _esp-modules-and-boards-esp32-pico-kit: @@ -257,12 +257,12 @@ ESP-WROVER-KIT V4.1 This board features: -- dual port USB-to-serial converter for programming +- Dual port USB-to-serial converter for programming - JTAG interface for debugging - MicroSD card slot - 3.2” SPI LCD screen -- header for a camera module -- RGB diode for diagnostics +- Female headers for a camera module +- RGB LED for diagnostics - 32.768 kHz XTAL for internal RTC to operate it in low power modes Power can be supplied either via USB or via a standard 5 mm power supply jack. A power source can be selected with a jumper and can be turned on/off with a separate switch. diff --git a/docs/zh_CN/hw-reference/modules-and-boards.rst b/docs/zh_CN/hw-reference/modules-and-boards.rst index 311e160fe..eeeb746d2 100644 --- a/docs/zh_CN/hw-reference/modules-and-boards.rst +++ b/docs/zh_CN/hw-reference/modules-and-boards.rst @@ -1 +1,310 @@ -.. include:: ../../en/hw-reference/modules-and-boards.rst \ No newline at end of file +.. _esp-modules-and-boards: + +***************************** +ESP32 系列模组和开发板 +***************************** + +:link_to_translation:`en:[English]` + +乐鑫设计并提供多种模组和开发板以供用户体验 ESP32 系列芯片的强大功能。 + +本文档主要介绍了当前乐鑫所提供的各种模组和开发板。 + +.. note:: + + 如需了解较早版本或已停产的模组和开发板,请参考 :ref:`esp-modules-and-boards-previous`。 + +.. _esp-wroom-solo-wrover-modules: + +WROOM、SOLO、WROVER 和 PICO 系列模组 +===================================== + +WROOM、SOLO、WROVER 和 PICO 系列模组内置 ESP32 芯片并集成了晶振、天线匹配电路等重要组件,可直接集成到终端产品中。如果再结合一些其他组件,例如编程接口、Bootstrapping 电阻和排针,您就可以体验 ESP32 的强大功能了。 + +下表总结了上述系列模组的主要特点,详细信息见后续章节。 + ++---------------------+--------------+-------------+-------------+------+-----------------+ +| 模组 | 芯片 | Flash (MB) | PSRAM (MB) | 天线 | 尺寸 (mm) | ++---------------------+--------------+-------------+-------------+------+-----------------+ +| ESP32-WROOM-32 | ESP32-D0WDQ6 | 4 | – | MIFA | 18 × 25.5 × 3.1 | ++---------------------+--------------+-------------+-------------+------+-----------------+ +| ESP32-WROOM-32D | ESP32-D0WD | 4、8 或 16 | – | MIFA | 18 × 25.5 × 3.1 | ++---------------------+--------------+-------------+-------------+------+-----------------+ +| ESP32-WROOM-32U | ESP32-D0WD | 4、8 或 16 | – | U.FL | 18 × 19.2 × 3.1 | ++---------------------+--------------+-------------+-------------+------+-----------------+ +| ESP32-SOLO-1 | ESP32-S0WD | 4 | – | MIFA | 18 × 25.5 × 3.1 | ++---------------------+--------------+-------------+-------------+------+-----------------+ +| ESP32-WROVER (PCB) | ESP32-D0WDQ6 | 4 | 8 | MIFA | 18 × 31.4 × 3.3 | ++---------------------+--------------+-------------+-------------+------+-----------------+ +| ESP32-WROVER (IPEX) | ESP32-D0WDQ6 | 4 | 8 | U.FL | 18 × 31.4 × 3.3 | ++---------------------+--------------+-------------+-------------+------+-----------------+ +| ESP32-WROVER-B | ESP32-D0WD | 4、8 或 16 | 8 | MIFA | 18 × 31.4 × 3.3 | ++---------------------+--------------+-------------+-------------+------+-----------------+ +| ESP32-WROVER-IB | ESP32-D0WD | 4、8 或 16 | 8 | U.FL | 18 × 31.4 × 3.3 | ++---------------------+--------------+-------------+-------------+------+-----------------+ + + +* ESP32-**D**.. 代表双核芯片,ESP32-**S**.. 代表单核芯片; +* MIFA - 蛇形倒 F 天线; +* U.FL - U.FL/IPEX 天线连接器; +* ESP32-WROOM-32x、ESP32-WROVER-B 和 ESP32-WROVER-IB 模组默认内置 4 MB flash,客户可定制 8 MB 和 16 MB flash,详情见 `乐鑫产品订购信息`_ (PDF) 和《`ESP32 技术规格书 `_》(PDF); +* 最初发布的 ESP32-WROVER 模组内置 4 MB PSRAM; +* *ESP-WROOM-32* 是 *ESP32-WROOM-32* 的曾用名。 + +.. _esp-modules-and-boards-esp32-wroom-32: + +ESP32-WROOM-32 模组 +-------------------- + +ESP32-WROOM-32 模组是 WROOM/WROVER 系列最先发布的模组,内置 ESP32-D0WDQ6 芯片,是一款基础且常用的 ESP32 模组。 + +有关该模组的详细信息,请查看 :ref:`esp-wroom-solo-wrover-modules` 章节中的表格。 + +.. figure:: https://dl.espressif.com/dl/schematics/pictures/esp32-wroom-32-front-back.jpg + :align: center + :alt: ESP32-WROOM-32 module (front and back) + :width: 45% + + ESP32-WROOM-32 模组(正反面图) + +相关文档 +^^^^^^^^^^^^^ + +* 《`ESP32-WROOM-32 技术规格书 `_》(PDF); +* `ESP32-WROOM-32 参考设计 `_,包括原理图(由 OrCAD Capture 绘制)、PCB 布局(由 Mentor PADS 绘制)、GERBER 文件和 BOM 清单。 + +.. _esp-modules-and-boards-esp32-wroom-32d-and-u: + +ESP32-WROOM-32D/ESP32-WROOM-32U 模组 +-------------------------------------- + +两款模组均集成了 ESP32-D0WD 芯片,与 :ref:`esp-modules-and-boards-esp32-wroom-32` 集成的 ESP32-D0WDQ6 相比,ESP32-D0WD 芯片的封装更小,在 PCB 上占用的面积更小。 + +有关这两款模组的详细信息,请查看 :ref:`esp-wroom-solo-wrover-modules` 中的表格和 `乐鑫产品订购信息`_。 + +ESP32-WROOM-32U 是整个 WROOM/WROVER 模组系列中最小的模组。 + +.. figure:: https://dl.espressif.com/dl/schematics/pictures/esp32-wroom-32d-front-back.jpg + :align: center + :alt: ESP32-WROOM-32D module (front and back) + :width: 45% + + ESP32-WROOM-32D 模组(正反面图) + +.. figure:: https://dl.espressif.com/dl/schematics/pictures/esp32-wroom-32u-front-back.jpg + :align: center + :alt: ESP32-WROOM-32U module (front and back) + :width: 45% + + ESP32-WROOM-32U 模组(正反面图) + +相关文档 +^^^^^^^^^^^^^ + +* 《`ESP32-WROOM-32D/ESP32-WROOM-32U 技术规格书 `_》(PDF) + + +.. _esp-modules-and-boards-esp32-solo-1: + +ESP32-SOLO-1 模组 +----------------- + +ESP32-SOLO-1 模组是 ESP32-WROOM-32D 模组的简化版本,内置一个 ESP32 单核芯片,支持高达 160 MHz 的时钟频率。 + +有关此模组的详细信息,请查看 :ref:`esp-wroom-solo-wrover-modules` 章节中的表格和 `乐鑫产品订购信息`_。 + +.. figure:: https://dl.espressif.com/dl/schematics/pictures/esp32-solo-1-front-back.jpg + :align: center + :alt: ESP32-SOLO-1 module (front and back) + :width: 45% + + ESP32-SOLO-1 模组(正反面图) + +相关文档 +^^^^^^^^^^^^^ + +* 《`ESP32-SOLO-1 技术规格书 `__》(PDF) + +.. _esp-modules-and-boards-esp32-wrover: + +ESP32-WROVER 系列模组 +------------------------- + +ESP32-WROVER 系列模组在 ESP32-WROOM-32x 模组的基础上进行了一些修改,其中包含一些功能升级,并新增 8 MB SPI PSRAM(伪静态 RAM)。 + +有关该模组的详细信息,请查看 :ref:`esp-wroom-solo-wrover-modules` 章节中的表格和 `乐鑫产品订购信息`_。 + +* **ESP32-WROVER (PCB)** 模组和 **ESP32-WROVER (IPEX)** 模组内置 1.8 V PSRAM,支持 144 MHz 时钟频率。 +* **ESP32-WROVER-B** 模组和 **ESP32-WROVER-IB** 模组内置 3.3 V PSRAM,支持 133 MHz 时钟频率。 + +下图为配备有 PCB 天线的 ESP32-WROVER 模组: + +.. figure:: https://dl.espressif.com/dl/schematics/pictures/esp32-wrover.jpg + :align: center + :alt: ESP32-WROVER module (front and back) + :width: 40% + + ESP32-WROVER 模组(正反面图) + +相关文档 +^^^^^^^^^^^^^ + +* 《`ESP32-WROVER 技术规格书 `__》(PDF) +* 《`ESP32-WROVER-B 技术规格书 `__》(PDF) +* 《`ESP-PSRAM64 & ESP-PSRAM64H 技术规格书 `__》(PDF) +* `ESP32-WROVER 参考设计 `_ 包含原理图(由 OrCAD Capture 绘制)、PCB 布局(由 Mentor PADS 绘制)、GERBER 文件和 BOM 清单。 + +ESP32-PICO-D4 模组 +------------------ + +ESP32-PICO-D4 模组是一款 SiP 模组,无缝集成了所有外设,包括: + +- 4 MB flash +- 晶振 +- 滤波电容 +- RF 匹配电路 + +有关该模组的详细信息,请查看 `乐鑫产品订购信息`_。 + +相关文档 +^^^^^^^^^^^^^ + +* 《`ESP32-PICO-D4 技术规格书 `__》(PDF) + +ESP32 开发板 +================== + +ESP32 系列开发板功能各异,具体有以下不同点: + +- 访问的 ESP32 GPIO 管脚不同; +- 接口不同,包括 USB 和 JTAG; +- 外设不同,包括 TouchPad、LCD 显示屏、SD 卡槽和相机模组排母等。 + +.. _esp-modules-and-boards-esp32-pico-kit: + +ESP32-PICO-KIT V4.1 开发板 +--------------------------- +ESP32-PICO-KIT V4.1 开发板是基于 ESP32 的最小开发板,内置连接至电脑 USB 端口所需的所有组件,同时设有排针,可直接将此开发板插接于迷你面包板。 + +ESP32-PICO-KIT V4.1 开发板集成了 `ESP32-PICO-D4 模组`_,只需在 PCB (20 x 52 mm) 上添加少许外部组件即可构成一个功能齐全的开发板。这部分外部组件包括天线、LDO、USB 至 UART 桥接器、一个重置按钮和一个固件下载模式激活按钮。 + + +.. figure:: https://dl.espressif.com/dl/schematics/pictures/esp32-pico-kit-v4.1.jpg + :align: center + :alt: ESP32-PICO-KIT V4.1 board + :width: 50% + + ESP32-PICO-KIT V4.1 开发板 + +与 ESP32-PICO-KIT V4 相比,ESP32-PICO-KIT V4.1 开发板支持 CP2102N USB 至 UART 桥接器,可提供高达 3 Mbps 的传输速率。 + +相关文档 +^^^^^^^^^^^^^ + +* :doc:`../hw-reference/get-started-pico-kit` +* `ESP32-PICO-KIT V4.1 原理图 `_ (PDF) +* `ESP32-PICO-KIT 参考设计 `_,包含原理图(由 OrCAD Capture 绘制)、PCB 布局(由 Mentor PADS 绘制)、GERBER 文件和 BOM 清单。 +* 《`ESP32-PICO-D4 技术规格书 `_》(PDF) + +较早版本开发板 +^^^^^^^^^^^^^^^^^ + +* :ref:`esp-modules-and-boards-esp32-pico-kit-v4` +* :ref:`esp-modules-and-boards-esp32-pico-kit-v3` + + +.. _esp-modules-and-boards-esp32-devkitc: + +ESP32 DevKitC V4 开发板 +------------------------------ + +ESP32 DevKitC V4 开发板是一款小巧实用的开发板,具备以下特色功能: + +- 集成了 :ref:`esp-modules-and-boards-esp32-wroom-32` +- USB 转串口编程接口同时可为开发板供电 +- 设有排针 +- 设有重置按钮和固件下载模式激活按钮 +- 以及其他组件 + +与较早版本的 :ref:`esp-modules-and-boards-esp32-devkitc-v2` 相比,ESP32 DevKitC V4 开发板集成了 :ref:`esp-modules-and-boards-esp32-wrover` (而非 ESP32-WROOM-32 模组),同时内置 CP2102N 芯片,支持更高波特率。 + +.. figure:: https://dl.espressif.com/dl/schematics/pictures/esp32-devkitc-v4-front.jpg + :align: center + :alt: ESP32 DevKitC V4 board + :width: 50% + + ESP32 DevKitC V4 开发板 + +相关文档 +^^^^^^^^^^^^^ + +* :doc:`../hw-reference/get-started-devkitc` +* `ESP32-DevKitC 原理图 `_ (PDF) +* `ESP32-DevKitC 参考设计 `_,包含原理图(由 OrCAD Capture 绘制)、PCB 布局(由 Mentor PADS 绘制)、GERBER 文件和 BOM 清单。 +* `CP210x USB 至 UART 桥 VCP 驱动器 `_ + +较早版本开发板 +^^^^^^^^^^^^^^^^^ + +* :ref:`esp-modules-and-boards-esp32-devkitc-v2` + + +.. _esp-modules-and-boards-esp-wrover-kit: + +ESP-WROVER-KIT V4.1 开发板 +------------------------------- + +ESP-WROVER-KIT V4.1 开发板具备以下特色功能: + +- USB 转双串口转换器(用于后续编程) +- JTAG 调试接口 +- MicroSD 卡槽 +- 3.2” SPI LCD 显示屏 +- 相机模组排母 +- RGB 发光二极管 +- 支持 32.768 kHz 晶振输入用于 RTC 及低功耗模式操作 + +ESP-WROVER-KIT V4.1 开发板支持 USB 供电或标准的 5 毫米电源插座供电,可使用跳线选择电源,或使用独立的开关控制电源。 + +ESP-WROVER-KIT V4.1 开发板集成了 ESP-WROVER-B 模组,该模组集成了 8 MB PSRAM,方便用户灵活扩展存储空间,增强数据处理能力。ESP-WROVER-KIT V4.1 开发板还可以集成 :ref:`esp-wroom-solo-wrover-modules` 中所述的 ESP 其他版本模组。 + +与 :ref:`esp-modules-and-boards-esp-wrover-kit-v3` 相比,ESP-WROVER-KIT V4.1 开发板在设计上有以下改动: + +- JP8、JP11 和 JP13 合并成了一个 JP2。 +- USB 连接器的固定脚改为直插式,并移至板子右下角。 +- R61 已变更为零欧姆电阻。 +- 基于测试结果和采购选择,部分组件已由功能对等组件替代,例如 EN 和 Boot 按钮。 + +.. figure:: https://dl.espressif.com/dl/schematics/pictures/esp-wrover-kit-v4.1-front.jpg + :align: center + :alt: ESP-WROVER-KIT V4.1 board + :width: 90% + + ESP-WROVER-KIT V4.1 开发板 + +上图所示开发板集成了 ESP32-WROVER-B 模组。 + +相关文档 +^^^^^^^^^^^^^ + +* :doc:`../hw-reference/get-started-wrover-kit` +* `ESP-WROVER-KIT V4.1 原理图 `__ (PDF) +* :doc:`../api-guides/jtag-debugging/index` +* `FTDI 虚拟 COM 端口驱动`_ + +较早版本开发板 +^^^^^^^^^^^^^^^^^ + +* :ref:`esp-modules-and-boards-esp-wrover-kit-v3` +* :ref:`esp-modules-and-boards-esp-wrover-kit-v2` +* :ref:`esp-modules-and-boards-esp-wrover-kit-v1` + + +相关文档 +================= + +* :doc:`modules-and-boards-previous` + + +.. _FTDI 虚拟 COM 端口驱动: http://www.ftdichip.com/Drivers/VCP.htm +.. _乐鑫产品订购信息: https://www.espressif.com/sites/default/files/documentation/espressif_products_ordering_information_cn.pdf From 3753283ef31f60d6142957ec00e08c1a221fe06f Mon Sep 17 00:00:00 2001 From: suda-morris <362953310@qq.com> Date: Thu, 1 Aug 2019 10:40:10 +0800 Subject: [PATCH 32/36] idf_tool: fix unicode decode error Closes https://github.com/espressif/esp-idf/issues/3841 --- tools/idf_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/idf_tools.py b/tools/idf_tools.py index 9ad9f019d..3d2341237 100755 --- a/tools/idf_tools.py +++ b/tools/idf_tools.py @@ -442,7 +442,7 @@ class IDFTool(object): raise ToolExecError('Command {} has returned non-zero exit code ({})\n'.format( ' '.join(self._current_options.version_cmd), e.returncode)) - in_str = version_cmd_result.decode() + in_str = version_cmd_result.decode("utf-8") match = re.search(self._current_options.version_regex, in_str) if not match: return UNKNOWN_VERSION From 1aaec808da079e5d5ad887e6973bbe3505456924 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Sat, 13 Apr 2019 12:15:28 +0100 Subject: [PATCH 33/36] Add DTLS support to libcoap using MbedTLS This update supports DTLS, TLS is a future TODO components/coap/CMakeLists.txt: components/coap/component.mk: Add in the new files that have to be built Replace libcoap/src/coap_notls.c with libcoap/src/coap_mbedtls.c components/coap/libcoap: Update the version to include the current version for supporting MbedTLS components/coap/port/coap_debug.c: components/coap/port/coap_mbedtls.c: components/coap/port/include/coap/coap_dtls.h: New port files for DTLS components/coap/port/include/coap_config_posix.h: Include building with MbedTLS examples/protocols/coap_client/README.md: examples/protocols/coap_client/main/CMakeLists.txt: examples/protocols/coap_client/main/Kconfig.projbuild: examples/protocols/coap_client/main/coap_client_example_main.c: examples/protocols/coap_client/main/component.mk: Update CoAP client to support DTLS examples/protocols/coap_client/main/coap_ca.pem examples/protocols/coap_client/main/coap_client.crt examples/protocols/coap_client/main/coap_client.key New PKI Certs for CoAP client (copied from wpa2_enterprise example) examples/protocols/coap_server/README.md: examples/protocols/coap_server/main/CMakeLists.txt: examples/protocols/coap_server/main/Kconfig.projbuild: examples/protocols/coap_server/main/coap_server_example_main.c: examples/protocols/coap_server/main/component.mk: Update CoAP server to support DTLS Change "no data" to "Hello World!" to prevent confusion examples/protocols/coap_server/main/coap_ca.pem examples/protocols/coap_server/main/coap_server.crt examples/protocols/coap_server/main/coap_server.key New PKI Certs for CoAP server (copied from wpa2_enterprise example) Closes https://github.com/espressif/esp-idf/pull/3345 Closes https://github.com/espressif/esp-idf/issues/1379 --- components/coap/CMakeLists.txt | 8 +- components/coap/component.mk | 4 +- components/coap/libcoap | 2 +- components/coap/port/coap_debug.c | 888 ++++++++ components/coap/port/coap_io.c | 1417 ------------- components/coap/port/coap_mbedtls.c | 1796 +++++++++++++++++ components/coap/port/include/coap/coap_dtls.h | 631 ++++++ .../coap/port/include/coap_config_posix.h | 11 +- components/mbedtls/CMakeLists.txt | 3 +- components/mbedtls/port/esp_timing.c | 102 + examples/protocols/coap_client/README.md | 54 +- .../protocols/coap_client/main/CMakeLists.txt | 4 +- .../coap_client/main/Kconfig.projbuild | 91 +- .../protocols/coap_client/main/coap_ca.pem | 23 + .../coap_client/main/coap_client.crt | 70 + .../coap_client/main/coap_client.key | 27 + .../main/coap_client_example_main.c | 226 ++- .../protocols/coap_client/main/component.mk | 5 + examples/protocols/coap_server/README.md | 52 +- .../protocols/coap_server/main/CMakeLists.txt | 3 +- .../coap_server/main/Kconfig.projbuild | 74 + .../protocols/coap_server/main/coap_ca.pem | 23 + .../coap_server/main/coap_server.crt | 70 + .../coap_server/main/coap_server.key | 27 + .../main/coap_server_example_main.c | 176 +- .../protocols/coap_server/main/component.mk | 5 + 26 files changed, 4292 insertions(+), 1500 deletions(-) create mode 100644 components/coap/port/coap_debug.c delete mode 100644 components/coap/port/coap_io.c create mode 100644 components/coap/port/coap_mbedtls.c create mode 100644 components/coap/port/include/coap/coap_dtls.h create mode 100644 components/mbedtls/port/esp_timing.c create mode 100644 examples/protocols/coap_client/main/coap_ca.pem create mode 100644 examples/protocols/coap_client/main/coap_client.crt create mode 100644 examples/protocols/coap_client/main/coap_client.key create mode 100644 examples/protocols/coap_server/main/Kconfig.projbuild create mode 100644 examples/protocols/coap_server/main/coap_ca.pem create mode 100644 examples/protocols/coap_server/main/coap_server.crt create mode 100644 examples/protocols/coap_server/main/coap_server.key diff --git a/components/coap/CMakeLists.txt b/components/coap/CMakeLists.txt index aef9d3168..6d7dbb451 100644 --- a/components/coap/CMakeLists.txt +++ b/components/coap/CMakeLists.txt @@ -8,7 +8,7 @@ set(srcs "libcoap/src/coap_hashkey.c" "libcoap/src/coap_session.c" "libcoap/src/coap_time.c" - "libcoap/src/coap_debug.c" + "port/coap_debug.c" "libcoap/src/encode.c" "libcoap/src/mem.c" "libcoap/src/net.c" @@ -18,8 +18,8 @@ set(srcs "libcoap/src/str.c" "libcoap/src/subscribe.c" "libcoap/src/uri.c" - "libcoap/src/coap_notls.c" - "port/coap_io.c") + "libcoap/src/coap_io.c" + "port/coap_mbedtls.c") set(COMPONENT_REQUIRES lwip) @@ -28,7 +28,7 @@ idf_component_register(SRCS "${srcs}" REQUIRES lwip) # Silence format truncation warning, until it is fixed upstream -set_source_files_properties(libcoap/src/coap_debug.c PROPERTIES COMPILE_FLAGS -Wno-format-truncation) +set_source_files_properties(port/coap_debug.c PROPERTIES COMPILE_FLAGS -Wno-format-truncation) # Needed for coap headers in public builds, also. # diff --git a/components/coap/component.mk b/components/coap/component.mk index 2eb07afd2..46f703987 100644 --- a/components/coap/component.mk +++ b/components/coap/component.mk @@ -4,11 +4,11 @@ COMPONENT_ADD_INCLUDEDIRS := port/include port/include/coap libcoap/include libcoap/include/coap2 -COMPONENT_OBJS = libcoap/src/address.o libcoap/src/async.o libcoap/src/block.o libcoap/src/coap_event.o libcoap/src/coap_hashkey.o libcoap/src/coap_session.o libcoap/src/coap_time.o libcoap/src/coap_debug.o libcoap/src/encode.o libcoap/src/mem.o libcoap/src/net.o libcoap/src/option.o libcoap/src/pdu.o libcoap/src/resource.o libcoap/src/str.o libcoap/src/subscribe.o libcoap/src/uri.o libcoap/src/coap_notls.o port/coap_io.o +COMPONENT_OBJS = libcoap/src/address.o libcoap/src/async.o libcoap/src/block.o libcoap/src/coap_event.o libcoap/src/coap_hashkey.o libcoap/src/coap_session.o libcoap/src/coap_time.o port/coap_debug.o libcoap/src/encode.o libcoap/src/mem.o libcoap/src/net.o libcoap/src/option.o libcoap/src/pdu.o libcoap/src/resource.o libcoap/src/str.o libcoap/src/subscribe.o libcoap/src/uri.o port/coap_mbedtls.o libcoap/src/coap_io.o COMPONENT_SRCDIRS := libcoap/src libcoap port COMPONENT_SUBMODULES += libcoap # Silence format truncation warning, until it is fixed upstream -libcoap/src/coap_debug.o: CFLAGS += -Wno-format-truncation +port/coap_debug.o: CFLAGS += -Wno-format-truncation diff --git a/components/coap/libcoap b/components/coap/libcoap index cfec0d072..98954eb30 160000 --- a/components/coap/libcoap +++ b/components/coap/libcoap @@ -1 +1 @@ -Subproject commit cfec0d072c5b99ed3e54828ca50ea2f6b91e1f50 +Subproject commit 98954eb30a2e728e172a6cd29430ae5bc999b585 diff --git a/components/coap/port/coap_debug.c b/components/coap/port/coap_debug.c new file mode 100644 index 000000000..64d6a0180 --- /dev/null +++ b/components/coap/port/coap_debug.c @@ -0,0 +1,888 @@ +/* debug.c -- debug utilities + * + * Copyright (C) 2010--2012,2014--2019 Olaf Bergmann and others + * + * This file is part of the CoAP library libcoap. Please see + * README for terms of use. + */ + +#include "coap_config.h" + +#if defined(HAVE_STRNLEN) && defined(__GNUC__) && !defined(_GNU_SOURCE) +#define _GNU_SOURCE 1 +#endif + +#if defined(HAVE_ASSERT_H) && !defined(assert) +# include +#endif + +#include +#include +#include +#include + +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_WS2TCPIP_H +#include +#endif + +#ifdef HAVE_TIME_H +#include +#endif + +#include "libcoap.h" +#include "coap_dtls.h" +#include "block.h" +#include "coap_debug.h" +#include "encode.h" +#include "net.h" +#include "coap_mutex.h" + +#ifdef WITH_LWIP +# define fprintf(fd, ...) LWIP_PLATFORM_DIAG((__VA_ARGS__)) +# define fflush(...) +#endif + +#ifdef WITH_CONTIKI +# ifndef DEBUG +# define DEBUG DEBUG_PRINT +# endif /* DEBUG */ +#include "net/ip/uip-debug.h" +#endif + +static coap_log_t maxlog = LOG_WARNING; /* default maximum log level */ + +static int use_fprintf_for_show_pdu = 1; /* non zero to output with fprintf */ + +const char *coap_package_name(void) { + return PACKAGE_NAME; +} + +const char *coap_package_version(void) { + return PACKAGE_STRING; +} + +void +coap_set_show_pdu_output(int use_fprintf) { + use_fprintf_for_show_pdu = use_fprintf; +} + +coap_log_t +coap_get_log_level(void) { + return maxlog; +} + +void +coap_set_log_level(coap_log_t level) { + maxlog = level; +} + +/* this array has the same order as the type log_t */ +static const char *loglevels[] = { + "EMRG", "ALRT", "CRIT", "ERR ", "WARN", "NOTE", "INFO", "DEBG" +}; + +#ifdef HAVE_TIME_H + +COAP_STATIC_INLINE size_t +print_timestamp(char *s, size_t len, coap_tick_t t) { + struct tm *tmp; + time_t now = coap_ticks_to_rt(t); + tmp = localtime(&now); + return strftime(s, len, "%b %d %H:%M:%S", tmp); +} + +#else /* alternative implementation: just print the timestamp */ + +COAP_STATIC_INLINE size_t +print_timestamp(char *s, size_t len, coap_tick_t t) { +#ifdef HAVE_SNPRINTF + return snprintf(s, len, "%u.%03u", + (unsigned int)coap_ticks_to_rt(t), + (unsigned int)(t % COAP_TICKS_PER_SECOND)); +#else /* HAVE_SNPRINTF */ + /* @todo do manual conversion of timestamp */ + return 0; +#endif /* HAVE_SNPRINTF */ +} + +#endif /* HAVE_TIME_H */ + +#ifndef HAVE_STRNLEN +/** + * A length-safe strlen() fake. + * + * @param s The string to count characters != 0. + * @param maxlen The maximum length of @p s. + * + * @return The length of @p s. + */ +static inline size_t +strnlen(const char *s, size_t maxlen) { + size_t n = 0; + while(*s++ && n < maxlen) + ++n; + return n; +} +#endif /* HAVE_STRNLEN */ + +static size_t +print_readable( const uint8_t *data, size_t len, + unsigned char *result, size_t buflen, int encode_always ) { + const uint8_t hex[] = "0123456789ABCDEF"; + size_t cnt = 0; + assert(data || len == 0); + + if (buflen == 0) { /* there is nothing we can do here but return */ + return 0; + } + + while (len) { + if (!encode_always && isprint(*data)) { + if (cnt+1 < buflen) { /* keep one byte for terminating zero */ + *result++ = *data; + ++cnt; + } else { + break; + } + } else { + if (cnt+4 < buflen) { /* keep one byte for terminating zero */ + *result++ = '\\'; + *result++ = 'x'; + *result++ = hex[(*data & 0xf0) >> 4]; + *result++ = hex[*data & 0x0f]; + cnt += 4; + } else + break; + } + + ++data; --len; + } + + *result = '\0'; /* add a terminating zero */ + return cnt; +} + +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif + +size_t +coap_print_addr(const struct coap_address_t *addr, unsigned char *buf, size_t len) { +#if defined( HAVE_ARPA_INET_H ) || defined( HAVE_WS2TCPIP_H ) + const void *addrptr = NULL; + in_port_t port; + unsigned char *p = buf; + size_t need_buf; + + switch (addr->addr.sa.sa_family) { + case AF_INET: + addrptr = &addr->addr.sin.sin_addr; + port = ntohs(addr->addr.sin.sin_port); + need_buf = INET_ADDRSTRLEN; + break; + case AF_INET6: + if (len < 7) /* do not proceed if buffer is even too short for [::]:0 */ + return 0; + + *p++ = '['; + + addrptr = &addr->addr.sin6.sin6_addr; + port = ntohs(addr->addr.sin6.sin6_port); + need_buf = INET6_ADDRSTRLEN; + + break; + default: + memcpy(buf, "(unknown address type)", min(22, len)); + return min(22, len); + } + + /* Cast needed for Windows, since it doesn't have the correct API signature. */ + if (inet_ntop(addr->addr.sa.sa_family, addrptr, (char *)p, + min(len, need_buf)) == 0) { + perror("coap_print_addr"); + return 0; + } + + p += strnlen((char *)p, len); + + if (addr->addr.sa.sa_family == AF_INET6) { + if (p < buf + len) { + *p++ = ']'; + } else + return 0; + } + + p += snprintf((char *)p, buf + len - p + 1, ":%d", port); + + return buf + len - p; +#else /* HAVE_ARPA_INET_H */ +# if WITH_CONTIKI + unsigned char *p = buf; + uint8_t i; +# if NETSTACK_CONF_WITH_IPV6 + const uint8_t hex[] = "0123456789ABCDEF"; + + if (len < 41) + return 0; + + *p++ = '['; + + for (i=0; i < 16; i += 2) { + if (i) { + *p++ = ':'; + } + *p++ = hex[(addr->addr.u8[i] & 0xf0) >> 4]; + *p++ = hex[(addr->addr.u8[i] & 0x0f)]; + *p++ = hex[(addr->addr.u8[i+1] & 0xf0) >> 4]; + *p++ = hex[(addr->addr.u8[i+1] & 0x0f)]; + } + *p++ = ']'; +# else /* WITH_UIP6 */ +# warning "IPv4 network addresses will not be included in debug output" + + if (len < 21) + return 0; +# endif /* WITH_UIP6 */ + if (buf + len - p < 6) + return 0; + +#ifdef HAVE_SNPRINTF + p += snprintf((char *)p, buf + len - p + 1, ":%d", uip_htons(addr->port)); +#else /* HAVE_SNPRINTF */ + /* @todo manual conversion of port number */ +#endif /* HAVE_SNPRINTF */ + + return p - buf; +# else /* WITH_CONTIKI */ + /* TODO: output addresses manually */ +# warning "inet_ntop() not available, network addresses will not be included in debug output" +# endif /* WITH_CONTIKI */ + return 0; +#endif +} + +#ifdef WITH_CONTIKI +# define fprintf(fd, ...) PRINTF(__VA_ARGS__) +# define fflush(...) + +# ifdef HAVE_VPRINTF +# define vfprintf(fd, ...) vprintf(__VA_ARGS__) +# else /* HAVE_VPRINTF */ +# define vfprintf(fd, ...) PRINTF(__VA_ARGS__) +# endif /* HAVE_VPRINTF */ +#endif /* WITH_CONTIKI */ + +/** Returns a textual description of the message type @p t. */ +static const char * +msg_type_string(uint16_t t) { + static const char *types[] = { "CON", "NON", "ACK", "RST", "???" }; + + return types[min(t, sizeof(types)/sizeof(char *) - 1)]; +} + +/** Returns a textual description of the method or response code. */ +static const char * +msg_code_string(uint16_t c) { + static const char *methods[] = { "0.00", "GET", "POST", "PUT", "DELETE", + "FETCH", "PATCH", "iPATCH" }; + static const char *signals[] = { "7.00", "CSM", "Ping", "Pong", "Release", + "Abort" }; + static char buf[5]; + + if (c < sizeof(methods)/sizeof(const char *)) { + return methods[c]; + } else if (c >= 224 && c - 224 < (int)(sizeof(signals)/sizeof(const char *))) { + return signals[c-224]; + } else { + snprintf(buf, sizeof(buf), "%u.%02u", (c >> 5) & 0x7, c & 0x1f); + return buf; + } +} + +/** Returns a textual description of the option name. */ +static const char * +msg_option_string(uint8_t code, uint16_t option_type) { + struct option_desc_t { + uint16_t type; + const char *name; + }; + + static struct option_desc_t options[] = { + { COAP_OPTION_IF_MATCH, "If-Match" }, + { COAP_OPTION_URI_HOST, "Uri-Host" }, + { COAP_OPTION_ETAG, "ETag" }, + { COAP_OPTION_IF_NONE_MATCH, "If-None-Match" }, + { COAP_OPTION_OBSERVE, "Observe" }, + { COAP_OPTION_URI_PORT, "Uri-Port" }, + { COAP_OPTION_LOCATION_PATH, "Location-Path" }, + { COAP_OPTION_URI_PATH, "Uri-Path" }, + { COAP_OPTION_CONTENT_FORMAT, "Content-Format" }, + { COAP_OPTION_MAXAGE, "Max-Age" }, + { COAP_OPTION_URI_QUERY, "Uri-Query" }, + { COAP_OPTION_ACCEPT, "Accept" }, + { COAP_OPTION_LOCATION_QUERY, "Location-Query" }, + { COAP_OPTION_BLOCK2, "Block2" }, + { COAP_OPTION_BLOCK1, "Block1" }, + { COAP_OPTION_PROXY_URI, "Proxy-Uri" }, + { COAP_OPTION_PROXY_SCHEME, "Proxy-Scheme" }, + { COAP_OPTION_SIZE1, "Size1" }, + { COAP_OPTION_SIZE2, "Size2" }, + { COAP_OPTION_NORESPONSE, "No-Response" } + }; + + static struct option_desc_t options_csm[] = { + { COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE, "Max-Message-Size" }, + { COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER, "Block-wise-Transfer" } + }; + + static struct option_desc_t options_pingpong[] = { + { COAP_SIGNALING_OPTION_CUSTODY, "Custody" } + }; + + static struct option_desc_t options_release[] = { + { COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS, "Alternative-Address" }, + { COAP_SIGNALING_OPTION_HOLD_OFF, "Hold-Off" } + }; + + static struct option_desc_t options_abort[] = { + { COAP_SIGNALING_OPTION_BAD_CSM_OPTION, "Bad-CSM-Option" } + }; + + static char buf[6]; + size_t i; + + if (code == COAP_SIGNALING_CSM) { + for (i = 0; i < sizeof(options_csm)/sizeof(struct option_desc_t); i++) { + if (option_type == options_csm[i].type) { + return options_csm[i].name; + } + } + } else if (code == COAP_SIGNALING_PING || code == COAP_SIGNALING_PONG) { + for (i = 0; i < sizeof(options_pingpong)/sizeof(struct option_desc_t); i++) { + if (option_type == options_pingpong[i].type) { + return options_pingpong[i].name; + } + } + } else if (code == COAP_SIGNALING_RELEASE) { + for (i = 0; i < sizeof(options_release)/sizeof(struct option_desc_t); i++) { + if (option_type == options_release[i].type) { + return options_release[i].name; + } + } + } else if (code == COAP_SIGNALING_ABORT) { + for (i = 0; i < sizeof(options_abort)/sizeof(struct option_desc_t); i++) { + if (option_type == options_abort[i].type) { + return options_abort[i].name; + } + } + } else { + /* search option_type in list of known options */ + for (i = 0; i < sizeof(options)/sizeof(struct option_desc_t); i++) { + if (option_type == options[i].type) { + return options[i].name; + } + } + } + /* unknown option type, just print to buf */ + snprintf(buf, sizeof(buf), "%u", option_type); + return buf; +} + +static unsigned int +print_content_format(unsigned int format_type, + unsigned char *result, unsigned int buflen) { + struct desc_t { + unsigned int type; + const char *name; + }; + + static struct desc_t formats[] = { + { COAP_MEDIATYPE_TEXT_PLAIN, "text/plain" }, + { COAP_MEDIATYPE_APPLICATION_LINK_FORMAT, "application/link-format" }, + { COAP_MEDIATYPE_APPLICATION_XML, "application/xml" }, + { COAP_MEDIATYPE_APPLICATION_OCTET_STREAM, "application/octet-stream" }, + { COAP_MEDIATYPE_APPLICATION_EXI, "application/exi" }, + { COAP_MEDIATYPE_APPLICATION_JSON, "application/json" }, + { COAP_MEDIATYPE_APPLICATION_CBOR, "application/cbor" }, + { COAP_MEDIATYPE_APPLICATION_COSE_SIGN, "application/cose; cose-type=\"cose-sign\"" }, + { COAP_MEDIATYPE_APPLICATION_COSE_SIGN1, "application/cose; cose-type=\"cose-sign1\"" }, + { COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT, "application/cose; cose-type=\"cose-encrypt\"" }, + { COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0, "application/cose; cose-type=\"cose-encrypt0\"" }, + { COAP_MEDIATYPE_APPLICATION_COSE_MAC, "application/cose; cose-type=\"cose-mac\"" }, + { COAP_MEDIATYPE_APPLICATION_COSE_MAC0, "application/cose; cose-type=\"cose-mac0\"" }, + { COAP_MEDIATYPE_APPLICATION_COSE_KEY, "application/cose-key" }, + { COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET, "application/cose-key-set" }, + { COAP_MEDIATYPE_APPLICATION_SENML_JSON, "application/senml+json" }, + { COAP_MEDIATYPE_APPLICATION_SENSML_JSON, "application/sensml+json" }, + { COAP_MEDIATYPE_APPLICATION_SENML_CBOR, "application/senml+cbor" }, + { COAP_MEDIATYPE_APPLICATION_SENSML_CBOR, "application/sensml+cbor" }, + { COAP_MEDIATYPE_APPLICATION_SENML_EXI, "application/senml-exi" }, + { COAP_MEDIATYPE_APPLICATION_SENSML_EXI, "application/sensml-exi" }, + { COAP_MEDIATYPE_APPLICATION_SENML_XML, "application/senml+xml" }, + { COAP_MEDIATYPE_APPLICATION_SENSML_XML, "application/sensml+xml" }, + { 75, "application/dcaf+cbor" } + }; + + size_t i; + + /* search format_type in list of known content formats */ + for (i = 0; i < sizeof(formats)/sizeof(struct desc_t); i++) { + if (format_type == formats[i].type) { + return snprintf((char *)result, buflen, "%s", formats[i].name); + } + } + + /* unknown content format, just print numeric value to buf */ + return snprintf((char *)result, buflen, "%d", format_type); +} + +/** + * Returns 1 if the given @p content_format is either unknown or known + * to carry binary data. The return value @c 0 hence indicates + * printable data which is also assumed if @p content_format is @c 01. + */ +COAP_STATIC_INLINE int +is_binary(int content_format) { + return !(content_format == -1 || + content_format == COAP_MEDIATYPE_TEXT_PLAIN || + content_format == COAP_MEDIATYPE_APPLICATION_LINK_FORMAT || + content_format == COAP_MEDIATYPE_APPLICATION_XML || + content_format == COAP_MEDIATYPE_APPLICATION_JSON); +} + +#define COAP_DO_SHOW_OUTPUT_LINE \ + do { \ + if (use_fprintf_for_show_pdu) { \ + fprintf(COAP_DEBUG_FD, "%s", outbuf); \ + } \ + else { \ + coap_log(level, "%s", outbuf); \ + } \ + } while (0) + +void +coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu) { +#if COAP_CONSTRAINED_STACK + static coap_mutex_t static_show_pdu_mutex = COAP_MUTEX_INITIALIZER; + static unsigned char buf[1024]; /* need some space for output creation */ + static char outbuf[COAP_DEBUG_BUF_SIZE]; +#else /* ! COAP_CONSTRAINED_STACK */ + unsigned char buf[1024]; /* need some space for output creation */ + char outbuf[COAP_DEBUG_BUF_SIZE]; +#endif /* ! COAP_CONSTRAINED_STACK */ + size_t buf_len = 0; /* takes the number of bytes written to buf */ + int encode = 0, have_options = 0, i; + coap_opt_iterator_t opt_iter; + coap_opt_t *option; + int content_format = -1; + size_t data_len; + unsigned char *data; + int outbuflen = 0; + + /* Save time if not needed */ + if (level > coap_get_log_level()) + return; + +#if COAP_CONSTRAINED_STACK + coap_mutex_lock(&static_show_pdu_mutex); +#endif /* COAP_CONSTRAINED_STACK */ + + snprintf(outbuf, sizeof(outbuf), "v:%d t:%s c:%s i:%04x {", + COAP_DEFAULT_VERSION, msg_type_string(pdu->type), + msg_code_string(pdu->code), pdu->tid); + + for (i = 0; i < pdu->token_length; i++) { + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, + "%02x", pdu->token[i]); + } + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, "}"); + + /* show options, if any */ + coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL); + + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, " ["); + while ((option = coap_option_next(&opt_iter))) { + if (!have_options) { + have_options = 1; + } else { + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, ","); + } + + if (pdu->code == COAP_SIGNALING_CSM) switch(opt_iter.type) { + case COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE: + buf_len = snprintf((char *)buf, sizeof(buf), "%u", + coap_decode_var_bytes(coap_opt_value(option), + coap_opt_length(option))); + break; + default: + buf_len = 0; + break; + } else if (pdu->code == COAP_SIGNALING_PING + || pdu->code == COAP_SIGNALING_PONG) { + buf_len = 0; + } else if (pdu->code == COAP_SIGNALING_RELEASE) switch(opt_iter.type) { + case COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS: + buf_len = print_readable(coap_opt_value(option), + coap_opt_length(option), + buf, sizeof(buf), 0); + break; + case COAP_SIGNALING_OPTION_HOLD_OFF: + buf_len = snprintf((char *)buf, sizeof(buf), "%u", + coap_decode_var_bytes(coap_opt_value(option), + coap_opt_length(option))); + break; + default: + buf_len = 0; + break; + } else if (pdu->code == COAP_SIGNALING_ABORT) switch(opt_iter.type) { + case COAP_SIGNALING_OPTION_BAD_CSM_OPTION: + buf_len = snprintf((char *)buf, sizeof(buf), "%u", + coap_decode_var_bytes(coap_opt_value(option), + coap_opt_length(option))); + break; + default: + buf_len = 0; + break; + } else switch (opt_iter.type) { + case COAP_OPTION_CONTENT_FORMAT: + content_format = (int)coap_decode_var_bytes(coap_opt_value(option), + coap_opt_length(option)); + + buf_len = print_content_format(content_format, buf, sizeof(buf)); + break; + + case COAP_OPTION_BLOCK1: + case COAP_OPTION_BLOCK2: + /* split block option into number/more/size where more is the + * letter M if set, the _ otherwise */ + buf_len = snprintf((char *)buf, sizeof(buf), "%u/%c/%u", + coap_opt_block_num(option), /* block number */ + COAP_OPT_BLOCK_MORE(option) ? 'M' : '_', /* M bit */ + (1 << (COAP_OPT_BLOCK_SZX(option) + 4))); /* block size */ + + break; + + case COAP_OPTION_URI_PORT: + case COAP_OPTION_MAXAGE: + case COAP_OPTION_OBSERVE: + case COAP_OPTION_SIZE1: + case COAP_OPTION_SIZE2: + /* show values as unsigned decimal value */ + buf_len = snprintf((char *)buf, sizeof(buf), "%u", + coap_decode_var_bytes(coap_opt_value(option), + coap_opt_length(option))); + break; + + default: + /* generic output function for all other option types */ + if (opt_iter.type == COAP_OPTION_URI_PATH || + opt_iter.type == COAP_OPTION_PROXY_URI || + opt_iter.type == COAP_OPTION_URI_HOST || + opt_iter.type == COAP_OPTION_LOCATION_PATH || + opt_iter.type == COAP_OPTION_LOCATION_QUERY || + opt_iter.type == COAP_OPTION_URI_QUERY) { + encode = 0; + } else { + encode = 1; + } + + buf_len = print_readable(coap_opt_value(option), + coap_opt_length(option), + buf, sizeof(buf), encode); + } + + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, + " %s:%.*s", msg_option_string(pdu->code, opt_iter.type), + (int)buf_len, buf); + } + + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, " ]"); + + if (coap_get_data(pdu, &data_len, &data)) { + + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, " :: "); + + if (is_binary(content_format)) { + int keep_data_len = data_len; + uint8_t *keep_data = data; + + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, + "binary data length %zu\n", data_len); + COAP_DO_SHOW_OUTPUT_LINE; + /* + * Output hex dump of binary data as a continuous entry + */ + outbuf[0] = '\000'; + snprintf(outbuf, sizeof(outbuf), "<<"); + while (data_len--) { + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, + "%02x", *data++); + } + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, ">>"); + data_len = keep_data_len; + data = keep_data; + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, "\n"); + COAP_DO_SHOW_OUTPUT_LINE; + /* + * Output ascii readable (if possible), immediately under the + * hex value of the character output above to help binary debugging + */ + outbuf[0] = '\000'; + snprintf(outbuf, sizeof(outbuf), "<<"); + while (data_len--) { + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, + "%c ", isprint (*data) ? *data : '.'); + data++; + } + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, ">>"); + } else { + if (print_readable(data, data_len, buf, sizeof(buf), 0)) { + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, "'%s'", buf); + } + } + } + + outbuflen = strlen(outbuf); + snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, "\n"); + COAP_DO_SHOW_OUTPUT_LINE; + +#if COAP_CONSTRAINED_STACK + coap_mutex_unlock(&static_show_pdu_mutex); +#endif /* COAP_CONSTRAINED_STACK */ +} + +void coap_show_tls_version(coap_log_t level) +{ + char buffer[64]; + coap_string_tls_version(buffer, sizeof(buffer)); + coap_log(level, "%s\n", buffer); +} + +char *coap_string_tls_version(char *buffer, size_t bufsize) +{ + coap_tls_version_t *tls_version = coap_get_tls_library_version(); + char beta[8]; + char sub[2]; + char b_beta[8]; + char b_sub[2]; + + switch (tls_version->type) { + case COAP_TLS_LIBRARY_NOTLS: + snprintf(buffer, bufsize, "TLS Library: None"); + break; + case COAP_TLS_LIBRARY_TINYDTLS: + snprintf(buffer, bufsize, "TLS Library: TinyDTLS - runtime %lu.%lu.%lu, " + "libcoap built for %lu.%lu.%lu", + (unsigned long)(tls_version->version >> 16), + (unsigned long)((tls_version->version >> 8) & 0xff), + (unsigned long)(tls_version->version & 0xff), + (unsigned long)(tls_version->built_version >> 16), + (unsigned long)((tls_version->built_version >> 8) & 0xff), + (unsigned long)(tls_version->built_version & 0xff)); + break; + case COAP_TLS_LIBRARY_OPENSSL: + switch (tls_version->version &0xf) { + case 0: + strcpy(beta, "-dev"); + break; + case 0xf: + strcpy(beta, ""); + break; + default: + strcpy(beta, "-beta"); + beta[5] = (tls_version->version &0xf) + '0'; + beta[6] = '\000'; + break; + } + sub[0] = ((tls_version->version >> 4) & 0xff) ? + ((tls_version->version >> 4) & 0xff) + 'a' -1 : '\000'; + sub[1] = '\000'; + switch (tls_version->built_version &0xf) { + case 0: + strcpy(b_beta, "-dev"); + break; + case 0xf: + strcpy(b_beta, ""); + break; + default: + strcpy(b_beta, "-beta"); + b_beta[5] = (tls_version->built_version &0xf) + '0'; + b_beta[6] = '\000'; + break; + } + b_sub[0] = ((tls_version->built_version >> 4) & 0xff) ? + ((tls_version->built_version >> 4) & 0xff) + 'a' -1 : '\000'; + b_sub[1] = '\000'; + snprintf(buffer, bufsize, "TLS Library: OpenSSL - runtime " + "%lu.%lu.%lu%s%s, libcoap built for %lu.%lu.%lu%s%s", + (unsigned long)(tls_version->version >> 28), + (unsigned long)((tls_version->version >> 20) & 0xff), + (unsigned long)((tls_version->version >> 12) & 0xff), sub, beta, + (unsigned long)(tls_version->built_version >> 28), + (unsigned long)((tls_version->built_version >> 20) & 0xff), + (unsigned long)((tls_version->built_version >> 12) & 0xff), + b_sub, b_beta); + break; + case COAP_TLS_LIBRARY_GNUTLS: + snprintf(buffer, bufsize, "TLS Library: GnuTLS - runtime %lu.%lu.%lu, " + "libcoap built for %lu.%lu.%lu", + (unsigned long)(tls_version->version >> 16), + (unsigned long)((tls_version->version >> 8) & 0xff), + (unsigned long)(tls_version->version & 0xff), + (unsigned long)(tls_version->built_version >> 16), + (unsigned long)((tls_version->built_version >> 8) & 0xff), + (unsigned long)(tls_version->built_version & 0xff)); + break; + case COAP_TLS_LIBRARY_MBEDTLS: + snprintf(buffer, bufsize, "TLS Library: MbedTLS - runtime %lu.%lu.%lu, " + "libcoap built for %lu.%lu.%lu", + (unsigned long)(tls_version->version >> 24), + (unsigned long)((tls_version->version >> 16) & 0xff), + (unsigned long)((tls_version->version >> 8) & 0xff), + (unsigned long)(tls_version->built_version >> 24), + (unsigned long)((tls_version->built_version >> 16) & 0xff), + (unsigned long)((tls_version->built_version >> 8) & 0xff)); + break; + default: + snprintf(buffer, bufsize, "Library type %d unknown", tls_version->type); + break; + } + return buffer; +} + +static coap_log_handler_t log_handler = NULL; + +void coap_set_log_handler(coap_log_handler_t handler) { + log_handler = handler; +} + +void +coap_log_impl(coap_log_t level, const char *format, ...) { + + if (maxlog < level) + return; + + if (log_handler) { +#if COAP_CONSTRAINED_STACK + static coap_mutex_t static_log_mutex = COAP_MUTEX_INITIALIZER; + static char message[COAP_DEBUG_BUF_SIZE]; +#else /* ! COAP_CONSTRAINED_STACK */ + char message[COAP_DEBUG_BUF_SIZE]; +#endif /* ! COAP_CONSTRAINED_STACK */ + va_list ap; + va_start(ap, format); +#if COAP_CONSTRAINED_STACK + coap_mutex_lock(&static_log_mutex); +#endif /* COAP_CONSTRAINED_STACK */ + + vsnprintf( message, sizeof(message), format, ap); + va_end(ap); + log_handler(level, message); +#if COAP_CONSTRAINED_STACK + coap_mutex_unlock(&static_log_mutex); +#endif /* COAP_CONSTRAINED_STACK */ + } else { + char timebuf[32]; + coap_tick_t now; + va_list ap; + FILE *log_fd; + + log_fd = level <= LOG_CRIT ? COAP_ERR_FD : COAP_DEBUG_FD; + + coap_ticks(&now); + if (print_timestamp(timebuf,sizeof(timebuf), now)) + fprintf(log_fd, "%s ", timebuf); + + if (level <= LOG_DEBUG) + fprintf(log_fd, "%s ", loglevels[level]); + + va_start(ap, format); + vfprintf(log_fd, format, ap); + va_end(ap); + fflush(log_fd); + } +} + +static struct packet_num_interval { + int start; + int end; +} packet_loss_intervals[10]; +static int num_packet_loss_intervals = 0; +static int packet_loss_level = 0; +static int send_packet_count = 0; + +int coap_debug_set_packet_loss(const char *loss_level) { + const char *p = loss_level; + char *end = NULL; + int n = (int)strtol(p, &end, 10), i = 0; + if (end == p || n < 0) + return 0; + if (*end == '%') { + if (n > 100) + n = 100; + packet_loss_level = n * 65536 / 100; + coap_log(LOG_DEBUG, "packet loss level set to %d%%\n", n); + } else { + if (n <= 0) + return 0; + while (i < 10) { + packet_loss_intervals[i].start = n; + if (*end == '-') { + p = end + 1; + n = (int)strtol(p, &end, 10); + if (end == p || n <= 0) + return 0; + } + packet_loss_intervals[i++].end = n; + if (*end == 0) + break; + if (*end != ',') + return 0; + p = end + 1; + n = (int)strtol(p, &end, 10); + if (end == p || n <= 0) + return 0; + } + if (i == 10) + return 0; + num_packet_loss_intervals = i; + } + send_packet_count = 0; + return 1; +} + +int coap_debug_send_packet(void) { + ++send_packet_count; + if (num_packet_loss_intervals > 0) { + int i; + for (i = 0; i < num_packet_loss_intervals; i++) { + if (send_packet_count >= packet_loss_intervals[i].start + && send_packet_count <= packet_loss_intervals[i].end) + return 0; + } + } + if ( packet_loss_level > 0 ) { + uint16_t r = 0; + prng( (uint8_t*)&r, 2 ); + if ( r < packet_loss_level ) + return 0; + } + return 1; +} diff --git a/components/coap/port/coap_io.c b/components/coap/port/coap_io.c deleted file mode 100644 index 00c0ad1d3..000000000 --- a/components/coap/port/coap_io.c +++ /dev/null @@ -1,1417 +0,0 @@ -/* coap_io.c -- Default network I/O functions for libcoap - * - * Copyright (C) 2012,2014,2016-2019 Olaf Bergmann and others - * - * This file is part of the CoAP library libcoap. Please see - * README for terms of use. - */ - -#include "coap_config.h" - -#ifdef HAVE_STDIO_H -# include -#endif - -#ifdef HAVE_SYS_SELECT_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -# define OPTVAL_T(t) (t) -# define OPTVAL_GT(t) (t) -#endif -#ifdef HAVE_SYS_IOCTL_H - #include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#ifdef HAVE_WS2TCPIP_H -#include -# define OPTVAL_T(t) (const char*)(t) -# define OPTVAL_GT(t) (char*)(t) -# undef CMSG_DATA -# define CMSG_DATA WSA_CMSG_DATA -#endif -#ifdef HAVE_SYS_UIO_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#include - -#ifdef WITH_CONTIKI -# include "uip.h" -#endif - -#include "libcoap.h" -#include "coap_debug.h" -#include "mem.h" -#include "net.h" -#include "coap_io.h" -#include "pdu.h" -#include "utlist.h" -#include "resource.h" - -#if !defined(WITH_CONTIKI) - /* define generic PKTINFO for IPv4 */ -#if defined(IP_PKTINFO) -# define GEN_IP_PKTINFO IP_PKTINFO -#elif defined(IP_RECVDSTADDR) -# define GEN_IP_PKTINFO IP_RECVDSTADDR -#else -# error "Need IP_PKTINFO or IP_RECVDSTADDR to request ancillary data from OS." -#endif /* IP_PKTINFO */ - -/* define generic KTINFO for IPv6 */ -#ifdef IPV6_RECVPKTINFO -# define GEN_IPV6_PKTINFO IPV6_RECVPKTINFO -#elif defined(IPV6_PKTINFO) -# define GEN_IPV6_PKTINFO IPV6_PKTINFO -#else -# error "Need IPV6_PKTINFO or IPV6_RECVPKTINFO to request ancillary data from OS." -#endif /* IPV6_RECVPKTINFO */ -#endif - -void coap_free_endpoint(coap_endpoint_t *ep); - -#ifdef WITH_CONTIKI -static int ep_initialized = 0; - -struct coap_endpoint_t * - coap_malloc_endpoint(void) { - static struct coap_endpoint_t ep; - - if (ep_initialized) { - return NULL; - } else { - ep_initialized = 1; - return &ep; - } -} - -void -coap_mfree_endpoint(struct coap_endpoint_t *ep) { - ep_initialized = 0; - coap_session_mfree(&ep->hello); -} - -int -coap_socket_bind_udp(coap_socket_t *sock, - const coap_address_t *listen_addr, - coap_address_t *bound_addr) { - sock->conn = udp_new(NULL, 0, NULL); - - if (!sock->conn) { - coap_log(LOG_WARNING, "coap_socket_bind_udp"); - return 0; - } - - coap_address_init(bound_addr); - uip_ipaddr_copy(&bound_addr->addr, &listen_addr->addr); - bound_addr->port = listen_addr->port; - udp_bind((struct uip_udp_conn *)sock->conn, bound_addr->port); - return 1; -} - -int -coap_socket_connect_udp(coap_socket_t *sock, - const coap_address_t *local_if, - const coap_address_t *server, - int default_port, - coap_address_t *local_addr, - coap_address_t *remote_addr) { - return 0; -} - -int -coap_socket_connect_tcp1(coap_socket_t *sock, - const coap_address_t *local_if, - const coap_address_t *server, - int default_port, - coap_address_t *local_addr, - coap_address_t *remote_addr) { - return 0; -} - -int -coap_socket_connect_tcp2(coap_socket_t *sock, - coap_address_t *local_addr, - coap_address_t *remote_addr) { - return 0; -} - -int -coap_socket_bind_tcp(coap_socket_t *sock, - const coap_address_t *listen_addr, - coap_address_t *bound_addr) { - return 0; -} - -int -coap_socket_accept_tcp(coap_socket_t *server, - coap_socket_t *new_client, - coap_address_t *local_addr, - coap_address_t *remote_addr) { - return 0; -} - -ssize_t -coap_socket_write(coap_socket_t *sock, const uint8_t *data, size_t data_len) { - return -1; -} - -ssize_t -coap_socket_read(coap_socket_t *sock, uint8_t *data, size_t data_len) { - return -1; -} - -void coap_socket_close(coap_socket_t *sock) { - if (sock->conn) - uip_udp_remove((struct uip_udp_conn *)sock->conn); - sock->flags = COAP_SOCKET_EMPTY; -} - -#else - -static const char *coap_socket_format_errno( int error ); - -struct coap_endpoint_t * - coap_malloc_endpoint(void) { - return (struct coap_endpoint_t *)coap_malloc_type(COAP_ENDPOINT, sizeof(struct coap_endpoint_t)); -} - -void -coap_mfree_endpoint(struct coap_endpoint_t *ep) { - coap_session_mfree(&ep->hello); - coap_free_type(COAP_ENDPOINT, ep); -} - -int -coap_socket_bind_udp(coap_socket_t *sock, - const coap_address_t *listen_addr, - coap_address_t *bound_addr) { - int on = 1, off = 0; -#ifdef _WIN32 - u_long u_on = 1; -#endif - - sock->fd = socket(listen_addr->addr.sa.sa_family, SOCK_DGRAM, 0); - - if (sock->fd == COAP_INVALID_SOCKET) { - coap_log(LOG_WARNING, - "coap_socket_bind_udp: socket: %s\n", coap_socket_strerror()); - goto error; - } - -#ifdef _WIN32 - if (ioctlsocket(sock->fd, FIONBIO, &u_on) == COAP_SOCKET_ERROR) { -#else - if (ioctl(sock->fd, FIONBIO, &on) == COAP_SOCKET_ERROR) { -#endif - coap_log(LOG_WARNING, - "coap_socket_bind_udp: ioctl FIONBIO: %s\n", coap_socket_strerror()); - } - - if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, OPTVAL_T(&on), sizeof(on)) == COAP_SOCKET_ERROR) - coap_log(LOG_WARNING, - "coap_socket_bind_udp: setsockopt SO_REUSEADDR: %s\n", - coap_socket_strerror()); - - switch (listen_addr->addr.sa.sa_family) { - case AF_INET: - if (setsockopt(sock->fd, IPPROTO_IP, GEN_IP_PKTINFO, OPTVAL_T(&on), sizeof(on)) == COAP_SOCKET_ERROR) - coap_log(LOG_ALERT, - "coap_socket_bind_udp: setsockopt IP_PKTINFO: %s\n", - coap_socket_strerror()); - break; - case AF_INET6: - /* Configure the socket as dual-stacked */ - if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_V6ONLY, OPTVAL_T(&off), sizeof(off)) == COAP_SOCKET_ERROR) - coap_log(LOG_ALERT, - "coap_socket_bind_udp: setsockopt IPV6_V6ONLY: %s\n", - coap_socket_strerror()); - if (setsockopt(sock->fd, IPPROTO_IPV6, GEN_IPV6_PKTINFO, OPTVAL_T(&on), sizeof(on)) == COAP_SOCKET_ERROR) - coap_log(LOG_ALERT, - "coap_socket_bind_udp: setsockopt IPV6_PKTINFO: %s\n", - coap_socket_strerror()); - setsockopt(sock->fd, IPPROTO_IP, GEN_IP_PKTINFO, OPTVAL_T(&on), sizeof(on)); /* ignore error, because the likely cause is that IPv4 is disabled at the os level */ - break; - default: - coap_log(LOG_ALERT, "coap_socket_bind_udp: unsupported sa_family\n"); - break; - } - - if (bind(sock->fd, &listen_addr->addr.sa, listen_addr->size) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, "coap_socket_bind_udp: bind: %s\n", - coap_socket_strerror()); - goto error; - } - - bound_addr->size = (socklen_t)sizeof(*bound_addr); - if (getsockname(sock->fd, &bound_addr->addr.sa, &bound_addr->size) < 0) { - coap_log(LOG_WARNING, - "coap_socket_bind_udp: getsockname: %s\n", - coap_socket_strerror()); - goto error; - } - - return 1; - -error: - coap_socket_close(sock); - return 0; -} - -int -coap_socket_connect_tcp1(coap_socket_t *sock, - const coap_address_t *local_if, - const coap_address_t *server, - int default_port, - coap_address_t *local_addr, - coap_address_t *remote_addr) { - int on = 1, off = 0; -#ifdef _WIN32 - u_long u_on = 1; -#endif - coap_address_t connect_addr; - coap_address_copy( &connect_addr, server ); - - sock->flags &= ~COAP_SOCKET_CONNECTED; - sock->fd = socket(server->addr.sa.sa_family, SOCK_STREAM, 0); - - if (sock->fd == COAP_INVALID_SOCKET) { - coap_log(LOG_WARNING, - "coap_socket_connect_tcp1: socket: %s\n", - coap_socket_strerror()); - goto error; - } - -#ifdef _WIN32 - if (ioctlsocket(sock->fd, FIONBIO, &u_on) == COAP_SOCKET_ERROR) { -#else - if (ioctl(sock->fd, FIONBIO, &on) == COAP_SOCKET_ERROR) { -#endif - coap_log(LOG_WARNING, - "coap_socket_connect_tcp1: ioctl FIONBIO: %s\n", - coap_socket_strerror()); - } - - switch (server->addr.sa.sa_family) { - case AF_INET: - if (connect_addr.addr.sin.sin_port == 0) - connect_addr.addr.sin.sin_port = htons(default_port); - break; - case AF_INET6: - if (connect_addr.addr.sin6.sin6_port == 0) - connect_addr.addr.sin6.sin6_port = htons(default_port); - /* Configure the socket as dual-stacked */ - if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_V6ONLY, OPTVAL_T(&off), sizeof(off)) == COAP_SOCKET_ERROR) - coap_log(LOG_WARNING, - "coap_socket_connect_tcp1: setsockopt IPV6_V6ONLY: %s\n", - coap_socket_strerror()); - break; - default: - coap_log(LOG_ALERT, "coap_socket_connect_tcp1: unsupported sa_family\n"); - break; - } - - if (local_if && local_if->addr.sa.sa_family) { - coap_address_copy(local_addr, local_if); - if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, OPTVAL_T(&on), sizeof(on)) == COAP_SOCKET_ERROR) - coap_log(LOG_WARNING, - "coap_socket_connect_tcp1: setsockopt SO_REUSEADDR: %s\n", - coap_socket_strerror()); - if (bind(sock->fd, &local_if->addr.sa, local_if->size) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, "coap_socket_connect_tcp1: bind: %s\n", - coap_socket_strerror()); - goto error; - } - } else { - local_addr->addr.sa.sa_family = server->addr.sa.sa_family; - } - - if (connect(sock->fd, &connect_addr.addr.sa, connect_addr.size) == COAP_SOCKET_ERROR) { -#ifdef _WIN32 - if (WSAGetLastError() == WSAEWOULDBLOCK) { -#else - if (errno == EINPROGRESS) { -#endif - /* - * COAP_SOCKET_CONNECTED needs to be set here as there will be reads/writes - * by underlying TLS libraries during connect() and we do not want to - * assert() in coap_read_session() or coap_write_session() when called by coap_read() - */ - sock->flags |= COAP_SOCKET_WANT_CONNECT | COAP_SOCKET_CONNECTED; - return 1; - } - coap_log(LOG_WARNING, "coap_socket_connect_tcp1: connect: %s\n", - coap_socket_strerror()); - goto error; - } - - if (getsockname(sock->fd, &local_addr->addr.sa, &local_addr->size) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, "coap_socket_connect_tcp1: getsockname: %s\n", - coap_socket_strerror()); - } - - if (getpeername(sock->fd, &remote_addr->addr.sa, &remote_addr->size) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, "coap_socket_connect_tcp1: getpeername: %s\n", - coap_socket_strerror()); - } - - sock->flags |= COAP_SOCKET_CONNECTED; - return 1; - -error: - coap_socket_close(sock); - return 0; -} - -int -coap_socket_connect_tcp2(coap_socket_t *sock, - coap_address_t *local_addr, - coap_address_t *remote_addr) { - int error = 0; -#ifdef _WIN32 - int optlen = (int)sizeof( error ); -#else - socklen_t optlen = (socklen_t)sizeof( error ); -#endif - - sock->flags &= ~(COAP_SOCKET_WANT_CONNECT | COAP_SOCKET_CAN_CONNECT); - - if (getsockopt(sock->fd, SOL_SOCKET, SO_ERROR, OPTVAL_GT(&error), - &optlen) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, "coap_socket_finish_connect_tcp: getsockopt: %s\n", - coap_socket_strerror()); - } - - if (error) { - coap_log(LOG_WARNING, - "coap_socket_finish_connect_tcp: connect failed: %s\n", - coap_socket_format_errno(error)); - coap_socket_close(sock); - return 0; - } - - if (getsockname(sock->fd, &local_addr->addr.sa, &local_addr->size) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, "coap_socket_connect_tcp: getsockname: %s\n", - coap_socket_strerror()); - } - - if (getpeername(sock->fd, &remote_addr->addr.sa, &remote_addr->size) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, "coap_socket_connect_tcp: getpeername: %s\n", - coap_socket_strerror()); - } - - return 1; -} - -int -coap_socket_bind_tcp(coap_socket_t *sock, - const coap_address_t *listen_addr, - coap_address_t *bound_addr) { - int on = 1, off = 0; -#ifdef _WIN32 - u_long u_on = 1; -#endif - - sock->fd = socket(listen_addr->addr.sa.sa_family, SOCK_STREAM, 0); - - if (sock->fd == COAP_INVALID_SOCKET) { - coap_log(LOG_WARNING, "coap_socket_bind_tcp: socket: %s\n", - coap_socket_strerror()); - goto error; - } - -#ifdef _WIN32 - if (ioctlsocket(sock->fd, FIONBIO, &u_on) == COAP_SOCKET_ERROR) { -#else - if (ioctl(sock->fd, FIONBIO, &on) == COAP_SOCKET_ERROR) { -#endif - coap_log(LOG_WARNING, "coap_socket_bind_tcp: ioctl FIONBIO: %s\n", - coap_socket_strerror()); - } - if (setsockopt (sock->fd, SOL_SOCKET, SO_KEEPALIVE, OPTVAL_T(&on), - sizeof (on)) == COAP_SOCKET_ERROR) - coap_log(LOG_WARNING, - "coap_socket_bind_tcp: setsockopt SO_KEEPALIVE: %s\n", - coap_socket_strerror()); - - if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, OPTVAL_T(&on), - sizeof(on)) == COAP_SOCKET_ERROR) - coap_log(LOG_WARNING, - "coap_socket_bind_tcp: setsockopt SO_REUSEADDR: %s\n", - coap_socket_strerror()); - - switch (listen_addr->addr.sa.sa_family) { - case AF_INET: - break; - case AF_INET6: - /* Configure the socket as dual-stacked */ - if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_V6ONLY, OPTVAL_T(&off), sizeof(off)) == COAP_SOCKET_ERROR) - coap_log(LOG_ALERT, - "coap_socket_bind_tcp: setsockopt IPV6_V6ONLY: %s\n", - coap_socket_strerror()); - break; - default: - coap_log(LOG_ALERT, "coap_socket_bind_tcp: unsupported sa_family\n"); - } - - if (bind(sock->fd, &listen_addr->addr.sa, listen_addr->size) == COAP_SOCKET_ERROR) { - coap_log(LOG_ALERT, "coap_socket_bind_tcp: bind: %s\n", - coap_socket_strerror()); - goto error; - } - - bound_addr->size = (socklen_t)sizeof(*bound_addr); - if (getsockname(sock->fd, &bound_addr->addr.sa, &bound_addr->size) < 0) { - coap_log(LOG_WARNING, "coap_socket_bind_tcp: getsockname: %s\n", - coap_socket_strerror()); - goto error; - } - - if (listen(sock->fd, 5) == COAP_SOCKET_ERROR) { - coap_log(LOG_ALERT, "coap_socket_bind_tcp: listen: %s\n", - coap_socket_strerror()); - goto error; - } - - return 1; - -error: - coap_socket_close(sock); - return 0; -} - -int -coap_socket_accept_tcp(coap_socket_t *server, - coap_socket_t *new_client, - coap_address_t *local_addr, - coap_address_t *remote_addr) { -#ifdef _WIN32 - u_long u_on = 1; -#else - int on = 1; -#endif - - server->flags &= ~COAP_SOCKET_CAN_ACCEPT; - - new_client->fd = accept(server->fd, &remote_addr->addr.sa, - &remote_addr->size); - if (new_client->fd == COAP_INVALID_SOCKET) { - coap_log(LOG_WARNING, "coap_socket_accept_tcp: accept: %s\n", - coap_socket_strerror()); - return 0; - } - - if (getsockname( new_client->fd, &local_addr->addr.sa, &local_addr->size) < 0) - coap_log(LOG_WARNING, "coap_socket_accept_tcp: getsockname: %s\n", - coap_socket_strerror()); - - #ifdef _WIN32 - if (ioctlsocket(new_client->fd, FIONBIO, &u_on) == COAP_SOCKET_ERROR) { -#else - if (ioctl(new_client->fd, FIONBIO, &on) == COAP_SOCKET_ERROR) { -#endif - coap_log(LOG_WARNING, "coap_socket_accept_tcp: ioctl FIONBIO: %s\n", - coap_socket_strerror()); - } - - return 1; -} - -int -coap_socket_connect_udp(coap_socket_t *sock, - const coap_address_t *local_if, - const coap_address_t *server, - int default_port, - coap_address_t *local_addr, - coap_address_t *remote_addr) { - int on = 1, off = 0; -#ifdef _WIN32 - u_long u_on = 1; -#endif - coap_address_t connect_addr; - int is_mcast = coap_is_mcast(server); - coap_address_copy(&connect_addr, server); - - sock->flags &= ~(COAP_SOCKET_CONNECTED | COAP_SOCKET_MULTICAST); - sock->fd = socket(connect_addr.addr.sa.sa_family, SOCK_DGRAM, 0); - - if (sock->fd == COAP_INVALID_SOCKET) { - coap_log(LOG_WARNING, "coap_socket_connect_udp: socket: %s\n", - coap_socket_strerror()); - goto error; - } - -#ifdef _WIN32 - if (ioctlsocket(sock->fd, FIONBIO, &u_on) == COAP_SOCKET_ERROR) { -#else - if (ioctl(sock->fd, FIONBIO, &on) == COAP_SOCKET_ERROR) { -#endif - coap_log(LOG_WARNING, "coap_socket_connect_udp: ioctl FIONBIO: %s\n", - coap_socket_strerror()); - } - - switch (connect_addr.addr.sa.sa_family) { - case AF_INET: - if (connect_addr.addr.sin.sin_port == 0) - connect_addr.addr.sin.sin_port = htons(default_port); - break; - case AF_INET6: - if (connect_addr.addr.sin6.sin6_port == 0) - connect_addr.addr.sin6.sin6_port = htons(default_port); - /* Configure the socket as dual-stacked */ - if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_V6ONLY, OPTVAL_T(&off), sizeof(off)) == COAP_SOCKET_ERROR) - coap_log(LOG_WARNING, - "coap_socket_connect_udp: setsockopt IPV6_V6ONLY: %s\n", - coap_socket_strerror()); - break; - default: - coap_log(LOG_ALERT, "coap_socket_connect_udp: unsupported sa_family\n"); - break; - } - - if (local_if && local_if->addr.sa.sa_family) { - if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, OPTVAL_T(&on), sizeof(on)) == COAP_SOCKET_ERROR) - coap_log(LOG_WARNING, - "coap_socket_connect_udp: setsockopt SO_REUSEADDR: %s\n", - coap_socket_strerror()); - if (bind(sock->fd, &local_if->addr.sa, local_if->size) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, "coap_socket_connect_udp: bind: %s\n", - coap_socket_strerror()); - goto error; - } - } - - /* special treatment for sockets that are used for multicast communication */ - if (is_mcast) { - if (getsockname(sock->fd, &local_addr->addr.sa, &local_addr->size) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, - "coap_socket_connect_udp: getsockname for multicast socket: %s\n", - coap_socket_strerror()); - } - coap_address_copy(remote_addr, &connect_addr); - sock->flags |= COAP_SOCKET_MULTICAST; - return 1; - } - - if (connect(sock->fd, &connect_addr.addr.sa, connect_addr.size) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, "coap_socket_connect_udp: connect: %s\n", - coap_socket_strerror()); - goto error; - } - - if (getsockname(sock->fd, &local_addr->addr.sa, &local_addr->size) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, "coap_socket_connect_udp: getsockname: %s\n", - coap_socket_strerror()); - } - - if (getpeername(sock->fd, &remote_addr->addr.sa, &remote_addr->size) == COAP_SOCKET_ERROR) { - coap_log(LOG_WARNING, "coap_socket_connect_udp: getpeername: %s\n", - coap_socket_strerror()); - } - - sock->flags |= COAP_SOCKET_CONNECTED; - return 1; - -error: - coap_socket_close(sock); - return 0; -} - -void coap_socket_close(coap_socket_t *sock) { - if (sock->fd != COAP_INVALID_SOCKET) { - coap_closesocket(sock->fd); - sock->fd = COAP_INVALID_SOCKET; - } - sock->flags = COAP_SOCKET_EMPTY; -} - -ssize_t -coap_socket_write(coap_socket_t *sock, const uint8_t *data, size_t data_len) { - ssize_t r; - - sock->flags &= ~(COAP_SOCKET_WANT_WRITE | COAP_SOCKET_CAN_WRITE); -#ifdef _WIN32 - r = send(sock->fd, (const char *)data, (int)data_len, 0); -#else - r = send(sock->fd, data, data_len, 0); -#endif - if (r == COAP_SOCKET_ERROR) { -#ifdef _WIN32 - if (WSAGetLastError() == WSAEWOULDBLOCK) { -#elif EAGAIN != EWOULDBLOCK - if (errno==EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { -#else - if (errno==EAGAIN || errno == EINTR) { -#endif - sock->flags |= COAP_SOCKET_WANT_WRITE; - return 0; - } - coap_log(LOG_WARNING, "coap_socket_write: send: %s\n", - coap_socket_strerror()); - return -1; - } - if (r < (ssize_t)data_len) - sock->flags |= COAP_SOCKET_WANT_WRITE; - return r; -} - -ssize_t -coap_socket_read(coap_socket_t *sock, uint8_t *data, size_t data_len) { - ssize_t r; -#ifdef _WIN32 - int error; -#endif - -#ifdef _WIN32 - r = recv(sock->fd, (char *)data, (int)data_len, 0); -#else - r = recv(sock->fd, data, data_len, 0); -#endif - if (r == 0) { - /* graceful shutdown */ - sock->flags &= ~COAP_SOCKET_CAN_READ; - return -1; - } else if (r == COAP_SOCKET_ERROR) { - sock->flags &= ~COAP_SOCKET_CAN_READ; -#ifdef _WIN32 - error = WSAGetLastError(); - if (error == WSAEWOULDBLOCK) { -#elif EAGAIN != EWOULDBLOCK - if (errno==EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { -#else - if (errno==EAGAIN || errno == EINTR) { -#endif - return 0; - } -#ifdef _WIN32 - if (error != WSAECONNRESET) -#else - if (errno != ECONNRESET) -#endif - coap_log(LOG_WARNING, "coap_socket_read: recv: %s\n", - coap_socket_strerror()); - return -1; - } - if (r < (ssize_t)data_len) - sock->flags &= ~COAP_SOCKET_CAN_READ; - return r; -} - -#endif /* WITH_CONTIKI */ - -#if (!defined(WITH_CONTIKI)) != ( defined(HAVE_NETINET_IN_H) || defined(HAVE_WS2TCPIP_H) ) -/* define struct in6_pktinfo and struct in_pktinfo if not available - FIXME: check with configure -*/ -struct in6_pktinfo { - struct in6_addr ipi6_addr; /* src/dst IPv6 address */ - unsigned int ipi6_ifindex; /* send/recv interface index */ -}; - -#endif - -#if !defined(WITH_CONTIKI) && !defined(SOL_IP) -/* Solaris expects level IPPROTO_IP for ancillary data. */ -#define SOL_IP IPPROTO_IP -#endif - -#ifdef __GNUC__ -#define UNUSED_PARAM __attribute__ ((unused)) -#else /* not a GCC */ -#define UNUSED_PARAM -#endif /* GCC */ - -#if defined(_WIN32) -#include -static __declspec(thread) LPFN_WSARECVMSG lpWSARecvMsg = NULL; -/* Map struct WSABUF fields to their posix counterpart */ -#define msghdr _WSAMSG -#define msg_name name -#define msg_namelen namelen -#define msg_iov lpBuffers -#define msg_iovlen dwBufferCount -#define msg_control Control.buf -#define msg_controllen Control.len -#define iovec _WSABUF -#define iov_base buf -#define iov_len len -#define iov_len_t u_long -#undef CMSG_DATA -#define CMSG_DATA WSA_CMSG_DATA -#define ipi_spec_dst ipi_addr -#else -#define iov_len_t size_t -#endif - -ssize_t -coap_network_send(coap_socket_t *sock, const coap_session_t *session, const uint8_t *data, size_t datalen) { - ssize_t bytes_written = 0; - - if (!coap_debug_send_packet()) { - bytes_written = (ssize_t)datalen; -#ifndef WITH_CONTIKI - } else if (sock->flags & COAP_SOCKET_CONNECTED) { -#ifdef _WIN32 - bytes_written = send(sock->fd, (const char *)data, (int)datalen, 0); -#else - bytes_written = send(sock->fd, data, datalen, 0); -#endif -#endif - } else { -#ifndef WITH_CONTIKI -#ifdef _WIN32 - DWORD dwNumberOfBytesSent = 0; - int r; -#endif -#ifndef COAP_BAD_RECVMSG - /* a buffer large enough to hold all packet info types, ipv6 is the largest */ - char buf[CMSG_SPACE(sizeof(struct in6_pktinfo))]; - struct msghdr mhdr; - struct iovec iov[1]; - const void *addr = &session->remote_addr.addr; - - assert(session); - - memcpy (&iov[0].iov_base, &data, sizeof (iov[0].iov_base)); - iov[0].iov_len = (iov_len_t)datalen; - - memset(buf, 0, sizeof (buf)); - - memset(&mhdr, 0, sizeof(struct msghdr)); - memcpy (&mhdr.msg_name, &addr, sizeof (mhdr.msg_name)); - mhdr.msg_namelen = session->remote_addr.size; - - mhdr.msg_iov = iov; - mhdr.msg_iovlen = 1; - - if (!coap_address_isany(&session->local_addr) && !coap_is_mcast(&session->local_addr)) switch (session->local_addr.addr.sa.sa_family) { - case AF_INET6: - { - struct cmsghdr *cmsg; - - if (IN6_IS_ADDR_V4MAPPED(&session->local_addr.addr.sin6.sin6_addr)) { -#if defined(IP_PKTINFO) - struct in_pktinfo *pktinfo; - mhdr.msg_control = buf; - mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo)); - - cmsg = CMSG_FIRSTHDR(&mhdr); - cmsg->cmsg_level = SOL_IP; - cmsg->cmsg_type = IP_PKTINFO; - cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo)); - - pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg); - - pktinfo->ipi_ifindex = session->ifindex; - memcpy(&pktinfo->ipi_spec_dst, session->local_addr.addr.sin6.sin6_addr.s6_addr + 12, sizeof(pktinfo->ipi_spec_dst)); -#elif defined(IP_SENDSRCADDR) - mhdr.msg_control = buf; - mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_addr)); - - cmsg = CMSG_FIRSTHDR(&mhdr); - cmsg->cmsg_level = IPPROTO_IP; - cmsg->cmsg_type = IP_SENDSRCADDR; - cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr)); - - memcpy(CMSG_DATA(cmsg), session->local_addr.addr.sin6.sin6_addr.s6_addr + 12, sizeof(struct in_addr)); -#endif /* IP_PKTINFO */ - } else { - struct in6_pktinfo *pktinfo; - mhdr.msg_control = buf; - mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)); - - cmsg = CMSG_FIRSTHDR(&mhdr); - cmsg->cmsg_level = IPPROTO_IPV6; - cmsg->cmsg_type = IPV6_PKTINFO; - cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); - - pktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsg); - - pktinfo->ipi6_ifindex = session->ifindex; - memcpy(&pktinfo->ipi6_addr, &session->local_addr.addr.sin6.sin6_addr, sizeof(pktinfo->ipi6_addr)); - } - break; - } - case AF_INET: - { -#if defined(IP_PKTINFO) - struct cmsghdr *cmsg; - struct in_pktinfo *pktinfo; - - mhdr.msg_control = buf; - mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo)); - - cmsg = CMSG_FIRSTHDR(&mhdr); - cmsg->cmsg_level = SOL_IP; - cmsg->cmsg_type = IP_PKTINFO; - cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo)); - - pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg); - - pktinfo->ipi_ifindex = session->ifindex; - memcpy(&pktinfo->ipi_spec_dst, &session->local_addr.addr.sin.sin_addr, sizeof(pktinfo->ipi_spec_dst)); -#elif defined(IP_SENDSRCADDR) - struct cmsghdr *cmsg; - mhdr.msg_control = buf; - mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_addr)); - - cmsg = CMSG_FIRSTHDR(&mhdr); - cmsg->cmsg_level = IPPROTO_IP; - cmsg->cmsg_type = IP_SENDSRCADDR; - cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr)); - - memcpy(CMSG_DATA(cmsg), &session->local_addr.addr.sin.sin_addr, sizeof(struct in_addr)); -#endif /* IP_PKTINFO */ - break; - } - default: - /* error */ - coap_log(LOG_WARNING, "protocol not supported\n"); - bytes_written = -1; - } -#endif /* ! COAP_BAD_RECVMSG */ - -#ifdef _WIN32 - r = WSASendMsg(sock->fd, &mhdr, 0 /*dwFlags*/, &dwNumberOfBytesSent, NULL /*lpOverlapped*/, NULL /*lpCompletionRoutine*/); - if (r == 0) - bytes_written = (ssize_t)dwNumberOfBytesSent; - else - bytes_written = -1; -#else -#ifndef COAP_BAD_RECVMSG - bytes_written = sendmsg(sock->fd, &mhdr, 0); -#else /* COAP_BAD_RECVMSG */ - bytes_written = sendto(sock->fd, data, datalen, 0, &session->remote_addr.addr.sa, session->remote_addr.size); -#endif /* COAP_BAD_RECVMSG */ -#endif -#else /* WITH_CONTIKI */ - /* FIXME: untested */ - /* FIXME: is there a way to check if send was successful? */ - (void)datalen; - (void)data; - uip_udp_packet_sendto((struct uip_udp_conn *)sock->conn, data, datalen, - &session->remote_addr.addr, session->remote_addr.port); - bytes_written = datalen; -#endif /* WITH_CONTIKI */ - } - - if (bytes_written < 0) - coap_log(LOG_CRIT, "coap_network_send: %s\n", coap_socket_strerror()); - - return bytes_written; -} - -#define SIN6(A) ((struct sockaddr_in6 *)(A)) - -void -coap_packet_get_memmapped(coap_packet_t *packet, unsigned char **address, size_t *length) { - *address = packet->payload; - *length = packet->length; -} - -void coap_packet_set_addr(coap_packet_t *packet, const coap_address_t *src, const coap_address_t *dst) { - coap_address_copy(&packet->src, src); - coap_address_copy(&packet->dst, dst); -} - -ssize_t -coap_network_read(coap_socket_t *sock, coap_packet_t *packet) { - ssize_t len = -1; - - assert(sock); - assert(packet); - - if ((sock->flags & COAP_SOCKET_CAN_READ) == 0) { - return -1; - } else { - /* clear has-data flag */ - sock->flags &= ~COAP_SOCKET_CAN_READ; - } - -#ifndef WITH_CONTIKI - if (sock->flags & COAP_SOCKET_CONNECTED) { -#ifdef _WIN32 - len = recv(sock->fd, (char *)packet->payload, COAP_RXBUFFER_SIZE, 0); -#else - len = recv(sock->fd, packet->payload, COAP_RXBUFFER_SIZE, 0); -#endif - if (len < 0) { -#ifdef _WIN32 - if (WSAGetLastError() == WSAECONNRESET) { -#else - if (errno == ECONNREFUSED) { -#endif - /* client-side ICMP destination unreachable, ignore it */ - coap_log(LOG_WARNING, "coap_network_read: unreachable\n"); - return -2; - } - coap_log(LOG_WARNING, "coap_network_read: %s\n", coap_socket_strerror()); - goto error; - } else if (len > 0) { - packet->length = (size_t)len; - } - } else { -#endif /* WITH_CONTIKI */ -#if defined(_WIN32) - DWORD dwNumberOfBytesRecvd = 0; - int r; -#endif -#if !defined(WITH_CONTIKI) -#ifndef COAP_BAD_RECVMSG - /* a buffer large enough to hold all packet info types, ipv6 is the largest */ - char buf[CMSG_SPACE(sizeof(struct in6_pktinfo))]; - struct msghdr mhdr; - struct iovec iov[1]; - - iov[0].iov_base = packet->payload; - iov[0].iov_len = (iov_len_t)COAP_RXBUFFER_SIZE; - - memset(&mhdr, 0, sizeof(struct msghdr)); - - mhdr.msg_name = (struct sockaddr*)&packet->src.addr; - mhdr.msg_namelen = sizeof(packet->src.addr); - - mhdr.msg_iov = iov; - mhdr.msg_iovlen = 1; - - mhdr.msg_control = buf; - mhdr.msg_controllen = sizeof(buf); - -#if defined(_WIN32) - if (!lpWSARecvMsg) { - GUID wsaid = WSAID_WSARECVMSG; - DWORD cbBytesReturned = 0; - if (WSAIoctl(sock->fd, SIO_GET_EXTENSION_FUNCTION_POINTER, &wsaid, sizeof(wsaid), &lpWSARecvMsg, sizeof(lpWSARecvMsg), &cbBytesReturned, NULL, NULL) != 0) { - coap_log(LOG_WARNING, "coap_network_read: no WSARecvMsg\n"); - return -1; - } - } - r = lpWSARecvMsg(sock->fd, &mhdr, &dwNumberOfBytesRecvd, NULL /* LPWSAOVERLAPPED */, NULL /* LPWSAOVERLAPPED_COMPLETION_ROUTINE */); - if (r == 0) - len = (ssize_t)dwNumberOfBytesRecvd; -#else - len = recvmsg(sock->fd, &mhdr, 0); -#endif - -#else /* COAP_BAD_RECVMSG */ - packet->src.size = packet->src.size; - len = recvfrom(sock->fd, packet->payload, COAP_RXBUFFER_SIZE, 0, &packet->src.addr.sa, &packet->src.size); -#endif /* COAP_BAD_RECVMSG */ - - if (len < 0) { -#ifdef _WIN32 - if (WSAGetLastError() == WSAECONNRESET) { -#else - if (errno == ECONNREFUSED) { -#endif - /* server-side ICMP destination unreachable, ignore it. The destination address is in msg_name. */ - return 0; - } - coap_log(LOG_WARNING, "coap_network_read: %s\n", coap_socket_strerror()); - goto error; - } else { -#ifndef COAP_BAD_RECVMSG - struct cmsghdr *cmsg; - - packet->src.size = mhdr.msg_namelen; - packet->length = (size_t)len; - - /* Walk through ancillary data records until the local interface - * is found where the data was received. */ - for (cmsg = CMSG_FIRSTHDR(&mhdr); cmsg; cmsg = CMSG_NXTHDR(&mhdr, cmsg)) { - - /* get the local interface for IPv6 */ - if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO) { - union { - uint8_t *c; - struct in6_pktinfo *p; - } u; - u.c = CMSG_DATA(cmsg); - packet->ifindex = (int)(u.p->ipi6_ifindex); - memcpy(&packet->dst.addr.sin6.sin6_addr, &u.p->ipi6_addr, sizeof(struct in6_addr)); - break; - } - - /* local interface for IPv4 */ -#if defined(IP_PKTINFO) - if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_PKTINFO) { - union { - uint8_t *c; - struct in_pktinfo *p; - } u; - u.c = CMSG_DATA(cmsg); - packet->ifindex = u.p->ipi_ifindex; - if (packet->dst.addr.sa.sa_family == AF_INET6) { - memset(packet->dst.addr.sin6.sin6_addr.s6_addr, 0, 10); - packet->dst.addr.sin6.sin6_addr.s6_addr[10] = 0xff; - packet->dst.addr.sin6.sin6_addr.s6_addr[11] = 0xff; - memcpy(packet->dst.addr.sin6.sin6_addr.s6_addr + 12, &u.p->ipi_addr, sizeof(struct in_addr)); - } else { - memcpy(&packet->dst.addr.sin.sin_addr, &u.p->ipi_addr, sizeof(struct in_addr)); - } - break; - } -#elif defined(IP_RECVDSTADDR) - if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_RECVDSTADDR) { - packet->ifindex = 0; - memcpy(&packet->dst.addr.sin.sin_addr, CMSG_DATA(cmsg), sizeof(struct in_addr)); - break; - } -#endif /* IP_PKTINFO */ - } -#else /* COAP_BAD_RECVMSG */ - packet->length = (size_t)len; - packet->ifindex = 0; - if (getsockname(sock->fd, &packet->dst.addr.sa, &packet->dst.size) < 0) { - coap_log(LOG_DEBUG, "Cannot determine local port\n"); - goto error; - } -#endif /* COAP_BAD_RECVMSG */ - } -#endif /* !defined(WITH_CONTIKI) */ -#ifdef WITH_CONTIKI - /* FIXME: untested, make this work */ -#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) -#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[UIP_LLIPH_LEN]) - - if (uip_newdata()) { - uip_ipaddr_copy(&packet->src.addr, &UIP_IP_BUF->srcipaddr); - packet->src.port = UIP_UDP_BUF->srcport; - uip_ipaddr_copy(&(packet)->dst.addr, &UIP_IP_BUF->destipaddr); - packet->dst.port = UIP_UDP_BUF->destport; - - len = uip_datalen(); - - if (len > COAP_RXBUFFER_SIZE) { - /* FIXME: we might want to send back a response */ - coap_log(LOG_WARNING, "discarded oversized packet\n"); - return -1; - } - - ((char *)uip_appdata)[len] = 0; -#ifndef NDEBUG - if (LOG_DEBUG <= coap_get_log_level()) { -#ifndef INET6_ADDRSTRLEN -#define INET6_ADDRSTRLEN 40 -#endif - unsigned char addr_str[INET6_ADDRSTRLEN + 8]; - - if (coap_print_addr(&packet->src, addr_str, INET6_ADDRSTRLEN + 8)) { - coap_log(LOG_DEBUG, "received %zd bytes from %s\n", len, addr_str); - } - } -#endif /* NDEBUG */ - - packet->length = len; - memcpy(&packet->payload, uip_appdata, len); - } - -#undef UIP_IP_BUF -#undef UIP_UDP_BUF -#endif /* WITH_CONTIKI */ -#ifndef WITH_CONTIKI - } -#endif /* WITH_CONTIKI */ - - if (len >= 0) - return len; -#if !defined(WITH_CONTIKI) -error: -#endif - return -1; -} - -#if !defined(WITH_CONTIKI) - -unsigned int -coap_write(coap_context_t *ctx, - coap_socket_t *sockets[], - unsigned int max_sockets, - unsigned int *num_sockets, - coap_tick_t now) -{ - coap_queue_t *nextpdu; - coap_endpoint_t *ep; - coap_session_t *s; - coap_tick_t session_timeout; - coap_tick_t timeout = 0; - coap_session_t *tmp; - - *num_sockets = 0; - - /* Check to see if we need to send off any Observe requests */ - coap_check_notify(ctx); - - if (ctx->session_timeout > 0) - session_timeout = ctx->session_timeout * COAP_TICKS_PER_SECOND; - else - session_timeout = COAP_DEFAULT_SESSION_TIMEOUT * COAP_TICKS_PER_SECOND; - - LL_FOREACH(ctx->endpoint, ep) { - if (ep->sock.flags & (COAP_SOCKET_WANT_READ | COAP_SOCKET_WANT_WRITE | COAP_SOCKET_WANT_ACCEPT)) { - if (*num_sockets < max_sockets) - sockets[(*num_sockets)++] = &ep->sock; - } - LL_FOREACH_SAFE(ep->sessions, s, tmp) { - if (s->type == COAP_SESSION_TYPE_SERVER && s->ref == 0 && - s->delayqueue == NULL && - (s->last_rx_tx + session_timeout <= now || - s->state == COAP_SESSION_STATE_NONE)) { - coap_session_free(s); - } else { - if (s->type == COAP_SESSION_TYPE_SERVER && s->ref == 0 && s->delayqueue == NULL) { - coap_tick_t s_timeout = (s->last_rx_tx + session_timeout) - now; - if (timeout == 0 || s_timeout < timeout) - timeout = s_timeout; - } - if (s->sock.flags & (COAP_SOCKET_WANT_READ | COAP_SOCKET_WANT_WRITE)) { - if (*num_sockets < max_sockets) - sockets[(*num_sockets)++] = &s->sock; - } - } - } - } - LL_FOREACH_SAFE(ctx->sessions, s, tmp) { - if ( - s->type == COAP_SESSION_TYPE_CLIENT - && COAP_PROTO_RELIABLE(s->proto) - && s->state == COAP_SESSION_STATE_ESTABLISHED - && ctx->ping_timeout > 0 - ) { - coap_tick_t s_timeout; - if (s->last_rx_tx + ctx->ping_timeout * COAP_TICKS_PER_SECOND <= now) { - if ((s->last_ping > 0 && s->last_pong < s->last_ping) - || coap_session_send_ping(s) == COAP_INVALID_TID) - { - /* Make sure the session object is not deleted in the callback */ - coap_session_reference(s); - coap_session_disconnected(s, COAP_NACK_NOT_DELIVERABLE); - coap_session_release(s); - continue; - } - s->last_rx_tx = now; - s->last_ping = now; - } - s_timeout = (s->last_rx_tx + ctx->ping_timeout * COAP_TICKS_PER_SECOND) - now; - if (timeout == 0 || s_timeout < timeout) - timeout = s_timeout; - } - - if ( - s->type == COAP_SESSION_TYPE_CLIENT - && COAP_PROTO_RELIABLE(s->proto) - && s->state == COAP_SESSION_STATE_CSM - && ctx->csm_timeout > 0 - ) { - coap_tick_t s_timeout; - if (s->csm_tx == 0) { - s->csm_tx = now; - } else if (s->csm_tx + ctx->csm_timeout * COAP_TICKS_PER_SECOND <= now) { - /* Make sure the session object is not deleted in the callback */ - coap_session_reference(s); - coap_session_disconnected(s, COAP_NACK_NOT_DELIVERABLE); - coap_session_release(s); - continue; - } - s_timeout = (s->csm_tx + ctx->csm_timeout * COAP_TICKS_PER_SECOND) - now; - if (timeout == 0 || s_timeout < timeout) - timeout = s_timeout; - } - - if (s->sock.flags & (COAP_SOCKET_WANT_READ | COAP_SOCKET_WANT_WRITE | COAP_SOCKET_WANT_CONNECT)) { - if (*num_sockets < max_sockets) - sockets[(*num_sockets)++] = &s->sock; - } - } - - nextpdu = coap_peek_next(ctx); - - while (nextpdu && now >= ctx->sendqueue_basetime && nextpdu->t <= now - ctx->sendqueue_basetime) { - coap_retransmit(ctx, coap_pop_next(ctx)); - nextpdu = coap_peek_next(ctx); - } - - if (nextpdu && (timeout == 0 || nextpdu->t - ( now - ctx->sendqueue_basetime ) < timeout)) - timeout = nextpdu->t - (now - ctx->sendqueue_basetime); - - if (ctx->dtls_context) { - if (coap_dtls_is_context_timeout()) { - coap_tick_t tls_timeout = coap_dtls_get_context_timeout(ctx->dtls_context); - if (tls_timeout > 0) { - if (tls_timeout < now + COAP_TICKS_PER_SECOND / 10) - tls_timeout = now + COAP_TICKS_PER_SECOND / 10; - coap_log(LOG_DEBUG, "** DTLS global timeout set to %dms\n", - (int)((tls_timeout - now) * 1000 / COAP_TICKS_PER_SECOND)); - if (timeout == 0 || tls_timeout - now < timeout) - timeout = tls_timeout - now; - } - } else { - LL_FOREACH(ctx->endpoint, ep) { - if (ep->proto == COAP_PROTO_DTLS) { - LL_FOREACH(ep->sessions, s) { - if (s->proto == COAP_PROTO_DTLS && s->tls) { - coap_tick_t tls_timeout = coap_dtls_get_timeout(s); - while (tls_timeout > 0 && tls_timeout <= now) { - coap_log(LOG_DEBUG, "** %s: DTLS retransmit timeout\n", - coap_session_str(s)); - coap_dtls_handle_timeout(s); - if (s->tls) - tls_timeout = coap_dtls_get_timeout(s); - else { - tls_timeout = 0; - timeout = 1; - } - } - if (tls_timeout > 0 && (timeout == 0 || tls_timeout - now < timeout)) - timeout = tls_timeout - now; - } - } - } - } - LL_FOREACH(ctx->sessions, s) { - if (s->proto == COAP_PROTO_DTLS && s->tls) { - coap_tick_t tls_timeout = coap_dtls_get_timeout(s); - while (tls_timeout > 0 && tls_timeout <= now) { - coap_log(LOG_DEBUG, "** %s: DTLS retransmit timeout\n", coap_session_str(s)); - coap_dtls_handle_timeout(s); - if (s->tls) - tls_timeout = coap_dtls_get_timeout(s); - else { - tls_timeout = 0; - timeout = 1; - } - } - if (tls_timeout > 0 && (timeout == 0 || tls_timeout - now < timeout)) - timeout = tls_timeout - now; - } - } - } - } - - return (unsigned int)((timeout * 1000 + COAP_TICKS_PER_SECOND - 1) / COAP_TICKS_PER_SECOND); -} - -int -coap_run_once(coap_context_t *ctx, unsigned timeout_ms) { - fd_set readfds, writefds, exceptfds; - coap_fd_t nfds = 0; - struct timeval tv; - coap_tick_t before, now; - int result; - coap_socket_t *sockets[64]; - unsigned int num_sockets = 0, i, timeout; - - coap_ticks(&before); - - timeout = coap_write(ctx, sockets, (unsigned int)(sizeof(sockets) / sizeof(sockets[0])), &num_sockets, before); - if (timeout == 0 || timeout_ms < timeout) - timeout = timeout_ms; - - FD_ZERO(&readfds); - FD_ZERO(&writefds); - FD_ZERO(&exceptfds); - for (i = 0; i < num_sockets; i++) { - if (sockets[i]->fd + 1 > nfds) - nfds = sockets[i]->fd + 1; - if (sockets[i]->flags & COAP_SOCKET_WANT_READ) - FD_SET(sockets[i]->fd, &readfds); - if (sockets[i]->flags & COAP_SOCKET_WANT_WRITE) - FD_SET(sockets[i]->fd, &writefds); - if (sockets[i]->flags & COAP_SOCKET_WANT_ACCEPT) - FD_SET(sockets[i]->fd, &readfds); - if (sockets[i]->flags & COAP_SOCKET_WANT_CONNECT) { - FD_SET(sockets[i]->fd, &writefds); - FD_SET(sockets[i]->fd, &exceptfds); - } - } - - if ( timeout > 0 ) { - tv.tv_usec = (timeout % 1000) * 1000; - tv.tv_sec = (long)(timeout / 1000); - } - - result = select(nfds, &readfds, &writefds, &exceptfds, timeout > 0 ? &tv : NULL); - - if (result < 0) { /* error */ -#ifdef _WIN32 - if (WSAGetLastError() != WSAEINVAL) { /* May happen because of ICMP */ -#else - if (errno != EINTR) { -#endif - coap_log(LOG_DEBUG, "%s", coap_socket_strerror()); - return -1; - } - } - - if (result > 0) { - for (i = 0; i < num_sockets; i++) { - if ((sockets[i]->flags & COAP_SOCKET_WANT_READ) && FD_ISSET(sockets[i]->fd, &readfds)) - sockets[i]->flags |= COAP_SOCKET_CAN_READ; - if ((sockets[i]->flags & COAP_SOCKET_WANT_ACCEPT) && FD_ISSET(sockets[i]->fd, &readfds)) - sockets[i]->flags |= COAP_SOCKET_CAN_ACCEPT; - if ((sockets[i]->flags & COAP_SOCKET_WANT_WRITE) && FD_ISSET(sockets[i]->fd, &writefds)) - sockets[i]->flags |= COAP_SOCKET_CAN_WRITE; - if ((sockets[i]->flags & COAP_SOCKET_WANT_CONNECT) && (FD_ISSET(sockets[i]->fd, &writefds) || FD_ISSET(sockets[i]->fd, &exceptfds))) - sockets[i]->flags |= COAP_SOCKET_CAN_CONNECT; - } - } - - coap_ticks(&now); - coap_read(ctx, now); - - return (int)(((now - before) * 1000) / COAP_TICKS_PER_SECOND); -} - -#else -int coap_run_once(coap_context_t *ctx, unsigned int timeout_ms) { - return -1; -} - -unsigned int -coap_write(coap_context_t *ctx, - coap_socket_t *sockets[], - unsigned int max_sockets, - unsigned int *num_sockets, - coap_tick_t now) -{ - *num_sockets = 0; - return 0; -} -#endif - -#ifdef _WIN32 -static const char *coap_socket_format_errno(int error) { - static char szError[256]; - if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD)error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)szError, (DWORD)sizeof(szError), NULL) == 0) - strcpy(szError, "Unknown error"); - return szError; -} - -const char *coap_socket_strerror(void) { - return coap_socket_format_errno(WSAGetLastError()); -} -#else -#ifndef WITH_CONTIKI -static const char *coap_socket_format_errno(int error) { - return strerror(error); -} -#endif /* WITH_CONTIKI */ - -const char *coap_socket_strerror(void) { - return strerror(errno); -} -#endif - -ssize_t -coap_socket_send(coap_socket_t *sock, coap_session_t *session, - const uint8_t *data, size_t data_len) { - return session->context->network_send(sock, session, data, data_len); -} - -#undef SIN6 diff --git a/components/coap/port/coap_mbedtls.c b/components/coap/port/coap_mbedtls.c new file mode 100644 index 000000000..9f8c1fab9 --- /dev/null +++ b/components/coap/port/coap_mbedtls.c @@ -0,0 +1,1796 @@ +/* +* coap_mbedtls.c -- mbedTLS Datagram Transport Layer Support for libcoap +* +* Copyright (C) 2019 Jon Shallow +* 2019 Jitin George +* +* This file is part of the CoAP library libcoap. Please see README for terms +* of use. +*/ + +/* + * Naming used to prevent confusion between coap sessions, mbedtls sessions etc. + * when reading the code. + * + * c_context A coap_context_t * + * c_session A coap_session_t * + * m_context A coap_mbedtls_context_t * (held in c_context->dtls_context) + * m_env A coap_mbedtls_env_t * (held in c_session->tls) + */ + +#include "coap_config.h" + +#ifdef HAVE_MBEDTLS + +/* + * Once PS #335 has been merged in, then code following a rebase needs to be + * updated removing sections that are "#ifndef PSK2_PR", and then remove all + * references to PSK2_PR. + */ +#undef PSK2_PR + +#include "libcoap.h" +#include "coap_dtls.h" +#include "net.h" +#include "mem.h" +#include "coap_debug.h" +#include "prng.h" +#include "coap_mutex.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(ESPIDF_VERSION) && defined(CONFIG_MBEDTLS_DEBUG) +#include +#endif /* ESPIDF_VERSION && CONFIG_MBEDTLS_DEBUG */ +#include +#include + +#define mbedtls_malloc(a) malloc(a) +#define mbedtls_realloc(a,b) realloc(a,b) +#define mbedtls_strdup(a) strdup(a) + +#ifdef __GNUC__ +#define UNUSED __attribute__((unused)) +#else /* __GNUC__ */ +#define UNUSED +#endif /* __GNUC__ */ + +#define IS_PSK (1 << 0) +#define IS_PKI (1 << 1) +#define IS_CLIENT (1 << 6) +#define IS_SERVER (1 << 7) + +typedef struct coap_ssl_t { + const uint8_t *pdu; + unsigned pdu_len; + unsigned peekmode; + coap_tick_t timeout; +} coap_ssl_t; + +/* + * This structure encapsulates the mbedTLS session object. + * It handles both TLS and DTLS. + * c_session->tls points to this. + */ +typedef struct coap_mbedtls_env_t { + mbedtls_ssl_context ssl; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_config conf; + mbedtls_timing_delay_context timer; + mbedtls_x509_crt cacert; + mbedtls_x509_crt public_cert; + mbedtls_pk_context private_key; + mbedtls_ssl_cookie_ctx cookie_ctx; + /* If not set, need to do do_mbedtls_handshake */ + int established; + int seen_client_hello; + coap_ssl_t coap_ssl_data; +} coap_mbedtls_env_t; + +typedef struct pki_sni_entry { + char *sni; + coap_dtls_key_t pki_key; + mbedtls_x509_crt cacert; + mbedtls_x509_crt public_cert; + mbedtls_pk_context private_key; +} pki_sni_entry; + +#ifdef PSK2_PR +typedef struct psk_sni_entry { + coap_string_t sni; + coap_dtls_spsk_info_t psk_info; +} psk_sni_entry; +#endif /* PSK2_PR */ + +typedef struct coap_mbedtls_context_t { + coap_dtls_pki_t setup_data; + size_t pki_sni_count; + pki_sni_entry *pki_sni_entry_list; +#ifdef PSK2_PR + size_t psk_sni_count; + psk_sni_entry *psk_sni_entry_list; +#endif /* PSK2_PR */ + char *root_ca_file; + char *root_ca_path; + int psk_pki_enabled; +} coap_mbedtls_context_t; + +static int coap_dgram_read(void *ctx, unsigned char *out, size_t outl) +{ + ssize_t ret = 0; + coap_session_t *c_session = (struct coap_session_t *)ctx; + coap_ssl_t *data = &((coap_mbedtls_env_t *)c_session->tls)->coap_ssl_data; + + if (!c_session->tls) { + errno = EAGAIN; + return MBEDTLS_ERR_SSL_WANT_READ; + } + + if (out != NULL) { + if (data != NULL && data->pdu_len > 0) { + if (outl < data->pdu_len) { + memcpy(out, data->pdu, outl); + ret = outl; + data->pdu += outl; + data->pdu_len -= outl; + } + else { + memcpy(out, data->pdu, data->pdu_len); + ret = data->pdu_len; + if (!data->peekmode) { + data->pdu_len = 0; + data->pdu = NULL; + } + } + } + else { + ret = MBEDTLS_ERR_SSL_WANT_READ; + errno = EAGAIN; + return ret; + } + } + return ret; +} + +/* + * return +ve data amount + * 0 no more + * -1 error (error in errno) + */ +/* callback function given to mbedtls for sending data over socket */ +static int +coap_dgram_write(void *ctx, const unsigned char *send_buffer, + size_t send_buffer_length) +{ + ssize_t result = -1; + coap_session_t *c_session = (struct coap_session_t *)ctx; + + if (c_session) { + result = coap_session_send(c_session, send_buffer, send_buffer_length); + if (result != (int)send_buffer_length) { + coap_log(LOG_WARNING, "coap_network_send failed (%zd != %zd)\n", + result, send_buffer_length); + result = 0; + } + } else { + result = 0; + } + return result; +} + +#if !defined(ESPIDF_VERSION) || defined(CONFIG_MBEDTLS_SSL_PROTO_DTLS) +static char* +get_ip_addr(const struct coap_address_t *addr) +{ + const void *addrptr = NULL; + size_t buf_len; + + if (!addr) { + return NULL; + } + switch (addr->addr.sa.sa_family) { + case AF_INET: + addrptr = &addr->addr.sin.sin_addr; + buf_len = INET_ADDRSTRLEN; + break; + case AF_INET6: + addrptr = &addr->addr.sin6.sin6_addr; + buf_len = INET6_ADDRSTRLEN; + break; + default: + return NULL; + } + char *str = (char *)mbedtls_calloc(1, buf_len); + if (!str) { + coap_log(LOG_ERR, "Memory allocation failed\n"); + return NULL; + } + if (inet_ntop(addr->addr.sa.sa_family, addrptr, str, + buf_len) == 0) { + perror("coap_print_addr"); + return 0; + } + return str; +} +#endif /* !ESPIDF_VERSION || CONFIG_MBEDTLS_SSL_PROTO_DTLS */ + +#if !defined(ESPIDF_VERSION) || (defined(CONFIG_MBEDTLS_SSL_PROTO_DTLS) && defined(CONFIG_MBEDTLS_PSK_MODES)) +/* + * Server side PSK callback + */ +static int psk_server_callback(void *p_info, mbedtls_ssl_context *ssl, + const unsigned char *name, size_t name_len ) +{ + coap_session_t *c_session = + (coap_session_t *)p_info; + uint8_t buf[128]; + size_t psk_len; +#ifdef PSK2_PR + coap_dtls_spsk_t *setup_data; +#endif /* PSK2_PR */ + coap_mbedtls_env_t *m_env; + + coap_log(LOG_DEBUG, "got psk_identity: '%.*s'\n", + (int)name_len, name); + + if (c_session == NULL || c_session->context == NULL || + c_session->context->get_server_psk == NULL) { + return -1; + } + m_env = (coap_mbedtls_env_t *)c_session->tls; +#ifdef PSK2_PR + setup_data = &c_session->context->spsk_setup_data; + + if (setup_data->validate_id_call_back) { + coap_bin_const_t lidentity; + lidentity.length = name_len; + lidentity.s = (const uint8_t*)name; + const coap_bin_const_t *psk_key = + setup_data->validate_id_call_back(&lidentity, + c_session, + setup_data->id_call_back_arg); + + if (psk_key == NULL) + return -1; + mbedtls_ssl_set_hs_psk(ssl, psk_key->s, psk_key->length); + coap_session_refresh_psk_key(c_session, psk_key); + m_env->seen_client_hello = 1; + return 0; + } +#endif /* PSK2_PR */ + + psk_len = c_session->context->get_server_psk(c_session, + (const uint8_t*)name, + name_len, + (uint8_t*)buf, sizeof(buf)); + m_env->seen_client_hello = 1; + mbedtls_ssl_set_hs_psk(ssl, buf, psk_len); + return 0; +} +#endif /* !ESPIDF_VERSION || CONFIG_MBEDTLS_SSL_PROTO_DTLS */ + +static char* +get_san_or_cn_from_cert(mbedtls_x509_crt *crt) +{ + if (crt) { +#if COAP_CONSTRAINED_STACK + static coap_mutex_t a_static_mutex = COAP_MUTEX_INITIALIZER; + static char buf[1024]; +#else /* ! COAP_CONSTRAINED_STACK */ + char buf[1024]; +#endif /* ! COAP_CONSTRAINED_STACK */ + char *cn; + char *cp; + char *tcp; + int n; + +#if COAP_CONSTRAINED_STACK + coap_mutex_lock(&a_static_mutex); +#endif /* COAP_CONSTRAINED_STACK */ + + mbedtls_x509_crt_info(buf, sizeof(buf) - 1, "", crt ); + + /* Look first to see if Subject Alt Name is defined */ + cp = strstr(buf, "subject alt name"); + if (cp) { + cp = strchr(cp, ':'); + if (cp) { + cp++; + while (*cp == ' ') cp++; + tcp = strchr(cp, '\n'); + if (tcp) + *tcp = '\000'; + /* Take only the first entry */ + tcp = strchr(cp, ','); + if (tcp) + *tcp = '\000'; + /* Return the Subject Alt Name */ +#if COAP_CONSTRAINED_STACK + coap_mutex_unlock(&a_static_mutex); +#endif /* COAP_CONSTRAINED_STACK */ + return mbedtls_strdup(cp); + } + } + + /* Pull CN= out of subject name */ + cp = strstr(buf, "subject name"); + if (cp) { + cp = strchr(cp, ':'); + if (cp) { + cp++; + while (*cp == ' ') cp++; + tcp = strchr(cp, '\n'); + if (tcp) + *tcp = '\000'; + + /* Need to emulate strcasestr() here. Looking for CN= */ + n = strlen(cp) - 3; + cn = cp; + while (n > 0) { + if (((cn[0] == 'C') || (cn[0] == 'c')) && + ((cn[1] == 'N') || (cn[1] == 'n')) && + (cn[2] == '=')) { + cn += 3; + break; + } + cn++; + n--; + } + if (n > 0) { + tcp = strchr(cn, ','); + if (tcp) + *tcp = '\000'; +#if COAP_CONSTRAINED_STACK + coap_mutex_unlock(&a_static_mutex); +#endif /* COAP_CONSTRAINED_STACK */ + return mbedtls_strdup(cn); + } + } + } +#if COAP_CONSTRAINED_STACK + coap_mutex_unlock(&a_static_mutex); +#endif /* COAP_CONSTRAINED_STACK */ + } + return NULL; +} + +/* + * return 0 All OK + * -ve Error Code + */ +static int +cert_verify_callback_mbedtls(void *data, mbedtls_x509_crt *crt, + int depth, uint32_t *flags) +{ + coap_session_t *c_session = (coap_session_t*)data; + coap_mbedtls_context_t *m_context = + (coap_mbedtls_context_t *)c_session->context->dtls_context; + coap_dtls_pki_t *setup_data = &m_context->setup_data; + char *cn = NULL; + + if (*flags == 0) + return 0; + + if (!setup_data->verify_peer_cert) { + /* Nothing is being checked */ + *flags = 0; + return 0; + } + + cn = get_san_or_cn_from_cert(crt); + + if (*flags & MBEDTLS_X509_BADCERT_EXPIRED) { + if (setup_data->allow_expired_certs) { + *flags &= ~MBEDTLS_X509_BADCERT_EXPIRED; + coap_log(LOG_WARNING, + " %s: %s: overridden: '%s' depth %d\n", + coap_session_str(c_session), + "The certificate has expired", cn ? cn : "?", depth); + } + } + if (*flags & MBEDTLS_X509_BADCERT_FUTURE) { + if (setup_data->allow_expired_certs) { + *flags &= ~MBEDTLS_X509_BADCERT_FUTURE; + coap_log(LOG_WARNING, + " %s: %s: overridden: '%s' depth %d\n", + coap_session_str(c_session), + "The certificate has a future date", cn ? cn : "?", depth); + } + } + if (*flags & MBEDTLS_X509_BADCERT_BAD_MD) { + if (setup_data->allow_bad_md_hash) { + *flags &= ~MBEDTLS_X509_BADCERT_BAD_MD; + coap_log(LOG_WARNING, + " %s: %s: overridden: '%s' depth %d\n", + coap_session_str(c_session), + "The certificate has a bad MD hash", cn ? cn : "?", depth); + } + } + if (*flags & MBEDTLS_X509_BADCERT_BAD_KEY) { + if (setup_data->allow_short_rsa_length) { + *flags &= ~MBEDTLS_X509_BADCERT_BAD_KEY; + coap_log(LOG_WARNING, + " %s: %s: overridden: '%s' depth %d\n", + coap_session_str(c_session), + "The certificate has a short RSA length", cn ? cn : "?", depth); + } + } + if (*flags & MBEDTLS_X509_BADCRL_EXPIRED) { + if (setup_data->check_cert_revocation && setup_data->allow_expired_crl) { + *flags &= ~MBEDTLS_X509_BADCRL_EXPIRED; + coap_log(LOG_WARNING, + " %s: %s: overridden: '%s' depth %d\n", + coap_session_str(c_session), + "The certificate's CRL has expired", cn ? cn : "?", depth); + } + else if (!setup_data->check_cert_revocation) { + *flags &= ~MBEDTLS_X509_BADCRL_EXPIRED; + } + } + if (*flags & MBEDTLS_X509_BADCRL_FUTURE) { + if (setup_data->check_cert_revocation && setup_data->allow_expired_crl) { + *flags &= ~MBEDTLS_X509_BADCRL_FUTURE; + coap_log(LOG_WARNING, + " %s: %s: overridden: '%s' depth %d\n", + coap_session_str(c_session), + "The certificate's CRL has a future date", cn ? cn : "?", depth); + } + else if (!setup_data->check_cert_revocation) { + *flags &= ~MBEDTLS_X509_BADCRL_FUTURE; + } + } + + if (*flags & MBEDTLS_X509_BADCERT_CN_MISMATCH) { + *flags &= ~MBEDTLS_X509_BADCERT_CN_MISMATCH; + } + if (setup_data->validate_cn_call_back) { + if (!setup_data->validate_cn_call_back(cn, + crt->raw.p, + crt->raw.len, + c_session, + depth, + *flags == 0, + setup_data->cn_call_back_arg)) { + *flags |= MBEDTLS_X509_BADCERT_CN_MISMATCH; + } + } + if (*flags != 0) { + char buf[128]; + char *tcp; + + mbedtls_x509_crt_verify_info(buf, sizeof(buf), "", *flags); + tcp = strchr(buf, '\n'); + while (tcp) { + *tcp = '\000'; + coap_log(LOG_WARNING, + " %s: %s: issue 0x%x: '%s' depth %d\n", + coap_session_str(c_session), + buf, *flags, cn ? cn : "?", depth); + tcp = strchr(tcp+1, '\n'); + } + } + + if (cn) + mbedtls_free(cn); + + return 0; +} + +static int +setup_pki_credentials(mbedtls_x509_crt *cacert, + mbedtls_x509_crt *public_cert, + mbedtls_pk_context *private_key, + coap_mbedtls_env_t *m_env, + coap_mbedtls_context_t *m_context, + coap_session_t *c_session, + coap_dtls_pki_t *setup_data, + coap_dtls_role_t role) +{ + int ret; + + switch (setup_data->pki_key.key_type) { + case COAP_PKI_KEY_PEM: + if (setup_data->pki_key.key.pem.public_cert && + setup_data->pki_key.key.pem.public_cert[0] && + setup_data->pki_key.key.pem.private_key && + setup_data->pki_key.key.pem.private_key[0]) { + + mbedtls_x509_crt_init(public_cert); + mbedtls_pk_init(private_key); + + ret = mbedtls_x509_crt_parse_file(public_cert, + setup_data->pki_key.key.pem.public_cert); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_x509_crt_parse_file returned -0x%x\n\n", + -ret); + return ret; + } + + ret = mbedtls_pk_parse_keyfile(private_key, + setup_data->pki_key.key.pem.private_key, NULL); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_pk_parse_keyfile returned -0x%x\n\n", -ret); + return ret; + } + + ret = mbedtls_ssl_conf_own_cert(&m_env->conf, public_cert, private_key); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_ssl_conf_own_cert returned -0x%x\n\n", -ret); + return ret; + } + } + else if (role == COAP_DTLS_ROLE_SERVER) { + coap_log(LOG_ERR, + "***setup_pki: (D)TLS: No %s Certificate + Private " + "Key defined\n", + role == COAP_DTLS_ROLE_SERVER ? "Server" : "Client"); + return -1; + } + + if (setup_data->pki_key.key.pem.ca_file && + setup_data->pki_key.key.pem.ca_file[0]) { + mbedtls_x509_crt_init(cacert); + ret = mbedtls_x509_crt_parse_file(cacert, + setup_data->pki_key.key.pem.ca_file); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_x509_crt_parse returned -0x%x\n\n", -ret); + return ret; + } + mbedtls_ssl_conf_authmode(&m_env->conf, setup_data->require_peer_cert ? + MBEDTLS_SSL_VERIFY_REQUIRED : + MBEDTLS_SSL_VERIFY_OPTIONAL); + mbedtls_ssl_conf_ca_chain(&m_env->conf, cacert, NULL); + } + break; + case COAP_PKI_KEY_PEM_BUF: + if (setup_data->pki_key.key.pem_buf.public_cert && + setup_data->pki_key.key.pem_buf.public_cert_len && + setup_data->pki_key.key.pem_buf.private_key && + setup_data->pki_key.key.pem_buf.private_key_len > 0) { + mbedtls_x509_crt_init(public_cert); + mbedtls_pk_init(private_key); + ret = mbedtls_x509_crt_parse(public_cert, + (const unsigned char *)setup_data->pki_key.key.pem_buf.public_cert, + setup_data->pki_key.key.pem_buf.public_cert_len); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_x509_crt_parse returned -0x%x\n\n", -ret); + return ret; + } + + ret = mbedtls_pk_parse_key(private_key, + (const unsigned char *)setup_data->pki_key.key.pem_buf.private_key, + setup_data->pki_key.key.pem_buf.private_key_len, NULL, 0); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_pk_parse_keyfile returned -0x%x\n\n", -ret); + return ret; + } + + ret = mbedtls_ssl_conf_own_cert(&m_env->conf, public_cert, private_key); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_ssl_conf_own_cert returned -0x%x\n\n", -ret); + return ret; + } + } else if (role == COAP_DTLS_ROLE_SERVER) { + coap_log(LOG_ERR, + "***setup_pki: (D)TLS: No %s Certificate + Private " + "Key defined\n", + role == COAP_DTLS_ROLE_SERVER ? "Server" : "Client"); + return -1; + } + + if (setup_data->pki_key.key.pem_buf.ca_cert && + setup_data->pki_key.key.pem_buf.ca_cert_len > 0) { + mbedtls_x509_crt_init(cacert); + ret = mbedtls_x509_crt_parse(cacert, + (const unsigned char *)setup_data->pki_key.key.pem_buf.ca_cert, + setup_data->pki_key.key.pem_buf.ca_cert_len); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_x509_crt_parse returned -0x%x\n\n", -ret); + return ret; + } + mbedtls_ssl_conf_authmode(&m_env->conf, setup_data->require_peer_cert ? + MBEDTLS_SSL_VERIFY_REQUIRED : + MBEDTLS_SSL_VERIFY_OPTIONAL); + mbedtls_ssl_conf_ca_chain(&m_env->conf, cacert, NULL); + } + break; + case COAP_PKI_KEY_ASN1: + if (setup_data->pki_key.key.asn1.public_cert && + setup_data->pki_key.key.asn1.public_cert_len && + setup_data->pki_key.key.asn1.private_key && + setup_data->pki_key.key.asn1.private_key_len > 0) { + + mbedtls_x509_crt_init(public_cert); + mbedtls_pk_init(private_key); + ret = mbedtls_x509_crt_parse(public_cert, + (const unsigned char *)setup_data->pki_key.key.asn1.public_cert, + setup_data->pki_key.key.asn1.public_cert_len); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_x509_crt_parse returned -0x%x\n\n", -ret); + return ret; + } + + ret = mbedtls_pk_parse_key(private_key, + (const unsigned char *)setup_data->pki_key.key.asn1.private_key, + setup_data->pki_key.key.asn1.private_key_len, NULL, 0); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_pk_parse_keyfile returned -0x%x\n\n", -ret); + return ret; + } + + ret = mbedtls_ssl_conf_own_cert(&m_env->conf, public_cert, private_key); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_ssl_conf_own_cert returned -0x%x\n\n", -ret); + return ret; + } + } else if (role == COAP_DTLS_ROLE_SERVER) { + coap_log(LOG_ERR, + "***setup_pki: (D)TLS: No %s Certificate + Private " + "Key defined\n", + role == COAP_DTLS_ROLE_SERVER ? "Server" : "Client"); + return -1; + } + + if (setup_data->pki_key.key.asn1.ca_cert && + setup_data->pki_key.key.asn1.ca_cert_len > 0) { + mbedtls_x509_crt_init(cacert); + ret = mbedtls_x509_crt_parse(cacert, + (const unsigned char *)setup_data->pki_key.key.asn1.ca_cert, + setup_data->pki_key.key.asn1.ca_cert_len); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_x509_crt_parse returned -0x%x\n\n", -ret); + return ret; + } + mbedtls_ssl_conf_authmode(&m_env->conf, setup_data->require_peer_cert ? + MBEDTLS_SSL_VERIFY_REQUIRED : + MBEDTLS_SSL_VERIFY_OPTIONAL); + mbedtls_ssl_conf_ca_chain(&m_env->conf, cacert, NULL); + } + break; + default: + coap_log(LOG_ERR, + "***setup_pki: (D)TLS: Unknown key type %d\n", + setup_data->pki_key.key_type); + return -1; + } + + if (m_context->root_ca_file) { + ret = mbedtls_x509_crt_parse_file(cacert, m_context->root_ca_file); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_x509_crt_parse returned -0x%x\n\n", -ret); + return ret; + } + mbedtls_ssl_conf_ca_chain(&m_env->conf, cacert, NULL); + } + if (m_context->root_ca_path) { + ret = mbedtls_x509_crt_parse_file(cacert, m_context->root_ca_path); + if (ret < 0) { + coap_log(LOG_ERR, "mbedtls_x509_crt_parse returned -0x%x\n\n", -ret); + return ret; + } + mbedtls_ssl_conf_ca_chain(&m_env->conf, cacert, NULL); + } + + /* + * Verify Peer. + * Need to do all checking, even if setup_data->verify_peer_cert is not set + */ + mbedtls_ssl_conf_verify(&m_env->conf, + cert_verify_callback_mbedtls, c_session); + + return 0; +} + +/* + * PKI SNI callback. + */ +static int +pki_sni_callback(void *p_info, mbedtls_ssl_context *ssl, + const unsigned char *uname, size_t name_len) +{ + unsigned int i; + coap_dtls_pki_t sni_setup_data; + coap_session_t *c_session = (coap_session_t *)p_info; + coap_mbedtls_env_t *m_env = (coap_mbedtls_env_t *)c_session->tls; + coap_mbedtls_context_t *m_context = + (coap_mbedtls_context_t *)c_session->context->dtls_context; + int ret = 0; + + /* Is this a cached entry? */ + for (i = 0; i < m_context->pki_sni_count; i++) { + if (name_len == strlen(m_context->pki_sni_entry_list[i].sni) && + memcmp(uname, m_context->pki_sni_entry_list[i].sni, name_len) == 0) { + break; + } + } + if (i == m_context->pki_sni_count) { + /* + * New PKI SNI request + */ + char *name; + coap_dtls_key_t *new_entry; + + name = mbedtls_malloc(name_len+1); + memcpy(name, uname, name_len); + name[name_len] = '\000'; + new_entry = + m_context->setup_data.validate_sni_call_back(name, + m_context->setup_data.sni_call_back_arg); + if (!new_entry) { + ret = -1; + mbedtls_free(name); + goto end; + } + + m_context->pki_sni_entry_list = + mbedtls_realloc(m_context->pki_sni_entry_list, + (i+1)*sizeof(pki_sni_entry)); + m_context->pki_sni_entry_list[i].sni = name; + m_context->pki_sni_entry_list[i].pki_key = *new_entry; + sni_setup_data = m_context->setup_data; + sni_setup_data.pki_key = *new_entry; + if ((ret = setup_pki_credentials(&m_context->pki_sni_entry_list[i].cacert, + &m_context->pki_sni_entry_list[i].public_cert, + &m_context->pki_sni_entry_list[i].private_key, + m_env, + m_context, + c_session, + &sni_setup_data, COAP_DTLS_ROLE_SERVER)) < 0) { + ret = -1; + mbedtls_free(name); + goto end; + } + m_context->pki_sni_count++; + } + +end: + if (ret != -1) { + mbedtls_ssl_set_hs_ca_chain(ssl, &m_context->pki_sni_entry_list[i].cacert, + NULL); + return mbedtls_ssl_set_hs_own_cert(ssl, + &m_context->pki_sni_entry_list[i].public_cert, + &m_context->pki_sni_entry_list[i].private_key); + } + return ret; +} + +#ifdef PSK2_PR +/* + * PSK SNI callback. + */ +static int +psk_sni_callback(void *p_info, mbedtls_ssl_context *ssl, + const unsigned char *uname, size_t name_len) +{ + unsigned int i; + coap_dtls_spsk_t sni_setup_data; + coap_session_t *c_session = (coap_session_t *)p_info; + coap_mbedtls_context_t *m_context = + (coap_mbedtls_context_t *)c_session->context->dtls_context; + int ret = 0; + + /* Is this a cached entry? */ + for (i = 0; i < m_context->psk_sni_count; i++) { + if (name_len == m_context->psk_sni_entry_list[i].sni.length && + memcmp(uname, m_context->psk_sni_entry_list[i].sni.s, name_len) == 0) { + break; + } + } + if (i == m_context->psk_sni_count) { + /* + * New PSK SNI request + */ + coap_str_const_t lsni; + uint8_t *name; + const coap_dtls_spsk_info_t *new_entry; + + name = mbedtls_malloc(name_len+1); + memcpy(name, uname, name_len); + name[name_len] = '\000'; + + lsni.s = name; + lsni.length = name_len; + new_entry = + c_session->context->spsk_setup_data.validate_sni_call_back(&lsni, + c_session, + c_session->context->spsk_setup_data.sni_call_back_arg); + if (!new_entry) { + ret = -1; + mbedtls_free(name); + goto end; + } + + m_context->psk_sni_entry_list = + mbedtls_realloc(m_context->psk_sni_entry_list, + (i+1)*sizeof(psk_sni_entry)); + + m_context->psk_sni_entry_list[i].sni.s = name; + m_context->psk_sni_entry_list[i].sni.length = name_len; + m_context->psk_sni_entry_list[i].psk_info = *new_entry; + sni_setup_data = c_session->context->spsk_setup_data; + sni_setup_data.psk_info = *new_entry; + m_context->psk_sni_count++; + } + +end: + if (ret != -1) { + coap_session_refresh_psk_hint(c_session, + &m_context->psk_sni_entry_list[i].psk_info.hint); + coap_session_refresh_psk_key(c_session, + &m_context->psk_sni_entry_list[i].psk_info.key); + return mbedtls_ssl_set_hs_psk(ssl, + m_context->psk_sni_entry_list[i].psk_info.key.s, + m_context->psk_sni_entry_list[i].psk_info.key.length); + } + return ret; +} +#endif /* PSK2_PR */ + +static int setup_server_ssl_session(coap_session_t *c_session, + coap_mbedtls_env_t *m_env) +{ + coap_mbedtls_context_t *m_context = + (coap_mbedtls_context_t *)c_session->context->dtls_context; + int ret = 0; + m_context->psk_pki_enabled |= IS_SERVER; + + mbedtls_ssl_cookie_init(&m_env->cookie_ctx); + if ((ret = mbedtls_ssl_config_defaults(&m_env->conf, + MBEDTLS_SSL_IS_SERVER, + c_session->proto == COAP_PROTO_DTLS ? + MBEDTLS_SSL_TRANSPORT_DATAGRAM : + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT)) != 0) { + coap_log(LOG_ERR, "mbedtls_ssl_config_defaults returned -0x%x\n", -ret); + goto fail; + } + + mbedtls_ssl_conf_rng(&m_env->conf, mbedtls_ctr_drbg_random, &m_env->ctr_drbg); + +#if !defined(ESPIDF_VERSION) || defined(CONFIG_MBEDTLS_SSL_PROTO_DTLS) + mbedtls_ssl_conf_handshake_timeout(&m_env->conf, 1000, 60000); + + if (m_context->psk_pki_enabled & IS_PSK) { +#if !defined(ESPIDF_VERSION) || defined(CONFIG_MBEDTLS_PSK_MODES) + mbedtls_ssl_conf_psk_cb(&m_env->conf, psk_server_callback, c_session); +#ifdef PSK2_PR + if (c_session->context->spsk_setup_data.validate_sni_call_back) { + mbedtls_ssl_conf_sni(&m_env->conf, psk_sni_callback, c_session); + } +#endif /* PSK2_PR */ +#endif /* !ESPIDF_VERSION || CONFIG_MBEDTLS_PSK_MODES */ + } +#endif /* !ESPIDF_VERSION || CONFIG_MBEDTLS_SSL_PROTO_DTLS */ + + if (m_context->psk_pki_enabled & IS_PKI) { + ret = setup_pki_credentials(&m_env->cacert, &m_env->public_cert, + &m_env->private_key, m_env, m_context, + c_session, &m_context->setup_data, + COAP_DTLS_ROLE_SERVER); + if (ret < 0) { + coap_log(LOG_ERR, "PKI setup failed\n"); + return ret; + } + if (m_context->setup_data.validate_sni_call_back) { + mbedtls_ssl_conf_sni(&m_env->conf, pki_sni_callback, c_session); + } + } + + if ((ret = mbedtls_ssl_cookie_setup(&m_env->cookie_ctx, + mbedtls_ctr_drbg_random, + &m_env->ctr_drbg)) != 0) { + coap_log(LOG_ERR, "mbedtls_ssl_cookie_setup: returned -0x%x\n", -ret); + goto fail; + } + +#if !defined(ESPIDF_VERSION) || defined(CONFIG_MBEDTLS_SSL_PROTO_DTLS) + mbedtls_ssl_conf_dtls_cookies(&m_env->conf, mbedtls_ssl_cookie_write, + mbedtls_ssl_cookie_check, + &m_env->cookie_ctx ); + mbedtls_ssl_set_mtu(&m_env->ssl, c_session->mtu); +#endif /* !ESPIDF_VERSION || CONFIG_MBEDTLS_SSL_PROTO_DTLS */ +fail: + return ret; +} + +#define MAX_CIPHERS 100 +static int psk_ciphers[MAX_CIPHERS]; +static int pki_ciphers[MAX_CIPHERS]; +static int processed_ciphers = 0; + +static void +set_ciphersuites(mbedtls_ssl_config *conf, int is_psk) +{ + if (!processed_ciphers) { + const int *list = mbedtls_ssl_list_ciphersuites(); + int *psk_list = psk_ciphers; + int *pki_list = pki_ciphers; + + while (*list) { + const mbedtls_ssl_ciphersuite_t *cur = + mbedtls_ssl_ciphersuite_from_id(*list); + + if (cur) { + if (mbedtls_ssl_ciphersuite_uses_psk(cur)) { + if (&psk_ciphers[MAX_CIPHERS] - psk_list > 1) { + *psk_list = *list; + psk_list++; + } + else { + static int done = 0; + + if (!done) { + done = 1; + coap_log(LOG_ERR, "psk_ciphers[MAX_CIPHERS] insufficient\n"); + } + } + } + else { + if (&pki_ciphers[MAX_CIPHERS] - pki_list > 1) { + *pki_list = *list; + pki_list++; + } + else { + static int done = 0; + + if (!done) { + done = 1; + coap_log(LOG_ERR, "pki_ciphers[MAX_CIPHERS] insufficient\n"); + } + } + } + } + list++; + } + /* zero terminate */ + *psk_list = 0; + *pki_list = 0; + processed_ciphers = 1; + } + mbedtls_ssl_conf_ciphersuites(conf, is_psk ? psk_ciphers : pki_ciphers); +} + +static int setup_client_ssl_session(coap_session_t *c_session, + coap_mbedtls_env_t *m_env) +{ + int ret; + + coap_mbedtls_context_t *m_context = + (coap_mbedtls_context_t *)c_session->context->dtls_context; + + m_context->psk_pki_enabled |= IS_CLIENT; + + if ((ret = mbedtls_ssl_config_defaults(&m_env->conf, + MBEDTLS_SSL_IS_CLIENT, + c_session->proto == COAP_PROTO_DTLS ? + MBEDTLS_SSL_TRANSPORT_DATAGRAM : + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT)) != 0) { + coap_log(LOG_ERR, "mbedtls_ssl_config_defaults returned -0x%x", -ret); + goto fail; + } + +#if !defined(ESPIDF_VERSION) || defined(CONFIG_MBEDTLS_SSL_PROTO_DTLS) + mbedtls_ssl_conf_handshake_timeout(&m_env->conf, 1000, 60000); +#endif /* !ESPIDF_VERSION || CONFIG_MBEDTLS_SSL_PROTO_DTLS */ + + mbedtls_ssl_conf_authmode(&m_env->conf, MBEDTLS_SSL_VERIFY_REQUIRED); + mbedtls_ssl_conf_rng(&m_env->conf, mbedtls_ctr_drbg_random, &m_env->ctr_drbg); + + if (m_context->psk_pki_enabled & IS_PSK) { +#if !defined(ESPIDF_VERSION) || defined(CONFIG_MBEDTLS_PSK_MODES) + uint8_t identity[64]; + size_t identity_len; + uint8_t psk_key[64]; + size_t psk_len; + size_t max_identity_len = sizeof(identity); + + coap_log(LOG_INFO, "Setting PSK key\n"); + psk_len = c_session->context->get_client_psk(c_session, + NULL, + 0, + identity, + &identity_len, + max_identity_len, + psk_key, + sizeof(psk_key)); + assert(identity_len < sizeof(identity)); + mbedtls_ssl_conf_psk(&m_env->conf, (const unsigned char *)psk_key, + psk_len, (const unsigned char *)identity, + identity_len); +#ifdef PSK2_PR + if (c_session->cpsk_setup_data.client_sni) { + mbedtls_ssl_set_hostname(&m_env->ssl, + c_session->cpsk_setup_data.client_sni); + } +#if 0 +/* Identity Hint currently not supported in MbedTLS */ + if (c_session->cpsk_setup_data.validate_ih_call_back) { + coap_log(LOG_DEBUG, + "CoAP Client restricted to (D)TLS1.2 with Identity Hint callback\n"); + mbedtls_ssl_conf_max_version(&m_env->conf, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3); + } +#endif +#endif /* PSK2_PR */ + set_ciphersuites(&m_env->conf, 1); +#endif /* !ESPIDF_VERSION || CONFIG_MBEDTLS_PSK_MODES */ + } + else if ((m_context->psk_pki_enabled & IS_PKI) || + (m_context->psk_pki_enabled & (IS_PSK | IS_PKI)) == 0) { + /* + * If neither PSK or PKI have been set up, use PKI basics. + * This works providing COAP_PKI_KEY_PEM has a value of 0. + */ + if ((m_context->psk_pki_enabled & (IS_PSK | IS_PKI)) == 0) { + mbedtls_ssl_conf_authmode(&m_env->conf, MBEDTLS_SSL_VERIFY_OPTIONAL); + } + ret = setup_pki_credentials(&m_env->cacert, &m_env->public_cert, + &m_env->private_key, m_env, m_context, + c_session, &m_context->setup_data, + COAP_DTLS_ROLE_CLIENT); + if (ret < 0) { + coap_log(LOG_ERR, "PKI setup failed\n"); + return ret; + } + if (c_session->proto == COAP_PROTO_TLS) { + const char *alpn_list[2]; + + memset(alpn_list, 0, sizeof(alpn_list)); + alpn_list[0] = "coap"; + ret = mbedtls_ssl_conf_alpn_protocols(&m_env->conf, alpn_list); + if (ret != 0) { + coap_log(LOG_ERR, "ALPN setup failed %d)\n", ret); + } + } + if (m_context->setup_data.client_sni) { + mbedtls_ssl_set_hostname(&m_env->ssl, m_context->setup_data.client_sni); + } +#if !defined(ESPIDF_VERSION) || defined(CONFIG_MBEDTLS_SSL_PROTO_DTLS) + mbedtls_ssl_set_mtu(&m_env->ssl, c_session->mtu); +#endif /* !ESPIDF_VERSION || CONFIG_MBEDTLS_SSL_PROTO_DTLS */ + set_ciphersuites(&m_env->conf, 0); + } + return 0; + +fail: + return ret; +} + +static void mbedtls_cleanup(coap_mbedtls_env_t *m_env) +{ + if (!m_env) { + return; + } + + mbedtls_x509_crt_free(&m_env->cacert); + mbedtls_x509_crt_free(&m_env->public_cert); + mbedtls_pk_free(&m_env->private_key); + mbedtls_entropy_free(&m_env->entropy); + mbedtls_ssl_config_free(&m_env->conf); + mbedtls_ctr_drbg_free(&m_env->ctr_drbg); + mbedtls_ssl_free(&m_env->ssl); + mbedtls_ssl_cookie_free(&m_env->cookie_ctx); +} + +static void +coap_dtls_free_mbedtls_env(coap_mbedtls_env_t *m_env) { + if (m_env) { + mbedtls_cleanup(m_env); + free(m_env); + } +} + +/* + * return -1 failure + * 0 not completed + * 1 established + */ +static int do_mbedtls_handshake(coap_session_t *c_session, + coap_mbedtls_env_t *m_env) { + int ret; + char buf[128]; + + ret = mbedtls_ssl_handshake(&m_env->ssl); + switch (ret) { + case 0: + m_env->established = 1; + coap_log(LOG_DEBUG, "* %s: MbedTLS established\n", + coap_session_str(c_session)); + ret = 1; + break; + case MBEDTLS_ERR_SSL_WANT_READ: + case MBEDTLS_ERR_SSL_WANT_WRITE: + errno = EAGAIN; + ret = 0; + break; + case MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED: + coap_log(LOG_INFO, "hello verification requested\n"); + ret = -1; + mbedtls_ssl_session_reset(&m_env->ssl); + break; + case MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE: + c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; + ret = -1; + break; + default: + mbedtls_strerror(ret, buf, sizeof(buf)); + coap_log(LOG_WARNING, + "do_mbedtls_handshake: session establish " + "returned -0x%x: '%s'\n", + -ret, buf); + ret = -1; + break; + } + return ret; +} + +static void +mbedtls_debug_out(void *ctx UNUSED, int level, + const char *file, int line, const char *str) { + int log_level; + + switch (level) { + case 4: + case 3: + case 2: + log_level = LOG_DEBUG; + break; + case 1: + log_level = LOG_ERR; + break; + case 0: + default: + log_level = 0; + break; + } + coap_log(log_level, "%s:%04d: %s", file, line, str); +} + +static coap_mbedtls_env_t *coap_dtls_new_mbedtls_env(coap_session_t *c_session, + coap_dtls_role_t role) +{ + int ret = 0; + coap_mbedtls_env_t *m_env = (coap_mbedtls_env_t *)c_session->tls; + + if (m_env) + return m_env; + + m_env = (coap_mbedtls_env_t *)calloc(1, sizeof(coap_mbedtls_env_t)); + if (!m_env) { + return NULL; + } + + mbedtls_ssl_init(&m_env->ssl); + mbedtls_ctr_drbg_init(&m_env->ctr_drbg); + mbedtls_ssl_config_init(&m_env->conf); + mbedtls_entropy_init(&m_env->entropy); + +#if defined(ESPIDF_VERSION) && defined(CONFIG_MBEDTLS_DEBUG) + mbedtls_esp_enable_debug_log(&m_env->conf, CONFIG_MBEDTLS_DEBUG_LEVEL); +#endif /* ESPIDF_VERSION && CONFIG_MBEDTLS_DEBUG */ + if ((ret = mbedtls_ctr_drbg_seed(&m_env->ctr_drbg, + mbedtls_entropy_func, &m_env->entropy, NULL, 0)) != 0) { + coap_log(LOG_ERR, "mbedtls_ctr_drbg_seed returned -0x%x", -ret); + goto fail; + } + + if (role == COAP_DTLS_ROLE_CLIENT) { + if (setup_client_ssl_session(c_session, m_env) != 0) { + goto fail; + } + } else if (role == COAP_DTLS_ROLE_SERVER) { + if (setup_server_ssl_session(c_session, m_env) != 0) { + goto fail; + } + } else { + goto fail; + } + + if ((ret = mbedtls_ssl_setup(&m_env->ssl, &m_env->conf)) != 0) { + goto fail; + } + mbedtls_ssl_set_bio(&m_env->ssl, c_session, coap_dgram_write, + coap_dgram_read, NULL); + mbedtls_ssl_set_timer_cb(&m_env->ssl, &m_env->timer, + mbedtls_timing_set_delay, + mbedtls_timing_get_delay); + + mbedtls_ssl_conf_dbg(&m_env->conf, mbedtls_debug_out, stdout); + return m_env; + +fail: + if (m_env) { + free(m_env); + } + return NULL; +} + +int coap_dtls_is_supported(void) { +#if !defined(ESPIDF_VERSION) || defined(CONFIG_MBEDTLS_SSL_PROTO_DTLS) + return 1; +#else /* ESPIDF_VERSION && !CONFIG_MBEDTLS_SSL_PROTO_DTLS */ + coap_log(LOG_EMERG, + "libcoap not compiled for DTLS with MbedTLS" + " - update MbedTLS to include DTLS\n"); + return 0; +#endif /* ESPIDF_VERSION && !CONFIG_MBEDTLS_SSL_PROTO_DTLS */ +} + +int coap_tls_is_supported(void) +{ + return 0; +} + +void *coap_dtls_new_context(struct coap_context_t *c_context) +{ + coap_mbedtls_context_t *m_context; + (void)c_context; + + m_context = (coap_mbedtls_context_t *)calloc(1, sizeof(coap_mbedtls_context_t)); + if (m_context) { + memset(m_context, 0, sizeof(coap_mbedtls_context_t)); + } + return m_context; +} + +#ifndef PSK2_PR +int coap_dtls_context_set_psk(struct coap_context_t *c_context, + const char *identity_hint UNUSED, + coap_dtls_role_t role UNUSED) +{ + coap_mbedtls_context_t *m_context = + ((coap_mbedtls_context_t *)c_context->dtls_context); + m_context->psk_pki_enabled |= IS_PSK; + return 1; +} +#else /* PSK2_PR */ +/* + * return 0 failed + * 1 passed + */ +int +coap_dtls_context_set_spsk(coap_context_t *c_context, + coap_dtls_spsk_t *setup_data +) { + coap_mbedtls_context_t *m_context = + ((coap_mbedtls_context_t *)c_context->dtls_context); + + if (!m_context || !setup_data) + return 0; + + m_context->psk_pki_enabled |= IS_PSK; + return 1; +} + +/* + * return 0 failed + * 1 passed + */ +int +coap_dtls_context_set_cpsk(coap_context_t *c_context, + coap_dtls_cpsk_t *setup_data +) { + coap_mbedtls_context_t *m_context = + ((coap_mbedtls_context_t *)c_context->dtls_context); + + if (!m_context || !setup_data) + return 0; + + if (setup_data->validate_ih_call_back) { + coap_log(LOG_WARNING, + "CoAP Client with MbedTLS does not support Identity Hint selection\n"); + } + m_context->psk_pki_enabled |= IS_PSK; + return 1; +} + +#endif /* PSK2_PR */ + +int coap_dtls_context_set_pki(struct coap_context_t *c_context, + coap_dtls_pki_t *setup_data, + coap_dtls_role_t role UNUSED) +{ + coap_mbedtls_context_t *m_context = + ((coap_mbedtls_context_t *)c_context->dtls_context); + + m_context->setup_data = *setup_data; + m_context->psk_pki_enabled |= IS_PKI; + return 1; +} + +int coap_dtls_context_set_pki_root_cas(struct coap_context_t *c_context, + const char *ca_file, + const char *ca_path) +{ + coap_mbedtls_context_t *m_context = + ((coap_mbedtls_context_t *)c_context->dtls_context); + if (!m_context) { + coap_log(LOG_WARNING, + "coap_context_set_pki_root_cas: (D)TLS environment " + "not set up\n"); + return 0; + } + + if (ca_file == NULL && ca_path == NULL) { + coap_log(LOG_WARNING, + "coap_context_set_pki_root_cas: ca_file and/or ca_path " + "not defined\n"); + return 0; + } + if (m_context->root_ca_file) { + free(m_context->root_ca_file); + m_context->root_ca_file = NULL; + } + + if (ca_file) { + m_context->root_ca_file = mbedtls_strdup(ca_file); + } + + if (m_context->root_ca_path) { + free(m_context->root_ca_path); + m_context->root_ca_path = NULL; + } + + if (ca_path) { + m_context->root_ca_path = mbedtls_strdup(ca_path); + } + return 1; +} + +int coap_dtls_context_check_keys_enabled(struct coap_context_t *c_context) +{ + coap_mbedtls_context_t *m_context = + ((coap_mbedtls_context_t *)c_context->dtls_context); + return m_context->psk_pki_enabled ? 1 : 0; +} + +void coap_dtls_free_context(void *dtls_context) +{ + coap_mbedtls_context_t *m_context = (coap_mbedtls_context_t *)dtls_context; + unsigned int i; + + for (i = 0; i < m_context->pki_sni_count; i++) { + mbedtls_free(m_context->pki_sni_entry_list[i].sni); + + mbedtls_x509_crt_free(&m_context->pki_sni_entry_list[i].public_cert); + + mbedtls_pk_free(&m_context->pki_sni_entry_list[i].private_key); + + mbedtls_x509_crt_free(&m_context->pki_sni_entry_list[i].cacert); + } +#ifdef PSK2_PR + for (i = 0; i < m_context->psk_sni_count; i++) { + mbedtls_free(m_context->psk_sni_entry_list[i].sni.s); + } + if (m_context->psk_sni_entry_list) + mbedtls_free(m_context->pki_sni_entry_list); + +#endif /* PSK2_PR */ + + free(m_context); +} + +void *coap_dtls_new_client_session(coap_session_t *c_session) +{ + coap_mbedtls_env_t *m_env = coap_dtls_new_mbedtls_env(c_session, + COAP_DTLS_ROLE_CLIENT); + int ret; + + if (m_env) { + ret = do_mbedtls_handshake(c_session, m_env); + if (ret == -1) { + coap_dtls_free_mbedtls_env(m_env); + return NULL; + } + } + return m_env; +} + +void *coap_dtls_new_server_session(coap_session_t *c_session) +{ + coap_mbedtls_env_t *m_env = + (coap_mbedtls_env_t *)c_session->tls; + if (m_env) { + m_env->seen_client_hello = 1; +#if !defined(ESPIDF_VERSION) || defined(CONFIG_MBEDTLS_SSL_PROTO_DTLS) + mbedtls_ssl_set_mtu(&m_env->ssl, c_session->mtu); +#endif /* !ESPIDF_VERSION || CONFIG_MBEDTLS_SSL_PROTO_DTLS */ + } + return m_env; +} + +void coap_dtls_free_session(coap_session_t *c_session) +{ + if (c_session && c_session->context) { + coap_dtls_free_mbedtls_env(c_session->tls); + c_session->tls = NULL; + } + return; +} + +void coap_dtls_session_update_mtu(coap_session_t *c_session) +{ +#if !defined(ESPIDF_VERSION) || defined(CONFIG_MBEDTLS_SSL_PROTO_DTLS) + coap_mbedtls_env_t *m_env = + (coap_mbedtls_env_t *)c_session->tls; + if (m_env) { + mbedtls_ssl_set_mtu(&m_env->ssl, c_session->mtu); + } +#endif /* !ESPIDF_VERSION || CONFIG_MBEDTLS_SSL_PROTO_DTLS */ +} + +int coap_dtls_send(coap_session_t *c_session, + const uint8_t *data, + size_t data_len) +{ + int ret; + coap_mbedtls_env_t *m_env = (coap_mbedtls_env_t *)c_session->tls; + char buf[128]; + + assert(m_env != NULL); + + if (!m_env) { + return -1; + } + c_session->dtls_event = -1; + if (m_env->established) { + ret = mbedtls_ssl_write(&m_env->ssl, (const unsigned char*) data, data_len); + if (ret <= 0) { + switch (ret) { + case MBEDTLS_ERR_SSL_WANT_READ: + case MBEDTLS_ERR_SSL_WANT_WRITE: + ret = 0; + break; + case MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE: + c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; + ret = -1; + break; + default: + mbedtls_strerror(ret, buf, sizeof(buf)); + coap_log(LOG_WARNING, + "coap_dtls_send: " + "returned -0x%x: '%s'\n", + -ret, buf); + ret = -1; + break; + } + if (ret == -1) { + coap_log(LOG_WARNING, "coap_dtls_send: cannot send PDU\n"); + } + } + } else { + ret = do_mbedtls_handshake(c_session, m_env); + if (ret == 1) { + /* Just connected, so send the data */ + return coap_dtls_send(c_session, data, data_len); + } + ret = -1; + } + + if (c_session->dtls_event >= 0) { + coap_handle_event(c_session->context, c_session->dtls_event, c_session); + if (c_session->dtls_event == COAP_EVENT_DTLS_ERROR || + c_session->dtls_event == COAP_EVENT_DTLS_CLOSED) { + coap_session_disconnected(c_session, COAP_NACK_TLS_FAILED); + ret = -1; + } + } + return ret; +} + +int coap_dtls_is_context_timeout(void) +{ + return 0; +} + +coap_tick_t coap_dtls_get_context_timeout(void *dtls_context UNUSED) +{ + return 0; +} + +coap_tick_t coap_dtls_get_timeout(coap_session_t *c_session, coap_tick_t now) +{ + coap_mbedtls_env_t *m_env = (coap_mbedtls_env_t *)c_session->tls; + int ret = mbedtls_timing_get_delay(&m_env->timer); + + switch (ret) { + case 0: + case 1: + /* int_ms has timed out, but not fin_ms */ + return now + 1; + case 2: + /* fin_ms has timed out - time for a retry */ + return now; + default: + break; + } + + return 0; +} + +void coap_dtls_handle_timeout(coap_session_t *c_session) +{ + coap_mbedtls_env_t *m_env = (coap_mbedtls_env_t *)c_session->tls; + + assert(m_env != NULL); + if (((c_session->state == COAP_SESSION_STATE_HANDSHAKE) && + (++c_session->dtls_timeout_count > c_session->max_retransmit)) || + (do_mbedtls_handshake(c_session, m_env) < 0)) { + /* Too many retries */ + coap_session_disconnected(c_session, COAP_NACK_TLS_FAILED); + } + return; +} + +int coap_dtls_receive(coap_session_t *c_session, + const uint8_t *data, + size_t data_len) +{ + int ret = 1; + + c_session->dtls_event = -1; + coap_mbedtls_env_t *m_env = (coap_mbedtls_env_t *)c_session->tls; + assert(m_env != NULL); + + coap_ssl_t *ssl_data = &m_env->coap_ssl_data; + if (ssl_data->pdu_len) { + coap_log(LOG_INFO, "** %s: Previous data not read %u bytes\n", + coap_session_str(c_session), ssl_data->pdu_len); + } + ssl_data->pdu = data; + ssl_data->pdu_len = (unsigned)data_len; + + if (m_env->established) { +#if COAP_CONSTRAINED_STACK + static coap_mutex_t b_static_mutex = COAP_MUTEX_INITIALIZER; + static uint8_t pdu[COAP_RXBUFFER_SIZE]; +#else /* ! COAP_CONSTRAINED_STACK */ + uint8_t pdu[COAP_RXBUFFER_SIZE]; +#endif /* ! COAP_CONSTRAINED_STACK */ + +#if COAP_CONSTRAINED_STACK + coap_mutex_lock(&b_static_mutex); +#endif /* COAP_CONSTRAINED_STACK */ + + if (c_session->state == COAP_SESSION_STATE_HANDSHAKE) { + coap_handle_event(c_session->context, COAP_EVENT_DTLS_CONNECTED, + c_session); + coap_session_connected(c_session); + } + + ret = mbedtls_ssl_read(&m_env->ssl, pdu, (int)sizeof(pdu)); + if (ret > 0) { + ret = coap_handle_dgram(c_session->context, c_session, pdu, (size_t)ret); +#if COAP_CONSTRAINED_STACK + coap_mutex_unlock(&b_static_mutex); +#endif /* COAP_CONSTRAINED_STACK */ + return ret; + } + else if (ret == 0 || ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { + c_session->dtls_event = COAP_EVENT_DTLS_CLOSED; + } + else if (ret != MBEDTLS_ERR_SSL_WANT_READ) { + char buf[128]; + + mbedtls_strerror(ret, buf, sizeof(buf)); + coap_log(LOG_WARNING, + "coap_dtls_receive: " + "returned -0x%x: '%s' (length %zd)\n", + -ret, buf, data_len); + } +#if COAP_CONSTRAINED_STACK + coap_mutex_unlock(&b_static_mutex); +#endif /* COAP_CONSTRAINED_STACK */ + ret = -1; + } + else { + ret = do_mbedtls_handshake(c_session, m_env); + if (ret == 1) { + /* Just connected, so send the data */ + coap_session_connected(c_session); + } else { + if (ssl_data->pdu_len) { + /* Do the handshake again incase of internal timeout */ + ret = do_mbedtls_handshake(c_session, m_env); + if (ret == 1) { + /* Just connected, so send the data */ + coap_session_connected(c_session); + } else { + ret = -1; + } + } + ret = -1; + } + } + if (c_session->dtls_event >= 0) { + coap_handle_event(c_session->context, c_session->dtls_event, c_session); + if (c_session->dtls_event == COAP_EVENT_DTLS_ERROR || + c_session->dtls_event == COAP_EVENT_DTLS_CLOSED) { + coap_session_disconnected(c_session, COAP_NACK_TLS_FAILED); + ret = -1; + } + } + return ret; +} + +int coap_dtls_hello(coap_session_t *c_session, + const uint8_t *data, + size_t data_len) +{ +#if defined(ESPIDF_VERSION) && !defined(CONFIG_MBEDTLS_SSL_PROTO_DTLS) + (void)c_session; + (void)data; + (void)data_len; + return -1; +#else /* !ESPIDF_VERSION) || CONFIG_MBEDTLS_SSL_PROTO_DTLS */ + coap_mbedtls_env_t *m_env = (coap_mbedtls_env_t *)c_session->tls; + coap_ssl_t *ssl_data = m_env ? &m_env->coap_ssl_data : NULL; + int ret; + + if (m_env) { + char *str = get_ip_addr(&c_session->remote_addr); + if (!str) { + return -1; + } + if((ret = mbedtls_ssl_set_client_transport_id(&m_env->ssl, + (unsigned char *)str, strlen(str))) != 0) { + coap_log(LOG_ERR, + "mbedtls_ssl_set_client_transport_id() returned -0x%x\n\n", + -ret); + free(str); + return -1; + } + free(str); + } + + if (!m_env) { + m_env = coap_dtls_new_mbedtls_env(c_session, COAP_DTLS_ROLE_SERVER); + if (m_env) { + c_session->tls = m_env; + ssl_data = &m_env->coap_ssl_data; + ssl_data->pdu = data; + ssl_data->pdu_len = (unsigned)data_len; + char *str = get_ip_addr(&c_session->remote_addr); + if (!str) { + return -1; + } + if((ret = mbedtls_ssl_set_client_transport_id(&m_env->ssl, + (unsigned char *)str, strlen(str)) ) != 0) { + coap_log(LOG_ERR, + "mbedtls_ssl_set_client_transport_id() returned -0x%x\n", + -ret); + free(str); + return -1; + } + ret = do_mbedtls_handshake(c_session, m_env); + if (ret == 0 || m_env->seen_client_hello) { + m_env->seen_client_hello = 0; + free(str); + return 1; + } + free(str); + } + return 0; + } + + ssl_data->pdu = data; + ssl_data->pdu_len = (unsigned)data_len; + ret = do_mbedtls_handshake(c_session, m_env); + if (ret == 0 || m_env->seen_client_hello) { + /* The test for seen_client_hello gives the ability to setup a new + c_session to continue the do_mbedtls_handshake past the client hello + and safely allow updating of the m_env and separately + letting a new session cleanly start up. + */ + m_env->seen_client_hello = 0; + return 1; + } + return 0; +#endif /* !ESPIDF_VERSION || CONFIG_MBEDTLS_SSL_PROTO_DTLS */ +} + +unsigned int coap_dtls_get_overhead(coap_session_t *c_session UNUSED) +{ + return 13 + 8 + 8; +} + +void *coap_tls_new_client_session(coap_session_t *c_session UNUSED, int *connected UNUSED) +{ + return NULL; +} + +void *coap_tls_new_server_session(coap_session_t *c_session UNUSED, int *connected UNUSED) +{ + return NULL; +} + +void coap_tls_free_session( coap_session_t *c_session UNUSED) +{ + return; +} + +ssize_t coap_tls_write(coap_session_t *c_session UNUSED, + const uint8_t *data UNUSED, + size_t data_len UNUSED + ) +{ + return 0; +} + +ssize_t coap_tls_read(coap_session_t *c_session UNUSED, + uint8_t *data UNUSED, + size_t data_len UNUSED + ) +{ + return 0; +} + +void coap_dtls_startup(void) +{ + return; +} + +static int keep_log_level = 0; + +void coap_dtls_set_log_level(int level) +{ +#if !defined(ESPIDF_VERSION) + int use_level; + /* + * MbedTLS debug levels filter + * 0 No debug + * 1 Error + * 2 State change + * 3 Informational + * 4 Verbose + */ + + if (level <= LOG_ERR) { + use_level = 1; + } + else { + use_level = (level >= LOG_DEBUG) ? level - LOG_DEBUG + 2 : 0; + } + mbedtls_debug_set_threshold(use_level); +#endif /* !ESPIDF_VERSION) */ + keep_log_level = level; + return; +} + +int coap_dtls_get_log_level(void) +{ + return keep_log_level; +} + +coap_tls_version_t * coap_get_tls_library_version(void) +{ + static coap_tls_version_t version; + version.version = mbedtls_version_get_number(); + version.built_version = MBEDTLS_VERSION_NUMBER; + version.type = COAP_TLS_LIBRARY_MBEDTLS; + return &version; +} + +#else /* !HAVE_MBEDTLS */ + +#ifdef __clang__ +/* Make compilers happy that do not like empty modules. As this function is + * never used, we ignore -Wunused-function at the end of compiling this file + */ +#pragma GCC diagnostic ignored "-Wunused-function" +#endif +static inline void dummy(void) { +} + +#endif /* HAVE_MBEDTLS */ diff --git a/components/coap/port/include/coap/coap_dtls.h b/components/coap/port/include/coap/coap_dtls.h new file mode 100644 index 000000000..2dd0e88d2 --- /dev/null +++ b/components/coap/port/include/coap/coap_dtls.h @@ -0,0 +1,631 @@ +/* + * coap_dtls.h -- (Datagram) Transport Layer Support for libcoap + * + * Copyright (C) 2016 Olaf Bergmann + * Copyright (C) 2017 Jean-Claude Michelou + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_DTLS_H_ +#define COAP_DTLS_H_ + +#include "coap_time.h" +#include "str.h" + +struct coap_context_t; +struct coap_session_t; +struct coap_dtls_pki_t; + +/** + * @defgroup dtls DTLS Support + * API functions for interfacing with DTLS libraries. + * @{ + */ + +/** + * Check whether DTLS is available. + * + * @return @c 1 if support for DTLS is enabled, or @c 0 otherwise. + */ +int coap_dtls_is_supported(void); + +/** + * Check whether TLS is available. + * + * @return @c 1 if support for TLS is enabled, or @c 0 otherwise. + */ +int coap_tls_is_supported(void); + +typedef enum coap_tls_library_t { + COAP_TLS_LIBRARY_NOTLS = 0, /**< No DTLS library */ + COAP_TLS_LIBRARY_TINYDTLS, /**< Using TinyDTLS library */ + COAP_TLS_LIBRARY_OPENSSL, /**< Using OpenSSL library */ + COAP_TLS_LIBRARY_GNUTLS, /**< Using GnuTLS library */ + COAP_TLS_LIBRARY_MBEDTLS, /**< Using MbedTLS library */ +} coap_tls_library_t; + +/** + * The structure used for returning the underlying (D)TLS library + * information. + */ +typedef struct coap_tls_version_t { + uint64_t version; /**< (D)TLS runtime Library Version */ + coap_tls_library_t type; /**< Library type. One of COAP_TLS_LIBRARY_* */ + uint64_t built_version; /**< (D)TLS Built against Library Version */ +} coap_tls_version_t; + +/** + * Determine the type and version of the underlying (D)TLS library. + * + * @return The version and type of library libcoap was compiled against. + */ +coap_tls_version_t *coap_get_tls_library_version(void); + +/** + * Additional Security setup handler that can be set up by + * coap_context_set_pki(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to do some additional checks/changes/updates. + * + * @param tls_session The security session definition - e.g. SSL * for OpenSSL. + * NULL if server call-back. + * This will be dependent on the underlying TLS library - + * see coap_get_tls_library_version() + * @param setup_data A structure containing setup data originally passed into + * coap_context_set_pki() or coap_new_client_session_pki(). + * + * @return @c 1 if successful, else @c 0. + */ +typedef int (*coap_dtls_security_setup_t)(void* tls_session, + struct coap_dtls_pki_t *setup_data); + +/** + * CN Validation call-back that can be set up by coap_context_set_pki(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to check that the CN is allowed. + * CN is the SubjectAltName in the cert, if not present, then the leftmost + * Common Name (CN) component of the subject name. + * + * @param cn The determined CN from the certificate + * @param asn1_public_cert The ASN.1 DER encoded X.509 certificate + * @param asn1_length The ASN.1 length + * @param coap_session The CoAP session associated with the certificate update + * @param depth Depth in cert chain. If 0, then client cert, else a CA + * @param validated TLS layer can find no issues if 1 + * @param arg The same as was passed into coap_context_set_pki() + * in setup_data->cn_call_back_arg + * + * @return @c 1 if accepted, else @c 0 if to be rejected. + */ +typedef int (*coap_dtls_cn_callback_t)(const char *cn, + const uint8_t *asn1_public_cert, + size_t asn1_length, + struct coap_session_t *coap_session, + unsigned depth, + int validated, + void *arg); + +/** + * The enum used for determining the provided PKI ASN.1 (DER) Private Key + * formats. + */ +typedef enum coap_asn1_privatekey_type_t { + COAP_ASN1_PKEY_NONE, /**< NONE */ + COAP_ASN1_PKEY_RSA, /**< RSA type */ + COAP_ASN1_PKEY_RSA2, /**< RSA2 type */ + COAP_ASN1_PKEY_DSA, /**< DSA type */ + COAP_ASN1_PKEY_DSA1, /**< DSA1 type */ + COAP_ASN1_PKEY_DSA2, /**< DSA2 type */ + COAP_ASN1_PKEY_DSA3, /**< DSA3 type */ + COAP_ASN1_PKEY_DSA4, /**< DSA4 type */ + COAP_ASN1_PKEY_DH, /**< DH type */ + COAP_ASN1_PKEY_DHX, /**< DHX type */ + COAP_ASN1_PKEY_EC, /**< EC type */ + COAP_ASN1_PKEY_HMAC, /**< HMAC type */ + COAP_ASN1_PKEY_CMAC, /**< CMAC type */ + COAP_ASN1_PKEY_TLS1_PRF, /**< TLS1_PRF type */ + COAP_ASN1_PKEY_HKDF /**< HKDF type */ +} coap_asn1_privatekey_type_t; + +/** + * The enum used for determining the PKI key formats. + */ +typedef enum coap_pki_key_t { + COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM file */ + COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) */ + COAP_PKI_KEY_PEM_BUF, /**< The PKI key type is PEM buffer */ +} coap_pki_key_t; + +/** + * The structure that holds the PKI PEM definitions. + */ +typedef struct coap_pki_key_pem_t { + const char *ca_file; /**< File location of Common CA in PEM format */ + const char *public_cert; /**< File location of Public Cert in PEM format */ + const char *private_key; /**< File location of Private Key in PEM format */ +} coap_pki_key_pem_t; + +/** + * The structure that holds the PKI PEM buffer definitions. + */ +typedef struct coap_pki_key_pem_buf_t { + const uint8_t *ca_cert; /**< PEM buffer Common CA Cert */ + const uint8_t *public_cert; /**< PEM buffer Public Cert */ + const uint8_t *private_key; /**< PEM buffer Private Key */ + size_t ca_cert_len; /**< PEM buffer CA Cert length */ + size_t public_cert_len; /**< PEM buffer Public Cert length */ + size_t private_key_len; /**< PEM buffer Private Key length */ +} coap_pki_key_pem_buf_t; + +/** + * The structure that holds the PKI ASN.1 (DER) definitions. + */ +typedef struct coap_pki_key_asn1_t { + const uint8_t *ca_cert; /**< ASN1 (DER) Common CA Cert */ + const uint8_t *public_cert; /**< ASN1 (DER) Public Cert */ + const uint8_t *private_key; /**< ASN1 (DER) Private Key */ + size_t ca_cert_len; /**< ASN1 CA Cert length */ + size_t public_cert_len; /**< ASN1 Public Cert length */ + size_t private_key_len; /**< ASN1 Private Key length */ + coap_asn1_privatekey_type_t private_key_type; /**< Private Key Type */ +} coap_pki_key_asn1_t; + +/** + * The structure that holds the PKI key information. + */ +typedef struct coap_dtls_key_t { + coap_pki_key_t key_type; /**< key format type */ + union { + coap_pki_key_pem_t pem; /**< for PEM file keys */ + coap_pki_key_pem_buf_t pem_buf; /**< for PEM memory keys */ + coap_pki_key_asn1_t asn1; /**< for ASN.1 (DER) file keys */ + } key; +} coap_dtls_key_t; + +/** + * Server Name Indication (SNI) Validation call-back that can be set up by + * coap_context_set_pki(). + * Invoked if the SNI is not previously seen and prior to sending a certificate + * set back to the client so that the appropriate certificate set can be used + * based on the requesting SNI. + * + * @param sni The requested SNI + * @param arg The same as was passed into coap_context_set_pki() + * in setup_data->sni_call_back_arg + * + * @return New set of certificates to use, or @c NULL if SNI is to be rejected. + */ +typedef coap_dtls_key_t *(*coap_dtls_sni_callback_t)(const char *sni, + void* arg); + + +#define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */ + +/** + * The structure used for defining the PKI setup data to be used. + */ +typedef struct coap_dtls_pki_t { + uint8_t version; /** Set to 1 to support this version of the struct */ + + /* Options to enable different TLS functionality in libcoap */ + uint8_t verify_peer_cert; /**< 1 if peer cert is to be verified */ + uint8_t require_peer_cert; /**< 1 if peer cert is required */ + uint8_t allow_self_signed; /**< 1 if self signed certs are allowed */ + uint8_t allow_expired_certs; /**< 1 if expired certs are allowed */ + uint8_t cert_chain_validation; /**< 1 if to check cert_chain_verify_depth */ + uint8_t cert_chain_verify_depth; /**< recommended depth is 3 */ + uint8_t check_cert_revocation; /**< 1 if revocation checks wanted */ + uint8_t allow_no_crl; /**< 1 ignore if CRL not there */ + uint8_t allow_expired_crl; /**< 1 if expired crl is allowed */ + uint8_t allow_bad_md_hash; /**< 1 if expired certs are allowed */ + uint8_t allow_short_rsa_length; /**< 1 if expired certs are allowed */ + uint8_t reserved[4]; /**< Reserved - must be set to 0 for + future compatibility */ + /* Size of 4 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_PKI_SETUP_VERSION and just + * decrement the reserved[] count. + */ + + /** CN check call-back function. + * If not NULL, is called when the TLS connection has passed the configured + * TLS options above for the application to verify if the CN is valid. + */ + coap_dtls_cn_callback_t validate_cn_call_back; + void *cn_call_back_arg; /**< Passed in to the CN call-back function */ + + /** SNI check call-back function. + * If not @p NULL, called if the SNI is not previously seen and prior to + * sending a certificate set back to the client so that the appropriate + * certificate set can be used based on the requesting SNI. + */ + coap_dtls_sni_callback_t validate_sni_call_back; + void *sni_call_back_arg; /**< Passed in to the sni call-back function */ + + /** Additional Security call-back handler that is invoked when libcoap has + * done the standerd, defined validation checks at the TLS level, + * If not @p NULL, called from within the TLS Client Hello connection + * setup. + */ + coap_dtls_security_setup_t additional_tls_setup_call_back; + + char* client_sni; /**< If not NULL, SNI to use in client TLS setup. + Owned by the client app and must remain valid + during the call to coap_new_client_session_pki() */ + + coap_dtls_key_t pki_key; /**< PKI key definition */ +} coap_dtls_pki_t; + +/** @} */ + +/** + * @defgroup dtls_internal DTLS Support (Internal) + * Internal API functions for interfacing with DTLS libraries. + * @{ + */ + +/** + * Creates a new DTLS context for the given @p coap_context. This function + * returns a pointer to a new DTLS context object or @c NULL on error. + * + * Internal function. + * + * @param coap_context The CoAP context where the DTLS object shall be used. + * + * @return A DTLS context object or @c NULL on error. + */ +void * +coap_dtls_new_context(struct coap_context_t *coap_context); + +typedef enum coap_dtls_role_t { + COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */ + COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */ +} coap_dtls_role_t; + +/** + * Set the DTLS context's default PSK information. + * This does the PSK specifics following coap_dtls_new_context(). + * If @p COAP_DTLS_ROLE_SERVER, then identity hint will also get set. + * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the + * TLS library's context (from which sessions are derived). + * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the + * TLS library's session. + * + * Internal function. + * + * @param coap_context The CoAP context. + * @param identity_hint The default PSK server identity hint sent to a client. + * Required parameter. If @p NULL, will be set to "". + * Empty string is a valid hint. + * This parameter is ignored if COAP_DTLS_ROLE_CLIENT + * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_psk(struct coap_context_t *coap_context, + const char *identity_hint, + coap_dtls_role_t role); + +/** + * Set the DTLS context's default server PKI information. + * This does the PKI specifics following coap_dtls_new_context(). + * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the + * TLS library's context (from which sessions are derived). + * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the + * TLS library's session. + * + * Internal function. + * + * @param coap_context The CoAP context. + * @param setup_data Setup information defining how PKI is to be setup. + * Required parameter. If @p NULL, PKI will not be + * set up. + * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_pki(struct coap_context_t *coap_context, + coap_dtls_pki_t *setup_data, + coap_dtls_role_t role); + +/** + * Set the dtls context's default Root CA information for a client or server. + * + * Internal function. + * + * @param coap_context The current coap_context_t object. + * @param ca_file If not @p NULL, is the full path name of a PEM encoded + * file containing all the Root CAs to be used. + * @param ca_dir If not @p NULL, points to a directory containing PEM + * encoded files containing all the Root CAs to be used. + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_pki_root_cas(struct coap_context_t *coap_context, + const char *ca_file, + const char *ca_dir); + +/** + * Check whether one of the coap_dtls_context_set_{psk|pki}() functions have + * been called. + * + * Internal function. + * + * @param coap_context The current coap_context_t object. + * + * @return @c 1 if coap_dtls_context_set_{psk|pki}() called, else @c 0. + */ + +int coap_dtls_context_check_keys_enabled(struct coap_context_t *coap_context); + +/** + * Releases the storage allocated for @p dtls_context. + * + * Internal function. + * + * @param dtls_context The DTLS context as returned by coap_dtls_new_context(). + */ +void coap_dtls_free_context(void *dtls_context); + +/** + * Create a new client-side session. This should send a HELLO to the server. + * + * Internal function. + * + * @param coap_session The CoAP session. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. +*/ +void *coap_dtls_new_client_session(struct coap_session_t *coap_session); + +/** + * Create a new DTLS server-side session. + * Called after coap_dtls_hello() has returned @c 1, signalling that a validated + * HELLO was received from a client. + * This should send a HELLO to the server. + * + * Internal function. + * + * @param coap_session The CoAP session. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the DTLS session. + */ +void *coap_dtls_new_server_session(struct coap_session_t *coap_session); + +/** + * Terminates the DTLS session (may send an ALERT if necessary) then frees the + * underlying TLS library object containing security parameters for the session. + * + * Internal function. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_free_session(struct coap_session_t *coap_session); + +/** + * Notify of a change in the CoAP session's MTU, for example after + * a PMTU update. + * + * Internal function. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_session_update_mtu(struct coap_session_t *coap_session); + +/** + * Send data to a DTLS peer. + * + * Internal function. + * + * @param coap_session The CoAP session. + * @param data pointer to data. + * @param data_len Number of bytes to send. + * + * @return @c 0 if this would be blocking, @c -1 if there is an error or the + * number of cleartext bytes sent. + */ +int coap_dtls_send(struct coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Check if timeout is handled per CoAP session or per CoAP context. + * + * Internal function. + * + * @return @c 1 of timeout and retransmit is per context, @c 0 if it is + * per session. + */ +int coap_dtls_is_context_timeout(void); + +/** + * Do all pending retransmits and get next timeout + * + * Internal function. + * + * @param dtls_context The DTLS context. + * + * @return @c 0 if no event is pending or date of the next retransmit. + */ +coap_tick_t coap_dtls_get_context_timeout(void *dtls_context); + +/** + * Get next timeout for this session. + * + * Internal function. + * + * @param coap_session The CoAP session. + * @param now The current time in ticks. + * + * @return @c 0 If no event is pending or ticks time of the next retransmit. + */ +coap_tick_t coap_dtls_get_timeout(struct coap_session_t *coap_session, + coap_tick_t now); + +/** + * Handle a DTLS timeout expiration. + * + * Internal function. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_handle_timeout(struct coap_session_t *coap_session); + +/** + * Handling incoming data from a DTLS peer. + * + * Internal function. + * + * @param coap_session The CoAP session. + * @param data Encrypted datagram. + * @param data_len Encrypted datagram size. + * + * @return Result of coap_handle_dgram on the decrypted CoAP PDU + * or @c -1 for error. + */ +int coap_dtls_receive(struct coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Handling client HELLO messages from a new candiate peer. + * Note that session->tls is empty. + * + * Internal function. + * + * @param coap_session The CoAP session. + * @param data Encrypted datagram. + * @param data_len Encrypted datagram size. + * + * @return @c 0 if a cookie verification message has been sent, @c 1 if the + * HELLO contains a valid cookie and a server session should be created, + * @c -1 if the message is invalid. + */ +int coap_dtls_hello(struct coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Get DTLS overhead over cleartext PDUs. + * + * Internal function. + * + * @param coap_session The CoAP session. + * + * @return Maximum number of bytes added by DTLS layer. + */ +unsigned int coap_dtls_get_overhead(struct coap_session_t *coap_session); + +/** + * Create a new TLS client-side session. + * + * Internal function. + * + * @param coap_session The CoAP session. + * @param connected Updated with whether the connection is connected yet or not. + * @c 0 is not connected, @c 1 is connected. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. +*/ +void *coap_tls_new_client_session(struct coap_session_t *coap_session, int *connected); + +/** + * Create a TLS new server-side session. + * + * Internal function. + * + * @param coap_session The CoAP session. + * @param connected Updated with whether the connection is connected yet or not. + * @c 0 is not connected, @c 1 is connected. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. + */ +void *coap_tls_new_server_session(struct coap_session_t *coap_session, int *connected); + +/** + * Terminates the TLS session (may send an ALERT if necessary) then frees the + * underlying TLS library object containing security parameters for the session. + * + * Internal function. + * + * @param coap_session The CoAP session. + */ +void coap_tls_free_session( struct coap_session_t *coap_session ); + +/** + * Send data to a TLS peer, with implicit flush. + * + * Internal function. + * + * @param coap_session The CoAP session. + * @param data Pointer to data. + * @param data_len Number of bytes to send. + * + * @return @c 0 if this should be retried, @c -1 if there is an error + * or the number of cleartext bytes sent. + */ +ssize_t coap_tls_write(struct coap_session_t *coap_session, + const uint8_t *data, + size_t data_len + ); + +/** + * Read some data from a TLS peer. + * + * Internal function. + * + * @param coap_session The CoAP session. + * @param data Pointer to data. + * @param data_len Maximum number of bytes to read. + * + * @return @c 0 if this should be retried, @c -1 if there is an error + * or the number of cleartext bytes read. + */ +ssize_t coap_tls_read(struct coap_session_t *coap_session, + uint8_t *data, + size_t data_len + ); + +/** + * Initialize the underlying (D)TLS Library layer. + * + * Internal function. + * + */ +void coap_dtls_startup(void); + +/** @} */ + +/** + * @ingroup logging + * Sets the (D)TLS logging level to the specified @p level. + * Note: coap_log_level() will influence output if at a specified level. + * + * @param level The logging level to use - LOG_* + */ +void coap_dtls_set_log_level(int level); + +/** + * @ingroup logging + * Get the current (D)TLS logging. + * + * @return The current log level (one of LOG_*). + */ +int coap_dtls_get_log_level(void); + + +#endif /* COAP_DTLS_H */ diff --git a/components/coap/port/include/coap_config_posix.h b/components/coap/port/include/coap_config_posix.h index 8f5a5cfb1..dc1166090 100644 --- a/components/coap/port/include/coap_config_posix.h +++ b/components/coap/port/include/coap_config_posix.h @@ -21,18 +21,27 @@ #ifdef WITH_POSIX #include +#include #define HAVE_SYS_SOCKET_H #define HAVE_MALLOC #define HAVE_ARPA_INET_H #define HAVE_TIME_H +#define HAVE_NETDB_H +#define HAVE_NETINET_IN_H #define IPV6_PKTINFO IPV6_V6ONLY #define PACKAGE_NAME "libcoap-posix" #define PACKAGE_VERSION "?" -#define COAP_BAD_RECVMSG +#define HAVE_MBEDTLS +#define COAP_CONSTRAINED_STACK 1 +#define ESPIDF_VERSION + +#define _POSIX_TIMERS 1 + +#define gai_strerror(x) "gai_strerror() not supported" #endif /* WITH_POSIX */ #endif /* COAP_CONFIG_POSIX_H_ */ diff --git a/components/mbedtls/CMakeLists.txt b/components/mbedtls/CMakeLists.txt index 5cfac4d9b..b37269f02 100644 --- a/components/mbedtls/CMakeLists.txt +++ b/components/mbedtls/CMakeLists.txt @@ -25,6 +25,7 @@ target_sources(mbedtls PRIVATE "${COMPONENT_DIR}/port/esp_bignum.c" "${COMPONENT_DIR}/port/esp_sha1.c" "${COMPONENT_DIR}/port/esp_sha256.c" "${COMPONENT_DIR}/port/esp_sha512.c" + "${COMPONENT_DIR}/port/esp_timing.c" "${COMPONENT_DIR}/port/mbedtls_debug.c" "${COMPONENT_DIR}/port/net_sockets.c" "${COMPONENT_DIR}/port/esp32/aes.c" @@ -36,4 +37,4 @@ foreach(target ${mbedtls_targets}) endforeach() # Link mbedtls libraries to component library -target_link_libraries(${COMPONENT_LIB} INTERFACE ${mbedtls_targets}) \ No newline at end of file +target_link_libraries(${COMPONENT_LIB} INTERFACE ${mbedtls_targets}) diff --git a/components/mbedtls/port/esp_timing.c b/components/mbedtls/port/esp_timing.c new file mode 100644 index 000000000..93a34f5fa --- /dev/null +++ b/components/mbedtls/port/esp_timing.c @@ -0,0 +1,102 @@ +/* + * Portable interface to the CPU cycle counter + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * mbedtls_timing_get_timer()m mbedtls_timing_set_delay() and + * mbedtls_timing_set_delay only abstracted from mbedtls/library/timing.c + * as that does not build on ESP-IDF but these 2 functions are needed for + * DTLS (in particular mbedtls_ssl_set_timer_cb() must be called for DTLS + * which requires these 2 delay functions). + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if !defined(MBEDTLS_ESP_TIMING_C) + +#include +#include "mbedtls/timing.h" + +struct _hr_time +{ + struct timeval start; +}; + +unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset ) +{ + struct _hr_time *t = (struct _hr_time *) val; + + if( reset ) + { + gettimeofday( &t->start, NULL ); + return( 0 ); + } + else + { + unsigned long delta; + struct timeval now; + gettimeofday( &now, NULL ); + delta = ( now.tv_sec - t->start.tv_sec ) * 1000ul + + ( now.tv_usec - t->start.tv_usec ) / 1000; + return( delta ); + } +} + +/* + * Set delays to watch + */ +void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms ) +{ + mbedtls_timing_delay_context *ctx = (mbedtls_timing_delay_context *) data; + + ctx->int_ms = int_ms; + ctx->fin_ms = fin_ms; + + if( fin_ms != 0 ) + (void) mbedtls_timing_get_timer( &ctx->timer, 1 ); +} + +/* + * Get number of delays expired + */ +int mbedtls_timing_get_delay( void *data ) +{ + mbedtls_timing_delay_context *ctx = (mbedtls_timing_delay_context *) data; + unsigned long elapsed_ms; + + if( ctx->fin_ms == 0 ) + return( -1 ); + + elapsed_ms = mbedtls_timing_get_timer( &ctx->timer, 0 ); + + if( elapsed_ms >= ctx->fin_ms ) + return( 2 ); + + if( elapsed_ms >= ctx->int_ms ) + return( 1 ); + + return( 0 ); +} + +#endif /* MBEDTLS_ESP_TIMING_C */ diff --git a/examples/protocols/coap_client/README.md b/examples/protocols/coap_client/README.md index bc3159dbb..7c317dddd 100644 --- a/examples/protocols/coap_client/README.md +++ b/examples/protocols/coap_client/README.md @@ -2,14 +2,27 @@ # CoAP client example (See the README.md file in the upper level 'examples' directory for more information about examples.) -this CoAP client example is adaptation of one of the [libcoap](https://github.com/obgm/libcoap) example. +This CoAP client example is very simplified adaptation of one of the +[libcoap](https://github.com/obgm/libcoap) examples. -CoAP client example would connect your ESP32 device to any CoAP server, fetch data from CoAP server and upstream data to CoAP server. +CoAP client example will connect your ESP32 device to a CoAP server, send off a GET request and +fetch the response data from CoAP server. The client can be extended to PUT / POST / DELETE requests, +as well as supporting the Observer extensions [RFC7641](https://tools.ietf.org/html/rfc7641). -The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained networks in the Internet of Things. -The protocol is designed for machine-to-machine (M2M) applications such as smart energy and building automation. +If the URI is prefixed with coaps:// instead of coap://, then the CoAP client will attempt to use +the DTLS protocol using the defined Pre-Shared Keys(PSK) or Public Key Infrastructure (PKI) which the +CoAP server needs to know about. -please refer to [RFC7252](https://www.rfc-editor.org/rfc/pdfrfc/rfc7252.txt.pdf) for more details. +If the URI is prefixed with coap+tcp://, then the CoAP will try to use TCP for the communication. + +NOTE: coaps+tcp:// is not currently supported, even though both libcoap and MbedTLS support it. + +The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with +constrained nodes and constrained networks in the Internet of Things. +The protocol is designed for machine-to-machine (M2M) applications such as smart energy and +building automation. + +Please refer to [RFC7252](https://www.rfc-editor.org/rfc/pdfrfc/rfc7252.txt.pdf) for more details. ## How to use example @@ -19,16 +32,29 @@ please refer to [RFC7252](https://www.rfc-editor.org/rfc/pdfrfc/rfc7252.txt.pdf) idf.py menuconfig ``` -* Set serial port under Serial Flasher config -* Set Target Uri under Example Configuration -* Set WiFi SSID under Example Configuration -* Set WiFi Password under Example Configuration +Example Connection Configuration ---> + * Set WiFi SSID under Example Configuration + * Set WiFi Password under Example Configuration +Example CoAP Client Configuration ---> + * Set CoAP Target Uri + * Set encryption method definitions (None, PSK or PKI) + * If PSK Set CoAP Preshared Key to use in connection to the server + * If PSK Set CoAP PSK Client identity (username) + Enable CoAP debugging if required +Component config ---> + mbedTLS ---> + [*] Enable mbedtls certificate expiry check + TLS Key Exchange Methods ---> + [*] Enable pre-shared-key ciphersuites + [*] Enable PSK based ciphersuite modes + [*] Support DTLS protocol (all versions) ### Build and Flash Build the project and flash it to the board, then run monitor tool to view serial output: ``` +idf.py build idf.py -p PORT flash monitor ``` @@ -72,9 +98,11 @@ published under EPL+EDL: http://www.eclipse.org/californium/ This can be found at https://libcoap.net/doc/reference/4.2.0/ ## Troubleshooting -* Please make sure Target Url includes valid `host`, optional `port`, optional `path`, and begins -with `coap://` or `coap+tcp://` for a coap server that supports TCP +* Please make sure Target Url includes valid `host`, optional `port`, +optional `path`, and begins with `coap://`, `coaps://` or `coap+tcp://` +for a coap server that supports TCP (not all do including coap+tcp://californium.eclipse.org). -* libcoap logging can be increased by changing `#define COAP_LOGGING_LEVEL 0` -to `#define COAP_LOGGING_LEVEL 9` +* CoAP logging can be enabled by running 'make menuconfig' and enable debugging + +* Encryption (MbedTLS) can be enabled by running 'make menuconfig' and enable debugging diff --git a/examples/protocols/coap_client/main/CMakeLists.txt b/examples/protocols/coap_client/main/CMakeLists.txt index 90a88c9d3..eb0d27066 100644 --- a/examples/protocols/coap_client/main/CMakeLists.txt +++ b/examples/protocols/coap_client/main/CMakeLists.txt @@ -1,2 +1,4 @@ +# Embed CA, certificate & key directly into binary idf_component_register(SRCS "coap_client_example_main.c" - INCLUDE_DIRS ".") \ No newline at end of file + INCLUDE_DIRS "." + EMBED_TXTFILES coap_ca.pem coap_client.crt coap_client.key) diff --git a/examples/protocols/coap_client/main/Kconfig.projbuild b/examples/protocols/coap_client/main/Kconfig.projbuild index 929b8cf4f..f96ac41e4 100644 --- a/examples/protocols/coap_client/main/Kconfig.projbuild +++ b/examples/protocols/coap_client/main/Kconfig.projbuild @@ -1,9 +1,96 @@ -menu "Example Configuration" +menu "Example CoAP Client Configuration" config TARGET_DOMAIN_URI string "Target Uri" default "coap://californium.eclipse.org" help - Target uri for the example to use. + Target uri for the example to use. Use coaps:// prefix for encrypted traffic + using Pre-Shared Key (PSK) or Public Key Infrastructure (PKI). + + choice MBEDTLS_COAP_ENCRYPTION_MODE + prompt "CoAP Encryption method" + default MBEDTLS_COAP_PKI_NONE + help + If the CoAP information is to be encrypted, the encryption environment + can be set up in one of three ways + + - None defined (will use PKI if coaps:// used) + - Encrypt using defined Pre-Shared Keys (PSK) + - Encrypt using defined Public Key Infrastructure (PKI) + + config MBEDTLS_COAP_NONE + bool "None defined" + + config MBEDTLS_COAP_PSK + bool "Pre-Shared Keys" + + config MBEDTLS_COAP_PKI + bool "PKI Certificates" + + endchoice #MBEDTLS_COAP_ENCRYPTION_MODE + + config COAP_PSK_KEY + string "Preshared Key (PSK) to used in the connection to the CoAP server" + depends on MBEDTLS_COAP_PSK + default "secret-key" + help + The Preshared Key to use to encrypt the communicatons. The same key must be + used at both ends of the CoAP connection, and the CoaP client must request + an URI prefixed with coaps:// instead of coap:// for DTLS to be used. + + config COAP_PSK_IDENTITY + string "PSK Client identity (username)" + depends on MBEDTLS_COAP_PSK + default "coap-client" + help + The identity (or username) to use to identify to the CoAP server which + PSK key to use. + + config MBEDTLS_COAP_DEBUG + bool "Enable CoAP debugging" + default n + help + Enable CoAP debugging functions at compile time for the example code. + + If this option is enabled, call coap_set_log_level() + at runtime in order to enable CoAP debug output via the ESP + log mechanism. + + choice MBEDTLS_COAP_DEBUG_LEVEL + bool "Set CoAP debugging level" + depends on MBEDTLS_COAP_DEBUG + default COAP_LOG_WARNING + help + Set CoAP debugging level + + config COAP_LOG_EMERG + bool "Emergency" + config COAP_LOG_ALERT + bool "Alert" + config COAP_LOG_CRIT + bool "Critical" + config COAP_LOG_ERROR + bool "Error" + config COAP_LOG_WARNING + bool "Warning" + config COAP_LOG_NOTICE + bool "Notice" + config COAP_LOG_INFO + bool "Info" + config COAP_LOG_DEBUG + bool "Debug" + endchoice + + config COAP_LOG_DEFAULT_LEVEL + int + default 0 if !MBEDTLS_COAP_DEBUG + default 0 if COAP_LOG_EMERG + default 1 if COAP_LOG_ALERT + default 2 if COAP_LOG_CRIT + default 3 if COAP_LOG_ERROR + default 4 if COAP_LOG_WARNING + default 5 if COAP_LOG_NOTICE + default 6 if COAP_LOG_INFO + default 7 if COAP_LOG_DEBUG endmenu diff --git a/examples/protocols/coap_client/main/coap_ca.pem b/examples/protocols/coap_client/main/coap_ca.pem new file mode 100644 index 000000000..1bdf23d94 --- /dev/null +++ b/examples/protocols/coap_client/main/coap_ca.pem @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIID3DCCA0WgAwIBAgIJAMnlgL1czsmjMA0GCSqGSIb3DQEBCwUAMIGTMQswCQYD +VQQGEwJGUjEPMA0GA1UECAwGUmFkaXVzMRIwEAYDVQQHDAlTb21ld2hlcmUxFTAT +BgNVBAoMDEV4YW1wbGUgSW5jLjEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhhbXBs +ZS5jb20xJjAkBgNVBAMMHUV4YW1wbGUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X +DTE3MDYwNzA4MDY0OVoXDTI3MDYwNTA4MDY0OVowgZMxCzAJBgNVBAYTAkZSMQ8w +DQYDVQQIDAZSYWRpdXMxEjAQBgNVBAcMCVNvbWV3aGVyZTEVMBMGA1UECgwMRXhh +bXBsZSBJbmMuMSAwHgYJKoZIhvcNAQkBFhFhZG1pbkBleGFtcGxlLmNvbTEmMCQG +A1UEAwwdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwgZ8wDQYJKoZIhvcN +AQEBBQADgY0AMIGJAoGBALpWR23fn/TmHxsXsHdrydzPSd17fZkc71WsaicgQR66 +1tIVYb22UWGfj9KPM8THMsV74ew4ZkaQ39qvU0iuQIRrKARFHFok+vbaecgWMeWe +vGIqdnmyB9gJYaFOKgtSkfXsu2ddsqdvLYwcDbczrq8X9yEXpN6mnxXeCcPG4F0p +AgMBAAGjggE0MIIBMDAdBgNVHQ4EFgQUgigpdAUpONoDq0pQ3yfxrslCSpcwgcgG +A1UdIwSBwDCBvYAUgigpdAUpONoDq0pQ3yfxrslCSpehgZmkgZYwgZMxCzAJBgNV +BAYTAkZSMQ8wDQYDVQQIDAZSYWRpdXMxEjAQBgNVBAcMCVNvbWV3aGVyZTEVMBMG +A1UECgwMRXhhbXBsZSBJbmMuMSAwHgYJKoZIhvcNAQkBFhFhZG1pbkBleGFtcGxl +LmNvbTEmMCQGA1UEAwwdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHmCCQDJ +5YC9XM7JozAMBgNVHRMEBTADAQH/MDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly93 +d3cuZXhhbXBsZS5jb20vZXhhbXBsZV9jYS5jcmwwDQYJKoZIhvcNAQELBQADgYEA +euxOBPInSJRKAIseMxPmAabtAqKNslZSmpG4He3lkKt+HM3jfznUt3psmD7j1hFW +S4l7KXzzajvaGYybDq5N9MqrDjhGn3VXZqOLMUNDL7OQq96TzgqsTBT1dmVSbNlt +PQgiAeKAk3tmH4lRRi9MTBSyJ6I92JYcS5H6Bs4ZwCc= +-----END CERTIFICATE----- diff --git a/examples/protocols/coap_client/main/coap_client.crt b/examples/protocols/coap_client/main/coap_client.crt new file mode 100644 index 000000000..0e03a1b79 --- /dev/null +++ b/examples/protocols/coap_client/main/coap_client.crt @@ -0,0 +1,70 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 48 (0x30) + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=FR, ST=Radius, L=Somewhere, O=Example Inc./emailAddress=admin@example.com, CN=Example Certificate Authority + Validity + Not Before: Jun 7 08:06:49 2017 GMT + Not After : Jun 5 08:06:49 2027 GMT + Subject: C=FR, ST=Radius, O=Example Inc., CN=user@example.com/emailAddress=user@example.com + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (2048 bit) + Modulus: + 00:d2:f6:be:72:a5:ab:2e:56:0c:dd:f2:3b:2c:7c: + e0:5d:05:40:af:0c:8c:f3:82:0c:d0:18:34:b4:e3: + 7d:5f:8d:0a:3e:aa:79:02:f9:96:ad:10:00:ec:51: + e9:dc:3f:fb:ea:b0:57:eb:48:c7:ca:ef:e8:05:ab: + ee:3f:66:ba:5c:9e:7f:40:85:9f:25:a0:e0:e3:7c: + cf:b6:e6:31:f5:fd:24:03:c8:f4:fb:d8:a4:f3:92: + 29:05:aa:55:43:80:f7:3e:13:10:43:3a:89:24:be: + d8:01:86:d1:69:73:44:7d:f8:b9:46:2b:6b:51:d0: + 11:31:4b:06:ae:9f:45:fa:12:17:0c:ef:6a:fa:d0: + f7:36:46:eb:2e:db:4e:20:46:01:33:ac:b1:f7:4a: + e6:18:3d:53:22:dc:e8:4a:12:78:11:2f:e4:3b:92: + bd:d7:07:5a:c9:81:5d:48:58:c8:0f:9b:e9:a4:0f: + bb:89:b1:ad:38:07:6f:93:d0:a6:12:56:f9:07:48: + d2:23:2f:a3:a9:93:b0:11:0a:27:4c:48:0a:8d:70: + 41:68:76:7a:dd:bc:54:c3:42:33:b0:7b:f6:ae:1f: + e7:95:5e:11:ca:f2:b4:4b:5c:ba:47:64:f0:f3:d7: + 87:95:7f:93:06:a1:72:c9:81:12:a5:b7:8f:9d:7e: + d1:ef + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Extended Key Usage: + TLS Web Client Authentication + X509v3 CRL Distribution Points: + + Full Name: + URI:http://www.example.com/example_ca.crl + + Signature Algorithm: sha1WithRSAEncryption + 2d:02:bc:7b:88:b8:5c:e1:07:b8:bb:ba:b2:f3:98:14:8f:cb: + b0:21:13:b5:e5:6f:05:4f:92:fa:ac:c0:53:a7:b0:cd:7e:ba: + 87:36:85:25:d7:41:c5:29:84:22:74:af:bf:3e:34:36:d5:24: + 7a:81:e2:1b:54:52:85:6f:76:de:dc:63:98:45:fc:2c:31:fa: + 22:a4:72:3a:8d:d4:6a:2e:de:33:10:41:eb:94:1d:e3:59:cd: + b2:be:ab:f0:b6:20:86:9c:b8:46:ee:c5:64:ba:b6:6c:cc:53: + 44:7a:80:12:77:7c:e7:51:67:91:32:2f:88:9d:93:a8:ef:d6: + cd:de +-----BEGIN CERTIFICATE----- +MIIDTjCCAregAwIBAgIBMDANBgkqhkiG9w0BAQUFADCBkzELMAkGA1UEBhMCRlIx +DzANBgNVBAgMBlJhZGl1czESMBAGA1UEBwwJU29tZXdoZXJlMRUwEwYDVQQKDAxF +eGFtcGxlIEluYy4xIDAeBgkqhkiG9w0BCQEWEWFkbWluQGV4YW1wbGUuY29tMSYw +JAYDVQQDDB1FeGFtcGxlIENlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNzA2MDcw +ODA2NDlaFw0yNzA2MDUwODA2NDlaMHExCzAJBgNVBAYTAkZSMQ8wDQYDVQQIDAZS +YWRpdXMxFTATBgNVBAoMDEV4YW1wbGUgSW5jLjEZMBcGA1UEAwwQdXNlckBleGFt +cGxlLmNvbTEfMB0GCSqGSIb3DQEJARYQdXNlckBleGFtcGxlLmNvbTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBANL2vnKlqy5WDN3yOyx84F0FQK8MjPOC +DNAYNLTjfV+NCj6qeQL5lq0QAOxR6dw/++qwV+tIx8rv6AWr7j9mulyef0CFnyWg +4ON8z7bmMfX9JAPI9PvYpPOSKQWqVUOA9z4TEEM6iSS+2AGG0WlzRH34uUYra1HQ +ETFLBq6fRfoSFwzvavrQ9zZG6y7bTiBGATOssfdK5hg9UyLc6EoSeBEv5DuSvdcH +WsmBXUhYyA+b6aQPu4mxrTgHb5PQphJW+QdI0iMvo6mTsBEKJ0xICo1wQWh2et28 +VMNCM7B79q4f55VeEcrytEtcukdk8PPXh5V/kwahcsmBEqW3j51+0e8CAwEAAaNP +ME0wEwYDVR0lBAwwCgYIKwYBBQUHAwIwNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDov +L3d3dy5leGFtcGxlLmNvbS9leGFtcGxlX2NhLmNybDANBgkqhkiG9w0BAQUFAAOB +gQAtArx7iLhc4Qe4u7qy85gUj8uwIRO15W8FT5L6rMBTp7DNfrqHNoUl10HFKYQi +dK+/PjQ21SR6geIbVFKFb3be3GOYRfwsMfoipHI6jdRqLt4zEEHrlB3jWc2yvqvw +tiCGnLhG7sVkurZszFNEeoASd3znUWeRMi+InZOo79bN3g== +-----END CERTIFICATE----- diff --git a/examples/protocols/coap_client/main/coap_client.key b/examples/protocols/coap_client/main/coap_client.key new file mode 100644 index 000000000..99936e25b --- /dev/null +++ b/examples/protocols/coap_client/main/coap_client.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA0va+cqWrLlYM3fI7LHzgXQVArwyM84IM0Bg0tON9X40KPqp5 +AvmWrRAA7FHp3D/76rBX60jHyu/oBavuP2a6XJ5/QIWfJaDg43zPtuYx9f0kA8j0 ++9ik85IpBapVQ4D3PhMQQzqJJL7YAYbRaXNEffi5RitrUdARMUsGrp9F+hIXDO9q ++tD3NkbrLttOIEYBM6yx90rmGD1TItzoShJ4ES/kO5K91wdayYFdSFjID5vppA+7 +ibGtOAdvk9CmElb5B0jSIy+jqZOwEQonTEgKjXBBaHZ63bxUw0IzsHv2rh/nlV4R +yvK0S1y6R2Tw89eHlX+TBqFyyYESpbePnX7R7wIDAQABAoIBAQC5PncO3tBIeMEF +pu007FZq9/DLhP7D2B9+HrMxX0y4uXUUf8aQyS74ukPFP0xV3U1M0BnzfU4KscyQ +Jl+nBoKAT6C3vF15wiGXQAJ4vPuD4Ate03fjKWH2ixJAakhCZR01QbIXBnBkdrvf +401BBjlPUDcIGZo8FbLzEMlGTo84vE9v3Qmkbi+PzPCh2YC+NDmsOcIW1zpmwyYC +ZYCpoWgl4++kqXXn0NGhuaOgB0JLsJOBpx/hOOjBU/wXCKaXZ1vchYqfbvvx2gf2 +WX4P0CiTH1z7MEAHanaZkcnNyxV/oF1EIMY5p0vDDzgrKtppvPOqspjydje03+CE +t0wKGPi5AoGBAPAG2Y4efgwLcoWdPjKZtsHLhDhLJnvxkqnNkzdPnLZojNi8pKkV +/Yu++pPemJZZa4YAp+OnqyEfhcha+HYqKMwRC8t3YrEVOlRQTfW/OoSrp059JIRV +jTvq/u7DdYGJRRgMLUJiEI+7xj1WbTc2EceJAgn0qfKvbvBtVJP0LH1TAoGBAOEA +xZB7SwyX+zDGRTugqMYg+sYobbQHJ7utLyoX+ckeG+sPEjEYLpQQfshET/gwF8ZK +4aILkACx/tna799xCjQdmyyc338NO9WULlY1xF+65WfeaxrtTAsqVikX3p19McRI +ijX8k7Msy3gYWJXev3MCtPT2+g68IgbL/W2wY+l1AoGAT7xGy0Jv5vpqid5pig+s +OYatHrJAT445hXUIQaiNy77Bg0JvhMgMWT8RKMwabl+4K2TOYP8TB0bcf2lQ/pgU +w22qOGYpf+AoZ1fh/hAPlYEcbCOAXQG6kDwJgjGmOGjsbgelhVbkX4smWLv8PgoV +L+7goYQIbNlAhlgbb6b+nIcCgYBB7Zr2Cdpkt0en9ACnRx0M6O7yDziNzqbqzAUM +3XeYYZUmnATlk8NaKTcs8S9JdrYQqTJR6/dm7MDTDt7IZvPpb19fhBvMu5DztPaa +1ihTMI01kStq+WsVvnL+mXrmRJ/HdsXgqcCReKep6eBTEbChP4LMYG3G0YNa4HzC +njO4XQKBgQDRnbqqg2CNTnS94BN2D3uzzELtwsIG6aVCtl09ZsLnGaBKVVDtP6BI +j2hGD7xw4g5JeSPIJU5J03nALTY3hz1JyI7AJCX7+JRtUTX2A8C4mlbeul7ilGaU +A7MFT8GqhjYYa84GzNcA1mK8ynlixpL8+yzTT/8lWInWRBa69SkktA== +-----END RSA PRIVATE KEY----- diff --git a/examples/protocols/coap_client/main/coap_client_example_main.c b/examples/protocols/coap_client/main/coap_client_example_main.c index 921541aef..067364a73 100644 --- a/examples/protocols/coap_client/main/coap_client_example_main.c +++ b/examples/protocols/coap_client/main/coap_client_example_main.c @@ -7,6 +7,13 @@ CONDITIONS OF ANY KIND, either express or implied. */ +/* + * WARNING + * libcoap is not multi-thread safe, so only this thread must make any coap_*() + * calls. Any external (to this thread) data transmitted in/out via libcoap + * therefore has to be passed in/out by xQueue*() via this thread. + */ + #include #include #include @@ -23,12 +30,36 @@ #include "protocol_examples_common.h" +#if 1 +/* Needed until coap_dtls.h becomes a part of libcoap proper */ +#include "libcoap.h" +#include "coap_dtls.h" +#endif #include "coap.h" #define COAP_DEFAULT_TIME_SEC 5 -/* Set this to 9 to get verbose logging from within libcoap */ -#define COAP_LOGGING_LEVEL 0 +/* The examples use simple Pre-Shared-Key configuration that you can set via + 'make menuconfig'. + + If you'd rather not, just change the below entries to strings with + the config you want - ie #define EXAMPLE_COAP_PSK_KEY "some-agreed-preshared-key" + + Note: PSK will only be used if the URI is prefixed with coaps:// + instead of coap:// and the PSK must be one that the server supports + (potentially associated with the IDENTITY) +*/ +#define EXAMPLE_COAP_PSK_KEY CONFIG_COAP_PSK_KEY +#define EXAMPLE_COAP_PSK_IDENTITY CONFIG_COAP_PSK_IDENTITY + +/* The examples use uri Logging Level that + you can set via 'make menuconfig'. + + If you'd rather not, just change the below entry to a value + that is between 0 and 7 with + the config you want - ie #define EXAMPLE_COAP_LOG_DEFAULT_LEVEL 7 +*/ +#define EXAMPLE_COAP_LOG_DEFAULT_LEVEL CONFIG_COAP_LOG_DEFAULT_LEVEL /* The examples use uri "coap://californium.eclipse.org" that you can set via the project configuration (idf.py menuconfig) @@ -124,17 +155,44 @@ clean_up: resp_wait = 0; } -static void coap_example_task(void *p) +#ifdef CONFIG_MBEDTLS_COAP_PKI + +#ifdef __GNUC__ +#define UNUSED_PARAM __attribute__ ((unused)) +#else /* not a GCC */ +#define UNUSED_PARAM +#endif /* GCC */ + +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif + +static int +verify_cn_callback(const char *cn, + const uint8_t *asn1_public_cert UNUSED_PARAM, + size_t asn1_length UNUSED_PARAM, + coap_session_t *session UNUSED_PARAM, + unsigned depth, + int validated UNUSED_PARAM, + void *arg UNUSED_PARAM +) { + coap_log(LOG_INFO, "CN '%s' presented by server (%s)\n", + cn, depth ? "CA" : "Certificate"); + return 1; +} +#endif /* CONFIG_MBEDTLS_COAP_PKI */ + +static void coap_example_client(void *p) { struct hostent *hp; - struct ip4_addr *ip4_addr; - coap_address_t dst_addr, src_addr; + coap_address_t dst_addr; static coap_uri_t uri; const char* server_uri = COAP_DEFAULT_DEMO_URI; char* phostname = NULL; - coap_set_log_level(COAP_LOGGING_LEVEL); + coap_set_log_level(EXAMPLE_COAP_LOG_DEFAULT_LEVEL); + while (1) { #define BUFSIZE 40 unsigned char _buf[BUFSIZE]; @@ -153,7 +211,7 @@ static void coap_example_task(void *p) if ((uri.scheme==COAP_URI_SCHEME_COAPS && !coap_dtls_is_supported()) || (uri.scheme==COAP_URI_SCHEME_COAPS_TCP && !coap_tls_is_supported())) { - ESP_LOGE(TAG, "CoAP server uri scheme error"); + ESP_LOGE(TAG, "CoAP server uri scheme is not supported"); break; } @@ -172,19 +230,31 @@ static void coap_example_task(void *p) ESP_LOGE(TAG, "DNS lookup failed"); vTaskDelay(1000 / portTICK_PERIOD_MS); free(phostname); - continue; + goto clean_up; + } + { + char tmpbuf[INET6_ADDRSTRLEN]; + coap_address_init(&dst_addr); + switch (hp->h_addrtype) { + case AF_INET: + dst_addr.addr.sin.sin_family = AF_INET; + dst_addr.addr.sin.sin_port = htons(uri.port); + memcpy(&dst_addr.addr.sin.sin_addr, hp->h_addr, sizeof(dst_addr.addr.sin.sin_addr)); + inet_ntop(AF_INET, &dst_addr.addr.sin.sin_addr, tmpbuf, sizeof(tmpbuf)); + ESP_LOGI(TAG, "DNS lookup succeeded. IP=%s", tmpbuf); + break; + case AF_INET6: + dst_addr.addr.sin6.sin6_family = AF_INET6; + dst_addr.addr.sin6.sin6_port = htons(uri.port); + memcpy(&dst_addr.addr.sin6.sin6_addr, hp->h_addr, sizeof(dst_addr.addr.sin6.sin6_addr)); + inet_ntop(AF_INET6, &dst_addr.addr.sin6.sin6_addr, tmpbuf, sizeof(tmpbuf)); + ESP_LOGI(TAG, "DNS lookup succeeded. IP=%s", tmpbuf); + break; + default: + ESP_LOGE(TAG, "DNS lookup response failed"); + goto clean_up; + } } - - /* Code to print the resolved IP. - - Note: inet_ntoa is non-reentrant, look at ipaddr_ntoa_r for "real" code */ - ip4_addr = (struct ip4_addr *)hp->h_addr; - ESP_LOGI(TAG, "DNS lookup succeeded. IP=%s", inet_ntoa(*ip4_addr)); - - coap_address_init(&src_addr); - src_addr.addr.sin.sin_family = AF_INET; - src_addr.addr.sin.sin_port = htons(0); - src_addr.addr.sin.sin_addr.s_addr = INADDR_ANY; if (uri.path.length) { buflen = BUFSIZE; @@ -222,15 +292,102 @@ static void coap_example_task(void *p) goto clean_up; } - coap_address_init(&dst_addr); - dst_addr.addr.sin.sin_family = AF_INET; - dst_addr.addr.sin.sin_port = htons(uri.port); - dst_addr.addr.sin.sin_addr.s_addr = ip4_addr->addr; + /* + * Note that if the URI starts with just coap:// (not coaps://) the + * session will still be plain text. + * + * coaps+tcp:// is NOT supported by the libcoap->mbedtls interface + * so COAP_URI_SCHEME_COAPS_TCP will have failed in a test above, + * but the code is left in for completeness. + */ + if (uri.scheme==COAP_URI_SCHEME_COAPS || uri.scheme==COAP_URI_SCHEME_COAPS_TCP) { +#ifdef CONFIG_MBEDTLS_COAP_PSK + session = coap_new_client_session_psk(ctx, NULL, &dst_addr, + uri.scheme==COAP_URI_SCHEME_COAPS ? COAP_PROTO_DTLS : COAP_PROTO_TLS, + EXAMPLE_COAP_PSK_IDENTITY, + (const uint8_t*)EXAMPLE_COAP_PSK_KEY, + sizeof(EXAMPLE_COAP_PSK_KEY)-1); +#endif /* CONFIG_MBEDTLS_COAP_PSK */ - session = coap_new_client_session(ctx, &src_addr, &dst_addr, - uri.scheme==COAP_URI_SCHEME_COAP_TCP ? COAP_PROTO_TCP : - uri.scheme==COAP_URI_SCHEME_COAPS_TCP ? COAP_PROTO_TLS : - uri.scheme==COAP_URI_SCHEME_COAPS ? COAP_PROTO_DTLS : COAP_PROTO_UDP); +#ifdef CONFIG_MBEDTLS_COAP_PKI +/* CA cert, taken from coap_ca.pem + Client cert, taken from coap_client.crt + Client key, taken from coap_client.key + + The PEM, CRT and KEY file are examples taken from the wpa2 enterprise + example. + + To embed it in the app binary, the PEM, CRT and KEY file is named + in the component.mk COMPONENT_EMBED_TXTFILES variable. +*/ +extern uint8_t ca_pem_start[] asm("_binary_coap_ca_pem_start"); +extern uint8_t ca_pem_end[] asm("_binary_coap_ca_pem_end"); +extern uint8_t client_crt_start[] asm("_binary_coap_client_crt_start"); +extern uint8_t client_crt_end[] asm("_binary_coap_client_crt_end"); +extern uint8_t client_key_start[] asm("_binary_coap_client_key_start"); +extern uint8_t client_key_end[] asm("_binary_coap_client_key_end"); + unsigned int ca_pem_bytes = ca_pem_end - ca_pem_start; + unsigned int client_crt_bytes = client_crt_end - client_crt_start; + unsigned int client_key_bytes = client_key_end - client_key_start; + coap_dtls_pki_t dtls_pki; + static char client_sni[256]; + + memset (&dtls_pki, 0, sizeof(dtls_pki)); + dtls_pki.version = COAP_DTLS_PKI_SETUP_VERSION; + if (ca_pem_bytes) { + /* + * Add in additional certificate checking. + * This list of enabled can be tuned for the specific + * requirements - see 'man coap_encryption'. + * + * Note: A list of root ca file can be setup separately using + * coap_context_set_pki_root_cas(), but the below is used to + * define what checking actually takes place. + */ + dtls_pki.verify_peer_cert = 1; + dtls_pki.require_peer_cert = 1; + dtls_pki.allow_self_signed = 1; + dtls_pki.allow_expired_certs = 1; + dtls_pki.cert_chain_validation = 1; + dtls_pki.cert_chain_verify_depth = 2; + dtls_pki.check_cert_revocation = 1; + dtls_pki.allow_no_crl = 1; + dtls_pki.allow_expired_crl = 1; + dtls_pki.allow_bad_md_hash = 1; + dtls_pki.allow_short_rsa_length = 1; + dtls_pki.validate_cn_call_back = verify_cn_callback; + dtls_pki.cn_call_back_arg = NULL; + dtls_pki.validate_sni_call_back = NULL; + dtls_pki.sni_call_back_arg = NULL; + memset(client_sni, 0, sizeof(client_sni)); + if (uri.host.length) + memcpy(client_sni, uri.host.s, min(uri.host.length, sizeof(client_sni))); + else + memcpy(client_sni, "localhost", 9); + dtls_pki.client_sni = client_sni; + } + dtls_pki.pki_key.key_type = COAP_PKI_KEY_PEM_BUF; + dtls_pki.pki_key.key.pem_buf.public_cert = client_crt_start; + dtls_pki.pki_key.key.pem_buf.public_cert_len = client_crt_bytes; + dtls_pki.pki_key.key.pem_buf.private_key = client_key_start; + dtls_pki.pki_key.key.pem_buf.private_key_len = client_key_bytes; + dtls_pki.pki_key.key.pem_buf.ca_cert = ca_pem_start; + dtls_pki.pki_key.key.pem_buf.ca_cert_len = ca_pem_bytes; + + session = coap_new_client_session_pki(ctx, NULL, &dst_addr, + uri.scheme==COAP_URI_SCHEME_COAPS ? COAP_PROTO_DTLS : COAP_PROTO_TLS, + &dtls_pki); +#endif /* CONFIG_MBEDTLS_COAP_PKI */ + +#ifdef CONFIG_MBEDTLS_COAP_NONE + session = coap_new_client_session(ctx, NULL, &dst_addr, + uri.scheme==COAP_URI_SCHEME_COAPS ? COAP_PROTO_DTLS : COAP_PROTO_TLS); +#endif /* CONFIG_MBEDTLS_COAP_NONE */ + } else { + session = coap_new_client_session(ctx, NULL, &dst_addr, + uri.scheme==COAP_URI_SCHEME_COAP_TCP ? COAP_PROTO_TCP : + COAP_PROTO_UDP); + } if (!session) { ESP_LOGE(TAG, "coap_new_client_session() failed"); goto clean_up; @@ -272,7 +429,10 @@ clean_up: if (session) coap_session_release(session); if (ctx) coap_free_context(ctx); coap_cleanup(); - /* Only send the request off once */ + /* + * change the following line to something like sleep(2) + * if you want the request to continually be sent + */ break; } @@ -285,11 +445,19 @@ void app_main(void) tcpip_adapter_init(); ESP_ERROR_CHECK(esp_event_loop_create_default()); +#if 0 +/* See https://github.com/Ebiroll/qemu_esp32 for further information */ +#include "emul_ip.h" + if (is_running_qemu()) { + xTaskCreate(task_lwip_init, "task_lwip_init", 2*4096, NULL, 20, NULL); + } + else +#endif /* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig. * Read "Establishing Wi-Fi or Ethernet Connection" section in * examples/protocols/README.md for more information about this function. */ ESP_ERROR_CHECK(example_connect()); - xTaskCreate(coap_example_task, "coap", 5 * 1024, NULL, 5, NULL); + xTaskCreate(coap_example_client, "coap", 8 * 1024, NULL, 5, NULL); } diff --git a/examples/protocols/coap_client/main/component.mk b/examples/protocols/coap_client/main/component.mk index 0b9d7585e..50306ea2f 100644 --- a/examples/protocols/coap_client/main/component.mk +++ b/examples/protocols/coap_client/main/component.mk @@ -3,3 +3,8 @@ # # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) +# embed files from the "certs" directory as binary data symbols +# in the app +COMPONENT_EMBED_TXTFILES := coap_ca.pem +COMPONENT_EMBED_TXTFILES += coap_client.crt +COMPONENT_EMBED_TXTFILES += coap_client.key diff --git a/examples/protocols/coap_server/README.md b/examples/protocols/coap_server/README.md index cf00279a4..60941855f 100644 --- a/examples/protocols/coap_server/README.md +++ b/examples/protocols/coap_server/README.md @@ -2,14 +2,26 @@ # CoAP server example (See the README.md file in the upper level 'examples' directory for more information about examples.) -This CoAP server example is adaptation of one of the [libcoap](https://github.com/obgm/libcoap) example. +This CoAP server example is very simplified adaptation of one of the +[libcoap](https://github.com/obgm/libcoap) examples. -CoAP server example would startup a daemon task, receive data from CoAP client and transmit data to CoAP client. +CoAP server example will startup a daemon task, receive requests / data from CoAP client and transmit +data to CoAP client. -The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained networks in the Internet of Things. -The protocol is designed for machine-to-machine (M2M) applications such as smart energy and building automation. +If the incoming request requests the use of DTLS (connecting to port 5684), then the CoAP server will +try to establish a DTLS session using the previously defined Pre-Shared Key (PSK) - which +must be the same as the one that the CoAP client is using, or Public Key Infrastructure (PKI) where +the PKI information must match as requested. -please refer to [RFC7252](https://www.rfc-editor.org/rfc/pdfrfc/rfc7252.txt.pdf) for more details. +NOTE: Client sessions trying to use coaps+tcp:// are not currently supported, even though both +libcoap and MbedTLS support it. + +The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with +constrained nodes and constrained networks in the Internet of Things. +The protocol is designed for machine-to-machine (M2M) applications such as smart energy and +building automation. + +Please refer to [RFC7252](https://www.rfc-editor.org/rfc/pdfrfc/rfc7252.txt.pdf) for more details. ## How to use example @@ -19,15 +31,29 @@ please refer to [RFC7252](https://www.rfc-editor.org/rfc/pdfrfc/rfc7252.txt.pdf) idf.py menuconfig ``` -* Set default serial port under Serial Flasher config -* Set WiFi SSID under Example Configuration -* Set WiFi Password under Example Configuration +Example Connection Configuration ---> + * Set WiFi SSID under Example Configuration + * Set WiFi Password under Example Configuration +Example CoAP Client Configuration ---> + * Set CoAP Target Uri + * Set encryption method definitions (None, PSK or PKI) + * If PSK Set CoAP Preshared Key to use in connection to the server + * If PSK Set CoAP PSK Client identity (username) + Enable CoAP debugging if required +Component config ---> + mbedTLS ---> + [*] Enable mbedtls certificate expiry check + TLS Key Exchange Methods ---> + [*] Enable pre-shared-key ciphersuites + [*] Enable PSK based ciphersuite modes + [*] Support DTLS protocol (all versions) ### Build and Flash Build the project and flash it to the board, then run monitor tool to view serial output: ``` +idf.py build idf.py -p PORT flash monitor ``` @@ -54,8 +80,8 @@ I (2622) CoAP_server: Connected to AP ... ``` -if a CoAP client query `/Espressif` resource, CoAP server would return `"no data"` -until a CoAP client does a PUT with some data. +If a CoAP client queries the `/Espressif` resource, CoAP server will return `"Hello World!"` +until a CoAP client does a PUT with different data. ## libcoap Documentation This can be found at https://libcoap.net/doc/reference/4.2.0/ @@ -64,5 +90,7 @@ This can be found at https://libcoap.net/doc/reference/4.2.0/ * Please make sure CoAP client fetchs or puts data under path: `/Espressif` or fetches `/.well-known/core` -* libcoap logging can be increased by changing `#define COAP_LOGGING_LEVEL 0` -to `#define COAP_LOGGING_LEVEL 9` +* CoAP logging can be enabled by running 'make menuconfig' and enable debugging + +* Encryption (MbedTLS) can be enabled by running 'make menuconfig' and enable debugging + diff --git a/examples/protocols/coap_server/main/CMakeLists.txt b/examples/protocols/coap_server/main/CMakeLists.txt index c28a7be75..d4738f691 100644 --- a/examples/protocols/coap_server/main/CMakeLists.txt +++ b/examples/protocols/coap_server/main/CMakeLists.txt @@ -1,2 +1,3 @@ idf_component_register(SRCS "coap_server_example_main.c" - INCLUDE_DIRS ".") \ No newline at end of file + INCLUDE_DIRS "." + EMBED_TXTFILES coap_ca.pem coap_server.crt coap_server.key) diff --git a/examples/protocols/coap_server/main/Kconfig.projbuild b/examples/protocols/coap_server/main/Kconfig.projbuild new file mode 100644 index 000000000..bdf3b1230 --- /dev/null +++ b/examples/protocols/coap_server/main/Kconfig.projbuild @@ -0,0 +1,74 @@ +menu "Example CoAP Server Configuration" + + config MBEDTLS_COAP_PSK + bool "Pre-Shared Keys (PSK)" + default n + help + Use Pre-Shared Keys to encrypt the communications between the + CoAP Server and CoAP Client. Both ends need the same + Pre-Shared Key. + + config COAP_PSK_KEY + string "Preshared Key (PSK) to used in the connection from the CoAP client" + depends on MBEDTLS_COAP_PSK + default "secret-key" + help + The Preshared Key to use to encrypt the communicatons. The same key must be + used at both ends of the CoAP connection, and the CoaP client must request + an URI prefixed with coaps:// instead of coap:// for DTLS to be used. + + config MBEDTLS_COAP_PKI + bool "Public Key Infrastructure (PKI)" + default n + help + Use PKI Certificates and Private Keys to encrypt the communications + between the CoAP Server and CoAP Client. + + config MBEDTLS_COAP_DEBUG + bool "Enable CoAP debugging" + default n + help + Enable CoAP debugging functions at compile time for the example code. + + If this option is enabled, call coap_set_log_level() + at runtime in order to enable CoAP debug output via the ESP + log mechanism. + + choice MBEDTLS_COAP_DEBUG_LEVEL + bool "Set CoAP debugging level" + depends on MBEDTLS_COAP_DEBUG + default COAP_LOG_WARNING + help + Set CoAP debugging level + + config COAP_LOG_EMERG + bool "Emergency" + config COAP_LOG_ALERT + bool "Alert" + config COAP_LOG_CRIT + bool "Critical" + config COAP_LOG_ERROR + bool "Error" + config COAP_LOG_WARNING + bool "Warning" + config COAP_LOG_NOTICE + bool "Notice" + config COAP_LOG_INFO + bool "Info" + config COAP_LOG_DEBUG + bool "Debug" + endchoice + + config COAP_LOG_DEFAULT_LEVEL + int + default 0 if !MBEDTLS_COAP_DEBUG + default 0 if COAP_LOG_EMERG + default 1 if COAP_LOG_ALERT + default 2 if COAP_LOG_CRIT + default 3 if COAP_LOG_ERROR + default 4 if COAP_LOG_WARNING + default 5 if COAP_LOG_NOTICE + default 6 if COAP_LOG_INFO + default 7 if COAP_LOG_DEBUG + +endmenu diff --git a/examples/protocols/coap_server/main/coap_ca.pem b/examples/protocols/coap_server/main/coap_ca.pem new file mode 100644 index 000000000..1bdf23d94 --- /dev/null +++ b/examples/protocols/coap_server/main/coap_ca.pem @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIID3DCCA0WgAwIBAgIJAMnlgL1czsmjMA0GCSqGSIb3DQEBCwUAMIGTMQswCQYD +VQQGEwJGUjEPMA0GA1UECAwGUmFkaXVzMRIwEAYDVQQHDAlTb21ld2hlcmUxFTAT +BgNVBAoMDEV4YW1wbGUgSW5jLjEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhhbXBs +ZS5jb20xJjAkBgNVBAMMHUV4YW1wbGUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X +DTE3MDYwNzA4MDY0OVoXDTI3MDYwNTA4MDY0OVowgZMxCzAJBgNVBAYTAkZSMQ8w +DQYDVQQIDAZSYWRpdXMxEjAQBgNVBAcMCVNvbWV3aGVyZTEVMBMGA1UECgwMRXhh +bXBsZSBJbmMuMSAwHgYJKoZIhvcNAQkBFhFhZG1pbkBleGFtcGxlLmNvbTEmMCQG +A1UEAwwdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwgZ8wDQYJKoZIhvcN +AQEBBQADgY0AMIGJAoGBALpWR23fn/TmHxsXsHdrydzPSd17fZkc71WsaicgQR66 +1tIVYb22UWGfj9KPM8THMsV74ew4ZkaQ39qvU0iuQIRrKARFHFok+vbaecgWMeWe +vGIqdnmyB9gJYaFOKgtSkfXsu2ddsqdvLYwcDbczrq8X9yEXpN6mnxXeCcPG4F0p +AgMBAAGjggE0MIIBMDAdBgNVHQ4EFgQUgigpdAUpONoDq0pQ3yfxrslCSpcwgcgG +A1UdIwSBwDCBvYAUgigpdAUpONoDq0pQ3yfxrslCSpehgZmkgZYwgZMxCzAJBgNV +BAYTAkZSMQ8wDQYDVQQIDAZSYWRpdXMxEjAQBgNVBAcMCVNvbWV3aGVyZTEVMBMG +A1UECgwMRXhhbXBsZSBJbmMuMSAwHgYJKoZIhvcNAQkBFhFhZG1pbkBleGFtcGxl +LmNvbTEmMCQGA1UEAwwdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHmCCQDJ +5YC9XM7JozAMBgNVHRMEBTADAQH/MDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly93 +d3cuZXhhbXBsZS5jb20vZXhhbXBsZV9jYS5jcmwwDQYJKoZIhvcNAQELBQADgYEA +euxOBPInSJRKAIseMxPmAabtAqKNslZSmpG4He3lkKt+HM3jfznUt3psmD7j1hFW +S4l7KXzzajvaGYybDq5N9MqrDjhGn3VXZqOLMUNDL7OQq96TzgqsTBT1dmVSbNlt +PQgiAeKAk3tmH4lRRi9MTBSyJ6I92JYcS5H6Bs4ZwCc= +-----END CERTIFICATE----- diff --git a/examples/protocols/coap_server/main/coap_server.crt b/examples/protocols/coap_server/main/coap_server.crt new file mode 100644 index 000000000..8f1dfcda6 --- /dev/null +++ b/examples/protocols/coap_server/main/coap_server.crt @@ -0,0 +1,70 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 47 (0x2f) + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=FR, ST=Radius, L=Somewhere, O=Example Inc./emailAddress=admin@example.com, CN=Example Certificate Authority + Validity + Not Before: Jun 7 08:06:49 2017 GMT + Not After : Jun 5 08:06:49 2027 GMT + Subject: C=FR, ST=Radius, O=Example Inc., CN=Example Server Certificate/emailAddress=admin@example.com + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (2048 bit) + Modulus: + 00:c9:d8:e2:e0:75:91:83:87:d8:c8:80:c6:20:4d: + e9:14:24:30:98:33:53:fa:56:0e:ec:9a:43:7f:87: + a9:22:94:26:06:c7:ac:b5:d9:ec:55:06:81:b7:0d: + c9:24:51:49:fa:47:fb:4b:4e:fc:ed:75:8a:e1:28: + 32:bc:c5:e0:4c:45:c4:58:60:15:67:1e:6b:40:19: + 3f:f0:ab:92:61:92:2d:71:10:2e:f2:eb:bc:81:2f: + 5a:3b:74:ca:5f:fd:e0:ee:d1:d9:07:6a:6c:20:c0: + 07:88:b4:8b:0f:ad:1e:c9:4f:7c:11:98:37:89:15: + de:24:b1:11:1a:7c:97:4a:cf:f3:c8:cb:79:9e:9c: + c3:71:da:a6:94:97:f5:95:fd:61:06:44:e2:3f:12: + 43:0b:1d:33:48:91:d2:ce:4f:97:a1:ed:6a:30:c7: + 5d:98:b5:6e:0a:b7:4f:d9:03:ec:80:76:09:b0:40: + a1:a1:af:ab:2a:59:c4:0f:56:22:bc:be:14:be:18: + df:10:7d:5d:22:bf:e5:04:77:7a:75:6b:3e:eb:6d: + 20:a1:a7:60:d4:f1:87:9d:9f:60:b9:d3:db:2c:25: + f4:91:4a:f1:d2:40:e5:a1:10:88:a0:41:5a:98:40: + ca:15:d7:e3:e6:3e:c0:6a:d5:46:b2:b4:90:b4:ae: + 3b:e3 + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Extended Key Usage: + TLS Web Server Authentication + X509v3 CRL Distribution Points: + + Full Name: + URI:http://www.example.com/example_ca.crl + + Signature Algorithm: sha1WithRSAEncryption + a4:25:21:51:0b:22:6c:63:8d:a9:c1:4f:04:33:69:79:34:f0: + 36:dd:8f:6a:27:5f:07:a2:1d:ef:8b:f0:96:e6:e7:a3:b8:3b: + 85:5e:3f:26:43:8a:8e:95:58:9c:a6:db:9c:51:bf:ea:53:16: + 3e:c1:a8:11:1a:c6:cf:0e:a1:17:18:64:d2:05:f1:c0:9c:a6: + 2b:16:c4:29:54:03:d2:17:bd:15:74:d6:ad:8a:8f:2d:cc:27: + 3b:88:88:f2:ea:d0:a2:cb:e9:42:57:df:26:9f:8a:a2:02:2f: + 35:b6:19:1d:26:43:44:af:12:4b:bc:b9:84:50:02:fd:1d:fa: + 50:e8 +-----BEGIN CERTIFICATE----- +MIIDWTCCAsKgAwIBAgIBLzANBgkqhkiG9w0BAQUFADCBkzELMAkGA1UEBhMCRlIx +DzANBgNVBAgMBlJhZGl1czESMBAGA1UEBwwJU29tZXdoZXJlMRUwEwYDVQQKDAxF +eGFtcGxlIEluYy4xIDAeBgkqhkiG9w0BCQEWEWFkbWluQGV4YW1wbGUuY29tMSYw +JAYDVQQDDB1FeGFtcGxlIENlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNzA2MDcw +ODA2NDlaFw0yNzA2MDUwODA2NDlaMHwxCzAJBgNVBAYTAkZSMQ8wDQYDVQQIDAZS +YWRpdXMxFTATBgNVBAoMDEV4YW1wbGUgSW5jLjEjMCEGA1UEAwwaRXhhbXBsZSBT +ZXJ2ZXIgQ2VydGlmaWNhdGUxIDAeBgkqhkiG9w0BCQEWEWFkbWluQGV4YW1wbGUu +Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAydji4HWRg4fYyIDG +IE3pFCQwmDNT+lYO7JpDf4epIpQmBsestdnsVQaBtw3JJFFJ+kf7S0787XWK4Sgy +vMXgTEXEWGAVZx5rQBk/8KuSYZItcRAu8uu8gS9aO3TKX/3g7tHZB2psIMAHiLSL +D60eyU98EZg3iRXeJLERGnyXSs/zyMt5npzDcdqmlJf1lf1hBkTiPxJDCx0zSJHS +zk+Xoe1qMMddmLVuCrdP2QPsgHYJsEChoa+rKlnED1YivL4UvhjfEH1dIr/lBHd6 +dWs+620goadg1PGHnZ9gudPbLCX0kUrx0kDloRCIoEFamEDKFdfj5j7AatVGsrSQ +tK474wIDAQABo08wTTATBgNVHSUEDDAKBggrBgEFBQcDATA2BgNVHR8ELzAtMCug +KaAnhiVodHRwOi8vd3d3LmV4YW1wbGUuY29tL2V4YW1wbGVfY2EuY3JsMA0GCSqG +SIb3DQEBBQUAA4GBAKQlIVELImxjjanBTwQzaXk08Dbdj2onXweiHe+L8Jbm56O4 +O4VePyZDio6VWJym25xRv+pTFj7BqBEaxs8OoRcYZNIF8cCcpisWxClUA9IXvRV0 +1q2Kjy3MJzuIiPLq0KLL6UJX3yafiqICLzW2GR0mQ0SvEku8uYRQAv0d+lDo +-----END CERTIFICATE----- diff --git a/examples/protocols/coap_server/main/coap_server.key b/examples/protocols/coap_server/main/coap_server.key new file mode 100644 index 000000000..9b3433273 --- /dev/null +++ b/examples/protocols/coap_server/main/coap_server.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAydji4HWRg4fYyIDGIE3pFCQwmDNT+lYO7JpDf4epIpQmBses +tdnsVQaBtw3JJFFJ+kf7S0787XWK4SgyvMXgTEXEWGAVZx5rQBk/8KuSYZItcRAu +8uu8gS9aO3TKX/3g7tHZB2psIMAHiLSLD60eyU98EZg3iRXeJLERGnyXSs/zyMt5 +npzDcdqmlJf1lf1hBkTiPxJDCx0zSJHSzk+Xoe1qMMddmLVuCrdP2QPsgHYJsECh +oa+rKlnED1YivL4UvhjfEH1dIr/lBHd6dWs+620goadg1PGHnZ9gudPbLCX0kUrx +0kDloRCIoEFamEDKFdfj5j7AatVGsrSQtK474wIDAQABAoIBAQC2kGDEPBJdMSW2 +VCLfXRiPixwYzXQLXIMrJWwfkQg9qlmqkDd6U50aWkRA2UswegW7RhfYSZ0i+cmf +VMhvTVpOIlwwwtcY6b5/v1bBy60eaySGuuh79xQMlFO8qynQIMStvUfbGTqrdIRb +9VBB4YeS9T12fILejtTZwv2BQ2dj1Y1SCay6Ri85UzJqSClRKgHISybvVdLNjPvP +0TRFBr57zyjL6WE8teKiKchzQko2u86No5uBCdKGsrAkrsdcR0YqlM/pZxd3VKNm ++eny0k+dZZlvcPxzkzP4hEp9+Rw5rP9/s3s/cCwvuuC5JO32ATBWKCbTvPv/XPDb +MdSJtOshAoGBAPzk0eswkcbFYtpnpBNmBAr1dtAdW1lfjUI2ucMMwt7Wns0P/tt+ +gq6Hi1wTaGP0l/dIECgeHwjtWj31ZJjQtFJ1y/kafxo4o9cA8vCydpdvSZaldAfg +sbLlDTDYzEpelaDIbNQBBXFoC5U9JlBhBsIFCL5Z8ZuIeFPsb7t5wwuHAoGBAMxT +jyWfNm1uNxp1xgCnrRsLPQPVnURrSFAqcHrECqRu3F7sozTN7q/cZViemxPvVDGQ +p9c+9bHwaYvW4trO5qDHJ++gGwm5L52bMAY1VUfeTt67fqrey43XpdmzcTX1V9Uj +QWawPUCSDzFjL1MjfCIejtyYf5ash53vj+T8r/vFAoGAA/OPVB1uKazr3n3AEo2F +gqZTNO1AgCT+EArK3EFWyiSQVqPpV4SihheYFdg3yVgJB9QYbIgL9BfBUTaEW97m +8mLkzP+c/Mvlw3ZAVYJ0V+llPPVY2saoACOUES9SAdd4fwqiqK1baGo3xB0wfBEI +CgAKIu9E1ylKuAT5ufQtGAECgYEAtP/kU5h5N3El4QupTdU7VDSdZTMqsHw0v8cI +gsf9AXKvRmtrnBA8u46KPHmruHoO5CVXeSZtsaXdaaH+rYQQ6yXg67WxnehtFLlv +TmCaXiLBTS9cYvMf8FOyuGnsBLeEietEOTov2G5KhR5uwsAxa2wUc7endor5S9/2 +YQuyvV0CgYALbiFpILd5l1ip65eE6JdA3hfttUbV2j2NSW12ej69vqbeOfaSgNse +uYCcXFsBbQPhNPwA+4d1oCe8SyXZg1f7gE812z2Tyr/3vdVnNZlitoxhsHmGiyS7 +gZdaTYCb78l9z0EBdaCVvA16owEle4SR6f9eCwzSI0WPOUra+x/hrA== +-----END RSA PRIVATE KEY----- diff --git a/examples/protocols/coap_server/main/coap_server_example_main.c b/examples/protocols/coap_server/main/coap_server_example_main.c index eb5e131ba..b2f78bb03 100644 --- a/examples/protocols/coap_server/main/coap_server_example_main.c +++ b/examples/protocols/coap_server/main/coap_server_example_main.c @@ -7,6 +7,13 @@ CONDITIONS OF ANY KIND, either express or implied. */ +/* + * WARNING + * libcoap is not multi-thread safe, so only this thread must make any coap_*() + * calls. Any external (to this thread) data transmitted in/out via libcoap + * therefore has to be passed in/out by xQueue*() via this thread. + */ + #include #include @@ -22,14 +29,39 @@ #include "protocol_examples_common.h" +#if 1 +/* Needed until coap_dtls.h becomes a part of libcoap proper */ +#include "libcoap.h" +#include "coap_dtls.h" +#endif #include "coap.h" -/* Set this to 9 to get verbose logging from within libcoap */ -#define COAP_LOGGING_LEVEL 0 +/* The examples use simple Pre-Shared-Key configuration that you can set via + 'make menuconfig'. + + If you'd rather not, just change the below entries to strings with + the config you want - ie #define EXAMPLE_COAP_PSK_KEY "some-agreed-preshared-key" + + Note: PSK will only be used if the URI is prefixed with coaps:// + instead of coap:// and the PSK must be one that the server supports + (potentially associated with the IDENTITY) +*/ +#define EXAMPLE_COAP_PSK_KEY CONFIG_COAP_PSK_KEY + +/* The examples use CoAP Logging Level that + you can set via 'make menuconfig'. + + If you'd rather not, just change the below entry to a value + that is between 0 and 7 with + the config you want - ie #define EXAMPLE_COAP_LOG_DEFAULT_LEVEL 7 +*/ +#define EXAMPLE_COAP_LOG_DEFAULT_LEVEL CONFIG_COAP_LOG_DEFAULT_LEVEL static char espressif_data[100]; static int espressif_data_len = 0; +#define INITIAL_DATA "Hello World!" + /* * The resource handler */ @@ -59,7 +91,7 @@ hnd_espressif_put(coap_context_t *ctx, coap_resource_notify_observers(resource, NULL); - if (strcmp (espressif_data, "no data") == 0) { + if (strcmp (espressif_data, INITIAL_DATA) == 0) { response->code = COAP_RESPONSE_CODE(201); } else { @@ -70,7 +102,7 @@ hnd_espressif_put(coap_context_t *ctx, (void)coap_get_data(request, &size, &data); if (size == 0) { /* re-init */ - snprintf(espressif_data, sizeof(espressif_data), "no data"); + snprintf(espressif_data, sizeof(espressif_data), INITIAL_DATA); espressif_data_len = strlen(espressif_data); } else { espressif_data_len = size > sizeof (espressif_data) ? sizeof (espressif_data) : size; @@ -88,23 +120,50 @@ hnd_espressif_delete(coap_context_t *ctx, coap_pdu_t *response) { coap_resource_notify_observers(resource, NULL); - snprintf(espressif_data, sizeof(espressif_data), "no data"); + snprintf(espressif_data, sizeof(espressif_data), INITIAL_DATA); espressif_data_len = strlen(espressif_data); response->code = COAP_RESPONSE_CODE(202); } -static void coap_example_thread(void *p) +#ifdef CONFIG_MBEDTLS_COAP_PKI + +#ifdef __GNUC__ +#define UNUSED_PARAM __attribute__ ((unused)) +#else /* not a GCC */ +#define UNUSED_PARAM +#endif /* GCC */ + +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif + +static int +verify_cn_callback(const char *cn, + const uint8_t *asn1_public_cert UNUSED_PARAM, + size_t asn1_length UNUSED_PARAM, + coap_session_t *session UNUSED_PARAM, + unsigned depth, + int validated UNUSED_PARAM, + void *arg UNUSED_PARAM +) { + coap_log(LOG_INFO, "CN '%s' presented by server (%s)\n", + cn, depth ? "CA" : "Certificate"); + return 1; +} +#endif /* CONFIG_MBEDTLS_COAP_PKI */ + +static void coap_example_server(void *p) { coap_context_t *ctx = NULL; - coap_address_t serv_addr; + coap_address_t serv_addr; coap_resource_t *resource = NULL; - snprintf(espressif_data, sizeof(espressif_data), "no data"); + snprintf(espressif_data, sizeof(espressif_data), INITIAL_DATA); espressif_data_len = strlen(espressif_data); - coap_set_log_level(COAP_LOGGING_LEVEL); + coap_set_log_level(EXAMPLE_COAP_LOG_DEFAULT_LEVEL); + while (1) { - coap_endpoint_t *ep_udp = NULL; - coap_endpoint_t *ep_tcp = NULL; + coap_endpoint_t *ep = NULL; unsigned wait_ms; /* Prepare the CoAP server socket */ @@ -117,14 +176,91 @@ static void coap_example_thread(void *p) if (!ctx) { continue; } - ep_udp = coap_new_endpoint(ctx, &serv_addr, COAP_PROTO_UDP); - if (!ep_udp) { +#ifdef CONFIG_MBEDTLS_COAP_PSK + /* Need PSK setup before we set up endpoints */ + coap_context_set_psk(ctx, "CoAP", + (const uint8_t*)EXAMPLE_COAP_PSK_KEY, + sizeof(EXAMPLE_COAP_PSK_KEY)-1); +#endif /* CONFIG_MBEDTLS_COAP_PSK */ + +#ifdef CONFIG_MBEDTLS_COAP_PKI +/* CA cert, taken from coap_ca.pem + Server cert, taken from coap_server.crt + Server key, taken from coap_server.key + + The PEM, CRT and KEY file are examples taken from the wpa2 enterprise + example. + + To embed it in the app binary, the PEM, CRT and KEY file is named + in the component.mk COMPONENT_EMBED_TXTFILES variable. +*/ +extern uint8_t ca_pem_start[] asm("_binary_coap_ca_pem_start"); +extern uint8_t ca_pem_end[] asm("_binary_coap_ca_pem_end"); +extern uint8_t server_crt_start[] asm("_binary_coap_server_crt_start"); +extern uint8_t server_crt_end[] asm("_binary_coap_server_crt_end"); +extern uint8_t server_key_start[] asm("_binary_coap_server_key_start"); +extern uint8_t server_key_end[] asm("_binary_coap_server_key_end"); + unsigned int ca_pem_bytes = ca_pem_end - ca_pem_start; + unsigned int server_crt_bytes = server_crt_end - server_crt_start; + unsigned int server_key_bytes = server_key_end - server_key_start; + coap_dtls_pki_t dtls_pki; + + memset (&dtls_pki, 0, sizeof(dtls_pki)); + dtls_pki.version = COAP_DTLS_PKI_SETUP_VERSION; + if (ca_pem_bytes) { + /* + * Add in additional certificate checking. + * This list of enabled can be tuned for the specific + * requirements - see 'man coap_encryption'. + * + * Note: A list of root ca file can be setup separately using + * coap_context_set_pki_root_cas(), but the below is used to + * define what checking actually takes place. + */ + dtls_pki.verify_peer_cert = 1; + dtls_pki.require_peer_cert = 1; + dtls_pki.allow_self_signed = 1; + dtls_pki.allow_expired_certs = 1; + dtls_pki.cert_chain_validation = 1; + dtls_pki.cert_chain_verify_depth = 2; + dtls_pki.check_cert_revocation = 1; + dtls_pki.allow_no_crl = 1; + dtls_pki.allow_expired_crl = 1; + dtls_pki.allow_bad_md_hash = 1; + dtls_pki.allow_short_rsa_length = 1; + dtls_pki.validate_cn_call_back = verify_cn_callback; + dtls_pki.cn_call_back_arg = NULL; + dtls_pki.validate_sni_call_back = NULL; + dtls_pki.sni_call_back_arg = NULL; + } + dtls_pki.pki_key.key_type = COAP_PKI_KEY_PEM_BUF; + dtls_pki.pki_key.key.pem_buf.public_cert = server_crt_start; + dtls_pki.pki_key.key.pem_buf.public_cert_len = server_crt_bytes; + dtls_pki.pki_key.key.pem_buf.private_key = server_key_start; + dtls_pki.pki_key.key.pem_buf.private_key_len = server_key_bytes; + dtls_pki.pki_key.key.pem_buf.ca_cert = ca_pem_start; + dtls_pki.pki_key.key.pem_buf.ca_cert_len = ca_pem_bytes; + + coap_context_set_pki(ctx, &dtls_pki); +#endif /* CONFIG_MBEDTLS_COAP_PKI */ + + ep = coap_new_endpoint(ctx, &serv_addr, COAP_PROTO_UDP); + if (!ep) { goto clean_up; } - ep_tcp = coap_new_endpoint(ctx, &serv_addr, COAP_PROTO_TCP); - if (!ep_tcp) { + ep = coap_new_endpoint(ctx, &serv_addr, COAP_PROTO_TCP); + if (!ep) { goto clean_up; } +#if defined(CONFIG_MBEDTLS_COAP_PSK) || defined(CONFIG_MBEDTLS_COAP_PKI) + if (coap_dtls_is_supported()) { + serv_addr.addr.sin.sin_port = htons(COAPS_DEFAULT_PORT); + ep = coap_new_endpoint(ctx, &serv_addr, COAP_PROTO_DTLS); + if (!ep) { + goto clean_up; + } + } +#endif /* CONFIG_MBEDTLS_COAP_PSK CONFIG_MBEDTLS_COAP_PKI */ resource = coap_resource_init(coap_make_str_const("Espressif"), 0); if (!resource) { goto clean_up; @@ -165,11 +301,19 @@ void app_main(void) tcpip_adapter_init(); ESP_ERROR_CHECK(esp_event_loop_create_default()); +#if 0 +/* See https://github.com/Ebiroll/qemu_esp32 for further information */ +#include "emul_ip.h" + if (is_running_qemu()) { + xTaskCreate(task_lwip_init, "task_lwip_init", 2*4096, NULL, 20, NULL); + } + else +#endif /* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig. * Read "Establishing Wi-Fi or Ethernet Connection" section in * examples/protocols/README.md for more information about this function. */ ESP_ERROR_CHECK(example_connect()); - xTaskCreate(coap_example_thread, "coap", 1024 * 5, NULL, 5, NULL); + xTaskCreate(coap_example_server, "coap", 8 * 1024, NULL, 5, NULL); } diff --git a/examples/protocols/coap_server/main/component.mk b/examples/protocols/coap_server/main/component.mk index 0b9d7585e..bccdac23f 100644 --- a/examples/protocols/coap_server/main/component.mk +++ b/examples/protocols/coap_server/main/component.mk @@ -3,3 +3,8 @@ # # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) +# embed files from the "certs" directory as binary data symbols +# in the app +COMPONENT_EMBED_TXTFILES := coap_ca.pem +COMPONENT_EMBED_TXTFILES += coap_server.crt +COMPONENT_EMBED_TXTFILES += coap_server.key From 852c176a408b18e8f4bf2e5af3adb742af5a5a42 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Wed, 31 Jul 2019 16:21:25 +0530 Subject: [PATCH 34/36] coap: add mbedtls in depedency list for CMake build --- components/coap/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/coap/CMakeLists.txt b/components/coap/CMakeLists.txt index 6d7dbb451..3b2da20ce 100644 --- a/components/coap/CMakeLists.txt +++ b/components/coap/CMakeLists.txt @@ -21,11 +21,9 @@ set(srcs "libcoap/src/coap_io.c" "port/coap_mbedtls.c") -set(COMPONENT_REQUIRES lwip) - idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" - REQUIRES lwip) + REQUIRES lwip mbedtls) # Silence format truncation warning, until it is fixed upstream set_source_files_properties(port/coap_debug.c PROPERTIES COMPILE_FLAGS -Wno-format-truncation) From 10c3b42f71566831d638b7b63850007fd434a2fa Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Wed, 31 Jul 2019 16:22:01 +0530 Subject: [PATCH 35/36] coap: kconfig cleanup, have component specific configuration for common options --- components/coap/Kconfig | 74 +++++++++++++++ .../coap_client/main/Kconfig.projbuild | 89 +++---------------- .../coap_server/main/Kconfig.projbuild | 71 +-------------- 3 files changed, 88 insertions(+), 146 deletions(-) create mode 100644 components/coap/Kconfig diff --git a/components/coap/Kconfig b/components/coap/Kconfig new file mode 100644 index 000000000..ad00334c1 --- /dev/null +++ b/components/coap/Kconfig @@ -0,0 +1,74 @@ +menu "CoAP Configuration" + + choice COAP_MBEDTLS_ENCRYPTION_MODE + prompt "CoAP Encryption method" + default COAP_MBEDTLS_PSK + help + If the CoAP information is to be encrypted, the encryption environment + can be set up in one of two ways (default being Pre-Shared key mode) + + - Encrypt using defined Pre-Shared Keys (PSK if uri includes coaps://) + - Encrypt using defined Public Key Infrastructure (PKI if uri includes coaps://) + + config COAP_MBEDTLS_PSK + select MBEDTLS_SSL_PROTO_DTLS + select MBEDTLS_PSK_MODES + select MBEDTLS_KEY_EXCHANGE_PSK + bool "Pre-Shared Keys" + + config COAP_MBEDTLS_PKI + select MBEDTLS_SSL_PROTO_DTLS + select MBEDTLS_PSK_MODES + select MBEDTLS_KEY_EXCHANGE_PSK + bool "PKI Certificates" + + endchoice #COAP_MBEDTLS_ENCRYPTION_MODE + + config COAP_MBEDTLS_DEBUG + bool "Enable CoAP debugging" + default n + help + Enable CoAP debugging functions at compile time for the example code. + + If this option is enabled, call coap_set_log_level() + at runtime in order to enable CoAP debug output via the ESP + log mechanism. + + choice COAP_MBEDTLS_DEBUG_LEVEL + bool "Set CoAP debugging level" + depends on COAP_MBEDTLS_DEBUG + default COAP_LOG_WARNING + help + Set CoAP debugging level + + config COAP_LOG_EMERG + bool "Emergency" + config COAP_LOG_ALERT + bool "Alert" + config COAP_LOG_CRIT + bool "Critical" + config COAP_LOG_ERROR + bool "Error" + config COAP_LOG_WARNING + bool "Warning" + config COAP_LOG_NOTICE + bool "Notice" + config COAP_LOG_INFO + bool "Info" + config COAP_LOG_DEBUG + bool "Debug" + endchoice + + config COAP_LOG_DEFAULT_LEVEL + int + default 0 if !COAP_MBEDTLS_DEBUG + default 0 if COAP_LOG_EMERG + default 1 if COAP_LOG_ALERT + default 2 if COAP_LOG_CRIT + default 3 if COAP_LOG_ERROR + default 4 if COAP_LOG_WARNING + default 5 if COAP_LOG_NOTICE + default 6 if COAP_LOG_INFO + default 7 if COAP_LOG_DEBUG + +endmenu diff --git a/examples/protocols/coap_client/main/Kconfig.projbuild b/examples/protocols/coap_client/main/Kconfig.projbuild index f96ac41e4..33b04a7b8 100644 --- a/examples/protocols/coap_client/main/Kconfig.projbuild +++ b/examples/protocols/coap_client/main/Kconfig.projbuild @@ -1,96 +1,27 @@ menu "Example CoAP Client Configuration" - config TARGET_DOMAIN_URI + config EXAMPLE_TARGET_DOMAIN_URI string "Target Uri" - default "coap://californium.eclipse.org" + default "coaps://californium.eclipse.org" help Target uri for the example to use. Use coaps:// prefix for encrypted traffic using Pre-Shared Key (PSK) or Public Key Infrastructure (PKI). - choice MBEDTLS_COAP_ENCRYPTION_MODE - prompt "CoAP Encryption method" - default MBEDTLS_COAP_PKI_NONE - help - If the CoAP information is to be encrypted, the encryption environment - can be set up in one of three ways - - - None defined (will use PKI if coaps:// used) - - Encrypt using defined Pre-Shared Keys (PSK) - - Encrypt using defined Public Key Infrastructure (PKI) - - config MBEDTLS_COAP_NONE - bool "None defined" - - config MBEDTLS_COAP_PSK - bool "Pre-Shared Keys" - - config MBEDTLS_COAP_PKI - bool "PKI Certificates" - - endchoice #MBEDTLS_COAP_ENCRYPTION_MODE - - config COAP_PSK_KEY + config EXAMPLE_COAP_PSK_KEY string "Preshared Key (PSK) to used in the connection to the CoAP server" - depends on MBEDTLS_COAP_PSK - default "secret-key" + depends on COAP_MBEDTLS_PSK + default "sesame" help - The Preshared Key to use to encrypt the communicatons. The same key must be - used at both ends of the CoAP connection, and the CoaP client must request + The Preshared Key to use to encrypt the communicatons. The same key must be + used at both ends of the CoAP connection, and the CoaP client must request an URI prefixed with coaps:// instead of coap:// for DTLS to be used. - config COAP_PSK_IDENTITY + config EXAMPLE_COAP_PSK_IDENTITY string "PSK Client identity (username)" - depends on MBEDTLS_COAP_PSK - default "coap-client" + depends on COAP_MBEDTLS_PSK + default "password" help The identity (or username) to use to identify to the CoAP server which PSK key to use. - config MBEDTLS_COAP_DEBUG - bool "Enable CoAP debugging" - default n - help - Enable CoAP debugging functions at compile time for the example code. - - If this option is enabled, call coap_set_log_level() - at runtime in order to enable CoAP debug output via the ESP - log mechanism. - - choice MBEDTLS_COAP_DEBUG_LEVEL - bool "Set CoAP debugging level" - depends on MBEDTLS_COAP_DEBUG - default COAP_LOG_WARNING - help - Set CoAP debugging level - - config COAP_LOG_EMERG - bool "Emergency" - config COAP_LOG_ALERT - bool "Alert" - config COAP_LOG_CRIT - bool "Critical" - config COAP_LOG_ERROR - bool "Error" - config COAP_LOG_WARNING - bool "Warning" - config COAP_LOG_NOTICE - bool "Notice" - config COAP_LOG_INFO - bool "Info" - config COAP_LOG_DEBUG - bool "Debug" - endchoice - - config COAP_LOG_DEFAULT_LEVEL - int - default 0 if !MBEDTLS_COAP_DEBUG - default 0 if COAP_LOG_EMERG - default 1 if COAP_LOG_ALERT - default 2 if COAP_LOG_CRIT - default 3 if COAP_LOG_ERROR - default 4 if COAP_LOG_WARNING - default 5 if COAP_LOG_NOTICE - default 6 if COAP_LOG_INFO - default 7 if COAP_LOG_DEBUG - endmenu diff --git a/examples/protocols/coap_server/main/Kconfig.projbuild b/examples/protocols/coap_server/main/Kconfig.projbuild index bdf3b1230..19da8165a 100644 --- a/examples/protocols/coap_server/main/Kconfig.projbuild +++ b/examples/protocols/coap_server/main/Kconfig.projbuild @@ -1,74 +1,11 @@ menu "Example CoAP Server Configuration" - config MBEDTLS_COAP_PSK - bool "Pre-Shared Keys (PSK)" - default n - help - Use Pre-Shared Keys to encrypt the communications between the - CoAP Server and CoAP Client. Both ends need the same - Pre-Shared Key. - - config COAP_PSK_KEY + config EXAMPLE_COAP_PSK_KEY string "Preshared Key (PSK) to used in the connection from the CoAP client" - depends on MBEDTLS_COAP_PSK + depends on COAP_MBEDTLS_PSK default "secret-key" help - The Preshared Key to use to encrypt the communicatons. The same key must be - used at both ends of the CoAP connection, and the CoaP client must request + The Preshared Key to use to encrypt the communicatons. The same key must be + used at both ends of the CoAP connection, and the CoaP client must request an URI prefixed with coaps:// instead of coap:// for DTLS to be used. - - config MBEDTLS_COAP_PKI - bool "Public Key Infrastructure (PKI)" - default n - help - Use PKI Certificates and Private Keys to encrypt the communications - between the CoAP Server and CoAP Client. - - config MBEDTLS_COAP_DEBUG - bool "Enable CoAP debugging" - default n - help - Enable CoAP debugging functions at compile time for the example code. - - If this option is enabled, call coap_set_log_level() - at runtime in order to enable CoAP debug output via the ESP - log mechanism. - - choice MBEDTLS_COAP_DEBUG_LEVEL - bool "Set CoAP debugging level" - depends on MBEDTLS_COAP_DEBUG - default COAP_LOG_WARNING - help - Set CoAP debugging level - - config COAP_LOG_EMERG - bool "Emergency" - config COAP_LOG_ALERT - bool "Alert" - config COAP_LOG_CRIT - bool "Critical" - config COAP_LOG_ERROR - bool "Error" - config COAP_LOG_WARNING - bool "Warning" - config COAP_LOG_NOTICE - bool "Notice" - config COAP_LOG_INFO - bool "Info" - config COAP_LOG_DEBUG - bool "Debug" - endchoice - - config COAP_LOG_DEFAULT_LEVEL - int - default 0 if !MBEDTLS_COAP_DEBUG - default 0 if COAP_LOG_EMERG - default 1 if COAP_LOG_ALERT - default 2 if COAP_LOG_CRIT - default 3 if COAP_LOG_ERROR - default 4 if COAP_LOG_WARNING - default 5 if COAP_LOG_NOTICE - default 6 if COAP_LOG_INFO - default 7 if COAP_LOG_DEBUG - endmenu From a8bfe59bd159e9191f3d83496ddf19ad8cebebf8 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Wed, 31 Jul 2019 16:22:49 +0530 Subject: [PATCH 36/36] coap: refactor examples, stylistic cleanups, move certs to independent dir --- examples/protocols/coap_client/README.md | 19 +- .../protocols/coap_client/main/CMakeLists.txt | 2 +- .../coap_client/main/{ => certs}/coap_ca.pem | 0 .../main/{ => certs}/coap_client.crt | 0 .../main/{ => certs}/coap_client.key | 0 .../main/coap_client_example_main.c | 203 ++++++++---------- .../protocols/coap_client/main/component.mk | 4 +- examples/protocols/coap_server/README.md | 20 +- .../protocols/coap_server/main/CMakeLists.txt | 2 +- .../coap_server/main/{ => certs}/coap_ca.pem | 0 .../main/{ => certs}/coap_server.crt | 0 .../main/{ => certs}/coap_server.key | 0 .../main/coap_server_example_main.c | 196 ++++++++--------- .../protocols/coap_server/main/component.mk | 4 +- 14 files changed, 202 insertions(+), 248 deletions(-) rename examples/protocols/coap_client/main/{ => certs}/coap_ca.pem (100%) rename examples/protocols/coap_client/main/{ => certs}/coap_client.crt (100%) rename examples/protocols/coap_client/main/{ => certs}/coap_client.key (100%) rename examples/protocols/coap_server/main/{ => certs}/coap_ca.pem (100%) rename examples/protocols/coap_server/main/{ => certs}/coap_server.crt (100%) rename examples/protocols/coap_server/main/{ => certs}/coap_server.key (100%) diff --git a/examples/protocols/coap_client/README.md b/examples/protocols/coap_client/README.md index 7c317dddd..a870f9363 100644 --- a/examples/protocols/coap_client/README.md +++ b/examples/protocols/coap_client/README.md @@ -37,17 +37,12 @@ Example Connection Configuration ---> * Set WiFi Password under Example Configuration Example CoAP Client Configuration ---> * Set CoAP Target Uri - * Set encryption method definitions (None, PSK or PKI) - * If PSK Set CoAP Preshared Key to use in connection to the server - * If PSK Set CoAP PSK Client identity (username) - Enable CoAP debugging if required + * If PSK, Set CoAP Preshared Key to use in connection to the server + * If PSK, Set CoAP PSK Client identity (username) Component config ---> - mbedTLS ---> - [*] Enable mbedtls certificate expiry check - TLS Key Exchange Methods ---> - [*] Enable pre-shared-key ciphersuites - [*] Enable PSK based ciphersuite modes - [*] Support DTLS protocol (all versions) + CoAP Configuration ---> + * Set encryption method definition, PSK (default) or PKI + * Enable CoAP debugging if required ### Build and Flash @@ -103,6 +98,4 @@ optional `path`, and begins with `coap://`, `coaps://` or `coap+tcp://` for a coap server that supports TCP (not all do including coap+tcp://californium.eclipse.org). -* CoAP logging can be enabled by running 'make menuconfig' and enable debugging - -* Encryption (MbedTLS) can be enabled by running 'make menuconfig' and enable debugging +* CoAP logging can be enabled by running 'idf.py menuconfig -> Component config -> CoAP Configuration' and setting appropriate log level diff --git a/examples/protocols/coap_client/main/CMakeLists.txt b/examples/protocols/coap_client/main/CMakeLists.txt index eb0d27066..d64daaee2 100644 --- a/examples/protocols/coap_client/main/CMakeLists.txt +++ b/examples/protocols/coap_client/main/CMakeLists.txt @@ -1,4 +1,4 @@ # Embed CA, certificate & key directly into binary idf_component_register(SRCS "coap_client_example_main.c" INCLUDE_DIRS "." - EMBED_TXTFILES coap_ca.pem coap_client.crt coap_client.key) + EMBED_TXTFILES certs/coap_ca.pem certs/coap_client.crt certs/coap_client.key) diff --git a/examples/protocols/coap_client/main/coap_ca.pem b/examples/protocols/coap_client/main/certs/coap_ca.pem similarity index 100% rename from examples/protocols/coap_client/main/coap_ca.pem rename to examples/protocols/coap_client/main/certs/coap_ca.pem diff --git a/examples/protocols/coap_client/main/coap_client.crt b/examples/protocols/coap_client/main/certs/coap_client.crt similarity index 100% rename from examples/protocols/coap_client/main/coap_client.crt rename to examples/protocols/coap_client/main/certs/coap_client.crt diff --git a/examples/protocols/coap_client/main/coap_client.key b/examples/protocols/coap_client/main/certs/coap_client.key similarity index 100% rename from examples/protocols/coap_client/main/coap_client.key rename to examples/protocols/coap_client/main/certs/coap_client.key diff --git a/examples/protocols/coap_client/main/coap_client_example_main.c b/examples/protocols/coap_client/main/coap_client_example_main.c index 067364a73..c7223bc0e 100644 --- a/examples/protocols/coap_client/main/coap_client_example_main.c +++ b/examples/protocols/coap_client/main/coap_client_example_main.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -49,8 +50,8 @@ instead of coap:// and the PSK must be one that the server supports (potentially associated with the IDENTITY) */ -#define EXAMPLE_COAP_PSK_KEY CONFIG_COAP_PSK_KEY -#define EXAMPLE_COAP_PSK_IDENTITY CONFIG_COAP_PSK_IDENTITY +#define EXAMPLE_COAP_PSK_KEY CONFIG_EXAMPLE_COAP_PSK_KEY +#define EXAMPLE_COAP_PSK_IDENTITY CONFIG_EXAMPLE_COAP_PSK_IDENTITY /* The examples use uri Logging Level that you can set via 'make menuconfig'. @@ -65,9 +66,9 @@ you can set via the project configuration (idf.py menuconfig) If you'd rather not, just change the below entries to strings with - the config you want - ie #define COAP_DEFAULT_DEMO_URI "coap://californium.eclipse.org" + the config you want - ie #define COAP_DEFAULT_DEMO_URI "coaps://californium.eclipse.org" */ -#define COAP_DEFAULT_DEMO_URI CONFIG_TARGET_DOMAIN_URI +#define COAP_DEFAULT_DEMO_URI CONFIG_EXAMPLE_TARGET_DOMAIN_URI const static char *TAG = "CoAP_client"; @@ -75,11 +76,30 @@ static int resp_wait = 1; static coap_optlist_t *optlist = NULL; static int wait_ms; +#ifdef CONFIG_COAP_MBEDTLS_PKI +/* CA cert, taken from coap_ca.pem + Client cert, taken from coap_client.crt + Client key, taken from coap_client.key + + The PEM, CRT and KEY file are examples taken from the wpa2 enterprise + example. + + To embed it in the app binary, the PEM, CRT and KEY file is named + in the component.mk COMPONENT_EMBED_TXTFILES variable. + */ +extern uint8_t ca_pem_start[] asm("_binary_coap_ca_pem_start"); +extern uint8_t ca_pem_end[] asm("_binary_coap_ca_pem_end"); +extern uint8_t client_crt_start[] asm("_binary_coap_client_crt_start"); +extern uint8_t client_crt_end[] asm("_binary_coap_client_crt_end"); +extern uint8_t client_key_start[] asm("_binary_coap_client_key_start"); +extern uint8_t client_key_end[] asm("_binary_coap_client_key_end"); +#endif /* CONFIG_COAP_MBEDTLS_PKI */ + static void message_handler(coap_context_t *ctx, coap_session_t *session, - coap_pdu_t *sent, coap_pdu_t *received, - const coap_tid_t id) + coap_pdu_t *sent, coap_pdu_t *received, + const coap_tid_t id) { - unsigned char* data = NULL; + unsigned char *data = NULL; size_t data_len; coap_pdu_t *pdu = NULL; coap_opt_t *block_opt; @@ -106,8 +126,8 @@ static void message_handler(coap_context_t *ctx, coap_session_t *session, /* create pdu with request for next block */ pdu = coap_new_pdu(session); if (!pdu) { - ESP_LOGE(TAG, "coap_new_pdu() failed"); - goto clean_up; + ESP_LOGE(TAG, "coap_new_pdu() failed"); + goto clean_up; } pdu->type = COAP_MESSAGE_CON; pdu->tid = coap_new_message_id(session); @@ -121,7 +141,7 @@ static void message_handler(coap_context_t *ctx, coap_session_t *session, case COAP_OPTION_URI_PATH : case COAP_OPTION_URI_QUERY : coap_add_option(pdu, option->number, option->length, - option->data); + option->data); break; default: ; /* skip other options */ @@ -133,8 +153,8 @@ static void message_handler(coap_context_t *ctx, coap_session_t *session, coap_add_option(pdu, blktype, coap_encode_var_safe(buf, sizeof(buf), - ((coap_opt_block_num(block_opt) + 1) << 4) | - COAP_OPT_BLOCK_SZX(block_opt)), buf); + ((coap_opt_block_num(block_opt) + 1) << 4) | + COAP_OPT_BLOCK_SZX(block_opt)), buf); tid = coap_send(session, pdu); @@ -155,41 +175,31 @@ clean_up: resp_wait = 0; } -#ifdef CONFIG_MBEDTLS_COAP_PKI - -#ifdef __GNUC__ -#define UNUSED_PARAM __attribute__ ((unused)) -#else /* not a GCC */ -#define UNUSED_PARAM -#endif /* GCC */ - -#ifndef min -#define min(a,b) ((a) < (b) ? (a) : (b)) -#endif +#ifdef CONFIG_COAP_MBEDTLS_PKI static int verify_cn_callback(const char *cn, - const uint8_t *asn1_public_cert UNUSED_PARAM, - size_t asn1_length UNUSED_PARAM, - coap_session_t *session UNUSED_PARAM, + const uint8_t *asn1_public_cert, + size_t asn1_length, + coap_session_t *session, unsigned depth, - int validated UNUSED_PARAM, - void *arg UNUSED_PARAM -) { - coap_log(LOG_INFO, "CN '%s' presented by server (%s)\n", - cn, depth ? "CA" : "Certificate"); - return 1; + int validated, + void *arg + ) +{ + coap_log(LOG_INFO, "CN '%s' presented by server (%s)\n", + cn, depth ? "CA" : "Certificate"); + return 1; } -#endif /* CONFIG_MBEDTLS_COAP_PKI */ +#endif /* CONFIG_COAP_MBEDTLS_PKI */ static void coap_example_client(void *p) { struct hostent *hp; - coap_address_t dst_addr; static coap_uri_t uri; - const char* server_uri = COAP_DEFAULT_DEMO_URI; - char* phostname = NULL; + const char *server_uri = COAP_DEFAULT_DEMO_URI; + char *phostname = NULL; coap_set_log_level(EXAMPLE_COAP_LOG_DEFAULT_LEVEL); @@ -209,17 +219,16 @@ static void coap_example_client(void *p) break; } - if ((uri.scheme==COAP_URI_SCHEME_COAPS && !coap_dtls_is_supported()) || - (uri.scheme==COAP_URI_SCHEME_COAPS_TCP && !coap_tls_is_supported())) { + if ((uri.scheme == COAP_URI_SCHEME_COAPS && !coap_dtls_is_supported()) || + (uri.scheme == COAP_URI_SCHEME_COAPS_TCP && !coap_tls_is_supported())) { ESP_LOGE(TAG, "CoAP server uri scheme is not supported"); break; } phostname = (char *)calloc(1, uri.host.length + 1); - if (phostname == NULL) { ESP_LOGE(TAG, "calloc failed"); - continue; + break; } memcpy(phostname, uri.host.s, uri.host.length); @@ -230,12 +239,11 @@ static void coap_example_client(void *p) ESP_LOGE(TAG, "DNS lookup failed"); vTaskDelay(1000 / portTICK_PERIOD_MS); free(phostname); - goto clean_up; + continue; } - { char tmpbuf[INET6_ADDRSTRLEN]; - coap_address_init(&dst_addr); - switch (hp->h_addrtype) { + coap_address_init(&dst_addr); + switch (hp->h_addrtype) { case AF_INET: dst_addr.addr.sin.sin_family = AF_INET; dst_addr.addr.sin.sin_port = htons(uri.port); @@ -253,7 +261,6 @@ static void coap_example_client(void *p) default: ESP_LOGE(TAG, "DNS lookup response failed"); goto clean_up; - } } if (uri.path.length) { @@ -263,9 +270,9 @@ static void coap_example_client(void *p) while (res--) { coap_insert_optlist(&optlist, - coap_new_optlist(COAP_OPTION_URI_PATH, - coap_opt_length(buf), - coap_opt_value(buf))); + coap_new_optlist(COAP_OPTION_URI_PATH, + coap_opt_length(buf), + coap_opt_value(buf))); buf += coap_opt_size(buf); } @@ -278,9 +285,9 @@ static void coap_example_client(void *p) while (res--) { coap_insert_optlist(&optlist, - coap_new_optlist(COAP_OPTION_URI_QUERY, - coap_opt_length(buf), - coap_opt_value(buf))); + coap_new_optlist(COAP_OPTION_URI_QUERY, + coap_opt_length(buf), + coap_opt_value(buf))); buf += coap_opt_size(buf); } @@ -288,8 +295,8 @@ static void coap_example_client(void *p) ctx = coap_new_context(NULL); if (!ctx) { - ESP_LOGE(TAG, "coap_new_context() failed"); - goto clean_up; + ESP_LOGE(TAG, "coap_new_context() failed"); + goto clean_up; } /* @@ -300,32 +307,16 @@ static void coap_example_client(void *p) * so COAP_URI_SCHEME_COAPS_TCP will have failed in a test above, * but the code is left in for completeness. */ - if (uri.scheme==COAP_URI_SCHEME_COAPS || uri.scheme==COAP_URI_SCHEME_COAPS_TCP) { -#ifdef CONFIG_MBEDTLS_COAP_PSK + if (uri.scheme == COAP_URI_SCHEME_COAPS || uri.scheme == COAP_URI_SCHEME_COAPS_TCP) { +#ifdef CONFIG_COAP_MBEDTLS_PSK session = coap_new_client_session_psk(ctx, NULL, &dst_addr, - uri.scheme==COAP_URI_SCHEME_COAPS ? COAP_PROTO_DTLS : COAP_PROTO_TLS, - EXAMPLE_COAP_PSK_IDENTITY, - (const uint8_t*)EXAMPLE_COAP_PSK_KEY, - sizeof(EXAMPLE_COAP_PSK_KEY)-1); -#endif /* CONFIG_MBEDTLS_COAP_PSK */ + uri.scheme == COAP_URI_SCHEME_COAPS ? COAP_PROTO_DTLS : COAP_PROTO_TLS, + EXAMPLE_COAP_PSK_IDENTITY, + (const uint8_t *)EXAMPLE_COAP_PSK_KEY, + sizeof(EXAMPLE_COAP_PSK_KEY) - 1); +#endif /* CONFIG_COAP_MBEDTLS_PSK */ -#ifdef CONFIG_MBEDTLS_COAP_PKI -/* CA cert, taken from coap_ca.pem - Client cert, taken from coap_client.crt - Client key, taken from coap_client.key - - The PEM, CRT and KEY file are examples taken from the wpa2 enterprise - example. - - To embed it in the app binary, the PEM, CRT and KEY file is named - in the component.mk COMPONENT_EMBED_TXTFILES variable. -*/ -extern uint8_t ca_pem_start[] asm("_binary_coap_ca_pem_start"); -extern uint8_t ca_pem_end[] asm("_binary_coap_ca_pem_end"); -extern uint8_t client_crt_start[] asm("_binary_coap_client_crt_start"); -extern uint8_t client_crt_end[] asm("_binary_coap_client_crt_end"); -extern uint8_t client_key_start[] asm("_binary_coap_client_key_start"); -extern uint8_t client_key_end[] asm("_binary_coap_client_key_end"); +#ifdef CONFIG_COAP_MBEDTLS_PKI unsigned int ca_pem_bytes = ca_pem_end - ca_pem_start; unsigned int client_crt_bytes = client_crt_end - client_crt_start; unsigned int client_key_bytes = client_key_end - client_key_start; @@ -360,10 +351,11 @@ extern uint8_t client_key_end[] asm("_binary_coap_client_key_end"); dtls_pki.validate_sni_call_back = NULL; dtls_pki.sni_call_back_arg = NULL; memset(client_sni, 0, sizeof(client_sni)); - if (uri.host.length) - memcpy(client_sni, uri.host.s, min(uri.host.length, sizeof(client_sni))); - else + if (uri.host.length) { + memcpy(client_sni, uri.host.s, MIN(uri.host.length, sizeof(client_sni))); + } else { memcpy(client_sni, "localhost", 9); + } dtls_pki.client_sni = client_sni; } dtls_pki.pki_key.key_type = COAP_PKI_KEY_PEM_BUF; @@ -375,30 +367,25 @@ extern uint8_t client_key_end[] asm("_binary_coap_client_key_end"); dtls_pki.pki_key.key.pem_buf.ca_cert_len = ca_pem_bytes; session = coap_new_client_session_pki(ctx, NULL, &dst_addr, - uri.scheme==COAP_URI_SCHEME_COAPS ? COAP_PROTO_DTLS : COAP_PROTO_TLS, - &dtls_pki); -#endif /* CONFIG_MBEDTLS_COAP_PKI */ - -#ifdef CONFIG_MBEDTLS_COAP_NONE - session = coap_new_client_session(ctx, NULL, &dst_addr, - uri.scheme==COAP_URI_SCHEME_COAPS ? COAP_PROTO_DTLS : COAP_PROTO_TLS); -#endif /* CONFIG_MBEDTLS_COAP_NONE */ + uri.scheme == COAP_URI_SCHEME_COAPS ? COAP_PROTO_DTLS : COAP_PROTO_TLS, + &dtls_pki); +#endif /* CONFIG_COAP_MBEDTLS_PKI */ } else { session = coap_new_client_session(ctx, NULL, &dst_addr, - uri.scheme==COAP_URI_SCHEME_COAP_TCP ? COAP_PROTO_TCP : - COAP_PROTO_UDP); + uri.scheme == COAP_URI_SCHEME_COAP_TCP ? COAP_PROTO_TCP : + COAP_PROTO_UDP); } if (!session) { - ESP_LOGE(TAG, "coap_new_client_session() failed"); - goto clean_up; + ESP_LOGE(TAG, "coap_new_client_session() failed"); + goto clean_up; } coap_register_response_handler(ctx, message_handler); request = coap_new_pdu(session); if (!request) { - ESP_LOGE(TAG, "coap_new_pdu() failed"); - goto clean_up; + ESP_LOGE(TAG, "coap_new_pdu() failed"); + goto clean_up; } request->type = COAP_MESSAGE_CON; request->tid = coap_new_message_id(session); @@ -413,12 +400,12 @@ extern uint8_t client_key_end[] asm("_binary_coap_client_key_end"); while (resp_wait) { int result = coap_run_once(ctx, wait_ms > 1000 ? 1000 : wait_ms); if (result >= 0) { - if (result >= wait_ms) { - ESP_LOGE(TAG, "select timeout"); - break; - } else { - wait_ms -= result; - } + if (result >= wait_ms) { + ESP_LOGE(TAG, "select timeout"); + break; + } else { + wait_ms -= result; + } } } clean_up: @@ -426,8 +413,12 @@ clean_up: coap_delete_optlist(optlist); optlist = NULL; } - if (session) coap_session_release(session); - if (ctx) coap_free_context(ctx); + if (session) { + coap_session_release(session); + } + if (ctx) { + coap_free_context(ctx); + } coap_cleanup(); /* * change the following line to something like sleep(2) @@ -445,14 +436,6 @@ void app_main(void) tcpip_adapter_init(); ESP_ERROR_CHECK(esp_event_loop_create_default()); -#if 0 -/* See https://github.com/Ebiroll/qemu_esp32 for further information */ -#include "emul_ip.h" - if (is_running_qemu()) { - xTaskCreate(task_lwip_init, "task_lwip_init", 2*4096, NULL, 20, NULL); - } - else -#endif /* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig. * Read "Establishing Wi-Fi or Ethernet Connection" section in * examples/protocols/README.md for more information about this function. diff --git a/examples/protocols/coap_client/main/component.mk b/examples/protocols/coap_client/main/component.mk index 50306ea2f..51bf0b68c 100644 --- a/examples/protocols/coap_client/main/component.mk +++ b/examples/protocols/coap_client/main/component.mk @@ -5,6 +5,4 @@ # embed files from the "certs" directory as binary data symbols # in the app -COMPONENT_EMBED_TXTFILES := coap_ca.pem -COMPONENT_EMBED_TXTFILES += coap_client.crt -COMPONENT_EMBED_TXTFILES += coap_client.key +COMPONENT_EMBED_TXTFILES := certs/coap_ca.pem certs/coap_client.crt certs/coap_client.key diff --git a/examples/protocols/coap_server/README.md b/examples/protocols/coap_server/README.md index 60941855f..9be65ad5a 100644 --- a/examples/protocols/coap_server/README.md +++ b/examples/protocols/coap_server/README.md @@ -35,18 +35,11 @@ Example Connection Configuration ---> * Set WiFi SSID under Example Configuration * Set WiFi Password under Example Configuration Example CoAP Client Configuration ---> - * Set CoAP Target Uri - * Set encryption method definitions (None, PSK or PKI) - * If PSK Set CoAP Preshared Key to use in connection to the server - * If PSK Set CoAP PSK Client identity (username) - Enable CoAP debugging if required + * If PSK, Set CoAP Preshared Key to use in connection to the server Component config ---> - mbedTLS ---> - [*] Enable mbedtls certificate expiry check - TLS Key Exchange Methods ---> - [*] Enable pre-shared-key ciphersuites - [*] Enable PSK based ciphersuite modes - [*] Support DTLS protocol (all versions) + CoAP Configuration ---> + * Set encryption method definition, PSK (default) or PKI + * Enable CoAP debugging if required ### Build and Flash @@ -90,7 +83,4 @@ This can be found at https://libcoap.net/doc/reference/4.2.0/ * Please make sure CoAP client fetchs or puts data under path: `/Espressif` or fetches `/.well-known/core` -* CoAP logging can be enabled by running 'make menuconfig' and enable debugging - -* Encryption (MbedTLS) can be enabled by running 'make menuconfig' and enable debugging - +* CoAP logging can be enabled by running 'idf.py menuconfig -> Component config -> CoAP Configuration' and setting appropriate log level diff --git a/examples/protocols/coap_server/main/CMakeLists.txt b/examples/protocols/coap_server/main/CMakeLists.txt index d4738f691..a014088ec 100644 --- a/examples/protocols/coap_server/main/CMakeLists.txt +++ b/examples/protocols/coap_server/main/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRCS "coap_server_example_main.c" INCLUDE_DIRS "." - EMBED_TXTFILES coap_ca.pem coap_server.crt coap_server.key) + EMBED_TXTFILES certs/coap_ca.pem certs/coap_server.crt certs/coap_server.key) diff --git a/examples/protocols/coap_server/main/coap_ca.pem b/examples/protocols/coap_server/main/certs/coap_ca.pem similarity index 100% rename from examples/protocols/coap_server/main/coap_ca.pem rename to examples/protocols/coap_server/main/certs/coap_ca.pem diff --git a/examples/protocols/coap_server/main/coap_server.crt b/examples/protocols/coap_server/main/certs/coap_server.crt similarity index 100% rename from examples/protocols/coap_server/main/coap_server.crt rename to examples/protocols/coap_server/main/certs/coap_server.crt diff --git a/examples/protocols/coap_server/main/coap_server.key b/examples/protocols/coap_server/main/certs/coap_server.key similarity index 100% rename from examples/protocols/coap_server/main/coap_server.key rename to examples/protocols/coap_server/main/certs/coap_server.key diff --git a/examples/protocols/coap_server/main/coap_server_example_main.c b/examples/protocols/coap_server/main/coap_server_example_main.c index b2f78bb03..29bf69122 100644 --- a/examples/protocols/coap_server/main/coap_server_example_main.c +++ b/examples/protocols/coap_server/main/coap_server_example_main.c @@ -46,7 +46,7 @@ instead of coap:// and the PSK must be one that the server supports (potentially associated with the IDENTITY) */ -#define EXAMPLE_COAP_PSK_KEY CONFIG_COAP_PSK_KEY +#define EXAMPLE_COAP_PSK_KEY CONFIG_EXAMPLE_COAP_PSK_KEY /* The examples use CoAP Logging Level that you can set via 'make menuconfig'. @@ -57,9 +57,30 @@ */ #define EXAMPLE_COAP_LOG_DEFAULT_LEVEL CONFIG_COAP_LOG_DEFAULT_LEVEL +const static char *TAG = "CoAP_server"; + static char espressif_data[100]; static int espressif_data_len = 0; +#ifdef CONFIG_COAP_MBEDTLS_PKI +/* CA cert, taken from coap_ca.pem + Server cert, taken from coap_server.crt + Server key, taken from coap_server.key + + The PEM, CRT and KEY file are examples taken from the wpa2 enterprise + example. + + To embed it in the app binary, the PEM, CRT and KEY file is named + in the component.mk COMPONENT_EMBED_TXTFILES variable. + */ +extern uint8_t ca_pem_start[] asm("_binary_coap_ca_pem_start"); +extern uint8_t ca_pem_end[] asm("_binary_coap_ca_pem_end"); +extern uint8_t server_crt_start[] asm("_binary_coap_server_crt_start"); +extern uint8_t server_crt_end[] asm("_binary_coap_server_crt_end"); +extern uint8_t server_key_start[] asm("_binary_coap_server_key_start"); +extern uint8_t server_key_end[] asm("_binary_coap_server_key_end"); +#endif /* CONFIG_COAP_MBEDTLS_PKI */ + #define INITIAL_DATA "Hello World!" /* @@ -93,8 +114,7 @@ hnd_espressif_put(coap_context_t *ctx, if (strcmp (espressif_data, INITIAL_DATA) == 0) { response->code = COAP_RESPONSE_CODE(201); - } - else { + } else { response->code = COAP_RESPONSE_CODE(204); } @@ -125,32 +145,23 @@ hnd_espressif_delete(coap_context_t *ctx, response->code = COAP_RESPONSE_CODE(202); } -#ifdef CONFIG_MBEDTLS_COAP_PKI - -#ifdef __GNUC__ -#define UNUSED_PARAM __attribute__ ((unused)) -#else /* not a GCC */ -#define UNUSED_PARAM -#endif /* GCC */ - -#ifndef min -#define min(a,b) ((a) < (b) ? (a) : (b)) -#endif +#ifdef CONFIG_COAP_MBEDTLS_PKI static int verify_cn_callback(const char *cn, - const uint8_t *asn1_public_cert UNUSED_PARAM, - size_t asn1_length UNUSED_PARAM, - coap_session_t *session UNUSED_PARAM, + const uint8_t *asn1_public_cert, + size_t asn1_length, + coap_session_t *session, unsigned depth, - int validated UNUSED_PARAM, - void *arg UNUSED_PARAM -) { - coap_log(LOG_INFO, "CN '%s' presented by server (%s)\n", - cn, depth ? "CA" : "Certificate"); - return 1; + int validated, + void *arg + ) +{ + coap_log(LOG_INFO, "CN '%s' presented by server (%s)\n", + cn, depth ? "CA" : "Certificate"); + return 1; } -#endif /* CONFIG_MBEDTLS_COAP_PKI */ +#endif /* CONFIG_COAP_MBEDTLS_PKI */ static void coap_example_server(void *p) { @@ -174,96 +185,85 @@ static void coap_example_server(void *p) ctx = coap_new_context(NULL); if (!ctx) { - continue; + ESP_LOGE(TAG, "coap_new_context() failed"); + continue; } -#ifdef CONFIG_MBEDTLS_COAP_PSK +#ifdef CONFIG_COAP_MBEDTLS_PSK /* Need PSK setup before we set up endpoints */ coap_context_set_psk(ctx, "CoAP", - (const uint8_t*)EXAMPLE_COAP_PSK_KEY, - sizeof(EXAMPLE_COAP_PSK_KEY)-1); -#endif /* CONFIG_MBEDTLS_COAP_PSK */ + (const uint8_t *)EXAMPLE_COAP_PSK_KEY, + sizeof(EXAMPLE_COAP_PSK_KEY) - 1); +#endif /* CONFIG_COAP_MBEDTLS_PSK */ -#ifdef CONFIG_MBEDTLS_COAP_PKI -/* CA cert, taken from coap_ca.pem - Server cert, taken from coap_server.crt - Server key, taken from coap_server.key +#ifdef CONFIG_COAP_MBEDTLS_PKI + unsigned int ca_pem_bytes = ca_pem_end - ca_pem_start; + unsigned int server_crt_bytes = server_crt_end - server_crt_start; + unsigned int server_key_bytes = server_key_end - server_key_start; + coap_dtls_pki_t dtls_pki; - The PEM, CRT and KEY file are examples taken from the wpa2 enterprise - example. + memset (&dtls_pki, 0, sizeof(dtls_pki)); + dtls_pki.version = COAP_DTLS_PKI_SETUP_VERSION; + if (ca_pem_bytes) { + /* + * Add in additional certificate checking. + * This list of enabled can be tuned for the specific + * requirements - see 'man coap_encryption'. + * + * Note: A list of root ca file can be setup separately using + * coap_context_set_pki_root_cas(), but the below is used to + * define what checking actually takes place. + */ + dtls_pki.verify_peer_cert = 1; + dtls_pki.require_peer_cert = 1; + dtls_pki.allow_self_signed = 1; + dtls_pki.allow_expired_certs = 1; + dtls_pki.cert_chain_validation = 1; + dtls_pki.cert_chain_verify_depth = 2; + dtls_pki.check_cert_revocation = 1; + dtls_pki.allow_no_crl = 1; + dtls_pki.allow_expired_crl = 1; + dtls_pki.allow_bad_md_hash = 1; + dtls_pki.allow_short_rsa_length = 1; + dtls_pki.validate_cn_call_back = verify_cn_callback; + dtls_pki.cn_call_back_arg = NULL; + dtls_pki.validate_sni_call_back = NULL; + dtls_pki.sni_call_back_arg = NULL; + } + dtls_pki.pki_key.key_type = COAP_PKI_KEY_PEM_BUF; + dtls_pki.pki_key.key.pem_buf.public_cert = server_crt_start; + dtls_pki.pki_key.key.pem_buf.public_cert_len = server_crt_bytes; + dtls_pki.pki_key.key.pem_buf.private_key = server_key_start; + dtls_pki.pki_key.key.pem_buf.private_key_len = server_key_bytes; + dtls_pki.pki_key.key.pem_buf.ca_cert = ca_pem_start; + dtls_pki.pki_key.key.pem_buf.ca_cert_len = ca_pem_bytes; - To embed it in the app binary, the PEM, CRT and KEY file is named - in the component.mk COMPONENT_EMBED_TXTFILES variable. -*/ -extern uint8_t ca_pem_start[] asm("_binary_coap_ca_pem_start"); -extern uint8_t ca_pem_end[] asm("_binary_coap_ca_pem_end"); -extern uint8_t server_crt_start[] asm("_binary_coap_server_crt_start"); -extern uint8_t server_crt_end[] asm("_binary_coap_server_crt_end"); -extern uint8_t server_key_start[] asm("_binary_coap_server_key_start"); -extern uint8_t server_key_end[] asm("_binary_coap_server_key_end"); - unsigned int ca_pem_bytes = ca_pem_end - ca_pem_start; - unsigned int server_crt_bytes = server_crt_end - server_crt_start; - unsigned int server_key_bytes = server_key_end - server_key_start; - coap_dtls_pki_t dtls_pki; - - memset (&dtls_pki, 0, sizeof(dtls_pki)); - dtls_pki.version = COAP_DTLS_PKI_SETUP_VERSION; - if (ca_pem_bytes) { - /* - * Add in additional certificate checking. - * This list of enabled can be tuned for the specific - * requirements - see 'man coap_encryption'. - * - * Note: A list of root ca file can be setup separately using - * coap_context_set_pki_root_cas(), but the below is used to - * define what checking actually takes place. - */ - dtls_pki.verify_peer_cert = 1; - dtls_pki.require_peer_cert = 1; - dtls_pki.allow_self_signed = 1; - dtls_pki.allow_expired_certs = 1; - dtls_pki.cert_chain_validation = 1; - dtls_pki.cert_chain_verify_depth = 2; - dtls_pki.check_cert_revocation = 1; - dtls_pki.allow_no_crl = 1; - dtls_pki.allow_expired_crl = 1; - dtls_pki.allow_bad_md_hash = 1; - dtls_pki.allow_short_rsa_length = 1; - dtls_pki.validate_cn_call_back = verify_cn_callback; - dtls_pki.cn_call_back_arg = NULL; - dtls_pki.validate_sni_call_back = NULL; - dtls_pki.sni_call_back_arg = NULL; - } - dtls_pki.pki_key.key_type = COAP_PKI_KEY_PEM_BUF; - dtls_pki.pki_key.key.pem_buf.public_cert = server_crt_start; - dtls_pki.pki_key.key.pem_buf.public_cert_len = server_crt_bytes; - dtls_pki.pki_key.key.pem_buf.private_key = server_key_start; - dtls_pki.pki_key.key.pem_buf.private_key_len = server_key_bytes; - dtls_pki.pki_key.key.pem_buf.ca_cert = ca_pem_start; - dtls_pki.pki_key.key.pem_buf.ca_cert_len = ca_pem_bytes; - - coap_context_set_pki(ctx, &dtls_pki); -#endif /* CONFIG_MBEDTLS_COAP_PKI */ + coap_context_set_pki(ctx, &dtls_pki); +#endif /* CONFIG_COAP_MBEDTLS_PKI */ ep = coap_new_endpoint(ctx, &serv_addr, COAP_PROTO_UDP); if (!ep) { - goto clean_up; + ESP_LOGE(TAG, "udp: coap_new_endpoint() failed"); + goto clean_up; } ep = coap_new_endpoint(ctx, &serv_addr, COAP_PROTO_TCP); if (!ep) { - goto clean_up; + ESP_LOGE(TAG, "tcp: coap_new_endpoint() failed"); + goto clean_up; } -#if defined(CONFIG_MBEDTLS_COAP_PSK) || defined(CONFIG_MBEDTLS_COAP_PKI) - if (coap_dtls_is_supported()) { +#if defined(CONFIG_COAP_MBEDTLS_PSK) || defined(CONFIG_COAP_MBEDTLS_PKI) + if (coap_dtls_is_supported()) { serv_addr.addr.sin.sin_port = htons(COAPS_DEFAULT_PORT); ep = coap_new_endpoint(ctx, &serv_addr, COAP_PROTO_DTLS); if (!ep) { - goto clean_up; + ESP_LOGE(TAG, "dtls: coap_new_endpoint() failed"); + goto clean_up; } } -#endif /* CONFIG_MBEDTLS_COAP_PSK CONFIG_MBEDTLS_COAP_PKI */ +#endif /* CONFIG_COAP_MBEDTLS_PSK CONFIG_COAP_MBEDTLS_PKI */ resource = coap_resource_init(coap_make_str_const("Espressif"), 0); if (!resource) { - goto clean_up; + ESP_LOGE(TAG, "coap_resource_init() failed"); + goto clean_up; } coap_register_handler(resource, COAP_REQUEST_GET, hnd_espressif_get); coap_register_handler(resource, COAP_REQUEST_PUT, hnd_espressif_put); @@ -301,14 +301,6 @@ void app_main(void) tcpip_adapter_init(); ESP_ERROR_CHECK(esp_event_loop_create_default()); -#if 0 -/* See https://github.com/Ebiroll/qemu_esp32 for further information */ -#include "emul_ip.h" - if (is_running_qemu()) { - xTaskCreate(task_lwip_init, "task_lwip_init", 2*4096, NULL, 20, NULL); - } - else -#endif /* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig. * Read "Establishing Wi-Fi or Ethernet Connection" section in * examples/protocols/README.md for more information about this function. diff --git a/examples/protocols/coap_server/main/component.mk b/examples/protocols/coap_server/main/component.mk index bccdac23f..d3d1de0b0 100644 --- a/examples/protocols/coap_server/main/component.mk +++ b/examples/protocols/coap_server/main/component.mk @@ -5,6 +5,4 @@ # embed files from the "certs" directory as binary data symbols # in the app -COMPONENT_EMBED_TXTFILES := coap_ca.pem -COMPONENT_EMBED_TXTFILES += coap_server.crt -COMPONENT_EMBED_TXTFILES += coap_server.key +COMPONENT_EMBED_TXTFILES := certs/coap_ca.pem certs/coap_server.crt certs/coap_server.key