mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-13 03:13:41 +00:00
espradio: implement support for wifi/BLE on the ESP32-C3
This is a work in progress. It does not yet work.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef __ESP_ASSERT_H__
|
||||
#define __ESP_ASSERT_H__
|
||||
|
||||
#include "assert.h"
|
||||
|
||||
/* Since IDF v5.0, C17 standard is used, which supports both _Static_assert and static_assert syntax */
|
||||
#define ESP_STATIC_ASSERT static_assert
|
||||
|
||||
/* Assert at compile time if possible, runtime otherwise */
|
||||
#ifndef __cplusplus
|
||||
/* __builtin_choose_expr() is only in C, makes this a lot cleaner */
|
||||
#define TRY_STATIC_ASSERT(CONDITION, MSG) do { \
|
||||
ESP_STATIC_ASSERT(__builtin_choose_expr(__builtin_constant_p(CONDITION), (CONDITION), 1), #MSG); \
|
||||
assert(#MSG && (CONDITION)); \
|
||||
} while(0)
|
||||
#else
|
||||
/* for C++, use __attribute__((error)) - works almost as well as ESP_STATIC_ASSERT */
|
||||
#define TRY_STATIC_ASSERT(CONDITION, MSG) do { \
|
||||
if (__builtin_constant_p(CONDITION) && !(CONDITION)) { \
|
||||
extern __attribute__((error(#MSG))) void failed_compile_time_assert(void); \
|
||||
failed_compile_time_assert(); \
|
||||
} \
|
||||
assert(#MSG && (CONDITION)); \
|
||||
} while(0)
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __ESP_ASSERT_H__ */
|
||||
@@ -0,0 +1 @@
|
||||
// empty
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief ETM channel handle
|
||||
*/
|
||||
typedef struct esp_etm_channel_t *esp_etm_channel_handle_t;
|
||||
|
||||
/**
|
||||
* @brief ETM event handle
|
||||
*/
|
||||
typedef struct esp_etm_event_t *esp_etm_event_handle_t;
|
||||
|
||||
/**
|
||||
* @brief ETM task handle
|
||||
*/
|
||||
typedef struct esp_etm_task_t *esp_etm_task_handle_t;
|
||||
|
||||
/**
|
||||
* @brief ETM channel configuration
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
} esp_etm_channel_config_t;
|
||||
|
||||
/**
|
||||
* @brief Allocate an ETM channel
|
||||
*
|
||||
* @note The channel can later be freed by `esp_etm_del_channel`
|
||||
*
|
||||
* @param[in] config ETM channel configuration
|
||||
* @param[out] ret_chan Returned ETM channel handle
|
||||
* @return
|
||||
* - ESP_OK: Allocate ETM channel successfully
|
||||
* - ESP_ERR_INVALID_ARG: Allocate ETM channel failed because of invalid argument
|
||||
* - ESP_ERR_NO_MEM: Allocate ETM channel failed because of out of memory
|
||||
* - ESP_ERR_NOT_FOUND: Allocate ETM channel failed because all channels are used up and no more free one
|
||||
* - ESP_FAIL: Allocate ETM channel failed because of other reasons
|
||||
*/
|
||||
esp_err_t esp_etm_new_channel(const esp_etm_channel_config_t *config, esp_etm_channel_handle_t *ret_chan);
|
||||
|
||||
/**
|
||||
* @brief Delete an ETM channel
|
||||
*
|
||||
* @param[in] chan ETM channel handle that created by `esp_etm_new_channel`
|
||||
* @return
|
||||
* - ESP_OK: Delete ETM channel successfully
|
||||
* - ESP_ERR_INVALID_ARG: Delete ETM channel failed because of invalid argument
|
||||
* - ESP_FAIL: Delete ETM channel failed because of other reasons
|
||||
*/
|
||||
esp_err_t esp_etm_del_channel(esp_etm_channel_handle_t chan);
|
||||
|
||||
/**
|
||||
* @brief Enable ETM channel
|
||||
*
|
||||
* @note This function will transit the channel state from init to enable.
|
||||
*
|
||||
* @param[in] chan ETM channel handle that created by `esp_etm_new_channel`
|
||||
* @return
|
||||
* - ESP_OK: Enable ETM channel successfully
|
||||
* - ESP_ERR_INVALID_ARG: Enable ETM channel failed because of invalid argument
|
||||
* - ESP_ERR_INVALID_STATE: Enable ETM channel failed because the channel has been enabled already
|
||||
* - ESP_FAIL: Enable ETM channel failed because of other reasons
|
||||
*/
|
||||
esp_err_t esp_etm_channel_enable(esp_etm_channel_handle_t chan);
|
||||
|
||||
/**
|
||||
* @brief Disable ETM channel
|
||||
*
|
||||
* @note This function will transit the channel state from enable to init.
|
||||
*
|
||||
* @param[in] chan ETM channel handle that created by `esp_etm_new_channel`
|
||||
* @return
|
||||
* - ESP_OK: Disable ETM channel successfully
|
||||
* - ESP_ERR_INVALID_ARG: Disable ETM channel failed because of invalid argument
|
||||
* - ESP_ERR_INVALID_STATE: Disable ETM channel failed because the channel is not enabled yet
|
||||
* - ESP_FAIL: Disable ETM channel failed because of other reasons
|
||||
*/
|
||||
esp_err_t esp_etm_channel_disable(esp_etm_channel_handle_t chan);
|
||||
|
||||
/**
|
||||
* @brief Connect an ETM event to an ETM task via a previously allocated ETM channel
|
||||
*
|
||||
* @note Setting the ETM event/task handle to NULL means to disconnect the channel from any event/task
|
||||
*
|
||||
* @param[in] chan ETM channel handle that created by `esp_etm_new_channel`
|
||||
* @param[in] event ETM event handle obtained from a driver/peripheral, e.g. `xxx_new_etm_event`
|
||||
* @param[in] task ETM task handle obtained from a driver/peripheral, e.g. `xxx_new_etm_task`
|
||||
* @return
|
||||
* - ESP_OK: Connect ETM event and task to the channel successfully
|
||||
* - ESP_ERR_INVALID_ARG: Connect ETM event and task to the channel failed because of invalid argument
|
||||
* - ESP_FAIL: Connect ETM event and task to the channel failed because of other reasons
|
||||
*/
|
||||
esp_err_t esp_etm_channel_connect(esp_etm_channel_handle_t chan, esp_etm_event_handle_t event, esp_etm_task_handle_t task);
|
||||
|
||||
/**
|
||||
* @brief Delete ETM event
|
||||
*
|
||||
* @note Although the ETM event comes from various peripherals, we provide the same user API to delete the event handle seamlessly.
|
||||
*
|
||||
* @param[in] event ETM event handle obtained from a driver/peripheral, e.g. `xxx_new_etm_event`
|
||||
* @return
|
||||
* - ESP_OK: Delete ETM event successfully
|
||||
* - ESP_ERR_INVALID_ARG: Delete ETM event failed because of invalid argument
|
||||
* - ESP_FAIL: Delete ETM event failed because of other reasons
|
||||
*/
|
||||
esp_err_t esp_etm_del_event(esp_etm_event_handle_t event);
|
||||
|
||||
/**
|
||||
* @brief Delete ETM task
|
||||
*
|
||||
* @note Although the ETM task comes from various peripherals, we provide the same user API to delete the task handle seamlessly.
|
||||
*
|
||||
* @param[in] task ETM task handle obtained from a driver/peripheral, e.g. `xxx_new_etm_task`
|
||||
* @return
|
||||
* - ESP_OK: Delete ETM task successfully
|
||||
* - ESP_ERR_INVALID_ARG: Delete ETM task failed because of invalid argument
|
||||
* - ESP_FAIL: Delete ETM task failed because of other reasons
|
||||
*/
|
||||
esp_err_t esp_etm_del_task(esp_etm_task_handle_t task);
|
||||
|
||||
/**
|
||||
* @brief Dump ETM channel usages to the given IO stream
|
||||
*
|
||||
* @param[in] out_stream IO stream (e.g. stdout)
|
||||
* @return
|
||||
* - ESP_OK: Dump ETM channel usages successfully
|
||||
* - ESP_ERR_INVALID_ARG: Dump ETM channel usages failed because of invalid argument
|
||||
* - ESP_FAIL: Dump ETM channel usages failed because of other reasons
|
||||
*/
|
||||
esp_err_t esp_etm_dump(FILE *out_stream);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
// empty
|
||||
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __ESP_NOW_H__
|
||||
#define __ESP_NOW_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup WiFi_APIs WiFi Related APIs
|
||||
* @brief WiFi APIs
|
||||
*/
|
||||
|
||||
/** @addtogroup WiFi_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \defgroup ESPNOW_APIs ESPNOW APIs
|
||||
* @brief ESP32 ESPNOW APIs
|
||||
*
|
||||
*/
|
||||
|
||||
/** @addtogroup ESPNOW_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define ESP_ERR_ESPNOW_BASE (ESP_ERR_WIFI_BASE + 100) /*!< ESPNOW error number base. */
|
||||
#define ESP_ERR_ESPNOW_NOT_INIT (ESP_ERR_ESPNOW_BASE + 1) /*!< ESPNOW is not initialized. */
|
||||
#define ESP_ERR_ESPNOW_ARG (ESP_ERR_ESPNOW_BASE + 2) /*!< Invalid argument */
|
||||
#define ESP_ERR_ESPNOW_NO_MEM (ESP_ERR_ESPNOW_BASE + 3) /*!< Out of memory */
|
||||
#define ESP_ERR_ESPNOW_FULL (ESP_ERR_ESPNOW_BASE + 4) /*!< ESPNOW peer list is full */
|
||||
#define ESP_ERR_ESPNOW_NOT_FOUND (ESP_ERR_ESPNOW_BASE + 5) /*!< ESPNOW peer is not found */
|
||||
#define ESP_ERR_ESPNOW_INTERNAL (ESP_ERR_ESPNOW_BASE + 6) /*!< Internal error */
|
||||
#define ESP_ERR_ESPNOW_EXIST (ESP_ERR_ESPNOW_BASE + 7) /*!< ESPNOW peer has existed */
|
||||
#define ESP_ERR_ESPNOW_IF (ESP_ERR_ESPNOW_BASE + 8) /*!< Interface error */
|
||||
|
||||
#define ESP_NOW_ETH_ALEN 6 /*!< Length of ESPNOW peer MAC address */
|
||||
#define ESP_NOW_KEY_LEN 16 /*!< Length of ESPNOW peer local master key */
|
||||
|
||||
#define ESP_NOW_MAX_TOTAL_PEER_NUM 20 /*!< Maximum number of ESPNOW total peers */
|
||||
#define ESP_NOW_MAX_ENCRYPT_PEER_NUM 6 /*!< Maximum number of ESPNOW encrypted peers */
|
||||
|
||||
#define ESP_NOW_MAX_DATA_LEN 250 /*!< Maximum length of ESPNOW data which is sent very time */
|
||||
|
||||
/**
|
||||
* @brief Status of sending ESPNOW data .
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_NOW_SEND_SUCCESS = 0, /**< Send ESPNOW data successfully */
|
||||
ESP_NOW_SEND_FAIL, /**< Send ESPNOW data fail */
|
||||
} esp_now_send_status_t;
|
||||
|
||||
/**
|
||||
* @brief ESPNOW peer information parameters.
|
||||
*/
|
||||
typedef struct esp_now_peer_info {
|
||||
uint8_t peer_addr[ESP_NOW_ETH_ALEN]; /**< ESPNOW peer MAC address that is also the MAC address of station or softap */
|
||||
uint8_t lmk[ESP_NOW_KEY_LEN]; /**< ESPNOW peer local master key that is used to encrypt data */
|
||||
uint8_t channel; /**< Wi-Fi channel that peer uses to send/receive ESPNOW data. If the value is 0,
|
||||
use the current channel which station or softap is on. Otherwise, it must be
|
||||
set as the channel that station or softap is on. */
|
||||
wifi_interface_t ifidx; /**< Wi-Fi interface that peer uses to send/receive ESPNOW data */
|
||||
bool encrypt; /**< ESPNOW data that this peer sends/receives is encrypted or not */
|
||||
void *priv; /**< ESPNOW peer private data */
|
||||
} esp_now_peer_info_t;
|
||||
|
||||
/**
|
||||
* @brief Number of ESPNOW peers which exist currently.
|
||||
*/
|
||||
typedef struct esp_now_peer_num {
|
||||
int total_num; /**< Total number of ESPNOW peers, maximum value is ESP_NOW_MAX_TOTAL_PEER_NUM */
|
||||
int encrypt_num; /**< Number of encrypted ESPNOW peers, maximum value is ESP_NOW_MAX_ENCRYPT_PEER_NUM */
|
||||
} esp_now_peer_num_t;
|
||||
|
||||
/**
|
||||
* @brief ESPNOW packet information
|
||||
*/
|
||||
typedef struct esp_now_recv_info {
|
||||
uint8_t * src_addr; /**< Source address of ESPNOW packet */
|
||||
uint8_t * des_addr; /**< Destination address of ESPNOW packet */
|
||||
wifi_pkt_rx_ctrl_t * rx_ctrl; /**< Rx control info of ESPNOW packet */
|
||||
} esp_now_recv_info_t;
|
||||
|
||||
/**
|
||||
* @brief ESPNOW rate config
|
||||
*
|
||||
*/
|
||||
typedef struct esp_now_rate_config {
|
||||
wifi_phy_mode_t phymode; /**< ESPNOW phymode of specified interface */
|
||||
wifi_phy_rate_t rate; /**< ESPNOW rate of specified interface*/
|
||||
bool ersu; /**< ESPNOW using ersu send frame*/
|
||||
bool dcm; /**< ESPNOW using dcm rate to send frame*/
|
||||
} esp_now_rate_config_t;
|
||||
|
||||
/**
|
||||
* @brief Callback function of receiving ESPNOW data
|
||||
* @param esp_now_info received ESPNOW packet information
|
||||
* @param data received data
|
||||
* @param data_len length of received data
|
||||
* @attention esp_now_info is a local variable,it can only be used in the callback.
|
||||
*/
|
||||
typedef void (*esp_now_recv_cb_t)(const esp_now_recv_info_t * esp_now_info, const uint8_t *data, int data_len);
|
||||
|
||||
/**
|
||||
* @brief Callback function of sending ESPNOW data
|
||||
* @param mac_addr peer MAC address
|
||||
* @param status status of sending ESPNOW data (succeed or fail)
|
||||
*/
|
||||
typedef void (*esp_now_send_cb_t)(const uint8_t *mac_addr, esp_now_send_status_t status);
|
||||
|
||||
/**
|
||||
* @brief Initialize ESPNOW function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : Internal error
|
||||
*/
|
||||
esp_err_t esp_now_init(void);
|
||||
|
||||
/**
|
||||
* @brief De-initialize ESPNOW function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
*/
|
||||
esp_err_t esp_now_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Get the version of ESPNOW
|
||||
*
|
||||
* @param version ESPNOW version
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_now_get_version(uint32_t *version);
|
||||
|
||||
/**
|
||||
* @brief Register callback function of receiving ESPNOW data
|
||||
*
|
||||
* @param cb callback function of receiving ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : internal error
|
||||
*/
|
||||
esp_err_t esp_now_register_recv_cb(esp_now_recv_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Unregister callback function of receiving ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
*/
|
||||
esp_err_t esp_now_unregister_recv_cb(void);
|
||||
|
||||
/**
|
||||
* @brief Register callback function of sending ESPNOW data
|
||||
*
|
||||
* @param cb callback function of sending ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : internal error
|
||||
*/
|
||||
esp_err_t esp_now_register_send_cb(esp_now_send_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Unregister callback function of sending ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
*/
|
||||
esp_err_t esp_now_unregister_send_cb(void);
|
||||
|
||||
/**
|
||||
* @brief Send ESPNOW data
|
||||
*
|
||||
* @attention 1. If peer_addr is not NULL, send data to the peer whose MAC address matches peer_addr
|
||||
* @attention 2. If peer_addr is NULL, send data to all of the peers that are added to the peer list
|
||||
* @attention 3. The maximum length of data must be less than ESP_NOW_MAX_DATA_LEN
|
||||
* @attention 4. The buffer pointed to by data argument does not need to be valid after esp_now_send returns
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
* @param data data to send
|
||||
* @param len length of data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : internal error
|
||||
* - ESP_ERR_ESPNOW_NO_MEM : out of memory, when this happens, you can delay a while before sending the next data
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
* - ESP_ERR_ESPNOW_IF : current WiFi interface doesn't match that of peer
|
||||
*/
|
||||
esp_err_t esp_now_send(const uint8_t *peer_addr, const uint8_t *data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Add a peer to peer list
|
||||
*
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_FULL : peer list is full
|
||||
* - ESP_ERR_ESPNOW_NO_MEM : out of memory
|
||||
* - ESP_ERR_ESPNOW_EXIST : peer has existed
|
||||
*/
|
||||
esp_err_t esp_now_add_peer(const esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Delete a peer from peer list
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
*/
|
||||
esp_err_t esp_now_del_peer(const uint8_t *peer_addr);
|
||||
|
||||
/**
|
||||
* @brief Modify a peer
|
||||
*
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_FULL : peer list is full
|
||||
*/
|
||||
esp_err_t esp_now_mod_peer(const esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Config ESPNOW rate of specified interface
|
||||
*
|
||||
* @deprecated please use esp_now_set_peer_rate_config() instead.
|
||||
*
|
||||
* @attention 1. This API should be called after esp_wifi_start().
|
||||
* @attention 2. This API only work when not use Wi-Fi 6 and esp_now_set_peer_rate_config() not called.
|
||||
*
|
||||
* @param ifx Interface to be configured.
|
||||
* @param rate Phy rate to be configured.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - others: failed
|
||||
*/
|
||||
esp_err_t esp_wifi_config_espnow_rate(wifi_interface_t ifx, wifi_phy_rate_t rate)
|
||||
__attribute__((deprecated("This API can be only used when rate is non-HE rate, \
|
||||
please use esp_now_set_peer_rate_config if you want full support of the rate.")));
|
||||
|
||||
/**
|
||||
* @brief Set ESPNOW rate config for each peer
|
||||
*
|
||||
* @attention 1. This API should be called after esp_wifi_start() and esp_now_init().
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
* @param config rate config to be configured.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : internal error
|
||||
*/
|
||||
esp_err_t esp_now_set_peer_rate_config(const uint8_t *peer_addr, esp_now_rate_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Get a peer whose MAC address matches peer_addr from peer list
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
*/
|
||||
esp_err_t esp_now_get_peer(const uint8_t *peer_addr, esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Fetch a peer from peer list. Only return the peer which address is unicast, for the multicast/broadcast address, the function will ignore and try to find the next in the peer list.
|
||||
*
|
||||
* @param from_head fetch from head of list or not
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
*/
|
||||
esp_err_t esp_now_fetch_peer(bool from_head, esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Peer exists or not
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
*
|
||||
* @return
|
||||
* - true : peer exists
|
||||
* - false : peer not exists
|
||||
*/
|
||||
bool esp_now_is_peer_exist(const uint8_t *peer_addr);
|
||||
|
||||
/**
|
||||
* @brief Get the number of peers
|
||||
*
|
||||
* @param num number of peers
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_now_get_peer_num(esp_now_peer_num_t *num);
|
||||
|
||||
/**
|
||||
* @brief Set the primary master key
|
||||
*
|
||||
* @param pmk primary master key
|
||||
*
|
||||
* @attention 1. primary master key is used to encrypt local master key
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_now_set_pmk(const uint8_t *pmk);
|
||||
|
||||
/**
|
||||
* @brief Set wake window for esp_now to wake up in interval unit
|
||||
*
|
||||
* @param window Milliseconds would the chip keep waked each interval, from 0 to 65535.
|
||||
*
|
||||
* @attention 1. This configuration could work at connected status.
|
||||
* When ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is enabled, this configuration could work at disconnected status.
|
||||
* @attention 2. Default value is the maximum.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
*/
|
||||
esp_err_t esp_now_set_wake_window(uint16_t window);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_NOW_H__ */
|
||||
@@ -0,0 +1 @@
|
||||
// empty
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_he_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set up an individual TWT agreement (NegotiationType=0) or change TWT parameters of the existing TWT agreement
|
||||
* - TWT Wake Interval = TWT Wake Interval Mantissa * (2 ^ TWT Wake Interval Exponent), unit: us
|
||||
* - e.g. TWT Wake Interval Mantissa = 512, TWT Wake Interval Exponent = 12, then TWT Wake Interval is 2097.152 ms
|
||||
* Nominal Minimum Wake Duration = 255, then TWT Wake Duration is 65.28 ms
|
||||
*
|
||||
* @attention Support at most 4 TWT agreements, otherwise ESP_ERR_WIFI_TWT_FULL will be returned.
|
||||
* Support sleep time up to (1 << 35) us.
|
||||
*
|
||||
* @param[in] setup_cmd Indicates the type of TWT command
|
||||
* @param[in] trigger true: a trigger-enabled TWT, false: a non-trigger-enabled TWT
|
||||
* @param[in] flow_type 0: an announced TWT, 1: an unannounced TWT
|
||||
* @param[in] min_wake_dura Nominal Minimum Wake Duration, indicates the minimum amount of time, in unit of 256 us, that the TWT requesting STA expects that it needs to be awake. The value range is [1, 255].
|
||||
* @param[in] wake_invl_expn TWT Wake Interval Exponent. The value range is [0, 31].
|
||||
* @param[in] wake_invl_mant TWT Wake Interval Mantissa. The value range is [1, 65535].
|
||||
* @param[in/out] flow_id When set up an individual TWT agreement, the flow id will be assigned by AP after a successful agreement setup.
|
||||
* flow_id is allowed to be NULL. flow_id could be specified to a value in the range of [0, 7], but it might be changed by AP in the response.
|
||||
* When change TWT parameters of the existing TWT agreement, flow_id should be an existing one. The value range is [0, 7].
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
|
||||
* - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
|
||||
* - ESP_ERR_WIFI_TWT_FULL: no available flow id
|
||||
* - ESP_ERR_INVALID_ARG: invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_itwt_setup(wifi_twt_setup_cmds_t setup_cmd, bool trigger, int flow_type, int min_wake_dura, int wake_invl_expn, int wake_invl_mant, int *flow_id);
|
||||
|
||||
/**
|
||||
* @brief Tear down individual TWT agreements
|
||||
*
|
||||
* @param[in] flow_id The value range is [0, 8]. 8 indicates tear down all individual TWT agreements.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
|
||||
* - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
|
||||
* - ESP_ERR_INVALID_ARG: invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_itwt_teardown(int flow_id);
|
||||
|
||||
/**
|
||||
* @brief Send a TWT Information frame to AP for suspending/resuming established iTWT agreements.
|
||||
*
|
||||
* @param[in] flow_id The value range is [0, 8]. 8 indicates suspend all individual TWT agreements
|
||||
* @param[in] suspend_time_ms If the value is 0, indicates the specified flow_id or all established agreements will be suspended until resume by users.
|
||||
* If the value is greater than 0, indicates the specified flow_id or all established agreements will be suspended until suspend_time_ms timeout, unit: ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
|
||||
* - ESP_ERR_WIFI_NOT_ASSOC: WiFi is not associated
|
||||
* - ESP_ERR_INVALID_ARG: invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_itwt_suspend(int flow_id, int suspend_time_ms);
|
||||
|
||||
/**
|
||||
* @brief Get flow id status
|
||||
*
|
||||
* @param[in] flow_id_bitmap Flow id status bitmap with 8 bit. Each bit represents that whether the corresponding flow id is setup.
|
||||
* 1: setup, 0: not setup.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
|
||||
* - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
|
||||
* - ESP_ERR_INVALID_ARG: invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_itwt_get_flow_id_status(int *flow_id_bitmap);
|
||||
|
||||
/**
|
||||
* @brief Send probe to update TSF time
|
||||
*
|
||||
* @attention In bad network, timeout_ms is variable with the network
|
||||
*
|
||||
* @param[in] timeout_ms The estimated time includes sending probe request and receiving probe response, unit: ms.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
|
||||
* - ESP_ERR_WIFI_NOT_ASSOC: WiFi is not associated
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_itwt_send_probe_req(int timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Set time offset with TBTT of target wake time field in itwt setup request frame.
|
||||
*
|
||||
* @param[in] offset_us Offset with TBTT of target wake time field in itwt setup request frame, range is [0, 102400], unit microseconds.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
|
||||
* - ESP_ERR_WIFI_NOT_ASSOC: WiFi is not associated
|
||||
* - ESP_ERR_INVALID_ARG: invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_itwt_set_target_wake_time_offset(int offset_us);
|
||||
|
||||
/**
|
||||
* @brief Enable the reception statistics.
|
||||
*
|
||||
* @param[in] rx_stats indicate whether enable the reception statistics for HT, HE SU, HE ER SU and legacy
|
||||
* @param[in] rx_mu_stats indicate whether enable the reception statistics for DL MU-MIMO and DL OFDMA
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_NO_MEM: out of memory
|
||||
*/
|
||||
esp_err_t esp_wifi_enable_rx_statistics(bool rx_stats, bool rx_mu_stats);
|
||||
|
||||
/**
|
||||
* @brief Enable the transmission statistics.
|
||||
*
|
||||
* @param[in] aci access category of the transmission
|
||||
* @param[in] tx_stats indicate whether enable the transmission statistics
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_NO_MEM: out of memory
|
||||
*/
|
||||
esp_err_t esp_wifi_enable_tx_statistics(esp_wifi_aci_t aci, bool tx_stats);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Access category
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_WIFI_ACI_VO, /**< voice traffic */
|
||||
ESP_WIFI_ACI_VI, /**< video traffic */
|
||||
ESP_WIFI_ACI_BE, /**< best effort traffic */
|
||||
ESP_WIFI_ACI_BK, /**< background traffic */
|
||||
ESP_WIFI_ACI_MAX, /**< the max value */
|
||||
} esp_wifi_aci_t;
|
||||
|
||||
/**
|
||||
* @brief Channel state information(CSI) HE STBC CSI selection
|
||||
*/
|
||||
enum {
|
||||
ESP_CSI_ACQUIRE_STBC_HELTF1, /**< HE STBC: select the first HE-LTF */
|
||||
ESP_CSI_ACQUIRE_STBC_HELTF2, /**< HE STBC: select the second HE-LTF */
|
||||
ESP_CSI_ACQUIRE_STBC_SAMPLE_HELTFS, /**< HE STBC: sample alternating scarier of HE-LTF1 and HE-LTF2 */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Channel state information(CSI) configuration type
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t enable : 1; /**< enable to acquire CSI */
|
||||
uint32_t acquire_csi_legacy : 1; /**< enable to acquire L-LTF when receiving a 11g PPDU */
|
||||
uint32_t acquire_csi_ht20 : 1; /**< enable to acquire HT-LTF when receiving an HT20 PPDU */
|
||||
uint32_t acquire_csi_ht40 : 1; /**< enable to acquire HT-LTF when receiving an HT40 PPDU */
|
||||
uint32_t acquire_csi_su : 1; /**< enable to acquire HE-LTF when receiving an HE20 SU PPDU */
|
||||
uint32_t acquire_csi_mu : 1; /**< enable to acquire HE-LTF when receiving an HE20 MU PPDU */
|
||||
uint32_t acquire_csi_dcm : 1; /**< enable to acquire HE-LTF when receiving an HE20 DCM applied PPDU */
|
||||
uint32_t acquire_csi_beamformed : 1; /**< enable to acquire HE-LTF when receiving an HE20 Beamformed applied PPDU */
|
||||
uint32_t acquire_csi_he_stbc : 2; /**< when receiving an STBC applied HE PPDU,
|
||||
0- acquire the complete HE-LTF1,
|
||||
1- acquire the complete HE-LTF2
|
||||
2- sample evenly among the HE-LTF1 and HE-LTF2 */
|
||||
uint32_t val_scale_cfg : 2; /**< value 0-3 */
|
||||
uint32_t reserved : 20; /**< reserved */
|
||||
} wifi_csi_acquire_config_t;
|
||||
|
||||
/**
|
||||
* @brief HE variant HT Control field including UPH(UL power headroom) and OM(Operation mode)
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t id : 2; /**< HE Variant ID = 3 */
|
||||
uint32_t uph_id : 4; /**< UPH control ID: 4 */
|
||||
uint32_t ul_pw_headroom : 5; /**< the available UL power headroom for the current HE-MCS, unit: dB, value[0, 31] */
|
||||
uint32_t min_tx_pw_flag : 1; /**< indicate that the min. transmit power for current HE-MCS is reached, set to 0 otherwise */
|
||||
uint32_t rsvd : 2; /**< reserved */
|
||||
uint32_t ctrl_id : 4; /**< OM control ID: 1 */
|
||||
uint32_t rx_nss : 3; /**< the max. number of spatial streams for the reception, only accept 0. */
|
||||
uint32_t bw : 2; /**< the operating channel width for both reception and transmission, only accept 0. */
|
||||
uint32_t ul_mu_disable : 1; /**< disable UL MU operations */
|
||||
uint32_t tx_nsts : 3; /**< the max. number of spatial streams for the transmission, only accept 0. */
|
||||
uint32_t er_su_disable : 1; /**< disable the reception of 242-tone HE ER SU PPDU */
|
||||
uint32_t dl_mu_mimo_resounding_recommendation : 1; /**< indicate the STA suggests the AP either resounding the channel or increase the channel sounding frequency with the STA */
|
||||
uint32_t ul_mu_data_disable : 1; /**< disable UL MU data operations */
|
||||
uint32_t padding : 2; /**< padding bits */
|
||||
} esp_wifi_htc_omc_t;
|
||||
|
||||
/**
|
||||
* @brief TWT setup commands
|
||||
*/
|
||||
typedef enum {
|
||||
TWT_REQUEST, /**< request to join a TWT without providing a set of TWT parameters */
|
||||
TWT_SUGGEST, /**< request to join a TWT and offer a set of preferred TWT parameters but might accept alternative TWT parameters */
|
||||
TWT_DEMAND, /**< request to join a TWT and currently accept only the indicated TWT parameters */
|
||||
TWT_GROUPING, /**< for S1G STA */
|
||||
TWT_ACCEPT, /**< accept the TWT request with the TWT parameters, also used in unsolicited TWT response */
|
||||
TWT_ALTERNATE, /**< indicate a counter-offer of TWT parameters without creation of a TWT agreement */
|
||||
TWT_DICTATE, /**< indicate no TWT agreement is created, but one is likely to be accepted only if the requesting STA transmits a new TWT setup request with the indicated TWT parameters */
|
||||
TWT_REJECT, /**< indicate that the negotiation has ended in failure to crate a new TWT agreement */
|
||||
} wifi_twt_setup_cmds_t;
|
||||
|
||||
/**
|
||||
* @brief HE SU GI and LTF types
|
||||
*/
|
||||
typedef enum {
|
||||
HE_SU_ERSU_1_LTF_0_8_US_GI, /**< 1 LTF and 0.8 us GI */
|
||||
HE_SU_ERSU_2_LTF_0_8_US_GI, /**< 2 LTF and 0.8 us GI */
|
||||
HE_SU_ERSU_2_LTF_1_6_US_GI, /**< 2 LTF and 1.6 us GI */
|
||||
HE_SU_ERSU_4_LTF_3_2_US_GI, /**< 4 LTF and 3.2 us GI */
|
||||
} he_su_gi_and_ltf_type_t;
|
||||
|
||||
/**
|
||||
* @brief Reception format
|
||||
*/
|
||||
typedef enum {
|
||||
RX_BB_FORMAT_11B = 0, /**< the reception frame is a 11b MPDU */
|
||||
RX_BB_FORMAT_11G = 1, /**< the reception frame is a 11g MPDU */
|
||||
RX_BB_FORMAT_HT = 2, /**< the reception frame is a HT MPDU */
|
||||
RX_BB_FORMAT_VHT = 3, /**< the reception frame is a VHT MPDU */
|
||||
RX_BB_FORMAT_HE_SU = 4, /**< the reception frame is a HE SU MPDU */
|
||||
RX_BB_FORMAT_HE_MU = 5, /**< the reception frame is a HE MU MPDU */
|
||||
RX_BB_FORMAT_HE_ERSU = 6, /**< the reception frame is a HE ER SU MPDU */
|
||||
RX_BB_FORMAT_HE_TB = 7, /**< the reception frame is a HE TB MPDU */
|
||||
} wifi_rx_bb_format_t;
|
||||
|
||||
/**
|
||||
* @brief RxControl Info
|
||||
*/
|
||||
typedef struct {
|
||||
signed rssi : 8; /**< the RSSI of the reception frame */
|
||||
unsigned rate : 5; /**< if cur_bb_format is RX_BB_FORMAT_11B, it's the transmission rate. otherwise it's Rate field of L-SIG */
|
||||
unsigned : 1; /**< reserved */
|
||||
unsigned : 2; /**< reserved */
|
||||
unsigned : 12; /**< reserved */
|
||||
unsigned rxmatch0 : 1; /**< indicate whether the reception frame is from interface 0 */
|
||||
unsigned rxmatch1 : 1; /**< indicate whether the reception frame is from interface 1 */
|
||||
unsigned rxmatch2 : 1; /**< indicate whether the reception frame is from interface 2 */
|
||||
unsigned rxmatch3 : 1; /**< indicate whether the reception frame is from interface 3 */
|
||||
uint32_t he_siga1; /**< HE-SIGA1 or HT-SIG */
|
||||
unsigned rxend_state : 8; /**< reception state, 0: successful, others: failure */
|
||||
uint16_t he_siga2; /**< HE-SIGA2 */
|
||||
unsigned : 7; /**< reserved */
|
||||
unsigned is_group : 1; /**< indicate whether the reception is a group addressed frame */
|
||||
unsigned : 32; /**< reserved */
|
||||
unsigned : 15; /**< reserved */
|
||||
unsigned : 15; /**< reserved */
|
||||
unsigned : 2; /**< reserved */
|
||||
unsigned noise_floor : 8; /**< the noise floor of the reception frame */
|
||||
signed data_rssi : 8; /**< the RSSI of the DATA field */
|
||||
unsigned : 8; /**< reserved */
|
||||
unsigned : 8; /**< reserved */
|
||||
unsigned channel : 4; /**< the primary channel */
|
||||
unsigned second : 4; /**< the second channel if in HT40 */
|
||||
unsigned : 24; /**< reserved */
|
||||
unsigned : 32; /**< reserved */
|
||||
unsigned : 2; /**< reserved */
|
||||
unsigned : 4; /**< reserved */
|
||||
unsigned : 2; /**< reserved */
|
||||
unsigned rx_channel_estimate_len : 10; /**< the length of the channel information */
|
||||
unsigned rx_channel_estimate_info_vld : 1; /**< indicate the channel information is valid */
|
||||
unsigned : 1; /**< reserved */
|
||||
unsigned : 11; /**< reserved */
|
||||
unsigned : 1; /**< reserved */
|
||||
unsigned : 24; /**< reserved */
|
||||
unsigned cur_bb_format : 4; /**< the format of the reception frame */
|
||||
unsigned cur_single_mpdu : 1; /**< indicate whether the reception MPDU is a S-MPDU */
|
||||
unsigned : 3; /**< reserved */
|
||||
unsigned : 32; /**< reserved */
|
||||
unsigned : 32; /**< reserved */
|
||||
unsigned : 32; /**< reserved */
|
||||
unsigned : 32; /**< reserved */
|
||||
unsigned : 32; /**< reserved */
|
||||
unsigned : 32; /**< reserved */
|
||||
unsigned : 32; /**< reserved */
|
||||
unsigned : 32; /**< reserved */
|
||||
unsigned : 8; /**< reserved */
|
||||
unsigned he_sigb_len : 6; /**< the length of HE-SIGB */
|
||||
unsigned : 2; /**< reserved */
|
||||
unsigned : 8; /**< reserved */
|
||||
unsigned : 8; /**< reserved */
|
||||
unsigned : 32; /**< reserved */
|
||||
unsigned : 7; /**< reserved */
|
||||
unsigned : 1; /**< reserved */
|
||||
unsigned : 8; /**< reserved */
|
||||
unsigned : 16; /**< reserved */
|
||||
unsigned sig_len : 14; /**< the length of the reception MPDU */
|
||||
unsigned : 2; /**< reserved */
|
||||
unsigned dump_len : 14; /**< the length of the reception MPDU excluding the FCS */
|
||||
unsigned : 2; /**< reserved */
|
||||
unsigned rx_state : 8; /**< reception state, 0: successful, others: failure */
|
||||
unsigned : 24; /**< reserved */
|
||||
} __attribute__((packed)) esp_wifi_rxctrl_t;
|
||||
|
||||
/** Argument structure for WIFI_EVENT_TWT_SET_UP event */
|
||||
typedef struct {
|
||||
wifi_twt_setup_cmds_t setup_cmd; /**< TWT setup command */
|
||||
uint8_t flow_id; /**< flow id */
|
||||
uint8_t min_wake_dura; /**< the min. wake duration, unit: 256 us by default */
|
||||
uint8_t wake_invl_expn; /**< the exponent of the TWT wake interval in microseconds, base 2 */
|
||||
uint16_t wake_invl_mant; /**< the value of the mantissa of the TWT wake interval value in microseconds, base 2 */
|
||||
bool trigger; /**< true: indicates a trigger-enabled TWT, false: indicates a non-trigger-enabled TWT */
|
||||
uint8_t flow_type; /**< 0: indicate an announced TWT, 1: indicates an unannounced TWT */
|
||||
} wifi_event_sta_itwt_setup_t;
|
||||
|
||||
/** Argument structure for WIFI_EVENT_TWT_TEARDOWN event */
|
||||
typedef struct {
|
||||
uint8_t flow_id; /**< flow id */
|
||||
} wifi_event_sta_itwt_teardown_t;
|
||||
|
||||
/**
|
||||
* @brief iTWT probe status
|
||||
*/
|
||||
typedef enum {
|
||||
ITWT_PROBE_FAIL, /**< station sends probe request fail */
|
||||
ITWT_PROBE_SUCCESS, /**< 1) station receives beacon from AP; 2) station receives probe response from AP */
|
||||
ITWT_PROBE_TIMEOUT, /**< 1) timeout of receiving ACK in response of previously probe request sending by station
|
||||
2) timeout of receiving probe response in response of previously probe request sending by station */
|
||||
ITWT_PROBE_STA_DISCONNECTED, /**< station is not connected */
|
||||
} wifi_itwt_probe_status_t;
|
||||
|
||||
/** Argument structure for WIFI_EVENT_ITWT_SEND_PROBE event */
|
||||
typedef struct {
|
||||
wifi_itwt_probe_status_t status; /**< probe status */
|
||||
uint8_t reason; /**< failure reason */
|
||||
} wifi_event_sta_itwt_probe_t;
|
||||
|
||||
/** Argument structure for WIFI_EVENT_ITWT_SUSPEND event */
|
||||
typedef struct {
|
||||
esp_err_t status; /**< suspend status */
|
||||
uint8_t flow_id_bitmap; /**< bitmap of the suspended flow id */
|
||||
uint32_t actual_suspend_time_ms[8]; /**< the actual suspend time for each flow id, unit: ms */
|
||||
} wifi_event_sta_itwt_suspend_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
// empty
|
||||
@@ -0,0 +1 @@
|
||||
// empty
|
||||
@@ -0,0 +1,18 @@
|
||||
typedef int _lock_t;
|
||||
|
||||
#define SOC_COEX_HW_PTI 1
|
||||
|
||||
#include "espidf_types.h"
|
||||
#include "esp_private/wifi.h"
|
||||
#include "esp_wpa.h"
|
||||
#include "esp_phy_init.h"
|
||||
#include "phy.h"
|
||||
#include "esp_timer.h"
|
||||
|
||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||
#include "esp_bt.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
#include "esp_coexist_adapter.h"
|
||||
#endif
|
||||
|
||||
#include "esp_now.h"
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* 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 _NIMBLE_NPL_H_
|
||||
#define _NIMBLE_NPL_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ble_npl_event;
|
||||
typedef void ble_npl_event_fn(struct ble_npl_event *ev);
|
||||
|
||||
enum ble_npl_error {
|
||||
BLE_NPL_OK = 0,
|
||||
BLE_NPL_ENOMEM = 1,
|
||||
BLE_NPL_EINVAL = 2,
|
||||
BLE_NPL_INVALID_PARAM = 3,
|
||||
BLE_NPL_MEM_NOT_ALIGNED = 4,
|
||||
BLE_NPL_BAD_MUTEX = 5,
|
||||
BLE_NPL_TIMEOUT = 6,
|
||||
BLE_NPL_ERR_IN_ISR = 7,
|
||||
BLE_NPL_ERR_PRIV = 8,
|
||||
BLE_NPL_OS_NOT_STARTED = 9,
|
||||
BLE_NPL_ENOENT = 10,
|
||||
BLE_NPL_EBUSY = 11,
|
||||
BLE_NPL_ERROR = 12,
|
||||
};
|
||||
|
||||
typedef enum ble_npl_error ble_npl_error_t;
|
||||
|
||||
/* Include OS-specific definitions */
|
||||
#include "nimble/nimble_npl_os.h"
|
||||
|
||||
/*
|
||||
* Generic
|
||||
*/
|
||||
|
||||
bool ble_npl_os_started(void);
|
||||
|
||||
void *ble_npl_get_current_task_id(void);
|
||||
|
||||
/*
|
||||
* Event queue
|
||||
*/
|
||||
|
||||
void ble_npl_eventq_init(struct ble_npl_eventq *evq);
|
||||
|
||||
void ble_npl_eventq_deinit(struct ble_npl_eventq *evq);
|
||||
|
||||
struct ble_npl_event *ble_npl_eventq_get(struct ble_npl_eventq *evq,
|
||||
ble_npl_time_t tmo);
|
||||
|
||||
void ble_npl_eventq_put(struct ble_npl_eventq *evq, struct ble_npl_event *ev);
|
||||
|
||||
void ble_npl_eventq_remove(struct ble_npl_eventq *evq,
|
||||
struct ble_npl_event *ev);
|
||||
|
||||
void ble_npl_event_init(struct ble_npl_event *ev, ble_npl_event_fn *fn,
|
||||
void *arg);
|
||||
|
||||
bool ble_npl_event_is_queued(struct ble_npl_event *ev);
|
||||
|
||||
void *ble_npl_event_get_arg(struct ble_npl_event *ev);
|
||||
|
||||
void ble_npl_event_set_arg(struct ble_npl_event *ev, void *arg);
|
||||
|
||||
bool ble_npl_eventq_is_empty(struct ble_npl_eventq *evq);
|
||||
|
||||
void ble_npl_event_run(struct ble_npl_event *ev);
|
||||
|
||||
/*
|
||||
* Mutexes
|
||||
*/
|
||||
|
||||
ble_npl_error_t ble_npl_mutex_init(struct ble_npl_mutex *mu);
|
||||
|
||||
ble_npl_error_t ble_npl_mutex_pend(struct ble_npl_mutex *mu,
|
||||
ble_npl_time_t timeout);
|
||||
|
||||
ble_npl_error_t ble_npl_mutex_release(struct ble_npl_mutex *mu);
|
||||
|
||||
ble_npl_error_t ble_npl_mutex_deinit(struct ble_npl_mutex *mu);
|
||||
|
||||
/*
|
||||
* Semaphores
|
||||
*/
|
||||
|
||||
ble_npl_error_t ble_npl_sem_init(struct ble_npl_sem *sem, uint16_t tokens);
|
||||
|
||||
ble_npl_error_t ble_npl_sem_pend(struct ble_npl_sem *sem,
|
||||
ble_npl_time_t timeout);
|
||||
|
||||
ble_npl_error_t ble_npl_sem_release(struct ble_npl_sem *sem);
|
||||
|
||||
ble_npl_error_t ble_npl_sem_deinit(struct ble_npl_sem *sem);
|
||||
|
||||
uint16_t ble_npl_sem_get_count(struct ble_npl_sem *sem);
|
||||
|
||||
/*
|
||||
* Callouts
|
||||
*/
|
||||
|
||||
int ble_npl_callout_init(struct ble_npl_callout *co, struct ble_npl_eventq *evq,
|
||||
ble_npl_event_fn *ev_cb, void *ev_arg);
|
||||
|
||||
ble_npl_error_t ble_npl_callout_reset(struct ble_npl_callout *co,
|
||||
ble_npl_time_t ticks);
|
||||
|
||||
void ble_npl_callout_stop(struct ble_npl_callout *co);
|
||||
|
||||
bool ble_npl_callout_is_active(struct ble_npl_callout *co);
|
||||
|
||||
ble_npl_time_t ble_npl_callout_get_ticks(struct ble_npl_callout *co);
|
||||
|
||||
ble_npl_time_t ble_npl_callout_remaining_ticks(struct ble_npl_callout *co,
|
||||
ble_npl_time_t time);
|
||||
|
||||
void ble_npl_callout_set_arg(struct ble_npl_callout *co,
|
||||
void *arg);
|
||||
/*
|
||||
* Time functions
|
||||
*/
|
||||
|
||||
ble_npl_time_t ble_npl_time_get(void);
|
||||
|
||||
ble_npl_error_t ble_npl_time_ms_to_ticks(uint32_t ms, ble_npl_time_t *out_ticks);
|
||||
|
||||
ble_npl_error_t ble_npl_time_ticks_to_ms(ble_npl_time_t ticks, uint32_t *out_ms);
|
||||
|
||||
ble_npl_time_t ble_npl_time_ms_to_ticks32(uint32_t ms);
|
||||
|
||||
uint32_t ble_npl_time_ticks_to_ms32(ble_npl_time_t ticks);
|
||||
|
||||
void ble_npl_time_delay(ble_npl_time_t ticks);
|
||||
|
||||
/*
|
||||
* Hardware-specific
|
||||
*
|
||||
* These symbols should be most likely defined by application since they are
|
||||
* specific to hardware, not to OS.
|
||||
*/
|
||||
|
||||
#if NIMBLE_CFG_CONTROLLER
|
||||
|
||||
void ble_npl_hw_set_isr(int irqn, uint32_t addr);
|
||||
|
||||
#endif
|
||||
|
||||
uint32_t ble_npl_hw_enter_critical(void);
|
||||
|
||||
void ble_npl_hw_exit_critical(uint32_t ctx);
|
||||
|
||||
bool ble_npl_hw_is_in_critical(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NIMBLE_NPL_H_ */
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 _NIMBLE_NPL_OS_H_
|
||||
#define _NIMBLE_NPL_OS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BLE_NPL_OS_ALIGNMENT 4
|
||||
|
||||
#define BLE_NPL_TIME_FOREVER UINT32_MAX
|
||||
|
||||
typedef uint32_t ble_npl_time_t;
|
||||
typedef int32_t ble_npl_stime_t;
|
||||
|
||||
struct ble_npl_event {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
struct ble_npl_eventq {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
struct ble_npl_callout {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
struct ble_npl_mutex {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
struct ble_npl_sem {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NPL_H_ */
|
||||
Reference in New Issue
Block a user