Commit Graph

6 Commits

Author SHA1 Message Date
Thomas Watson
aef6705a32 extmod/lwip-include: Increase number of lwIP timers when mDNS enabled.
Despite the code comments claiming one is sufficient, the mDNS application
is capable of using up to twelve timers.  Three per IP protocol are started
at once in `mdns_start_multicast_timeouts_ipvX`, then another two per
protocol can be started in `mdns_handle_question`.  Further timers can be
started for two additional callbacks.

Having certain timers, such as `MDNS_MULTICAST_TIMEOUT`, fail to start due
to none being free will break mDNS forever as the app will never realize
it's safe to transmit a packet.  Therefore, this commit goes somewhat
overkill and allocates the maximal amount of timers; it's uncertain if all
can run simultaneously, or how many callback timers are needed.

Each timer struct is 16 bytes on standard 32 bit builds.  Plus, say, 8
bytes of allocater overhead, that's 288 more bytes of RAM used which
shouldn't be too horrible.  Users who don't need mDNS can manually disable
it to recover the RAM if necessary.

This fixes mDNS on W5500_EVB_PICO (among other boards).  Before, mDNS would
work for a bit after connection until the host's cache expired a minute or
two later.  Then the board would never respond to further queries.  With
this patch, all works well.

Signed-off-by: Thomas Watson <twatson52@icloud.com>
2025-02-14 12:32:00 +11:00
Damien George
abb13b1e1e extmod/lwip-include: Factor common lwIP config into lwipopts_common.h.
This lwIP configuration file has options that are common to all ports, and
the ports are updated to use this file.  This change is a no-op, the lwIP
configuration remains the same for the four ports using this common file.

This reduces code duplication, keeps the ports in sync, and makes it easier
to update the configuration for all ports at once.

Signed-off-by: Damien George <damien@micropython.org>
2025-01-29 12:36:27 +11:00
Alexander Steffen
299bc62586 all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.

This commit ensures that all header files of the MicroPython project (that
were not simply copied from somewhere else) follow the same pattern, that
was already present in the majority of files, especially in the py folder.

The rules are as follows.

Naming convention:
* start with the words MICROPY_INCLUDED
* contain the full path to the file
* replace special characters with _

In addition, there are no empty lines before #ifndef, between #ifndef and
one empty line before #endif. #endif is followed by a comment containing
the name of the guard macro.

py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
2017-07-18 11:57:39 +10:00
Galen Hazelwood
af3e45419c extmod/lwip: Change void pointers to unions, include new mphal.h file 2015-11-04 23:24:04 +03:00
Paul Sokolovsky
404dae80a9 unix, stmhal: Introduce mp_hal_delay_ms(), mp_hal_ticks_ms().
These MPHAL functions are intended to replace previously used HAL_Delay(),
HAL_GetTick() to provide better naming and MPHAL separation (they are
fully equivalent otherwise).

Also, refactor extmod/modlwip to use them.
2015-10-27 23:31:42 +03:00
Galen Hazelwood
805c6534f8 extmod/modlwip: Initial commit of the lwip network stack module 2015-10-23 19:30:02 +03:00