mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-21 17:16:29 +08:00
feat(lwip): formatted code
This commit is contained in:
@ -121,8 +121,8 @@ typedef union {
|
||||
|
||||
/** @brief Parameters for an SSID scan. */
|
||||
typedef struct {
|
||||
uint8_t *ssid; /**< SSID of AP */
|
||||
uint8_t *bssid; /**< MAC address of AP */
|
||||
uint8_t* ssid; /**< SSID of AP */
|
||||
uint8_t* bssid; /**< MAC address of AP */
|
||||
uint8_t channel; /**< channel, scan the specific channel */
|
||||
bool show_hidden; /**< enable to scan AP whose SSID is hidden */
|
||||
wifi_scan_type_t scan_type; /**< scan type, active or passive */
|
||||
@ -156,30 +156,30 @@ typedef struct {
|
||||
wifi_cipher_type_t pairwise_cipher; /**< pairwise cipher of AP */
|
||||
wifi_cipher_type_t group_cipher; /**< group cipher of AP */
|
||||
wifi_ant_t ant; /**< antenna used to receive beacon from AP */
|
||||
uint32_t phy_11b:1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
|
||||
uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
|
||||
uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
|
||||
uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */
|
||||
uint32_t wps:1; /**< bit: 4 flag to identify if WPS is supported or not */
|
||||
uint32_t reserved:27; /**< bit: 5..31 reserved */
|
||||
uint32_t phy_11b: 1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
|
||||
uint32_t phy_11g: 1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
|
||||
uint32_t phy_11n: 1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
|
||||
uint32_t phy_lr: 1; /**< bit: 3 flag to identify if low rate is enabled or not */
|
||||
uint32_t wps: 1; /**< bit: 4 flag to identify if WPS is supported or not */
|
||||
uint32_t reserved: 27; /**< bit: 5..31 reserved */
|
||||
wifi_country_t country; /**< country information of AP */
|
||||
} wifi_ap_record_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_FAST_SCAN = 0, /**< Do fast scan, scan will end after find SSID match AP */
|
||||
WIFI_ALL_CHANNEL_SCAN, /**< All channel scan, scan will end after scan all the channel */
|
||||
}wifi_scan_method_t;
|
||||
} wifi_scan_method_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_CONNECT_AP_BY_SIGNAL = 0, /**< Sort match AP in scan list by RSSI */
|
||||
WIFI_CONNECT_AP_BY_SECURITY, /**< Sort match AP in scan list by security mode */
|
||||
}wifi_sort_method_t;
|
||||
} wifi_sort_method_t;
|
||||
|
||||
/** @brief Structure describing parameters for a WiFi fast scan */
|
||||
typedef struct {
|
||||
int8_t rssi; /**< The minimum rssi to accept in the fast scan mode */
|
||||
wifi_auth_mode_t authmode; /**< The weakest authmode to accept in the fast scan mode */
|
||||
}wifi_fast_scan_threshold_t;
|
||||
} wifi_fast_scan_threshold_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_PS_NONE, /**< No power save */
|
||||
@ -238,11 +238,11 @@ typedef union {
|
||||
/** @brief Description of STA associated with AP */
|
||||
typedef struct {
|
||||
uint8_t mac[6]; /**< mac address */
|
||||
uint32_t phy_11b:1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
|
||||
uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
|
||||
uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
|
||||
uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */
|
||||
uint32_t reserved:28; /**< bit: 4..31 reserved */
|
||||
uint32_t phy_11b: 1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
|
||||
uint32_t phy_11g: 1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
|
||||
uint32_t phy_11n: 1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
|
||||
uint32_t phy_lr: 1; /**< bit: 3 flag to identify if low rate is enabled or not */
|
||||
uint32_t reserved: 28; /**< bit: 4..31 reserved */
|
||||
} wifi_sta_info_t;
|
||||
|
||||
#define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP8266 soft-AP */
|
||||
@ -298,31 +298,31 @@ typedef struct {
|
||||
|
||||
/** @brief Received packet radio metadata header, this is the common header at the beginning of all promiscuous mode RX callback buffers */
|
||||
typedef struct {
|
||||
signed rssi:8; /**< signal intensity of packet */
|
||||
unsigned rate:4; /**< data rate */
|
||||
unsigned is_group:1;
|
||||
unsigned :1; /**< reserve */
|
||||
unsigned sig_mode:2; /**< 0:is not 11n packet; 1:is 11n packet */
|
||||
unsigned legacy_length:12;
|
||||
unsigned damatch0:1;
|
||||
unsigned damatch1:1;
|
||||
unsigned bssidmatch0:1;
|
||||
unsigned bssidmatch1:1;
|
||||
unsigned mcs:7; /**< if is 11n packet, shows the modulation(range from 0 to 76) */
|
||||
unsigned cwb:1; /**< if is 11n packet, shows if is HT40 packet or not */
|
||||
unsigned HT_length:16; /**< reserve */
|
||||
unsigned smoothing:1; /**< reserve */
|
||||
unsigned not_sounding:1; /**< reserve */
|
||||
unsigned :1; /**< reserve */
|
||||
unsigned aggregation:1; /**< Aggregation */
|
||||
unsigned stbc:2; /**< STBC */
|
||||
unsigned fec_coding:1; /**< Flag is set for 11n packets which are LDPC */
|
||||
unsigned sgi:1; /**< SGI */
|
||||
unsigned rxend_state:8;
|
||||
unsigned ampdu_cnt:8; /**< ampdu cnt */
|
||||
unsigned channel:4; /**< which channel this packet in */
|
||||
unsigned :4; /**< reserve */
|
||||
signed noise_floor:8;
|
||||
signed rssi: 8; /**< signal intensity of packet */
|
||||
unsigned rate: 4; /**< data rate */
|
||||
unsigned is_group: 1;
|
||||
unsigned : 1; /**< reserve */
|
||||
unsigned sig_mode: 2; /**< 0:is not 11n packet; 1:is 11n packet */
|
||||
unsigned legacy_length: 12;
|
||||
unsigned damatch0: 1;
|
||||
unsigned damatch1: 1;
|
||||
unsigned bssidmatch0: 1;
|
||||
unsigned bssidmatch1: 1;
|
||||
unsigned mcs: 7; /**< if is 11n packet, shows the modulation(range from 0 to 76) */
|
||||
unsigned cwb: 1; /**< if is 11n packet, shows if is HT40 packet or not */
|
||||
unsigned HT_length: 16; /**< reserve */
|
||||
unsigned smoothing: 1; /**< reserve */
|
||||
unsigned not_sounding: 1; /**< reserve */
|
||||
unsigned : 1; /**< reserve */
|
||||
unsigned aggregation: 1; /**< Aggregation */
|
||||
unsigned stbc: 2; /**< STBC */
|
||||
unsigned fec_coding: 1; /**< Flag is set for 11n packets which are LDPC */
|
||||
unsigned sgi: 1; /**< SGI */
|
||||
unsigned rxend_state: 8;
|
||||
unsigned ampdu_cnt: 8; /**< ampdu cnt */
|
||||
unsigned channel: 4; /**< which channel this packet in */
|
||||
unsigned : 4; /**< reserve */
|
||||
signed noise_floor: 8;
|
||||
} wifi_pkt_rx_ctrl_t;
|
||||
|
||||
/** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback.
|
||||
|
@ -48,11 +48,13 @@ static int low_level_send_cb(esp_aio_t* aio);
|
||||
|
||||
static inline bool check_pbuf_to_insert(struct pbuf* p)
|
||||
{
|
||||
uint8_t* buf = (uint8_t *)p->payload;
|
||||
uint8_t* buf = (uint8_t*)p->payload;
|
||||
|
||||
/*Check if pbuf is tcp ip*/
|
||||
if (buf[12] == 0x08 && buf[13] == 0x00 && buf[23] == 0x06) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -69,7 +71,8 @@ static void insert_to_list(int fd, struct pbuf* p)
|
||||
return;
|
||||
}
|
||||
|
||||
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Insert %p,%d\n",p,pbuf_send_list_num));
|
||||
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Insert %p,%d\n", p, pbuf_send_list_num));
|
||||
|
||||
if (pbuf_list_head == NULL) {
|
||||
tmp_pbuf_list1 = (pbuf_send_list_t*)malloc(sizeof(pbuf_send_list_t));
|
||||
|
||||
@ -77,6 +80,7 @@ static void insert_to_list(int fd, struct pbuf* p)
|
||||
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no menory malloc pbuf list error\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
pbuf_ref(p);
|
||||
tmp_pbuf_list1->aiofd = fd;
|
||||
tmp_pbuf_list1->p = p;
|
||||
@ -95,6 +99,7 @@ static void insert_to_list(int fd, struct pbuf* p)
|
||||
tmp_pbuf_list1->err_cnt ++;
|
||||
return;
|
||||
}
|
||||
|
||||
tmp_pbuf_list2 = tmp_pbuf_list1;
|
||||
tmp_pbuf_list1 = tmp_pbuf_list2->next;
|
||||
}
|
||||
@ -122,7 +127,7 @@ void send_from_list()
|
||||
while (pbuf_list_head != NULL) {
|
||||
if (pbuf_list_head->p->ref == 1) {
|
||||
tmp_pbuf_list1 = pbuf_list_head->next;
|
||||
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n",pbuf_list_head->p,pbuf_send_list_num));
|
||||
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
|
||||
pbuf_free(pbuf_list_head->p);
|
||||
free(pbuf_list_head);
|
||||
pbuf_send_list_num--;
|
||||
@ -142,21 +147,23 @@ void send_from_list()
|
||||
|
||||
if (err == ERR_MEM) {
|
||||
pbuf_list_head->err_cnt++;
|
||||
|
||||
if (pbuf_list_head->err_cnt >= 3) {
|
||||
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n",pbuf_list_head->p,pbuf_send_list_num));
|
||||
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
|
||||
pbuf_free(pbuf_list_head->p);
|
||||
free(pbuf_list_head);
|
||||
pbuf_send_list_num--;
|
||||
pbuf_list_head = tmp_pbuf_list1;
|
||||
}
|
||||
|
||||
return;
|
||||
} else if (err == ERR_OK){
|
||||
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n",pbuf_list_head->p,pbuf_send_list_num));
|
||||
} else if (err == ERR_OK) {
|
||||
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
|
||||
free(pbuf_list_head);
|
||||
pbuf_send_list_num--;
|
||||
pbuf_list_head = tmp_pbuf_list1;
|
||||
} else {
|
||||
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n",pbuf_list_head->p,pbuf_send_list_num));
|
||||
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
|
||||
pbuf_free(pbuf_list_head->p);
|
||||
free(pbuf_list_head);
|
||||
pbuf_send_list_num--;
|
||||
@ -203,9 +210,9 @@ static void low_level_init(struct netif* netif)
|
||||
*
|
||||
* @return 0 meaning successs
|
||||
*/
|
||||
static int low_level_send_cb(esp_aio_t *aio)
|
||||
static int low_level_send_cb(esp_aio_t* aio)
|
||||
{
|
||||
struct pbuf *pbuf = aio->arg;
|
||||
struct pbuf* pbuf = aio->arg;
|
||||
wifi_tx_status_t* status = (wifi_tx_status_t*) & (aio->ret);
|
||||
|
||||
if ((TX_STATUS_SUCCESS != status->wifi_tx_result) && check_pbuf_to_insert(pbuf)) {
|
||||
@ -242,9 +249,9 @@ static int low_level_send_cb(esp_aio_t *aio)
|
||||
*
|
||||
* @return LWIP pbuf pointer which it not "PBUF_FLAG_IS_CUSTOM" attribute
|
||||
*/
|
||||
static inline struct pbuf *ethernetif_transform_pbuf(struct pbuf *pbuf)
|
||||
static inline struct pbuf* ethernetif_transform_pbuf(struct pbuf* pbuf)
|
||||
{
|
||||
struct pbuf *p;
|
||||
struct pbuf* p;
|
||||
|
||||
if (!(pbuf->flags & PBUF_FLAG_IS_CUSTOM) && IS_DRAM(pbuf->payload)) {
|
||||
/*
|
||||
@ -255,8 +262,10 @@ static inline struct pbuf *ethernetif_transform_pbuf(struct pbuf *pbuf)
|
||||
}
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, pbuf->len, PBUF_RAM);
|
||||
if (!p)
|
||||
|
||||
if (!p) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (IS_IRAM(p->payload)) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output: data in IRAM\n"));
|
||||
@ -269,7 +278,7 @@ static inline struct pbuf *ethernetif_transform_pbuf(struct pbuf *pbuf)
|
||||
/*
|
||||
* The input pbuf(named "pbuf") should not be freed, becasue it will be
|
||||
* freed by upper layer.
|
||||
*
|
||||
*
|
||||
* The output pbuf(named "p") should not be freed either, becasue it will
|
||||
* be freed at callback function "low_level_send_cb".
|
||||
*/
|
||||
@ -308,6 +317,7 @@ static int8_t low_level_output(struct netif* netif, struct pbuf* p)
|
||||
#endif
|
||||
|
||||
p = ethernetif_transform_pbuf(p);
|
||||
|
||||
if (!p) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output: lack memory\n"));
|
||||
return ERR_OK;
|
||||
@ -328,8 +338,9 @@ static int8_t low_level_output(struct netif* netif, struct pbuf* p)
|
||||
#if ESP_UDP
|
||||
udp_sync_set_ret(netif, err);
|
||||
#endif
|
||||
|
||||
if (err != ERR_OK) {
|
||||
if (err == ERR_MEM){
|
||||
if (err == ERR_MEM) {
|
||||
insert_to_list(aio.fd, p);
|
||||
err = ERR_OK;
|
||||
}
|
||||
|
Reference in New Issue
Block a user