mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 03:45:50 +08:00
esp32: Add support for espnow based pktradio
Espnow is a connectionless WiFi communication protocol that can be used to exchange information between esp nodes. A espnow pktradio driver is proposed that allows building a 6lowpan network of nodes. The driver has been evaluated using udpclient & server running on different devices. Solves #15347 Signed-off-by: Laczen JMS <laczenjms@gmail.com>
This commit is contained in:
committed by
Tiago Medicci Serrano
parent
69b0cefe80
commit
eba0362bde
@@ -745,6 +745,108 @@ config ESP32_WIRELESS
|
|||||||
---help---
|
---help---
|
||||||
Enable Wireless support
|
Enable Wireless support
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO
|
||||||
|
bool "ESPNOW packet radio support"
|
||||||
|
select ESP32_WIRELESS
|
||||||
|
depends on WIRELESS_PKTRADIO
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Enable using espnow for packet radio
|
||||||
|
|
||||||
|
if ESP32_ESPNOW_PKTRADIO
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO_FRAMELEN
|
||||||
|
int "ESPNOW frame length"
|
||||||
|
range 127 250
|
||||||
|
default 196
|
||||||
|
---help---
|
||||||
|
Frame size used for espnow transmitions. Ensure that this is
|
||||||
|
set equal for all nodes.
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO_PANID
|
||||||
|
hex "ESPNOW node panid"
|
||||||
|
range 0x0 0xffff
|
||||||
|
default 0x0
|
||||||
|
---help---
|
||||||
|
PANID for espnow packet radio
|
||||||
|
|
||||||
|
if PKTRADIO_ADDRLEN = 1
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO_NODE_ADDR_0
|
||||||
|
hex "ESPNOW node address"
|
||||||
|
range 0x0 0xff
|
||||||
|
default 0x0
|
||||||
|
---help---
|
||||||
|
Node address for espnow packet radio
|
||||||
|
|
||||||
|
endif #PKTRADIO_ADDRLEN = 1
|
||||||
|
|
||||||
|
if PKTRADIO_ADDRLEN > 1
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO_NODE_ADDR_0
|
||||||
|
hex "ESPNOW node address[0]"
|
||||||
|
range 0x0 0xff
|
||||||
|
default 0x0
|
||||||
|
---help---
|
||||||
|
Node address for espnow packet radio
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO_NODE_ADDR_1
|
||||||
|
hex "ESPNOW node address[1]"
|
||||||
|
range 0x0 0xff
|
||||||
|
default 0x0
|
||||||
|
---help---
|
||||||
|
Node address for espnow packet radio
|
||||||
|
|
||||||
|
if PKTRADIO_ADDRLEN > 2
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO_NODE_ADDR_2
|
||||||
|
hex "ESPNOW node address[2]"
|
||||||
|
range 0x0 0xff
|
||||||
|
default 0x0
|
||||||
|
---help---
|
||||||
|
Node address for espnow packet radio
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO_NODE_ADDR_3
|
||||||
|
hex "ESPNOW node address[3]"
|
||||||
|
range 0x0 0xff
|
||||||
|
default 0x0
|
||||||
|
---help---
|
||||||
|
Node address for espnow packet radio
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO_NODE_ADDR_4
|
||||||
|
hex "ESPNOW node address[4]"
|
||||||
|
range 0x0 0xff
|
||||||
|
default 0x0
|
||||||
|
---help---
|
||||||
|
Node address for espnow packet radio
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO_NODE_ADDR_5
|
||||||
|
hex "ESPNOW node address[5]"
|
||||||
|
range 0x0 0xff
|
||||||
|
default 0x0
|
||||||
|
---help---
|
||||||
|
Node address for espnow packet radio
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO_NODE_ADDR_6
|
||||||
|
hex "ESPNOW node address[6]"
|
||||||
|
range 0x0 0xff
|
||||||
|
default 0x0
|
||||||
|
---help---
|
||||||
|
Node address for espnow packet radio
|
||||||
|
|
||||||
|
config ESP32_ESPNOW_PKTRADIO_NODE_ADDR_7
|
||||||
|
hex "ESPNOW node address[7]"
|
||||||
|
range 0x0 0xff
|
||||||
|
default 0x0
|
||||||
|
---help---
|
||||||
|
Node address for espnow packet radio
|
||||||
|
|
||||||
|
endif #PKTRADIO_ADDRLEN > 2
|
||||||
|
|
||||||
|
endif #PKTRADIO_ADDRLEN > 1
|
||||||
|
|
||||||
|
endif #ESP32_ESPNOW_PKTRADIO
|
||||||
|
|
||||||
config ESP32_WIFI
|
config ESP32_WIFI
|
||||||
bool "Wi-Fi"
|
bool "Wi-Fi"
|
||||||
default n
|
default n
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ ifeq ($(CONFIG_ESP32_WIFI),y)
|
|||||||
CHIP_CSRCS += esp32_wlan.c esp32_wifi_utils.c esp32_wifi_adapter.c
|
CHIP_CSRCS += esp32_wlan.c esp32_wifi_utils.c esp32_wifi_adapter.c
|
||||||
EXTRA_LIBS += -lcore -lnet80211 -lpp
|
EXTRA_LIBS += -lcore -lnet80211 -lpp
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ESP32_ESPNOW_PKTRADIO),y)
|
||||||
|
CHIP_CSRCS += esp32_espnow_pktradio.c
|
||||||
|
EXTRA_LIBS += -lespnow
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_WPA_WAPI_PSK),y)
|
ifeq ($(CONFIG_WPA_WAPI_PSK),y)
|
||||||
EXTRA_LIBS += -lwapi
|
EXTRA_LIBS += -lwapi
|
||||||
endif
|
endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,77 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/xtensa/src/esp32/esp32_espnow_pktradio.h
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_ESPNOW_PKTRADIO_H
|
||||||
|
#define __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_ESPNOW_PKTRADIO_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32_ESPNOW_PKTRADIO
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: pktradio_espnow
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize and register the 6LoWPAN over espnow MAC network driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; Negated errno on failure.
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int pktradio_espnow(void);
|
||||||
|
#endif /* CONFIG_ESP32_ESPNOW_PKTRADIO */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#undef EXTERN
|
||||||
|
|
||||||
|
#endif /* __ASSEMBLY__ */
|
||||||
|
#endif /* __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_ESPNOW_PKTRADIO_H */
|
||||||
@@ -179,6 +179,10 @@
|
|||||||
# include "espressif/esp_nxdiag.h"
|
# include "espressif/esp_nxdiag.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32_ESPNOW_PKTRADIO
|
||||||
|
# include "esp32_espnow_pktradio.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "esp32-devkitc.h"
|
#include "esp32-devkitc.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -362,6 +366,15 @@ int esp32_bringup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32_ESPNOW_PKTRADIO
|
||||||
|
ret = pktradio_espnow();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: Failed to initialize ESPNOW pktradio=%d\n",
|
||||||
|
ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ESP32_OPENETH
|
#ifdef CONFIG_ESP32_OPENETH
|
||||||
ret = esp_openeth_initialize();
|
ret = esp_openeth_initialize();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user