Skip to content

Commit

Permalink
socket_zep: port to radio HAL
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Nov 18, 2021
1 parent 5a9c659 commit fa2d9bd
Show file tree
Hide file tree
Showing 8 changed files with 479 additions and 278 deletions.
7 changes: 0 additions & 7 deletions boards/native/Makefile.dep
Expand Up @@ -14,11 +14,4 @@ ifneq (,$(filter periph_can,$(FEATURES_USED)))
endif
endif

ifneq (,$(filter socket_zep,$(USEMODULE)))
USEMODULE += iolist
USEMODULE += netdev_ieee802154
USEMODULE += checksum
USEMODULE += random
endif

USEMODULE += native_drivers
10 changes: 10 additions & 0 deletions cpu/native/Makefile.dep
Expand Up @@ -29,6 +29,16 @@ ifneq (,$(filter native_cli_eui_provider,$(USEMODULE)))
USEMODULE += l2util
endif

ifneq (,$(filter socket_zep,$(USEMODULE)))
USEMODULE += iolist
USEMODULE += checksum
USEMODULE += random
USEMODULE += ieee802154
ifneq (,$(filter netdev,$(USEMODULE)))
USEMODULE += netdev_ieee802154_submac
endif
endif

USEMODULE += periph

# UART is needed by startup.c
Expand Down
58 changes: 40 additions & 18 deletions cpu/native/include/socket_zep.h
Expand Up @@ -58,50 +58,64 @@

#include "net/netdev.h"
#include "net/netdev/ieee802154.h"
#include "net/ieee802154/radio.h"
#include "net/zep.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief ZEP device initialization parameters
*/
typedef struct {
char *local_addr; /**< local address string */
char *local_port; /**< local address string */
char *remote_addr; /**< remote address string */
char *remote_port; /**< local address string */
} socket_zep_params_t;

/**
* @brief ZEP device state
*/
typedef struct {
netdev_ieee802154_t netdev; /**< netdev internal member */
/**
* @brief command line parameters
*/
const socket_zep_params_t *params;
int sock_fd; /**< socket fd */
netdev_event_t last_event; /**< event triggered */
uint32_t seq; /**< ZEP sequence number */
/**
* @brief Receive buffer
*/
uint8_t rcv_buf[sizeof(zep_v2_data_hdr_t) + IEEE802154_FRAME_LEN_MAX];
/**
* @brief Buffer for send header
* @brief Send buffer
*/
uint8_t snd_buf[sizeof(zep_v2_data_hdr_t) + IEEE802154_FRAME_LEN_MAX];
uint8_t snd_len; /**< bytes to send */
uint16_t pan_id; /**< PAN ID of the ZEP network */
uint16_t chan; /**< virtual radio channel */
/**
* @brief Short address of the virtual radio
*/
uint8_t addr_short[IEEE802154_SHORT_ADDRESS_LEN];
/**
* @brief Long address of the virtual radio
*/
uint8_t snd_hdr_buf[sizeof(zep_v2_data_hdr_t)];
uint16_t chksum_buf; /**< buffer for send checksum calculation */
uint8_t addr_long[IEEE802154_LONG_ADDRESS_LEN];
ieee802154_filter_mode_t filter_mode; /**< frame filter mode */
ieee802154_trx_state_t state; /**< radio state */
bool send_hello; /**< send HELLO packet on connect */
} socket_zep_t;

/**
* @brief ZEP device initialization parameters
*/
typedef struct {
char *local_addr; /**< local address string */
char *local_port; /**< local address string */
char *remote_addr; /**< remote address string */
char *remote_port; /**< local address string */
} socket_zep_params_t;

/**
* @brief Setup socket_zep_t structure
*
* @param[in] dev the preallocated socket_zep_t device handle to setup
* @param[in] params initialization parameters
* @param[in] index index of @p params in a global parameter struct array.
* If initialized manually, pass a unique identifier instead.
*/
void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params, uint8_t index);
void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params);

/**
* @brief Cleanup socket resources
Expand All @@ -110,6 +124,14 @@ void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params, uint
*/
void socket_zep_cleanup(socket_zep_t *dev);

/**
* @brief Setup socket ZEP in order to be used with the IEEE 802.15.4 Radio HAL
*
* @param[in] dev pointer to the socket ZEP instance
* @param[in] hal pointer to the HAL descriptor associated to the device
*/
void socket_zep_hal_setup(socket_zep_t *dev, ieee802154_dev_t *hal);

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit fa2d9bd

Please sign in to comment.