Skip to content

Commit fa2d9bd

Browse files
committed
socket_zep: port to radio HAL
1 parent 5a9c659 commit fa2d9bd

8 files changed

Lines changed: 479 additions & 278 deletions

File tree

boards/native/Makefile.dep

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,4 @@ ifneq (,$(filter periph_can,$(FEATURES_USED)))
1414
endif
1515
endif
1616

17-
ifneq (,$(filter socket_zep,$(USEMODULE)))
18-
USEMODULE += iolist
19-
USEMODULE += netdev_ieee802154
20-
USEMODULE += checksum
21-
USEMODULE += random
22-
endif
23-
2417
USEMODULE += native_drivers

cpu/native/Makefile.dep

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ ifneq (,$(filter native_cli_eui_provider,$(USEMODULE)))
2929
USEMODULE += l2util
3030
endif
3131

32+
ifneq (,$(filter socket_zep,$(USEMODULE)))
33+
USEMODULE += iolist
34+
USEMODULE += checksum
35+
USEMODULE += random
36+
USEMODULE += ieee802154
37+
ifneq (,$(filter netdev,$(USEMODULE)))
38+
USEMODULE += netdev_ieee802154_submac
39+
endif
40+
endif
41+
3242
USEMODULE += periph
3343

3444
# UART is needed by startup.c

cpu/native/include/socket_zep.h

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,50 +58,64 @@
5858

5959
#include "net/netdev.h"
6060
#include "net/netdev/ieee802154.h"
61+
#include "net/ieee802154/radio.h"
6162
#include "net/zep.h"
6263

6364
#ifdef __cplusplus
6465
extern "C" {
6566
#endif
6667

68+
/**
69+
* @brief ZEP device initialization parameters
70+
*/
71+
typedef struct {
72+
char *local_addr; /**< local address string */
73+
char *local_port; /**< local address string */
74+
char *remote_addr; /**< remote address string */
75+
char *remote_port; /**< local address string */
76+
} socket_zep_params_t;
77+
6778
/**
6879
* @brief ZEP device state
6980
*/
7081
typedef struct {
71-
netdev_ieee802154_t netdev; /**< netdev internal member */
82+
/**
83+
* @brief command line parameters
84+
*/
85+
const socket_zep_params_t *params;
7286
int sock_fd; /**< socket fd */
73-
netdev_event_t last_event; /**< event triggered */
7487
uint32_t seq; /**< ZEP sequence number */
7588
/**
7689
* @brief Receive buffer
7790
*/
7891
uint8_t rcv_buf[sizeof(zep_v2_data_hdr_t) + IEEE802154_FRAME_LEN_MAX];
7992
/**
80-
* @brief Buffer for send header
93+
* @brief Send buffer
94+
*/
95+
uint8_t snd_buf[sizeof(zep_v2_data_hdr_t) + IEEE802154_FRAME_LEN_MAX];
96+
uint8_t snd_len; /**< bytes to send */
97+
uint16_t pan_id; /**< PAN ID of the ZEP network */
98+
uint16_t chan; /**< virtual radio channel */
99+
/**
100+
* @brief Short address of the virtual radio
101+
*/
102+
uint8_t addr_short[IEEE802154_SHORT_ADDRESS_LEN];
103+
/**
104+
* @brief Long address of the virtual radio
81105
*/
82-
uint8_t snd_hdr_buf[sizeof(zep_v2_data_hdr_t)];
83-
uint16_t chksum_buf; /**< buffer for send checksum calculation */
106+
uint8_t addr_long[IEEE802154_LONG_ADDRESS_LEN];
107+
ieee802154_filter_mode_t filter_mode; /**< frame filter mode */
108+
ieee802154_trx_state_t state; /**< radio state */
109+
bool send_hello; /**< send HELLO packet on connect */
84110
} socket_zep_t;
85111

86-
/**
87-
* @brief ZEP device initialization parameters
88-
*/
89-
typedef struct {
90-
char *local_addr; /**< local address string */
91-
char *local_port; /**< local address string */
92-
char *remote_addr; /**< remote address string */
93-
char *remote_port; /**< local address string */
94-
} socket_zep_params_t;
95-
96112
/**
97113
* @brief Setup socket_zep_t structure
98114
*
99115
* @param[in] dev the preallocated socket_zep_t device handle to setup
100116
* @param[in] params initialization parameters
101-
* @param[in] index index of @p params in a global parameter struct array.
102-
* If initialized manually, pass a unique identifier instead.
103117
*/
104-
void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params, uint8_t index);
118+
void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params);
105119

106120
/**
107121
* @brief Cleanup socket resources
@@ -110,6 +124,14 @@ void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params, uint
110124
*/
111125
void socket_zep_cleanup(socket_zep_t *dev);
112126

127+
/**
128+
* @brief Setup socket ZEP in order to be used with the IEEE 802.15.4 Radio HAL
129+
*
130+
* @param[in] dev pointer to the socket ZEP instance
131+
* @param[in] hal pointer to the HAL descriptor associated to the device
132+
*/
133+
void socket_zep_hal_setup(socket_zep_t *dev, ieee802154_dev_t *hal);
134+
113135
#ifdef __cplusplus
114136
}
115137
#endif

0 commit comments

Comments
 (0)