Loading...
Searching...
No Matches
esp_now_netdev.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Gunar Schorcht
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#include "net/netdev.h"
20#include "mutex.h"
21#include "net/ethernet/hdr.h"
22#ifdef MODULE_GNRC
23#include "net/gnrc/nettype.h"
24#endif
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
33#define ESP_NOW_MAX_SIZE_RAW (250)
34
38#define ESP_NOW_ADDR_LEN ETHERNET_ADDR_LEN
39
43#define ESP_NOW_HEADER_LENGTH (sizeof(esp_now_pkt_hdr_t))
44
48#define ESP_NOW_MAX_SIZE (ESP_NOW_MAX_SIZE_RAW - ESP_NOW_HEADER_LENGTH)
49
55#ifndef ESP_NOW_BUFSIZE
56#define ESP_NOW_BUFSIZE (ESP_NOW_MAX_SIZE_RAW + ESP_NOW_ADDR_LEN)
57#endif
58
63
67typedef struct __attribute__((packed))
68{
69 uint8_t flags;
71
75#define ESP_NOW_PKT_HDR_FLAG_SIXLO (1)
76
80typedef struct
81{
83
85
86 uint8_t rx_len;
87 uint8_t* rx_mac;
88 uint8_t* rx_data;
89
91
92#ifdef MODULE_GNRC
93 gnrc_nettype_t proto;
94#endif
95
97
98 uint8_t scan_event;
99
101
108
115int esp_now_set_channel(uint8_t channel);
116
117#ifdef __cplusplus
118}
119#endif
120
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.
struct netdev netdev_t
Forward declaration for netdev struct.
Definition netdev.h:288
struct netdev_driver netdev_driver_t
Structure to hold driver interface -> function mapping.
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 addr[ESP_NOW_ADDR_LEN]
device addr (MAC address)
uint8_t * rx_mac
source mac of received data
mutex_t dev_lock
device is already in use
uint8_t tx_mem[ESP_NOW_MAX_SIZE_RAW]
memory holding outgoing package
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:39