Loading...
Searching...
No Matches
esp_now_netdev.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Gunar Schorcht
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
20#ifndef ESP_NOW_NETDEV_H
21#define ESP_NOW_NETDEV_H
22
23#include "net/netdev.h"
24#include "mutex.h"
25#include "net/ethernet/hdr.h"
26#ifdef MODULE_GNRC
27#include "net/gnrc/nettype.h"
28#endif
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
37#define ESP_NOW_MAX_SIZE_RAW (250)
38
42#define ESP_NOW_ADDR_LEN ETHERNET_ADDR_LEN
43
47#define ESP_NOW_HEADER_LENGTH (sizeof(esp_now_pkt_hdr_t))
48
52#define ESP_NOW_MAX_SIZE (ESP_NOW_MAX_SIZE_RAW - ESP_NOW_HEADER_LENGTH)
53
59#ifndef ESP_NOW_BUFSIZE
60#define ESP_NOW_BUFSIZE (ESP_NOW_MAX_SIZE_RAW + ESP_NOW_ADDR_LEN)
61#endif
62
67
71typedef struct __attribute__((packed))
72{
73 uint8_t flags;
75
79#define ESP_NOW_PKT_HDR_FLAG_SIXLO (1)
80
84typedef struct
85{
88 uint8_t addr[ESP_NOW_ADDR_LEN];
90 uint8_t rx_len;
91 uint8_t* rx_mac;
92 uint8_t* rx_data;
94 uint8_t tx_mem[ESP_NOW_MAX_SIZE_RAW];
96#ifdef MODULE_GNRC
97 gnrc_nettype_t proto;
98#endif
99
102 uint8_t scan_event;
105
112
119int esp_now_set_channel(uint8_t channel);
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif /* ESP_NOW_NETDEV_H */
Definitions low-level network driver interface.
const netdev_driver_t esp_now_driver
Reference to the netdev device driver struct.
#define ESP_NOW_MAX_SIZE_RAW
Maximum raw packet size that can be used with ESP-NOW (including headers)
int esp_now_set_channel(uint8_t channel)
Set the channel used by ESP-NOW netdev.
#define ESP_NOW_ADDR_LEN
Length of ESP-NOW addresses.
esp_now_netdev_t * netdev_esp_now_setup(void)
ESP-NOW netdev initialization function.
gnrc_nettype_t
Definition of protocol types in the network stack.
Definition nettype.h:51
Mutex for thread synchronization.
Ethernet header definitions.
Protocol type definitions.
Device descriptor for ESP-NOW devices.
uint8_t scan_event
ESP-NOW peers have to be scanned.
netdev_t netdev
netdev parent struct
uint8_t * rx_mac
source mac of received data
mutex_t dev_lock
device is already in use
uint8_t rx_len
number of bytes received
uint8_t * rx_data
received
Header with necessary flags for ESP-NOW packets.
uint8_t flags
Flags.
Mutex structure.
Definition mutex.h:146
Structure to hold driver interface -> function mapping.
Definition netdev.h:424
Structure to hold driver state.
Definition netdev.h:363