Files
bacnet_stack/ports/lwip/README.md
T
Kari Argillander 369da70f2a Strip tabs and trailing white spaces, and fix end of files (#748)
* format: Strip trailing whitespaces

We want to get rid of trailing whitespaces completly as they make just git
noice. Much better to start using automated tools to get rid of them once and
not getting them back again. This way git history will be cleaner and review
easier.

Commit was generated with:

    pre-commit run --all-files trailing-whitespace

* format: Files should have exactly one new line end of them

It is good practice that every file has one new line. It is not now days so
mandatory but it also is not nice if file has lot of newlines end of it. We will
use pre-commit which takes automatically care about this so let's fix all.

Commit was generated with:

    pre-commit run --all-files end-of-file-fixer

* format: Convert tabs to spaces

Project mostly use spaces over tabs. When mixing tabs and spaces this usually
makes formatting issues and also when changing those in commits it will make lot
of git noise. We will force spaces most of the time and use pre-commit to fix.

Commit was generated with:

    pre-commit run --all-files remove-tabs

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-25 14:13:57 -05:00

1.6 KiB

Port of BACnet/IP to LwIP 2.x

This LwIP BACnet/IP port uses a Makefile designed to be used from the continuous integration pipeline. The container is configured with Ubuntu Linux and uses APT to install liblwip-dev library and header files. This build method ensures that the code is valid for the particular LwIP library that is released with Ubuntu.

Integration Hints

Developer must set the IP address, netmask, and UDP port into the BACnet/IP module.

Integration used a main loop bare metal design, shown here as an example.

int main(void)
{
    static bool valid_ip_address = false;
    static bool bacnet_ip_initialized = false;

    bacnet_init();
    LwIP_Init();
    /* Infinite loop */
    for (;;) {
        /* Periodic tasks */
        LwIP_Periodic_Handler();
        /* Run when there is a valid IP address */
        if (netif.ip_addr.addr != 0) {
            if (!valid_ip_address) {
                valid_ip_address = true;
                bip_set_addr(netif.ip_addr.addr);
                bip_set_broadcast_addr(
                    (netif.ip_addr.addr & netif.netmask.addr) |
                    (~netif.netmask.addr));
            } else {
                if (bacnet_ip_initialized) {
                    bacnet_task();
                } else {
                    bip_init(NULL);
                    bacnet_ip_initialized = true;
                }
            }
        } else {
            valid_ip_address = false;
        }
    }
}