From f5c63dce1f68a9b7efd6f50647ad0b5bf78b3d6a Mon Sep 17 00:00:00 2001 From: Zhang Jun Hao Date: Tue, 28 Aug 2018 15:18:56 +0800 Subject: [PATCH 1/4] feat(lib): add wifi buffer send result to aio ret --- components/esp8266/lib/VERSION | 2 +- components/esp8266/lib/libpp.a | Bin 242672 -> 242708 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp8266/lib/VERSION b/components/esp8266/lib/VERSION index ac05be87..f29d75ae 100644 --- a/components/esp8266/lib/VERSION +++ b/components/esp8266/lib/VERSION @@ -2,7 +2,7 @@ gwen: crypto: eca7811 core: 8ee40dd net80211: eca7811 - pp: eca7811 + pp: 82269d9 smartconfig:eca7811 wpa: eca7811 phy: 1055_8 \ No newline at end of file diff --git a/components/esp8266/lib/libpp.a b/components/esp8266/lib/libpp.a index 4e5d1f6a9e7bf98c3bd674be02f58354d74000cd..ce4bdfac09d51f1eeaa14a776fe3f7205db9fa30 100644 GIT binary patch delta 3076 zcmcJQT})g>6vt=gE?Wo)%ZIx*qTJn5K&9JVKJ0>RA*520S|X7r#D1iL)ifzdeW($0 zG4jwxQZN@?O-O~LCMeL*TqCVwiV23UC0ZIyTT+Qs6MWF54?bv8b3Omvvv41pS^}Nq z-1*Ia&d1z4v$MCCGW&ne?8{H7sHiNfe9vERR0~nNj@I^>5UVj`HO@)j#Ze*F$&B?% zl*}W0b+HOF?$7z!sE`lDj0ctYKJyyu@K)+VhPbO;`dg^Ese797e-8JW*Yx9Jjb^Mh z!5ZTqzUv#9Z$0j_-gTAdChiGyXwhfQ`-W3jhAELyB&0{fy|P$du`cVwu7j_(=LSo9 zA~~Uk=FraOu3g!Bd3LBmuTxpI<@8LQ+9hi@>5AE2Gd%A==-04ol3KmS^L>L(8!v z@$qRpeA*d1U`Og=byb~#OmQ>E|B)S0{`WCorR1P(O%|P$vel|D`B)j9LI_3H;Gze$ zR5Gxe`T$uYvBr86@iVOVIQ+rotY0KXKIHkv;eUr%vi>je^9lb$VsDBN4an;R#I?*DX~mB)hlzFOCUjLK`xYMB@ckt^D?r`uC2OoCu%ML!^V0=}oYgLuMtq$hXKIGBn_K}q` z_Y-er{*ZV(^8oR)%$1a64|6Z|2bhtkgBf{_Mg2Ra&p62v!r+dQXUHa*aRRO|BgHSw zNbxH(mU5dJOZkTxIWx$R6S4Wsh%HF4ArM^369}$m9we@D1enbDU>`8!gW<@b05&i^fF_|pJK+22boV;uWTDp27ZeR6oN1h z@dkcz@GxnT&MTUib!gyp)(ct3K90hlZWFX3)}evZSw}t8!f&0-h!5}sA4f1JZDA*9 z;AFAGtanlWIs7^4Ypg>9CyOC3is7PwfpIyUM{K;7A;fn)0TG-mcAa$`i%A4t939P54}99~?D_6Ttco4<83ybpgjj3G2A_svUX_>$n1iSy14MhGtZ@b!_{Dw(_TG z)z>y}b_~C0^St30-dgxlC5G0};?c2{nTgU~+0l>~PYhj?FD^363u-CL;pd8}QOBS3 Q#O$0JXmreX>)H|XKX@E_hyVZp delta 3135 zcmcJQUr1a>6vpSyx~sVH?^-oAhTW}otwFmRZL%AMN@{}-#!BOZ1Y24XMeIXM`_fR$ zZ3vWvls4%V){wNZe^L``AaJdl1R<9C5Q(HJ4M~WxZiQA#Lak5;H1zg-yXV?@2x&xf z;dp=Z%{kxM*%@bh7BUxq%RI8dS@m3`Dst4fL(dnYZVjXTLm^fY`bv`R-1tEu)+qF~ zGO~TNkMD~Wg#KvB*AEKqv4sA(j33cgUxQW2^9$mEarq}9r%pUH^#4nE*u2BrB32pt zY7JId|HK1VV7$Mvz&xB%NF zq=zT+cM1PQ$*4n=eYDQ8VNAPgjSAuW)tZ*#uAJGa{hk=lTcLSt)GKaE`V*19xD}S; zGScm;5gji$UD<-3j$K>XV>VH9ZQ0{iVmxhyrWKDI-=r1xkNe4_Ty*RSOY3hx-l)5$Q@X&9ZHP*tx&&Od&&xLAKxD7 z_GgNjT;G?p65r>Tk4Wu|WzLlz(zLMIRd!P9t+XmhQIdl736VwtcG25UQBLe&y@I%g z^-d)pT*dlvV)()5GbR59vBvsM;^t)j9`TG*h>YYwY$3*j;xKWL-ddRuoy6;jVZ5KX zn%?+u-x1d_|3zHLoI#)7%Ut1#&b2w(jM1Lm(M#pB-EdWuXg7>a74J!!8hF*=*RqW( z6#=a0nn-qERk&0}nA%67g(!(ei_yE5C^S0qG3^z}2ECubiuz>4hWE5oP^ z$b}+fq_R{C7(X@zv~I)wY`}RxONg217guG-SnTy0eZ^kmgW_ysviM~qJ@{^M7n$UW zRB^~QqBjoPrxcy$$>8%+-%D%Luy}gfzA@d1hA9D_w1eo8TcP%q~8kynq5;J_-nBmi&WL>}r z259^>MK3c>&>%BRN0?!Hi5aF7%rL#i49^8-)ZSx8?cdC(O>^qW#wgCGB7BHGiXvtd zyvdBO@NH&%g*dXv$JPxn<10VQjIB7wj4isz{2IOIn45zHfA9c%y2Ok#kV@wr4R8k1 znfIE9w|*;i{4dYa6sGS`%qx7FSj$Zwr6ty(f!(YN{t~dWgUF}b2#;hP8raP``k@!@ z3JN_jzy)y*#caBTlc0g^X7#LN`-hOvraM@N2DY2Q7tL_dAi%g>&Z9Qbi+1fBo`49p zn+>s!V=;mPZZ^z1G_c(a#%O@!M!zM?i}{6hXkgoa5xP!d8WoJ8fEz4v0W`4PAdm9w z2A7df_XeJ)Sce97vwjS^Cz;dFIXG&!6@A+sp1@W4k1~~uDX_|d3@CCC^T=iXYEtxT|Zxx>UbvJdR7_7nm^IrYEXrl>sozW6>2ZY b$*iOhqhI+SlwbJ5*q>AKcoR=j{{zOqcd2{B From 8e0084f7de5b0a85f81882c27cf0ca20d9f3b8e2 Mon Sep 17 00:00:00 2001 From: Zhang Jun Hao Date: Tue, 28 Aug 2018 17:51:52 +0800 Subject: [PATCH 2/4] feat(esp8266): add esp_aio send result --- components/esp8266/include/esp_wifi_types.h | 34 +++++++++++++++ .../lwip/port/esp8266/netif/ethernetif.c | 43 ++++++++++++++----- 2 files changed, 67 insertions(+), 10 deletions(-) diff --git a/components/esp8266/include/esp_wifi_types.h b/components/esp8266/include/esp_wifi_types.h index 0e741029..788b32bd 100755 --- a/components/esp8266/include/esp_wifi_types.h +++ b/components/esp8266/include/esp_wifi_types.h @@ -372,6 +372,40 @@ typedef struct { #define WIFI_EVENT_MASK_NONE (0) /**< mask none of the WiFi events */ #define WIFI_EVENT_MASK_AP_PROBEREQRECVED (BIT(0)) /**< mask SYSTEM_EVENT_AP_PROBEREQRECVED event */ +typedef enum { + TX_STATUS_SUCCESS = 1, + TX_STATUS_SRC_EXCEED, + TX_STATUS_LRC_EXCEED, + TX_STATUS_DISCARD, +} wifi_tx_result_t; + +typedef enum { + PHY_RATE_1_LONG, + PHY_RATE_2_LONG, + PHY_RATE_5_LONG, + PHY_RATE_11_LONG, + PHY_RATE_RESERVED, + PHY_RATE_2_SHORT, + PHY_RATE_5_SHORT, + PHY_RATE_11_SHORT, + PHY_RATE_48, + PHY_RATE_24, + PHY_RATE_12, + PHY_RATE_6, + PHY_RATE_54, + PHY_RATE_36, + PHY_RATE_18, + PHY_RATE_9, +} wifi_tx_rate_t; + +typedef struct { + unsigned wifi_tx_result: 8; + unsigned wifi_tx_src: 6; + unsigned wifi_tx_lrc: 6; + unsigned wifi_tx_rate: 8; + unsigned unused: 4; +} wifi_tx_status_t; + #ifdef __cplusplus } #endif diff --git a/components/lwip/port/esp8266/netif/ethernetif.c b/components/lwip/port/esp8266/netif/ethernetif.c index cabf6041..757cd7f6 100644 --- a/components/lwip/port/esp8266/netif/ethernetif.c +++ b/components/lwip/port/esp8266/netif/ethernetif.c @@ -71,18 +71,19 @@ static void insert_to_list(int fd, struct pbuf* p) LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Insert %p,%d\n",p,pbuf_send_list_num)); if (pbuf_list_head == NULL) { - pbuf_list_head = (pbuf_send_list_t* )malloc(sizeof(pbuf_send_list_t)); - pbuf_send_list_num++; + tmp_pbuf_list1 = (pbuf_send_list_t*)malloc(sizeof(pbuf_send_list_t)); - if (!pbuf_list_head) { + if (!tmp_pbuf_list1) { LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no menory malloc pbuf list error\n")); return; } pbuf_ref(p); - pbuf_list_head->aiofd = fd; - pbuf_list_head->p = p; - pbuf_list_head->next = NULL; - pbuf_list_head->err_cnt = 0; + tmp_pbuf_list1->aiofd = fd; + tmp_pbuf_list1->p = p; + tmp_pbuf_list1->next = NULL; + tmp_pbuf_list1->err_cnt = 0; + pbuf_list_head = tmp_pbuf_list1; + pbuf_send_list_num++; return; } @@ -98,9 +99,7 @@ static void insert_to_list(int fd, struct pbuf* p) tmp_pbuf_list1 = tmp_pbuf_list2->next; } - tmp_pbuf_list2->next = (pbuf_send_list_t*)malloc(sizeof(pbuf_send_list_t)); - pbuf_send_list_num++; - tmp_pbuf_list1 = tmp_pbuf_list2->next; + tmp_pbuf_list1 = (pbuf_send_list_t*)malloc(sizeof(pbuf_send_list_t)); if (!tmp_pbuf_list1) { LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no menory malloc pbuf list error\n")); @@ -112,6 +111,8 @@ static void insert_to_list(int fd, struct pbuf* p) tmp_pbuf_list1->p = p; tmp_pbuf_list1->next = NULL; tmp_pbuf_list1->err_cnt = 0; + tmp_pbuf_list2->next = tmp_pbuf_list1; + pbuf_send_list_num++; } void send_from_list() @@ -205,6 +206,28 @@ static void low_level_init(struct netif* netif) static int low_level_send_cb(esp_aio_t *aio) { 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)) { + uint8_t* buf = (uint8_t*)pbuf->payload; + struct eth_hdr ethhdr; + + if (*(buf - 17) & 0x01) { //From DS + memcpy(ðhdr.dest, buf - 2, ETH_HWADDR_LEN); + memcpy(ðhdr.src, buf - 2 - ETH_HWADDR_LEN, ETH_HWADDR_LEN); + } else if (*(buf - 17) & 0x02) { //To DS + memcpy(ðhdr.dest, buf - 2 - ETH_HWADDR_LEN - ETH_HWADDR_LEN, ETH_HWADDR_LEN); + memcpy(ðhdr.src, buf - 2, 6); + } else { + pbuf_free(pbuf); + return 0; + } + + memcpy(buf, ðhdr, (ETH_HWADDR_LEN + ETH_HWADDR_LEN)); + LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Send packet fail: result:%d, LRC:%d, SRC:%d, RATE:%d", + status->wifi_tx_result, status->wifi_tx_lrc, status->wifi_tx_src, status->wifi_tx_rate)); + insert_to_list(aio->fd, aio->arg); + } pbuf_free(pbuf); From d46f831d88356cd8f23e87d107c3d93f87fda6d1 Mon Sep 17 00:00:00 2001 From: Zhang Jun Hao Date: Wed, 29 Aug 2018 16:07:57 +0800 Subject: [PATCH 3/4] feat(lwip): formatted code --- components/esp8266/include/esp_wifi_types.h | 82 +++++++++---------- .../lwip/port/esp8266/netif/ethernetif.c | 41 ++++++---- 2 files changed, 67 insertions(+), 56 deletions(-) diff --git a/components/esp8266/include/esp_wifi_types.h b/components/esp8266/include/esp_wifi_types.h index 788b32bd..758edda2 100755 --- a/components/esp8266/include/esp_wifi_types.h +++ b/components/esp8266/include/esp_wifi_types.h @@ -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. diff --git a/components/lwip/port/esp8266/netif/ethernetif.c b/components/lwip/port/esp8266/netif/ethernetif.c index 757cd7f6..346c4663 100644 --- a/components/lwip/port/esp8266/netif/ethernetif.c +++ b/components/lwip/port/esp8266/netif/ethernetif.c @@ -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; } From fe0c6905d6e8b0f3a9cc6298e6cdcb994fbafa05 Mon Sep 17 00:00:00 2001 From: Zhang Jun Hao Date: Wed, 29 Aug 2018 19:57:50 +0800 Subject: [PATCH 4/4] fix(lwip): fix some writting error --- components/esp8266/lib/libpp.a | Bin 242708 -> 242708 bytes .../lwip/port/esp8266/netif/ethernetif.c | 4 ++-- components/tcpip_adapter/tcpip_adapter_lwip.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/esp8266/lib/libpp.a b/components/esp8266/lib/libpp.a index ce4bdfac09d51f1eeaa14a776fe3f7205db9fa30..05b23482509a404987671466ed9e8c010c763b06 100644 GIT binary patch delta 226 zcmbR8f^W(Tz6sLoX2u3429|~!m1c{>*polp6We@Cd^rb-z&wTZ@+bmX4#BD@0=H86 zD`5hgKioUd1ml1Wyz?-8EwaG&fPTh&4-}C**BPB3qKMe+WIE4}BBF7UX*G(&wtu+D OG}{kF%?btPoXG$LWm8E2 delta 226 zcmbR8f^W(Tz6sLorY0t)My3WEm1c{>*polp6We@Cd^rb-z&wTZ@+bmX4#BD@0=H86 zD`5hgKioUd1ml1Wyz?-8EwaG&fPTh&4-}C**BPB3qKMe+WIE4}BBF7UX*G(&wtu+D OG}{kF%?btPoXG$X^HXC0 diff --git a/components/lwip/port/esp8266/netif/ethernetif.c b/components/lwip/port/esp8266/netif/ethernetif.c index 346c4663..8ec20eca 100644 --- a/components/lwip/port/esp8266/netif/ethernetif.c +++ b/components/lwip/port/esp8266/netif/ethernetif.c @@ -77,7 +77,7 @@ static void insert_to_list(int fd, struct pbuf* p) tmp_pbuf_list1 = (pbuf_send_list_t*)malloc(sizeof(pbuf_send_list_t)); if (!tmp_pbuf_list1) { - LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no menory malloc pbuf list error\n")); + LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no memory malloc pbuf list error\n")); return; } @@ -107,7 +107,7 @@ static void insert_to_list(int fd, struct pbuf* p) tmp_pbuf_list1 = (pbuf_send_list_t*)malloc(sizeof(pbuf_send_list_t)); if (!tmp_pbuf_list1) { - LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no menory malloc pbuf list error\n")); + LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no memory malloc pbuf list error\n")); return; } diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index a4456c83..bb37573a 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -241,7 +241,7 @@ esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_a } if (esp_netif[tcpip_if] == NULL) { - ESP_LOGE(TAG, "TCPIP adapter has no menory\n"); + ESP_LOGE(TAG, "TCPIP adapter has no memory\n"); return ESP_ERR_NO_MEM; } memcpy(esp_netif[tcpip_if]->hwaddr, mac, NETIF_MAX_HWADDR_LEN);