This commit is contained in:
iranl
2025-06-25 22:52:12 +02:00
parent 5fe5614686
commit 6c74d62531
519 changed files with 191600 additions and 5 deletions

View File

@@ -0,0 +1,25 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/** prevent recursive inclusion **/
#ifndef __ESP_HOSTED_API_TYPES_H__
#define __ESP_HOSTED_API_TYPES_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
uint32_t major1;
uint32_t minor1;
uint32_t patch1;
} esp_hosted_coprocessor_fwver_t;
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,54 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_HOSTED_BT_CONFIG_H__
#define __ESP_HOSTED_BT_CONFIG_H__
// check: if co-processor SOC is ESP32, only BT BLE 4.2 is supported
#if CONFIG_SLAVE_IDF_TARGET_ESP32
#if CONFIG_BT_BLE_50_FEATURES_SUPPORTED || CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT
#error "ESP32 co-processor only supports BLE 4.2"
#endif
#endif
// Hosted BT defines for NimBLE
#if CONFIG_ESP_HOSTED_ENABLE_BT_NIMBLE
#define H_BT_HOST_ESP_NIMBLE 1
#else
#define H_BT_HOST_ESP_NIMBLE 0
#endif
#if CONFIG_ESP_HOSTED_NIMBLE_HCI_VHCI
#define H_BT_USE_VHCI 1
#else
#define H_BT_USE_VHCI 0
#endif
// Hosted BT defines for BlueDroid
#if CONFIG_ESP_HOSTED_ENABLE_BT_BLUEDROID
#define H_BT_HOST_ESP_BLUEDROID 1
#else
#define H_BT_HOST_ESP_BLUEDROID 0
#endif
#if CONFIG_ESP_HOSTED_BLUEDROID_HCI_VHCI
#define H_BT_BLUEDROID_USE_VHCI 1
#else
#define H_BT_BLUEDROID_USE_VHCI 1
#endif
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
// ll_init required
#define H_BT_ENABLE_LL_INIT 1
#else
#define H_BT_ENABLE_LL_INIT 0
#endif
// check: only one BT host stack can be enabled at a time
#if H_BT_HOST_ESP_NIMBLE && H_BT_HOST_ESP_BLUEDROID
#error "Enable only NimBLE or BlueDroid, not both"
#endif
#endif

View File

@@ -0,0 +1,396 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_HOSTED_CONFIG_H__
#define __ESP_HOSTED_CONFIG_H__
#include "sdkconfig.h"
#include "esp_task.h"
#define H_TRANSPORT_NONE 0
#define H_TRANSPORT_SDIO 1
#define H_TRANSPORT_SPI_HD 2
#define H_TRANSPORT_SPI 3
#define H_TRANSPORT_UART 4
#ifdef CONFIG_ESP_HOSTED_UART_HOST_INTERFACE
#include "hal/uart_types.h"
#endif
/* This file is to tune the main ESP-Hosted configurations.
* In case you are not sure of some value, Let it be default.
**/
#define H_GPIO_LOW 0
#define H_GPIO_HIGH 1
enum {
H_GPIO_INTR_DISABLE = 0, /*!< Disable GPIO interrupt */
H_GPIO_INTR_POSEDGE = 1, /*!< GPIO interrupt type : rising edge */
H_GPIO_INTR_NEGEDGE = 2, /*!< GPIO interrupt type : falling edge */
H_GPIO_INTR_ANYEDGE = 3, /*!< GPIO interrupt type : both rising and falling edge */
H_GPIO_INTR_LOW_LEVEL = 4, /*!< GPIO interrupt type : input low level trigger */
H_GPIO_INTR_HIGH_LEVEL = 5, /*!< GPIO interrupt type : input high level trigger */
H_GPIO_INTR_MAX,
};
#if CONFIG_SLAVE_IDF_TARGET_ESP32
#define H_SLAVE_TARGET_ESP32 1
#elif CONFIG_SLAVE_IDF_TARGET_ESP32S2
#define H_SLAVE_TARGET_ESP32S2 1
#elif CONFIG_SLAVE_IDF_TARGET_ESP32C3
#define H_SLAVE_TARGET_ESP32C3 1
#elif CONFIG_SLAVE_IDF_TARGET_ESP32S3
#define H_SLAVE_TARGET_ESP32S3 1
#elif CONFIG_SLAVE_IDF_TARGET_ESP32C2
#define H_SLAVE_TARGET_ESP32C2 1
#elif CONFIG_SLAVE_IDF_TARGET_ESP32C6
#define H_SLAVE_TARGET_ESP32C6 1
#elif CONFIG_SLAVE_IDF_TARGET_ESP32C5
#define H_SLAVE_TARGET_ESP32C5 1
#else
#error "Unknown Slave Target"
#endif
#if CONFIG_ESP_HOSTED_USE_MEMPOOL
#define H_USE_MEMPOOL 1
#endif
#define H_MAX_SYNC_RPC_REQUESTS CONFIG_ESP_HOSTED_MAX_SIMULTANEOUS_SYNC_RPC_REQUESTS
#define H_MAX_ASYNC_RPC_REQUESTS CONFIG_ESP_HOSTED_MAX_SIMULTANEOUS_ASYNC_RPC_REQUESTS
#undef H_TRANSPORT_IN_USE
#ifdef CONFIG_ESP_HOSTED_SPI_HOST_INTERFACE
#define H_TRANSPORT_IN_USE H_TRANSPORT_SPI
/* -------------------------- SPI Master Config start ---------------------- */
/*
Pins in use. The SPI Master can use the GPIO mux,
so feel free to change these if needed.
*/
/* SPI config */
#ifdef CONFIG_ESP_HOSTED_HS_ACTIVE_LOW
#define H_HANDSHAKE_ACTIVE_HIGH 0
#else
/* Default HS: Active High */
#define H_HANDSHAKE_ACTIVE_HIGH 1
#endif
#ifdef CONFIG_ESP_HOSTED_DR_ACTIVE_LOW
#define H_DATAREADY_ACTIVE_HIGH 0
#else
/* Default DR: Active High */
#define H_DATAREADY_ACTIVE_HIGH 1
#endif
#if H_HANDSHAKE_ACTIVE_HIGH
#define H_HS_VAL_ACTIVE H_GPIO_HIGH
#define H_HS_VAL_INACTIVE H_GPIO_LOW
#define H_HS_INTR_EDGE H_GPIO_INTR_POSEDGE
#else
#define H_HS_VAL_ACTIVE H_GPIO_LOW
#define H_HS_VAL_INACTIVE H_GPIO_HIGH
#define H_HS_INTR_EDGE H_GPIO_INTR_NEGEDGE
#endif
#if H_DATAREADY_ACTIVE_HIGH
#define H_DR_VAL_ACTIVE H_GPIO_HIGH
#define H_DR_VAL_INACTIVE H_GPIO_LOW
#define H_DR_INTR_EDGE H_GPIO_INTR_POSEDGE
#else
#define H_DR_VAL_ACTIVE H_GPIO_LOW
#define H_DR_VAL_INACTIVE H_GPIO_HIGH
#define H_DR_INTR_EDGE H_GPIO_INTR_NEGEDGE
#endif
#define H_GPIO_HANDSHAKE_Port NULL
#define H_GPIO_HANDSHAKE_Pin CONFIG_ESP_HOSTED_SPI_GPIO_HANDSHAKE
#define H_GPIO_DATA_READY_Port NULL
#define H_GPIO_DATA_READY_Pin CONFIG_ESP_HOSTED_SPI_GPIO_DATA_READY
#define H_GPIO_MOSI_Port NULL
#define H_GPIO_MOSI_Pin CONFIG_ESP_HOSTED_SPI_GPIO_MOSI
#define H_GPIO_MISO_Port NULL
#define H_GPIO_MISO_Pin CONFIG_ESP_HOSTED_SPI_GPIO_MISO
#define H_GPIO_SCLK_Port NULL
#define H_GPIO_SCLK_Pin CONFIG_ESP_HOSTED_SPI_GPIO_CLK
#define H_GPIO_CS_Port NULL
#define H_GPIO_CS_Pin CONFIG_ESP_HOSTED_SPI_GPIO_CS
#define H_SPI_TX_Q CONFIG_ESP_HOSTED_SPI_TX_Q_SIZE
#define H_SPI_RX_Q CONFIG_ESP_HOSTED_SPI_RX_Q_SIZE
#define H_SPI_MODE CONFIG_ESP_HOSTED_SPI_MODE
#define H_SPI_INIT_CLK_MHZ CONFIG_ESP_HOSTED_SPI_CLK_FREQ
/* -------------------------- SPI Master Config end ------------------------ */
#endif
#ifdef CONFIG_ESP_HOSTED_SDIO_HOST_INTERFACE
#define H_TRANSPORT_IN_USE H_TRANSPORT_SDIO
/* -------------------------- SDIO Host Config start ----------------------- */
#ifdef CONFIG_SOC_SDMMC_USE_GPIO_MATRIX
#define H_SDIO_SOC_USE_GPIO_MATRIX
#endif
#define H_SDIO_CLOCK_FREQ_KHZ CONFIG_ESP_HOSTED_SDIO_CLOCK_FREQ_KHZ
#define H_SDIO_BUS_WIDTH CONFIG_ESP_HOSTED_SDIO_BUS_WIDTH
#define H_SDMMC_HOST_SLOT CONFIG_ESP_HOSTED_SDIO_SLOT
#ifdef H_SDIO_SOC_USE_GPIO_MATRIX
#define H_SDIO_PIN_CLK CONFIG_ESP_HOSTED_SDIO_PIN_CLK
#define H_SDIO_PIN_CMD CONFIG_ESP_HOSTED_SDIO_PIN_CMD
#define H_SDIO_PIN_D0 CONFIG_ESP_HOSTED_SDIO_PIN_D0
#define H_SDIO_PIN_D1 CONFIG_ESP_HOSTED_SDIO_PIN_D1
#if (H_SDIO_BUS_WIDTH == 4)
#define H_SDIO_PIN_D2 CONFIG_ESP_HOSTED_SDIO_PIN_D2
#define H_SDIO_PIN_D3 CONFIG_ESP_HOSTED_SDIO_PIN_D3
#else
#define H_SDIO_PIN_D2 -1
#define H_SDIO_PIN_D3 -1
#endif
#else
#define H_SDIO_PIN_CLK -1
#define H_SDIO_PIN_CMD -1
#define H_SDIO_PIN_D0 -1
#define H_SDIO_PIN_D1 -1
#if (H_SDIO_BUS_WIDTH == 4)
#define H_SDIO_PIN_D2 -1
#define H_SDIO_PIN_D3 -1
#else
#define H_SDIO_PIN_D2 -1
#define H_SDIO_PIN_D3 -1
#endif
#endif
#define H_SDIO_TX_Q CONFIG_ESP_HOSTED_SDIO_TX_Q_SIZE
#define H_SDIO_RX_Q CONFIG_ESP_HOSTED_SDIO_RX_Q_SIZE
#define H_SDIO_CHECKSUM CONFIG_ESP_HOSTED_SDIO_CHECKSUM
#define H_SDIO_HOST_STREAMING_MODE 1
#define H_SDIO_ALWAYS_HOST_RX_MAX_TRANSPORT_SIZE 2
#define H_SDIO_OPTIMIZATION_RX_NONE 3
#ifdef CONFIG_ESP_HOSTED_SDIO_OPTIMIZATION_RX_STREAMING_MODE
#define H_SDIO_HOST_RX_MODE H_SDIO_HOST_STREAMING_MODE
#elif defined(CONFIG_ESP_HOSTED_SDIO_OPTIMIZATION_RX_MAX_SIZE)
#define H_SDIO_HOST_RX_MODE H_SDIO_ALWAYS_HOST_RX_MAX_TRANSPORT_SIZE
#else
/* Use this if unsure */
#define H_SDIO_HOST_RX_MODE H_SDIO_OPTIMIZATION_RX_NONE
#endif
// Pad transfer len for host operation
#define H_SDIO_TX_LEN_TO_TRANSFER(x) ((x + 3) & (~3))
#define H_SDIO_RX_LEN_TO_TRANSFER(x) ((x + 3) & (~3))
/* Do Block Mode only transfers
*
* When enabled, SDIO only uses block mode transfers for higher
* throughput. Data lengths are padded to multiples of ESP_BLOCK_SIZE.
*
* This is safe for the SDIO slave:
* - for Host Tx: slave will ignore extra data sent by Host
* - for Host Rx: slave will send extra 0 data, ignored by Host
*/
#define H_SDIO_TX_BLOCK_ONLY_XFER (1)
#define H_SDIO_RX_BLOCK_ONLY_XFER (1)
// workarounds for some SDIO transfer errors that may occur
#if 0
/* Below workarounds could be enabled for non-ESP MCUs to test first
* Once everything is stable, can disable workarounds and test again
* */
#define H_SDIO_TX_LIMIT_XFER_SIZE_WORKAROUND // limit transfer to one ESP_BLOCK_SIZE at a time
#define H_SDIO_RX_LIMIT_XFER_SIZE_WORKDAROUND // limit transfer to one ESP_BLOCK_SIZE at a time
#endif
#if defined(H_SDIO_TX_LIMIT_XFER_SIZE_WORKAROUND)
#define H_SDIO_TX_BLOCKS_TO_TRANSFER(x) (1)
#else
#define H_SDIO_TX_BLOCKS_TO_TRANSFER(x) (x / ESP_BLOCK_SIZE)
#endif
#if defined(H_SDIO_RX_LIMIT_XFER_SIZE_WORKDAROUND)
#define H_SDIO_RX_BLOCKS_TO_TRANSFER(x) (1)
#else
#define H_SDIO_RX_BLOCKS_TO_TRANSFER(x) (x / ESP_BLOCK_SIZE)
#endif
/* -------------------------- SDIO Host Config end ------------------------- */
#endif
#ifdef CONFIG_ESP_HOSTED_SPI_HD_HOST_INTERFACE
#define H_TRANSPORT_IN_USE H_TRANSPORT_SPI_HD
/* -------------------------- SPI_HD Host Config start ----------------------- */
#define H_SPI_HD_HOST_INTERFACE 1
enum {
H_SPI_HD_CONFIG_2_DATA_LINES,
H_SPI_HD_CONFIG_4_DATA_LINES,
};
#if CONFIG_ESP_HOSTED_SPI_HD_DR_ACTIVE_HIGH
#define H_SPI_HD_DATAREADY_ACTIVE_HIGH 1
#else
#define H_SPI_HD_DATAREADY_ACTIVE_HIGH 0
#endif
#if H_SPI_HD_DATAREADY_ACTIVE_HIGH
#define H_SPI_HD_DR_VAL_ACTIVE H_GPIO_HIGH
#define H_SPI_HD_DR_VAL_INACTIVE H_GPIO_LOW
#define H_SPI_HD_DR_INTR_EDGE H_GPIO_INTR_POSEDGE
#else
#define H_SPI_HD_DR_VAL_ACTIVE H_GPIO_LOW
#define H_SPI_HD_DR_VAL_INACTIVE H_GPIO_HIGH
#define H_SPI_HD_DR_INTR_EDGE H_GPIO_INTR_NEGEDGE
#endif
#define H_SPI_HD_HOST_NUM_DATA_LINES CONFIG_ESP_HOSTED_SPI_HD_INTERFACE_NUM_DATA_LINES
#define H_SPI_HD_PIN_D0 CONFIG_ESP_HOSTED_SPI_HD_GPIO_D0
#define H_SPI_HD_PIN_D1 CONFIG_ESP_HOSTED_SPI_HD_GPIO_D1
#if (CONFIG_ESP_HOSTED_SPI_HD_INTERFACE_NUM_DATA_LINES == 4)
#define H_SPI_HD_PIN_D2 CONFIG_ESP_HOSTED_SPI_HD_GPIO_D2
#define H_SPI_HD_PIN_D3 CONFIG_ESP_HOSTED_SPI_HD_GPIO_D3
#else
#define H_SPI_HD_PIN_D2 -1
#define H_SPI_HD_PIN_D3 -1
#endif
#define H_SPI_HD_PIN_CS CONFIG_ESP_HOSTED_SPI_HD_GPIO_CS
#define H_SPI_HD_PIN_CLK CONFIG_ESP_HOSTED_SPI_HD_GPIO_CLK
#define H_SPI_HD_GPIO_DATA_READY_Port NULL
#define H_SPI_HD_PIN_DATA_READY CONFIG_ESP_HOSTED_SPI_HD_GPIO_DATA_READY
#define H_SPI_HD_CLK_MHZ CONFIG_ESP_HOSTED_SPI_HD_CLK_FREQ
#define H_SPI_HD_MODE CONFIG_ESP_HOSTED_SPI_HD_MODE
#define H_SPI_HD_TX_QUEUE_SIZE CONFIG_ESP_HOSTED_SPI_HD_TX_Q_SIZE
#define H_SPI_HD_RX_QUEUE_SIZE CONFIG_ESP_HOSTED_SPI_HD_RX_Q_SIZE
#define H_SPI_HD_CHECKSUM CONFIG_ESP_HOSTED_SPI_HD_CHECKSUM
#define H_SPI_HD_NUM_COMMAND_BITS 8
#define H_SPI_HD_NUM_ADDRESS_BITS 8
#define H_SPI_HD_NUM_DUMMY_BITS 8
/* -------------------------- SPI_HD Host Config end ------------------------- */
#else
#define H_SPI_HD_HOST_INTERFACE 0
#endif
#ifdef CONFIG_ESP_HOSTED_UART_HOST_INTERFACE
#define H_TRANSPORT_IN_USE H_TRANSPORT_UART
/* -------------------------- UART Host Config start ------------------------- */
#define H_UART_HOST_TRANSPORT 1
#define H_UART_PORT CONFIG_ESP_HOSTED_UART_PORT
#define H_UART_NUM_DATA_BITS CONFIG_ESP_HOSTED_UART_NUM_DATA_BITS
#define H_UART_PARITY CONFIG_ESP_HOSTED_UART_PARITY
#define H_UART_START_BITS 1
#define H_UART_STOP_BITS CONFIG_ESP_HOSTED_UART_STOP_BITS
#define H_UART_FLOWCTRL UART_HW_FLOWCTRL_DISABLE
#define H_UART_CLK_SRC UART_SCLK_DEFAULT
#define H_UART_CHECKSUM CONFIG_ESP_HOSTED_UART_CHECKSUM
#define H_UART_BAUD_RATE CONFIG_ESP_HOSTED_UART_BAUDRATE
#define H_UART_TX_PIN CONFIG_ESP_HOSTED_UART_PIN_TX
#define H_UART_RX_PIN CONFIG_ESP_HOSTED_UART_PIN_RX
#define H_UART_TX_QUEUE_SIZE CONFIG_ESP_HOSTED_UART_TX_Q_SIZE
#define H_UART_RX_QUEUE_SIZE CONFIG_ESP_HOSTED_UART_RX_Q_SIZE
/* -------------------------- UART Host Config end ------------------------- */
#else
#define H_UART_HOST_TRANSPORT 0
#endif
/* Generic reset pin config */
#define H_GPIO_PIN_RESET_Port NULL
#define H_GPIO_PIN_RESET_Pin CONFIG_ESP_HOSTED_GPIO_SLAVE_RESET_SLAVE
/* If Reset pin is Enable, it is Active High.
* If it is RST, active low */
#ifdef CONFIG_ESP_HOSTED_RESET_GPIO_ACTIVE_LOW
#define H_RESET_ACTIVE_HIGH 0
#else
#define H_RESET_ACTIVE_HIGH 1
#endif
#if H_RESET_ACTIVE_HIGH
#define H_RESET_VAL_ACTIVE H_GPIO_HIGH
#define H_RESET_VAL_INACTIVE H_GPIO_LOW
#else
#define H_RESET_VAL_ACTIVE H_GPIO_LOW
#define H_RESET_VAL_INACTIVE H_GPIO_HIGH
#endif
#define TIMEOUT_PSERIAL_RESP 30
#define PRE_FORMAT_NEWLINE_CHAR ""
#define POST_FORMAT_NEWLINE_CHAR "\n"
#define USE_STD_C_LIB_MALLOC 0
#ifdef CONFIG_HOST_TO_ESP_WIFI_DATA_THROTTLE
#define H_WIFI_TX_DATA_THROTTLE_LOW_THRESHOLD CONFIG_ESP_HOSTED_TO_WIFI_DATA_THROTTLE_LOW_THRESHOLD
#define H_WIFI_TX_DATA_THROTTLE_HIGH_THRESHOLD CONFIG_ESP_HOSTED_TO_WIFI_DATA_THROTTLE_HIGH_THRESHOLD
#else
#define H_WIFI_TX_DATA_THROTTLE_LOW_THRESHOLD 0
#define H_WIFI_TX_DATA_THROTTLE_HIGH_THRESHOLD 0
#endif
#define H_PKT_STATS CONFIG_ESP_HOSTED_PKT_STATS
/* Raw Throughput Testing */
#define H_TEST_RAW_TP CONFIG_ESP_HOSTED_RAW_THROUGHPUT_TRANSPORT
#if H_TEST_RAW_TP
#define H_RAW_TP_REPORT_INTERVAL CONFIG_ESP_HOSTED_RAW_TP_REPORT_INTERVAL
#define H_RAW_TP_PKT_LEN CONFIG_ESP_HOSTED_RAW_TP_HOST_TO_ESP_PKT_LEN
#if CONFIG_ESP_HOSTED_RAW_THROUGHPUT_TX_TO_SLAVE
#define H_TEST_RAW_TP_DIR (ESP_TEST_RAW_TP__HOST_TO_ESP)
#elif CONFIG_ESP_HOSTED_RAW_THROUGHPUT_RX_FROM_SLAVE
#define H_TEST_RAW_TP_DIR (ESP_TEST_RAW_TP__ESP_TO_HOST)
#elif CONFIG_ESP_HOSTED_RAW_THROUGHPUT_BIDIRECTIONAL
#define H_TEST_RAW_TP_DIR (ESP_TEST_RAW_TP__BIDIRECTIONAL)
#else
#error Test Raw TP direction not defined
#endif
#else
#define H_TEST_RAW_TP_DIR (ESP_TEST_RAW_TP_NONE)
#endif
/* ---------------------- ESP-IDF Specific Config start -------------------- */
/* This section is for ESP-IDF specific support.
* Can be ignored on other hosts MCUs.
*/
/* Controls whether an Internal LDO powers the SDIO connection */
#if CONFIG_ESP_HOSTED_SD_PWR_CTRL_LDO_INTERNAL_IO
#define H_SDIO_PWR_CTRL_LDO 1
#define H_SDIO_PWR_CTRL_LDO_ID CONFIG_ESP_HOSTED_SD_PWR_CTRL_LDO_IO_ID
#else
#define H_SDIO_PWR_CTRL_LDO 0
#endif
/* ---------------------- ESP-IDF Specific Config end ---------------------- */
esp_err_t esp_hosted_set_default_config(void);
bool esp_hosted_is_config_valid(void);
#endif /*__ESP_HOSTED_CONFIG_H__*/

View File

@@ -0,0 +1,35 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* APIs to do OTA updates of the co-processor
*
* Note: This API is platform dependent
*
* Add additional APIs as required based on how the OTA binary is to
* be fetched.
*
* Source for the API should be in host/port/<platform>/...
*
* Procedure used by APIs to do OTA update:
* 1. Fetch and prepare OTA binary
* 2. Call rpc_ota_begin() to start OTA
* 3. Repeatedly call rpc_ota_write() with a continuous chunk of OTA data
* 4. Call rpc_ota_end()
*
*/
#ifndef __ESP_HOSTED_OTA_H__
#define __ESP_HOSTED_OTA_H__
#ifdef ESP_PLATFORM
// OTA API for ESP-IDF
#include "esp_err.h"
/* Fetch OTA image from a web server (image_url) */
esp_err_t esp_hosted_slave_ota(const char* image_url);
#endif
#endif /*__ESP_HOSTED_OTA_H__*/

View File

@@ -0,0 +1,240 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_HOSTED_TRANSPORT_CONFIG_H__
#define __ESP_HOSTED_TRANSPORT_CONFIG_H__
#include "esp_hosted_config.h"
#include "esp_err.h"
typedef enum {
ESP_TRANSPORT_OK = ESP_OK,
ESP_TRANSPORT_ERR_INVALID_ARG = ESP_ERR_INVALID_ARG,
ESP_TRANSPORT_ERR_ALREADY_SET = ESP_ERR_NOT_ALLOWED,
ESP_TRANSPORT_ERR_INVALID_STATE = ESP_ERR_INVALID_STATE,
} esp_hosted_transport_err_t;
/* GPIO pin configuration structure */
typedef struct {
void *port;
uint8_t pin;
} gpio_pin_t;
/* New Configuration Structures */
struct esp_hosted_sdio_config {
uint32_t clock_freq_khz;
uint8_t bus_width;
uint8_t slot;
gpio_pin_t pin_clk;
gpio_pin_t pin_cmd;
gpio_pin_t pin_d0;
gpio_pin_t pin_d1;
gpio_pin_t pin_d2;
gpio_pin_t pin_d3;
gpio_pin_t pin_reset;
uint8_t rx_mode;
bool block_mode;
bool iomux_enable;
};
struct esp_hosted_spi_hd_config {
/* Number of lines used */
uint8_t num_data_lines;
/* SPI HD pins */
gpio_pin_t pin_cs;
gpio_pin_t pin_clk;
gpio_pin_t pin_data_ready;
gpio_pin_t pin_d0;
gpio_pin_t pin_d1;
gpio_pin_t pin_d2;
gpio_pin_t pin_d3;
gpio_pin_t pin_reset;
/* SPI HD configuration */
uint32_t clk_mhz;
uint8_t mode;
uint16_t tx_queue_size;
uint16_t rx_queue_size;
bool checksum_enable;
uint8_t num_command_bits;
uint8_t num_address_bits;
uint8_t num_dummy_bits;
};
struct esp_hosted_spi_config {
/* SPI Full Duplex pins */
gpio_pin_t pin_mosi;
gpio_pin_t pin_miso;
gpio_pin_t pin_sclk;
gpio_pin_t pin_cs;
gpio_pin_t pin_handshake;
gpio_pin_t pin_data_ready;
gpio_pin_t pin_reset;
/* SPI Full Duplex configuration */
uint16_t tx_queue_size;
uint16_t rx_queue_size;
uint8_t mode;
uint32_t clk_mhz;
};
struct esp_hosted_uart_config {
/* UART bus number */
uint8_t port;
/* UART pins */
gpio_pin_t pin_tx;
gpio_pin_t pin_rx;
gpio_pin_t pin_reset;
/* UART configuration */
uint8_t num_data_bits;
uint8_t parity;
uint8_t stop_bits;
uint8_t flow_ctrl;
uint8_t clk_src;
bool checksum_enable;
uint32_t baud_rate;
uint16_t tx_queue_size;
uint16_t rx_queue_size;
};
struct esp_hosted_transport_config {
uint8_t transport_in_use;
union {
struct esp_hosted_sdio_config sdio;
struct esp_hosted_spi_hd_config spi_hd;
struct esp_hosted_spi_config spi;
struct esp_hosted_uart_config uart;
} u;
};
#if H_TRANSPORT_SDIO == H_TRANSPORT_IN_USE
#define INIT_DEFAULT_HOST_SDIO_CONFIG() \
(struct esp_hosted_sdio_config) { \
.clock_freq_khz = H_SDIO_CLOCK_FREQ_KHZ, \
.bus_width = H_SDIO_BUS_WIDTH, \
.slot = H_SDMMC_HOST_SLOT, \
.pin_clk = {.port = NULL, .pin = H_SDIO_PIN_CLK}, \
.pin_cmd = {.port = NULL, .pin = H_SDIO_PIN_CMD}, \
.pin_d0 = {.port = NULL, .pin = H_SDIO_PIN_D0}, \
.pin_d1 = {.port = NULL, .pin = H_SDIO_PIN_D1}, \
.pin_d2 = {.port = NULL, .pin = H_SDIO_PIN_D2}, \
.pin_d3 = {.port = NULL, .pin = H_SDIO_PIN_D3}, \
.pin_reset = {.port = NULL, .pin = H_GPIO_PIN_RESET_Pin }, \
.rx_mode = H_SDIO_HOST_RX_MODE, \
.block_mode = H_SDIO_TX_BLOCK_ONLY_XFER && H_SDIO_RX_BLOCK_ONLY_XFER, \
.iomux_enable = false, \
}
#define INIT_DEFAULT_HOST_SDIO_IOMUX_CONFIG() \
(struct esp_hosted_sdio_config) { \
.clock_freq_khz = H_SDIO_CLOCK_FREQ_KHZ, \
.bus_width = H_SDIO_BUS_WIDTH, \
.slot = H_SDMMC_HOST_SLOT, \
.rx_mode = H_SDIO_HOST_RX_MODE, \
.block_mode = H_SDIO_TX_BLOCK_ONLY_XFER && H_SDIO_RX_BLOCK_ONLY_XFER, \
.iomux_enable = true, \
}
#endif
#if H_TRANSPORT_SPI_HD == H_TRANSPORT_IN_USE
#define INIT_DEFAULT_HOST_SPI_HD_CONFIG() \
(struct esp_hosted_spi_hd_config) { \
.num_data_lines = H_SPI_HD_HOST_NUM_DATA_LINES, \
.pin_cs = {.port = NULL, .pin = H_SPI_HD_PIN_CS}, \
.pin_clk = {.port = NULL, .pin = H_SPI_HD_PIN_CLK}, \
.pin_data_ready = {.port = NULL, .pin = H_SPI_HD_PIN_DATA_READY}, \
.pin_d0 = {.port = NULL, .pin = H_SPI_HD_PIN_D0}, \
.pin_d1 = {.port = NULL, .pin = H_SPI_HD_PIN_D1}, \
.pin_d2 = {.port = NULL, .pin = H_SPI_HD_PIN_D2}, \
.pin_d3 = {.port = NULL, .pin = H_SPI_HD_PIN_D3}, \
.pin_reset = {.port = NULL, .pin = H_GPIO_PIN_RESET_Pin }, \
.clk_mhz = H_SPI_HD_CLK_MHZ, \
.mode = H_SPI_HD_MODE, \
.tx_queue_size = H_SPI_HD_TX_QUEUE_SIZE, \
.rx_queue_size = H_SPI_HD_RX_QUEUE_SIZE, \
.checksum_enable = H_SPI_HD_CHECKSUM, \
.num_command_bits = H_SPI_HD_NUM_COMMAND_BITS, \
.num_address_bits = H_SPI_HD_NUM_ADDRESS_BITS, \
.num_dummy_bits = H_SPI_HD_NUM_DUMMY_BITS, \
}
#endif
#if H_TRANSPORT_SPI == H_TRANSPORT_IN_USE
#define INIT_DEFAULT_HOST_SPI_CONFIG() \
(struct esp_hosted_spi_config) { \
.pin_mosi = {.port = NULL, .pin = H_GPIO_MOSI_Pin}, \
.pin_miso = {.port = NULL, .pin = H_GPIO_MISO_Pin}, \
.pin_sclk = {.port = NULL, .pin = H_GPIO_SCLK_Pin}, \
.pin_cs = {.port = NULL, .pin = H_GPIO_CS_Pin}, \
.pin_handshake = {.port = NULL, .pin = H_GPIO_HANDSHAKE_Pin}, \
.pin_data_ready = {.port = NULL, .pin = H_GPIO_DATA_READY_Pin}, \
.pin_reset = {.port = NULL, .pin = H_GPIO_PIN_RESET_Pin }, \
.tx_queue_size = H_SPI_TX_Q, \
.rx_queue_size = H_SPI_RX_Q, \
.mode = H_SPI_MODE, \
.clk_mhz = H_SPI_INIT_CLK_MHZ, \
}
#endif
#if H_TRANSPORT_UART == H_TRANSPORT_IN_USE
#define INIT_DEFAULT_HOST_UART_CONFIG() \
(struct esp_hosted_uart_config) { \
.port = H_UART_PORT, \
.pin_tx = {.port = NULL, .pin = H_UART_TX_PIN}, \
.pin_rx = {.port = NULL, .pin = H_UART_RX_PIN}, \
.pin_reset = {.port = NULL, .pin = H_GPIO_PIN_RESET_Pin }, \
.num_data_bits = H_UART_NUM_DATA_BITS, \
.parity = H_UART_PARITY, \
.stop_bits = H_UART_STOP_BITS, \
.flow_ctrl = H_UART_FLOWCTRL, \
.clk_src = H_UART_CLK_SRC, \
.checksum_enable = H_UART_CHECKSUM, \
.baud_rate = H_UART_BAUD_RATE, \
.tx_queue_size = H_UART_TX_QUEUE_SIZE, \
.rx_queue_size = H_UART_RX_QUEUE_SIZE \
}
#endif
/* Configuration get/set functions */
esp_hosted_transport_err_t esp_hosted_transport_set_default_config(void);
esp_hosted_transport_err_t esp_hosted_transport_get_config(struct esp_hosted_transport_config **config);
esp_hosted_transport_err_t esp_hosted_transport_get_reset_config(gpio_pin_t *pin_config);
bool esp_hosted_transport_is_config_valid(void);
#if H_TRANSPORT_SDIO == H_TRANSPORT_IN_USE
/* SDIO functions */
esp_hosted_transport_err_t esp_hosted_sdio_get_config(struct esp_hosted_sdio_config **config);
esp_hosted_transport_err_t esp_hosted_sdio_set_config(struct esp_hosted_sdio_config *config) __attribute__((warn_unused_result));
esp_hosted_transport_err_t esp_hosted_sdio_iomux_set_config(struct esp_hosted_sdio_config *config) __attribute__((warn_unused_result));
#endif
#if H_TRANSPORT_SPI_HD == H_TRANSPORT_IN_USE
/* SPI Half Duplex functions */
esp_hosted_transport_err_t esp_hosted_spi_hd_get_config(struct esp_hosted_spi_hd_config **config);
esp_hosted_transport_err_t esp_hosted_spi_hd_set_config(struct esp_hosted_spi_hd_config *config) __attribute__((warn_unused_result));
esp_hosted_transport_err_t esp_hosted_spi_hd_2lines_get_config(struct esp_hosted_spi_hd_config **config);
esp_hosted_transport_err_t esp_hosted_spi_hd_2lines_set_config(struct esp_hosted_spi_hd_config *config) __attribute__((warn_unused_result));
#endif
#if H_TRANSPORT_SPI == H_TRANSPORT_IN_USE
/* SPI Full Duplex functions */
esp_hosted_transport_err_t esp_hosted_spi_get_config(struct esp_hosted_spi_config **config);
esp_hosted_transport_err_t esp_hosted_spi_set_config(struct esp_hosted_spi_config *config) __attribute__((warn_unused_result));
#endif
#if H_TRANSPORT_UART == H_TRANSPORT_IN_USE
/* UART functions */
esp_hosted_transport_err_t esp_hosted_uart_get_config(struct esp_hosted_uart_config **config);
esp_hosted_transport_err_t esp_hosted_uart_set_config(struct esp_hosted_uart_config *config) __attribute__((warn_unused_result));
#endif
#endif /* __ESP_HOSTED_TRANSPORT_CONFIG_H__ */

View File

@@ -0,0 +1,44 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_HOSTED_WIFI_REMOTE_GLUE_H__
#define __ESP_HOSTED_WIFI_REMOTE_GLUE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "esp_hosted_interface.h"
#include "esp_wifi_remote.h"
#include "esp_wifi.h"
struct esp_remote_channel_config {
esp_hosted_if_type_t if_type;
bool secure;
};
typedef struct esp_remote_channel_config * esp_remote_channel_config_t;
/* Transport/Channel related data structures and macros */
#define ESP_HOSTED_CHANNEL_CONFIG_DEFAULT() { \
.secure = true, \
}
/* Function pointer types for channel callbacks */
typedef esp_err_t (*esp_remote_channel_rx_fn_t)(void *h, void *buffer,
void *buff_to_free, size_t len);
typedef esp_err_t (*esp_remote_channel_tx_fn_t)(void *h, void *buffer, size_t len);
/* Transport/Channel Management API Functions - use managed component typedef */
esp_remote_channel_t esp_hosted_add_channel(esp_remote_channel_config_t config,
esp_remote_channel_tx_fn_t *tx, const esp_remote_channel_rx_fn_t rx);
esp_err_t esp_hosted_remove_channel(esp_remote_channel_t channel);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_HOSTED_WIFI_REMOTE_GLUE_H__ */

View File

@@ -0,0 +1,84 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* prevent recursive inclusion */
#ifndef __ESP_HOSTED_API_PRIV_H__
#define __ESP_HOSTED_API_PRIV_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes */
#include "stdbool.h"
#include "esp_wifi.h"
#include "esp_wifi_remote.h"
#include "esp_hosted_api_types.h"
#include "esp_hosted_ota.h"
#include "esp_hosted_wifi_config.h"
/* Remote WiFi API Functions - Port/Implementation Specific */
esp_err_t esp_wifi_remote_init(const wifi_init_config_t *arg);
esp_err_t esp_wifi_remote_deinit(void);
esp_err_t esp_wifi_remote_set_mode(wifi_mode_t mode);
esp_err_t esp_wifi_remote_get_mode(wifi_mode_t* mode);
esp_err_t esp_wifi_remote_start(void);
esp_err_t esp_wifi_remote_stop(void);
esp_err_t esp_wifi_remote_connect(void);
esp_err_t esp_wifi_remote_disconnect(void);
esp_err_t esp_wifi_remote_set_config(wifi_interface_t interface, wifi_config_t *conf);
esp_err_t esp_wifi_remote_get_config(wifi_interface_t interface, wifi_config_t *conf);
esp_err_t esp_wifi_remote_get_mac(wifi_interface_t mode, uint8_t mac[6]);
esp_err_t esp_wifi_remote_set_mac(wifi_interface_t mode, const uint8_t mac[6]);
esp_err_t esp_wifi_remote_scan_start(const wifi_scan_config_t *config, bool block);
esp_err_t esp_wifi_remote_scan_stop(void);
esp_err_t esp_wifi_remote_scan_get_ap_num(uint16_t *number);
esp_err_t esp_wifi_remote_scan_get_ap_record(wifi_ap_record_t *ap_record);
esp_err_t esp_wifi_remote_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records);
esp_err_t esp_wifi_remote_clear_ap_list(void);
esp_err_t esp_wifi_remote_restore(void);
esp_err_t esp_wifi_remote_clear_fast_connect(void);
esp_err_t esp_wifi_remote_deauth_sta(uint16_t aid);
esp_err_t esp_wifi_remote_sta_get_ap_info(wifi_ap_record_t *ap_info);
esp_err_t esp_wifi_remote_set_ps(wifi_ps_type_t type);
esp_err_t esp_wifi_remote_get_ps(wifi_ps_type_t *type);
esp_err_t esp_wifi_remote_set_storage(wifi_storage_t storage);
esp_err_t esp_wifi_remote_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw);
esp_err_t esp_wifi_remote_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw);
esp_err_t esp_wifi_remote_set_channel(uint8_t primary, wifi_second_chan_t second);
esp_err_t esp_wifi_remote_get_channel(uint8_t *primary, wifi_second_chan_t *second);
esp_err_t esp_wifi_remote_set_country_code(const char *country, bool ieee80211d_enabled);
esp_err_t esp_wifi_remote_get_country_code(char *country);
esp_err_t esp_wifi_remote_set_country(const wifi_country_t *country);
esp_err_t esp_wifi_remote_get_country(wifi_country_t *country);
esp_err_t esp_wifi_remote_ap_get_sta_list(wifi_sta_list_t *sta);
esp_err_t esp_wifi_remote_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid);
esp_err_t esp_wifi_remote_sta_get_rssi(int *rssi);
esp_err_t esp_wifi_remote_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap);
esp_err_t esp_wifi_remote_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap);
esp_err_t esp_wifi_remote_set_max_tx_power(int8_t power);
esp_err_t esp_wifi_remote_get_max_tx_power(int8_t *power);
esp_err_t esp_wifi_remote_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode);
esp_err_t esp_wifi_remote_sta_get_aid(uint16_t *aid);
#if H_WIFI_DUALBAND_SUPPORT
/* Dual-band WiFi API (Depends upon co-processor used) */
esp_err_t esp_wifi_remote_set_band(wifi_band_t band);
esp_err_t esp_wifi_remote_get_band(wifi_band_t *band);
esp_err_t esp_wifi_remote_set_band_mode(wifi_band_mode_t band_mode);
esp_err_t esp_wifi_remote_get_band_mode(wifi_band_mode_t *band_mode);
esp_err_t esp_wifi_remote_set_protocols(wifi_interface_t ifx, wifi_protocols_t *protocols);
esp_err_t esp_wifi_remote_get_protocols(wifi_interface_t ifx, wifi_protocols_t *protocols);
esp_err_t esp_wifi_remote_set_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw);
esp_err_t esp_wifi_remote_get_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw);
#endif
#ifdef __cplusplus
}
#endif
#endif /* __ESP_HOSTED_API_PRIV_H__ */

View File

@@ -0,0 +1,480 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef __cplusplus
extern "C" {
#endif
/** Includes **/
#include "esp_hosted_transport_config.h"
#include "esp_hosted_wifi_config.h"
#include "esp_hosted_api_priv.h"
#include "esp_hosted_wifi_remote_glue.h"
#include "esp_check.h"
#include "transport_drv.h"
#include "rpc_wrap.h"
#include "esp_log.h"
/** Macros **/
static const char *TAG="H_API";
static uint8_t esp_hosted_init_done;
/** Exported variables **/
struct esp_remote_channel {
transport_channel_t *t_chan;
};
//static semaphore_handle_t transport_up_sem;
/** Inline functions **/
/** Exported Functions **/
static void transport_active_cb(void)
{
//g_h.funcs->_h_post_semaphore(transport_up_sem);
}
#if 0
static void create_esp_hosted_transport_up_sem(void)
{
if (!transport_up_sem) {
transport_up_sem = g_h.funcs->_h_create_semaphore(1);
assert(transport_up_sem);
/* clear semaphore */
g_h.funcs->_h_get_semaphore(transport_up_sem, 0);
}
}
esp_err_t esp_hosted_setup(void)
{
create_esp_hosted_transport_up_sem();
g_h.funcs->_h_get_semaphore(transport_up_sem, portMAX_DELAY);
g_h.funcs->_h_post_semaphore(transport_up_sem);
return ESP_OK;
}
#endif
static esp_err_t add_esp_wifi_remote_channels(void)
{
ESP_LOGI(TAG, "** %s **", __func__);
esp_remote_channel_tx_fn_t tx_cb;
esp_remote_channel_t ch;
/* Add an RPC channel with default config (i.e. secure=true) */
struct esp_remote_channel_config config = ESP_HOSTED_CHANNEL_CONFIG_DEFAULT();
config.if_type = ESP_SERIAL_IF;
/*TODO: add rpc channel from here
ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_rpc_channel_rx);
esp_wifi_remote_rpc_channel_set(ch, tx_cb); */
/* Add two other channels for the two WiFi interfaces (STA, softAP) in plain text */
config.secure = false;
config.if_type = ESP_STA_IF;
ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_channel_rx);
esp_wifi_remote_channel_set(WIFI_IF_STA, ch, tx_cb);
config.secure = false;
config.if_type = ESP_AP_IF;
ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_channel_rx);
esp_wifi_remote_channel_set(WIFI_IF_AP, ch, tx_cb);
return ESP_OK;
}
static void set_host_modules_log_level(void)
{
esp_log_level_set("rpc_core", ESP_LOG_WARN);
esp_log_level_set("rpc_rsp", ESP_LOG_WARN);
esp_log_level_set("rpc_evt", ESP_LOG_WARN);
}
int esp_hosted_init(void)
{
if (esp_hosted_init_done)
return ESP_OK;
set_host_modules_log_level();
//create_esp_hosted_transport_up_sem();
ESP_LOGI(TAG, "ESP-Hosted starting. Hosted_Tasks: prio:%u, stack: %u RPC_task_stack: %u",
DFLT_TASK_PRIO, DFLT_TASK_STACK_SIZE, RPC_TASK_STACK_SIZE);
if (esp_hosted_is_config_valid()) {
ESP_LOGW(TAG, "Transport already initialized, skipping initialization");
} else {
ESP_ERROR_CHECK(esp_hosted_set_default_config());
}
ESP_ERROR_CHECK(transport_drv_init(transport_active_cb));
ESP_ERROR_CHECK(add_esp_wifi_remote_channels());
ESP_ERROR_CHECK(rpc_init());
rpc_register_event_callbacks();
esp_hosted_init_done = 1;
return ESP_OK;
}
int esp_hosted_deinit(void)
{
ESP_LOGI(TAG, "ESP-Hosted deinit\n");
rpc_unregister_event_callbacks();
ESP_ERROR_CHECK(rpc_deinit());
ESP_ERROR_CHECK(transport_drv_deinit());
esp_hosted_init_done = 0;
return ESP_OK;
}
static inline esp_err_t esp_hosted_reconfigure(void)
{
if (!esp_hosted_is_config_valid()) {
ESP_LOGE(TAG, "Transport not initialized, call esp_hosted_init() first");
return ESP_FAIL;
}
ESP_ERROR_CHECK(transport_drv_reconfigure());
return ESP_OK;
}
int esp_hosted_connect_to_slave(void)
{
ESP_LOGI(TAG, "ESP-Hosted Try to communicate with ESP-Hosted slave\n");
return esp_hosted_reconfigure();
}
esp_remote_channel_t esp_hosted_add_channel(esp_remote_channel_config_t config,
esp_remote_channel_tx_fn_t *tx, const esp_remote_channel_rx_fn_t rx)
{
transport_channel_t *t_chan = NULL;
esp_remote_channel_t eh_chan = NULL;
eh_chan = g_h.funcs->_h_calloc(sizeof(struct esp_remote_channel), 1);
assert(eh_chan);
t_chan = transport_drv_add_channel(eh_chan, config->if_type, config->secure, tx, rx);
if (t_chan) {
*tx = t_chan->tx;
eh_chan->t_chan = t_chan;
return eh_chan;
} else {
g_h.funcs->_h_free(eh_chan);
}
return NULL;
}
esp_err_t esp_hosted_remove_channel(esp_remote_channel_t eh_chan)
{
if (eh_chan && eh_chan->t_chan) {
transport_drv_remove_channel(eh_chan->t_chan);
g_h.funcs->_h_free(eh_chan);
return ESP_OK;
}
return ESP_FAIL;
}
esp_err_t esp_wifi_remote_init(const wifi_init_config_t *arg)
{
ESP_ERROR_CHECK(esp_hosted_reconfigure());
return rpc_wifi_init(arg);
}
esp_err_t esp_wifi_remote_deinit(void)
{
return rpc_wifi_deinit();
}
esp_err_t esp_wifi_remote_set_mode(wifi_mode_t mode)
{
return rpc_wifi_set_mode(mode);
}
esp_err_t esp_wifi_remote_get_mode(wifi_mode_t* mode)
{
return rpc_wifi_get_mode(mode);
}
esp_err_t esp_wifi_remote_start(void)
{
return rpc_wifi_start();
}
esp_err_t esp_wifi_remote_stop(void)
{
return rpc_wifi_stop();
}
esp_err_t esp_wifi_remote_connect(void)
{
ESP_LOGI(TAG, "%s",__func__);
return rpc_wifi_connect();
}
esp_err_t esp_wifi_remote_disconnect(void)
{
return rpc_wifi_disconnect();
}
esp_err_t esp_wifi_remote_set_config(wifi_interface_t interface, wifi_config_t *conf)
{
return rpc_wifi_set_config(interface, conf);
}
esp_err_t esp_wifi_remote_get_config(wifi_interface_t interface, wifi_config_t *conf)
{
return rpc_wifi_get_config(interface, conf);
}
esp_err_t esp_wifi_remote_get_mac(wifi_interface_t mode, uint8_t mac[6])
{
return rpc_wifi_get_mac(mode, mac);
}
esp_err_t esp_wifi_remote_set_mac(wifi_interface_t mode, const uint8_t mac[6])
{
return rpc_wifi_set_mac(mode, mac);
}
esp_err_t esp_wifi_remote_scan_start(const wifi_scan_config_t *config, bool block)
{
return rpc_wifi_scan_start(config, block);
}
esp_err_t esp_wifi_remote_scan_stop(void)
{
return rpc_wifi_scan_stop();
}
esp_err_t esp_wifi_remote_scan_get_ap_num(uint16_t *number)
{
return rpc_wifi_scan_get_ap_num(number);
}
esp_err_t esp_wifi_remote_scan_get_ap_record(wifi_ap_record_t *ap_record)
{
return rpc_wifi_scan_get_ap_record(ap_record);
}
esp_err_t esp_wifi_remote_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records)
{
return rpc_wifi_scan_get_ap_records(number, ap_records);
}
esp_err_t esp_wifi_remote_clear_ap_list(void)
{
return rpc_wifi_clear_ap_list();
}
esp_err_t esp_wifi_remote_restore(void)
{
return rpc_wifi_restore();
}
esp_err_t esp_wifi_remote_clear_fast_connect(void)
{
return rpc_wifi_clear_fast_connect();
}
esp_err_t esp_wifi_remote_deauth_sta(uint16_t aid)
{
return rpc_wifi_deauth_sta(aid);
}
esp_err_t esp_wifi_remote_sta_get_ap_info(wifi_ap_record_t *ap_info)
{
return rpc_wifi_sta_get_ap_info(ap_info);
}
esp_err_t esp_wifi_remote_set_ps(wifi_ps_type_t type)
{
return rpc_wifi_set_ps(type);
}
esp_err_t esp_wifi_remote_get_ps(wifi_ps_type_t *type)
{
return rpc_wifi_get_ps(type);
}
esp_err_t esp_wifi_remote_set_storage(wifi_storage_t storage)
{
return rpc_wifi_set_storage(storage);
}
esp_err_t esp_wifi_remote_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw)
{
return rpc_wifi_set_bandwidth(ifx, bw);
}
esp_err_t esp_wifi_remote_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw)
{
return rpc_wifi_get_bandwidth(ifx, bw);
}
esp_err_t esp_wifi_remote_set_channel(uint8_t primary, wifi_second_chan_t second)
{
return rpc_wifi_set_channel(primary, second);
}
esp_err_t esp_wifi_remote_get_channel(uint8_t *primary, wifi_second_chan_t *second)
{
return rpc_wifi_get_channel(primary, second);
}
esp_err_t esp_wifi_remote_set_country_code(const char *country, bool ieee80211d_enabled)
{
return rpc_wifi_set_country_code(country, ieee80211d_enabled);
}
esp_err_t esp_wifi_remote_get_country_code(char *country)
{
return rpc_wifi_get_country_code(country);
}
esp_err_t esp_wifi_remote_set_country(const wifi_country_t *country)
{
return rpc_wifi_set_country(country);
}
esp_err_t esp_wifi_remote_get_country(wifi_country_t *country)
{
return rpc_wifi_get_country(country);
}
esp_err_t esp_wifi_remote_ap_get_sta_list(wifi_sta_list_t *sta)
{
return rpc_wifi_ap_get_sta_list(sta);
}
esp_err_t esp_wifi_remote_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid)
{
return rpc_wifi_ap_get_sta_aid(mac, aid);
}
esp_err_t esp_wifi_remote_sta_get_rssi(int *rssi)
{
return rpc_wifi_sta_get_rssi(rssi);
}
esp_err_t esp_wifi_remote_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap)
{
return rpc_wifi_set_protocol(ifx, protocol_bitmap);
}
esp_err_t esp_wifi_remote_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap)
{
return rpc_wifi_get_protocol(ifx, protocol_bitmap);
}
esp_err_t esp_wifi_remote_set_max_tx_power(int8_t power)
{
return rpc_wifi_set_max_tx_power(power);
}
esp_err_t esp_wifi_remote_get_max_tx_power(int8_t *power)
{
return rpc_wifi_get_max_tx_power(power);
}
esp_err_t esp_wifi_remote_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode)
{
return rpc_wifi_sta_get_negotiated_phymode(phymode);
}
esp_err_t esp_wifi_remote_sta_get_aid(uint16_t *aid)
{
return rpc_wifi_sta_get_aid(aid);
}
#if H_WIFI_DUALBAND_SUPPORT
/* Dual-band WiFi API - always available at high level, but returns ESP_ERR_NOT_SUPPORTED when co-processor do not support */
esp_err_t esp_wifi_remote_set_band(wifi_band_t band)
{
return rpc_wifi_set_band(band);
}
esp_err_t esp_wifi_remote_get_band(wifi_band_t *band)
{
return rpc_wifi_get_band(band);
}
esp_err_t esp_wifi_remote_set_band_mode(wifi_band_mode_t band_mode)
{
return rpc_wifi_set_band_mode(band_mode);
}
esp_err_t esp_wifi_remote_get_band_mode(wifi_band_mode_t *band_mode)
{
return rpc_wifi_get_band_mode(band_mode);
}
esp_err_t esp_wifi_remote_set_protocols(wifi_interface_t ifx, wifi_protocols_t *protocols)
{
return rpc_wifi_set_protocols(ifx, protocols);
}
esp_err_t esp_wifi_remote_get_protocols(wifi_interface_t ifx, wifi_protocols_t *protocols)
{
return rpc_wifi_get_protocols(ifx, protocols);
}
esp_err_t esp_wifi_remote_set_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw)
{
return rpc_wifi_set_bandwidths(ifx, bw);
}
esp_err_t esp_wifi_remote_get_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw)
{
return rpc_wifi_get_bandwidths(ifx, bw);
}
#endif
esp_err_t esp_hosted_get_coprocessor_fwversion(esp_hosted_coprocessor_fwver_t *ver_info)
{
return rpc_get_coprocessor_fwversion(ver_info);
}
/* esp_err_t esp_wifi_remote_scan_get_ap_record(wifi_ap_record_t *ap_record)
esp_err_t esp_wifi_remote_set_csi(_Bool en)
esp_err_t esp_wifi_remote_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx)
esp_err_t esp_wifi_remote_set_csi_config(const wifi_csi_config_t *config)
esp_err_t esp_wifi_remote_set_vendor_ie(_Bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie)
esp_err_t esp_wifi_remote_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx)
esp_err_t esp_wifi_remote_sta_get_aid(uint16_t *aid)
esp_err_t esp_wifi_remote_set_ant_gpio(const wifi_ant_gpio_config_t *config)
esp_err_t esp_wifi_remote_get_ant_gpio(wifi_ant_gpio_config_t *config)
esp_err_t esp_wifi_remote_set_ant(const wifi_ant_config_t *config)
esp_err_t esp_wifi_remote_get_ant(wifi_ant_config_t *config)
int64_t esp_wifi_remote_get_tsf_time(wifi_interface_t interface)
esp_err_t esp_wifi_remote_set_inactive_time(wifi_interface_t ifx, uint16_t sec)
esp_err_t esp_wifi_remote_get_inactive_time(wifi_interface_t ifx, uint16_t *sec)
esp_err_t esp_wifi_remote_statis_dump(uint32_t modules)
esp_err_t esp_wifi_remote_set_rssi_threshold(int32_t rssi)
esp_err_t esp_wifi_remote_ftm_initiate_session(wifi_ftm_initiator_cfg_t *cfg)
esp_err_t esp_wifi_remote_ftm_end_session(void)
esp_err_t esp_wifi_remote_ftm_resp_set_offset(int16_t offset_cm)
esp_err_t esp_wifi_remote_ftm_get_report(wifi_ftm_report_entry_t *report, uint8_t num_entries)
esp_err_t esp_wifi_remote_config_11b_rate(wifi_interface_t ifx, _Bool disable)
esp_err_t esp_wifi_remote_connectionless_module_set_wake_interval(uint16_t wake_interval)
esp_err_t esp_wifi_remote_force_wakeup_acquire(void)
esp_err_t esp_wifi_remote_force_wakeup_release(void)
esp_err_t esp_wifi_remote_disable_pmf_config(wifi_interface_t ifx)
esp_err_t esp_wifi_remote_set_event_mask(uint32_t mask)
esp_err_t esp_wifi_remote_get_event_mask(uint32_t *mask)
esp_err_t esp_wifi_remote_80211_tx(wifi_interface_t ifx, const void *buffer, int len, _Bool en_sys_seq)
esp_err_t esp_wifi_remote_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb)
esp_err_t esp_wifi_remote_set_promiscuous(_Bool en)
esp_err_t esp_wifi_remote_get_promiscuous(_Bool *en)
esp_err_t esp_wifi_remote_set_promiscuous_filter(const wifi_promiscuous_filter_t *filter)
esp_err_t esp_wifi_remote_get_promiscuous_filter(wifi_promiscuous_filter_t *filter)
esp_err_t esp_wifi_remote_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *filter)
esp_err_t esp_wifi_remote_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter)
esp_err_t esp_wifi_remote_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate)
esp_err_t esp_wifi_remote_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode)
esp_err_t esp_wifi_remote_set_dynamic_cs(_Bool enabled) */
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,277 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/**
* Weak version of esp_wifi API.
*
* Used when WiFi-Remote does not provide required esp_wifi calls
*/
#include "esp_hosted_api_priv.h"
#include "esp_hosted_wifi_config.h"
#define WEAK __attribute__((weak))
WEAK esp_err_t esp_wifi_init(const wifi_init_config_t *config)
{
return esp_wifi_remote_init(config);
}
WEAK esp_err_t esp_wifi_deinit(void)
{
return esp_wifi_remote_deinit();
}
WEAK esp_err_t esp_wifi_set_mode(wifi_mode_t mode)
{
return esp_wifi_remote_set_mode(mode);
}
WEAK esp_err_t esp_wifi_get_mode(wifi_mode_t *mode)
{
return esp_wifi_remote_get_mode(mode);
}
WEAK esp_err_t esp_wifi_start(void)
{
return esp_wifi_remote_start();
}
WEAK esp_err_t esp_wifi_stop(void)
{
return esp_wifi_remote_stop();
}
WEAK esp_err_t esp_wifi_restore(void)
{
return esp_wifi_remote_restore();
}
WEAK esp_err_t esp_wifi_connect(void)
{
return esp_wifi_remote_connect();
}
WEAK esp_err_t esp_wifi_disconnect(void)
{
return esp_wifi_remote_disconnect();
}
WEAK esp_err_t esp_wifi_clear_fast_connect(void)
{
return esp_wifi_remote_clear_fast_connect();
}
WEAK esp_err_t esp_wifi_deauth_sta(uint16_t aid)
{
return esp_wifi_remote_deauth_sta(aid);
}
WEAK esp_err_t esp_wifi_scan_start(const wifi_scan_config_t *config, bool block)
{
return esp_wifi_remote_scan_start(config, block);
}
WEAK esp_err_t esp_wifi_scan_stop(void)
{
return esp_wifi_remote_scan_stop();
}
WEAK esp_err_t esp_wifi_scan_get_ap_num(uint16_t *number)
{
return esp_wifi_remote_scan_get_ap_num(number);
}
WEAK esp_err_t esp_wifi_scan_get_ap_record(wifi_ap_record_t *ap_record)
{
return esp_wifi_remote_scan_get_ap_record(ap_record);
}
WEAK esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records)
{
return esp_wifi_remote_scan_get_ap_records(number, ap_records);
}
WEAK esp_err_t esp_wifi_clear_ap_list(void)
{
return esp_wifi_remote_clear_ap_list();
}
WEAK esp_err_t esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info)
{
return esp_wifi_remote_sta_get_ap_info(ap_info);
}
WEAK esp_err_t esp_wifi_set_ps(wifi_ps_type_t type)
{
return esp_wifi_remote_set_ps(type);
}
WEAK esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type)
{
return esp_wifi_remote_get_ps(type);
}
WEAK esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap)
{
return esp_wifi_remote_set_protocol(ifx, protocol_bitmap);
}
WEAK esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap)
{
return esp_wifi_remote_get_protocol(ifx, protocol_bitmap);
}
WEAK esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw)
{
return esp_wifi_remote_set_bandwidth(ifx, bw);
}
WEAK esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw)
{
return esp_wifi_remote_get_bandwidth(ifx, bw);
}
WEAK esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second)
{
return esp_wifi_remote_set_channel(primary, second);
}
WEAK esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second)
{
return esp_wifi_remote_get_channel(primary, second);
}
WEAK esp_err_t esp_wifi_set_country(const wifi_country_t *country)
{
return esp_wifi_remote_set_country(country);
}
WEAK esp_err_t esp_wifi_get_country(wifi_country_t *country)
{
return esp_wifi_remote_get_country(country);
}
WEAK esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6])
{
return esp_wifi_remote_set_mac(ifx, mac);
}
WEAK esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6])
{
return esp_wifi_remote_get_mac(ifx, mac);
}
WEAK esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf)
{
return esp_wifi_remote_set_config(interface, conf);
}
WEAK esp_err_t esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf)
{
return esp_wifi_remote_get_config(interface, conf);
}
WEAK esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta)
{
return esp_wifi_remote_ap_get_sta_list(sta);
}
WEAK esp_err_t esp_wifi_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid)
{
return esp_wifi_remote_ap_get_sta_aid(mac, aid);
}
WEAK esp_err_t esp_wifi_set_storage(wifi_storage_t storage)
{
return esp_wifi_remote_set_storage(storage);
}
WEAK esp_err_t esp_wifi_set_max_tx_power(int8_t power)
{
return esp_wifi_remote_set_max_tx_power(power);
}
WEAK esp_err_t esp_wifi_get_max_tx_power(int8_t *power)
{
return esp_wifi_remote_get_max_tx_power(power);
}
WEAK esp_err_t esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled)
{
return esp_wifi_remote_set_country_code(country, ieee80211d_enabled);
}
WEAK esp_err_t esp_wifi_get_country_code(char *country)
{
return esp_wifi_remote_get_country_code(country);
}
WEAK esp_err_t esp_wifi_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode)
{
return esp_wifi_remote_sta_get_negotiated_phymode(phymode);
}
WEAK esp_err_t esp_wifi_sta_get_aid(uint16_t *aid)
{
return esp_wifi_remote_sta_get_aid(aid);
}
WEAK esp_err_t esp_wifi_sta_get_rssi(int *rssi)
{
return esp_wifi_remote_sta_get_rssi(rssi);
}
#if H_WIFI_DUALBAND_SUPPORT
WEAK esp_err_t esp_wifi_set_band(wifi_band_t band)
{
return esp_wifi_remote_set_band(band);
}
WEAK esp_err_t esp_wifi_get_band(wifi_band_t *band)
{
return esp_wifi_remote_get_band(band);
}
WEAK esp_err_t esp_wifi_set_band_mode(wifi_band_mode_t band_mode)
{
return esp_wifi_remote_set_band_mode(band_mode);
}
WEAK esp_err_t esp_wifi_get_band_mode(wifi_band_mode_t *band_mode)
{
return esp_wifi_remote_get_band_mode(band_mode);
}
WEAK esp_err_t esp_wifi_set_protocols(wifi_interface_t ifx, wifi_protocols_t *protocols)
{
return esp_wifi_remote_set_protocols(ifx, protocols);
}
WEAK esp_err_t esp_wifi_get_protocols(wifi_interface_t ifx, wifi_protocols_t *protocols)
{
return esp_wifi_remote_get_protocols(ifx, protocols);
}
WEAK esp_err_t esp_wifi_set_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw)
{
return esp_wifi_remote_set_bandwidths(ifx, bw);
}
WEAK esp_err_t esp_wifi_get_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw)
{
return esp_wifi_remote_get_bandwidths(ifx, bw);
}
#endif