Skip to content

Commit 4cb130d

Browse files
committed
Fixed our interface to Zephyr net manager API changes in v4.2.0.
1 parent 3efa486 commit 4cb130d

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ of the following ways:
6161

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

64+
- Note that as Zephyr OS versions change, their API often changes.
65+
This library will use the following methods to accommodate the changes:
66+
1. Use defines from <zephyr/version.h> for API changes:
67+
```
68+
#if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(4,2,0)
69+
typedef uint64_t mgmt_event_t;
70+
#else
71+
typedef uint32_t mgmt_event_t;
72+
#endif
73+
```
74+
2. In CMakeLists.txt via trying to load specific versions of the Zephyr
75+
package or checking using:
76+
```
77+
if ("${KERNEL_VERSION_STRING}" VERSION_GREATER_EQUAL "4.2.0")
78+
# Do stuff...
79+
endif()
80+
```
81+
3. In Kconfig by using 2 above and trying to load specific versions
82+
of the Zephyr plugin and updating CONF_FILE accordingly.
6483
6584
## Hello BACnet Stack
6685

zephyr/subsys/bacnet_datalink/bip-init.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <zephyr/sys/printk.h>
1414
#include <zephyr/net/net_if.h>
1515
#include <zephyr/net/socket.h>
16+
#include <zephyr/version.h>
1617
/* BACnet Stack defines - first */
1718
#include "bacnet/bacdef.h"
1819
/* BACnet Stack API */
@@ -403,14 +404,20 @@ int bip_send_pdu(
403404
return bvlc_send_pdu(dest, npdu_data, pdu, pdu_len);
404405
}
405406

407+
#if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(4, 2, 0)
408+
typedef uint64_t mgmt_event_t;
409+
#else
410+
typedef uint32_t mgmt_event_t;
411+
#endif
412+
406413
struct wait_data {
407414
struct k_sem sem;
408415
struct net_mgmt_event_callback cb;
409416
};
410417

411418
static void event_cb_handler(
412419
struct net_mgmt_event_callback *cb,
413-
uint32_t mgmt_event,
420+
mgmt_event_t mgmt_event,
414421
struct net_if *iface)
415422
{
416423
struct wait_data *wait = CONTAINER_OF(cb, struct wait_data, cb);
@@ -420,7 +427,7 @@ static void event_cb_handler(
420427
}
421428
}
422429

423-
static void wait_for_net_event(struct net_if *iface, uint32_t event)
430+
static void wait_for_net_event(struct net_if *iface, mgmt_event_t event)
424431
{
425432
struct wait_data wait;
426433

0 commit comments

Comments
 (0)