Skip to content

Commit d46f831

Browse files
author
Zhang Jun Hao
committed
feat(lwip): formatted code
1 parent 8e0084f commit d46f831

File tree

2 files changed

+67
-56
lines changed

2 files changed

+67
-56
lines changed

components/esp8266/include/esp_wifi_types.h

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ typedef union {
121121

122122
/** @brief Parameters for an SSID scan. */
123123
typedef struct {
124-
uint8_t *ssid; /**< SSID of AP */
125-
uint8_t *bssid; /**< MAC address of AP */
124+
uint8_t* ssid; /**< SSID of AP */
125+
uint8_t* bssid; /**< MAC address of AP */
126126
uint8_t channel; /**< channel, scan the specific channel */
127127
bool show_hidden; /**< enable to scan AP whose SSID is hidden */
128128
wifi_scan_type_t scan_type; /**< scan type, active or passive */
@@ -156,30 +156,30 @@ typedef struct {
156156
wifi_cipher_type_t pairwise_cipher; /**< pairwise cipher of AP */
157157
wifi_cipher_type_t group_cipher; /**< group cipher of AP */
158158
wifi_ant_t ant; /**< antenna used to receive beacon from AP */
159-
uint32_t phy_11b:1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
160-
uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
161-
uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
162-
uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */
163-
uint32_t wps:1; /**< bit: 4 flag to identify if WPS is supported or not */
164-
uint32_t reserved:27; /**< bit: 5..31 reserved */
159+
uint32_t phy_11b: 1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
160+
uint32_t phy_11g: 1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
161+
uint32_t phy_11n: 1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
162+
uint32_t phy_lr: 1; /**< bit: 3 flag to identify if low rate is enabled or not */
163+
uint32_t wps: 1; /**< bit: 4 flag to identify if WPS is supported or not */
164+
uint32_t reserved: 27; /**< bit: 5..31 reserved */
165165
wifi_country_t country; /**< country information of AP */
166166
} wifi_ap_record_t;
167167

168168
typedef enum {
169169
WIFI_FAST_SCAN = 0, /**< Do fast scan, scan will end after find SSID match AP */
170170
WIFI_ALL_CHANNEL_SCAN, /**< All channel scan, scan will end after scan all the channel */
171-
}wifi_scan_method_t;
171+
} wifi_scan_method_t;
172172

173173
typedef enum {
174174
WIFI_CONNECT_AP_BY_SIGNAL = 0, /**< Sort match AP in scan list by RSSI */
175175
WIFI_CONNECT_AP_BY_SECURITY, /**< Sort match AP in scan list by security mode */
176-
}wifi_sort_method_t;
176+
} wifi_sort_method_t;
177177

178178
/** @brief Structure describing parameters for a WiFi fast scan */
179179
typedef struct {
180180
int8_t rssi; /**< The minimum rssi to accept in the fast scan mode */
181181
wifi_auth_mode_t authmode; /**< The weakest authmode to accept in the fast scan mode */
182-
}wifi_fast_scan_threshold_t;
182+
} wifi_fast_scan_threshold_t;
183183

184184
typedef enum {
185185
WIFI_PS_NONE, /**< No power save */
@@ -238,11 +238,11 @@ typedef union {
238238
/** @brief Description of STA associated with AP */
239239
typedef struct {
240240
uint8_t mac[6]; /**< mac address */
241-
uint32_t phy_11b:1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
242-
uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
243-
uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
244-
uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */
245-
uint32_t reserved:28; /**< bit: 4..31 reserved */
241+
uint32_t phy_11b: 1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
242+
uint32_t phy_11g: 1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
243+
uint32_t phy_11n: 1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
244+
uint32_t phy_lr: 1; /**< bit: 3 flag to identify if low rate is enabled or not */
245+
uint32_t reserved: 28; /**< bit: 4..31 reserved */
246246
} wifi_sta_info_t;
247247

248248
#define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP8266 soft-AP */
@@ -298,31 +298,31 @@ typedef struct {
298298

299299
/** @brief Received packet radio metadata header, this is the common header at the beginning of all promiscuous mode RX callback buffers */
300300
typedef struct {
301-
signed rssi:8; /**< signal intensity of packet */
302-
unsigned rate:4; /**< data rate */
303-
unsigned is_group:1;
304-
unsigned :1; /**< reserve */
305-
unsigned sig_mode:2; /**< 0:is not 11n packet; 1:is 11n packet */
306-
unsigned legacy_length:12;
307-
unsigned damatch0:1;
308-
unsigned damatch1:1;
309-
unsigned bssidmatch0:1;
310-
unsigned bssidmatch1:1;
311-
unsigned mcs:7; /**< if is 11n packet, shows the modulation(range from 0 to 76) */
312-
unsigned cwb:1; /**< if is 11n packet, shows if is HT40 packet or not */
313-
unsigned HT_length:16; /**< reserve */
314-
unsigned smoothing:1; /**< reserve */
315-
unsigned not_sounding:1; /**< reserve */
316-
unsigned :1; /**< reserve */
317-
unsigned aggregation:1; /**< Aggregation */
318-
unsigned stbc:2; /**< STBC */
319-
unsigned fec_coding:1; /**< Flag is set for 11n packets which are LDPC */
320-
unsigned sgi:1; /**< SGI */
321-
unsigned rxend_state:8;
322-
unsigned ampdu_cnt:8; /**< ampdu cnt */
323-
unsigned channel:4; /**< which channel this packet in */
324-
unsigned :4; /**< reserve */
325-
signed noise_floor:8;
301+
signed rssi: 8; /**< signal intensity of packet */
302+
unsigned rate: 4; /**< data rate */
303+
unsigned is_group: 1;
304+
unsigned : 1; /**< reserve */
305+
unsigned sig_mode: 2; /**< 0:is not 11n packet; 1:is 11n packet */
306+
unsigned legacy_length: 12;
307+
unsigned damatch0: 1;
308+
unsigned damatch1: 1;
309+
unsigned bssidmatch0: 1;
310+
unsigned bssidmatch1: 1;
311+
unsigned mcs: 7; /**< if is 11n packet, shows the modulation(range from 0 to 76) */
312+
unsigned cwb: 1; /**< if is 11n packet, shows if is HT40 packet or not */
313+
unsigned HT_length: 16; /**< reserve */
314+
unsigned smoothing: 1; /**< reserve */
315+
unsigned not_sounding: 1; /**< reserve */
316+
unsigned : 1; /**< reserve */
317+
unsigned aggregation: 1; /**< Aggregation */
318+
unsigned stbc: 2; /**< STBC */
319+
unsigned fec_coding: 1; /**< Flag is set for 11n packets which are LDPC */
320+
unsigned sgi: 1; /**< SGI */
321+
unsigned rxend_state: 8;
322+
unsigned ampdu_cnt: 8; /**< ampdu cnt */
323+
unsigned channel: 4; /**< which channel this packet in */
324+
unsigned : 4; /**< reserve */
325+
signed noise_floor: 8;
326326
} wifi_pkt_rx_ctrl_t;
327327

328328
/** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback.

components/lwip/port/esp8266/netif/ethernetif.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ static int low_level_send_cb(esp_aio_t* aio);
4848

4949
static inline bool check_pbuf_to_insert(struct pbuf* p)
5050
{
51-
uint8_t* buf = (uint8_t *)p->payload;
51+
uint8_t* buf = (uint8_t*)p->payload;
52+
5253
/*Check if pbuf is tcp ip*/
5354
if (buf[12] == 0x08 && buf[13] == 0x00 && buf[23] == 0x06) {
54-
return true;
55+
return true;
5556
}
57+
5658
return false;
5759
}
5860

@@ -69,14 +71,16 @@ static void insert_to_list(int fd, struct pbuf* p)
6971
return;
7072
}
7173

72-
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Insert %p,%d\n",p,pbuf_send_list_num));
74+
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Insert %p,%d\n", p, pbuf_send_list_num));
75+
7376
if (pbuf_list_head == NULL) {
7477
tmp_pbuf_list1 = (pbuf_send_list_t*)malloc(sizeof(pbuf_send_list_t));
7578

7679
if (!tmp_pbuf_list1) {
7780
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no menory malloc pbuf list error\n"));
7881
return;
7982
}
83+
8084
pbuf_ref(p);
8185
tmp_pbuf_list1->aiofd = fd;
8286
tmp_pbuf_list1->p = p;
@@ -95,6 +99,7 @@ static void insert_to_list(int fd, struct pbuf* p)
9599
tmp_pbuf_list1->err_cnt ++;
96100
return;
97101
}
102+
98103
tmp_pbuf_list2 = tmp_pbuf_list1;
99104
tmp_pbuf_list1 = tmp_pbuf_list2->next;
100105
}
@@ -122,7 +127,7 @@ void send_from_list()
122127
while (pbuf_list_head != NULL) {
123128
if (pbuf_list_head->p->ref == 1) {
124129
tmp_pbuf_list1 = pbuf_list_head->next;
125-
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n",pbuf_list_head->p,pbuf_send_list_num));
130+
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
126131
pbuf_free(pbuf_list_head->p);
127132
free(pbuf_list_head);
128133
pbuf_send_list_num--;
@@ -142,21 +147,23 @@ void send_from_list()
142147

143148
if (err == ERR_MEM) {
144149
pbuf_list_head->err_cnt++;
150+
145151
if (pbuf_list_head->err_cnt >= 3) {
146-
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n",pbuf_list_head->p,pbuf_send_list_num));
152+
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
147153
pbuf_free(pbuf_list_head->p);
148154
free(pbuf_list_head);
149155
pbuf_send_list_num--;
150156
pbuf_list_head = tmp_pbuf_list1;
151157
}
158+
152159
return;
153-
} else if (err == ERR_OK){
154-
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n",pbuf_list_head->p,pbuf_send_list_num));
160+
} else if (err == ERR_OK) {
161+
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
155162
free(pbuf_list_head);
156163
pbuf_send_list_num--;
157164
pbuf_list_head = tmp_pbuf_list1;
158165
} else {
159-
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n",pbuf_list_head->p,pbuf_send_list_num));
166+
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
160167
pbuf_free(pbuf_list_head->p);
161168
free(pbuf_list_head);
162169
pbuf_send_list_num--;
@@ -203,9 +210,9 @@ static void low_level_init(struct netif* netif)
203210
*
204211
* @return 0 meaning successs
205212
*/
206-
static int low_level_send_cb(esp_aio_t *aio)
213+
static int low_level_send_cb(esp_aio_t* aio)
207214
{
208-
struct pbuf *pbuf = aio->arg;
215+
struct pbuf* pbuf = aio->arg;
209216
wifi_tx_status_t* status = (wifi_tx_status_t*) & (aio->ret);
210217

211218
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)
242249
*
243250
* @return LWIP pbuf pointer which it not "PBUF_FLAG_IS_CUSTOM" attribute
244251
*/
245-
static inline struct pbuf *ethernetif_transform_pbuf(struct pbuf *pbuf)
252+
static inline struct pbuf* ethernetif_transform_pbuf(struct pbuf* pbuf)
246253
{
247-
struct pbuf *p;
254+
struct pbuf* p;
248255

249256
if (!(pbuf->flags & PBUF_FLAG_IS_CUSTOM) && IS_DRAM(pbuf->payload)) {
250257
/*
@@ -255,8 +262,10 @@ static inline struct pbuf *ethernetif_transform_pbuf(struct pbuf *pbuf)
255262
}
256263

257264
p = pbuf_alloc(PBUF_RAW, pbuf->len, PBUF_RAM);
258-
if (!p)
265+
266+
if (!p) {
259267
return NULL;
268+
}
260269

261270
if (IS_IRAM(p->payload)) {
262271
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)
269278
/*
270279
* The input pbuf(named "pbuf") should not be freed, becasue it will be
271280
* freed by upper layer.
272-
*
281+
*
273282
* The output pbuf(named "p") should not be freed either, becasue it will
274283
* be freed at callback function "low_level_send_cb".
275284
*/
@@ -308,6 +317,7 @@ static int8_t low_level_output(struct netif* netif, struct pbuf* p)
308317
#endif
309318

310319
p = ethernetif_transform_pbuf(p);
320+
311321
if (!p) {
312322
LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output: lack memory\n"));
313323
return ERR_OK;
@@ -328,8 +338,9 @@ static int8_t low_level_output(struct netif* netif, struct pbuf* p)
328338
#if ESP_UDP
329339
udp_sync_set_ret(netif, err);
330340
#endif
341+
331342
if (err != ERR_OK) {
332-
if (err == ERR_MEM){
343+
if (err == ERR_MEM) {
333344
insert_to_list(aio.fd, p);
334345
err = ERR_OK;
335346
}

0 commit comments

Comments
 (0)