Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ of the following ways:

`west init -m https://github.com/bacnet-stack/bacnet-stack-zephyr --mr default $my_workspace`

- Note that as Zephyr OS versions change, their API often changes.
This library will use the following methods to accommodate the changes:
1. Use defines from <zephyr/version.h> for API changes:
```
#if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(4,2,0)
typedef uint64_t mgmt_event_t;
#else
typedef uint32_t mgmt_event_t;
#endif
```
2. In CMakeLists.txt via trying to load specific versions of the Zephyr
package or checking using:
```
if ("${KERNEL_VERSION_STRING}" VERSION_GREATER_EQUAL "4.2.0")
# Do stuff...
endif()
```
3. In Kconfig by using 2 above and trying to load specific versions
of the Zephyr plugin and updating CONF_FILE accordingly.
## Hello BACnet Stack
Expand Down
11 changes: 9 additions & 2 deletions zephyr/subsys/bacnet_datalink/bip-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <zephyr/sys/printk.h>
#include <zephyr/net/net_if.h>
#include <zephyr/net/socket.h>
#include <zephyr/version.h>
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
/* BACnet Stack API */
Expand Down Expand Up @@ -403,14 +404,20 @@ int bip_send_pdu(
return bvlc_send_pdu(dest, npdu_data, pdu, pdu_len);
}

#if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(4, 2, 0)
typedef uint64_t mgmt_event_t;
#else
typedef uint32_t mgmt_event_t;
#endif

struct wait_data {
struct k_sem sem;
struct net_mgmt_event_callback cb;
};

static void event_cb_handler(
struct net_mgmt_event_callback *cb,
uint32_t mgmt_event,
mgmt_event_t mgmt_event,
struct net_if *iface)
{
struct wait_data *wait = CONTAINER_OF(cb, struct wait_data, cb);
Expand All @@ -420,7 +427,7 @@ static void event_cb_handler(
}
}

static void wait_for_net_event(struct net_if *iface, uint32_t event)
static void wait_for_net_event(struct net_if *iface, mgmt_event_t event)
{
struct wait_data wait;

Expand Down
Loading