Skip to content

Commit 1c539c0

Browse files
committed
Fix issue on close
1 parent 6858307 commit 1c539c0

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

binary/wifiHD.elf

-2.21 KB
Binary file not shown.

wifiHD/Release/wifiHD.elf

-2.21 KB
Binary file not shown.

wifiHD/src/ard_spi.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ void sendError()
356356
//Wait to empty the buffer
357357
while(!spi_writeRegisterEmptyCheck(&AVR32_SPI));
358358
}
359-
359+
BUSY_FOR_SPI();
360+
WARN("Send SPI error!");
360361
}
361362

362363
#define ENABLE_SPI_INT() do { \
@@ -379,13 +380,15 @@ void sendError()
379380
}while(0);
380381

381382
void dump(char* _buf, uint16_t _count) {
382-
#ifdef _APP_DEBUG_
383+
383384
int i;
384385
for (i = 0; i < _count; ++i)
385386
printk("0x%x ", _buf[i]);
386387
printk("\n");
387-
#endif
388388
}
389+
#ifdef _APP_DEBUG_
390+
#define DUMP dump
391+
#endif
389392

390393
#ifdef _APP_DEBUG_
391394
#define DUMP_SPI_DATA(BUF, COUNT) do { \
@@ -510,7 +513,7 @@ int set_key_cmd_cb(int numParam, char* buf, void* ctx) {
510513
//printk("KEY len out of range %d", len);
511514
RETURN_ERR(WL_FAILURE)
512515
}
513-
#ifdef _APP_DEBUG_
516+
#if 0
514517
printk("KEY IDX = %d\n", idx);
515518
dump(key, len);
516519
printk("KEY len %d\n", len);
@@ -990,7 +993,7 @@ cmd_spi_state_t get_reply_idx_net_cb(char* recv, char* reply, void* ctx, uint16_
990993

991994
END_HEADER_REPLY(reply, 3+len+1, *count);
992995

993-
dump(reply, *count);
996+
DUMP(reply, *count);
994997

995998
return SPI_CMD_DONE;
996999
}
@@ -1313,16 +1316,14 @@ unsigned char* getStartCmdSeq(unsigned char* _recv, int len, int *offset)
13131316
if (i!=0)
13141317
{
13151318
DEB_PIN_DN();
1316-
//WARN("Disall. %d/%d cmd:%d\n", i, len,_recv[i+1]);
1317-
WARN("D=%d\n", i);
1318-
1319+
WARN("Disall. %d/%d cmd:%d\n", i, len,_recv[i+1]);
13191320
}
13201321
*offset = i;
13211322
return &_recv[i];
13221323
}
13231324
}
13241325
DEB_PIN_DN();
1325-
WARN("D=%d\n", i);
1326+
WARN("Disall. %d\n", i);
13261327

13271328
return NULL;
13281329
}
@@ -1399,7 +1400,7 @@ int call_reply_cb(char* recv, char* reply) {
13991400
if (i==ARRAY_SIZE(cmd_spi_list))
14001401
{
14011402
WARN("Unknown cmd 0x%x\n", cmdId);
1402-
dump(recv, count);
1403+
DUMP(recv, count);
14031404
return REPLY_ERR_CMD;
14041405
}
14051406
return REPLY_NO_ERR;
@@ -1475,7 +1476,7 @@ bool checkMsgFormat(uint8_t* _recv, int len, int* offset)
14751476
unsigned char* recv = getStartCmdSeq(_recv, len, offset);
14761477
if ((recv == NULL)||(recv!=_recv))
14771478
{
1478-
if ((/*verboseDebug & */INFO_SPI_FLAG)&&(len < 20)) //TODO stamp only short messages wrong
1479+
if ((INFO_WARN_FLAG)&&(len < 20)) //TODO stamp only short messages wrong
14791480
dump((char*)_recv, len);
14801481

14811482
if (recv == NULL)
@@ -1550,7 +1551,8 @@ void spi_poll(struct netif* netif) {
15501551
{
15511552
sendError();
15521553
WARN("Check format msg failed!\n");
1553-
dump((char*)_receiveBuffer, receivedChars);
1554+
if (INFO_WARN_FLAG)
1555+
dump((char*)_receiveBuffer, receivedChars);
15541556
state = SPI_CMD_IDLE;
15551557
count=0;
15561558
}

wifiHD/src/ard_tcp.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ bool pending_accept = false;
3838

3939
static err_t tcp_data_sent(void *arg, struct tcp_pcb *pcb, u16_t len);
4040

41-
static void atcp_init()
41+
static void atcp_init_pend_flags()
4242
{
4343
pending_close = false;
44+
pending_accept = false;
4445
}
4546

4647
/**
@@ -229,7 +230,7 @@ static void atcp_conn_err_cb(void *arg, err_t err) {
229230
printk("Abort connection\n");
230231
cleanSockState_cb(_ttcp);
231232

232-
pending_close = false;
233+
atcp_init_pend_flags();
233234
}
234235

235236
static void atcp_conn_cli_err_cb(void *arg, err_t err) {
@@ -251,7 +252,7 @@ static void atcp_conn_cli_err_cb(void *arg, err_t err) {
251252
free(_ttcp);
252253
}
253254

254-
pending_close = false;
255+
atcp_init_pend_flags();
255256
}
256257

257258

@@ -265,7 +266,7 @@ static void close_conn(struct ttcp *_ttcp) {
265266
if (err == ERR_MEM)
266267
pending_close = true;
267268
else{
268-
pending_accept = false;
269+
atcp_init_pend_flags();
269270
WARN("----------------------\n");
270271
}
271272
}
@@ -339,8 +340,7 @@ static err_t atcp_poll(void *arg, struct tcp_pcb *pcb) {
339340
pcb, arg, tcp_poll_retries);
340341
tcp_poll_retries = 0;
341342
tcp_abort(pcb);
342-
pending_accept = false;
343-
pending_close = false;
343+
atcp_init_pend_flags();
344344
return ERR_ABRT;
345345
}
346346

@@ -357,7 +357,7 @@ static err_t atcp_poll(void *arg, struct tcp_pcb *pcb) {
357357
}
358358
else
359359
{
360-
pending_close = false;
360+
atcp_init_pend_flags();
361361
}
362362

363363
INFO_TCP("ARD TCP [%p-%p] try to close pending:%d\n", pcb, (_ttcp)?_ttcp->tpcb:0, pending_close);
@@ -450,7 +450,7 @@ static int atcp_start(struct ttcp* ttcp) {
450450
}
451451

452452
tcp_arg(ttcp->tpcb, ttcp);
453-
atcp_init();
453+
atcp_init_pend_flags();
454454

455455
if (ttcp->mode == TTCP_MODE_TRANSMIT) {
456456
tcp_err(ttcp->tpcb, atcp_conn_cli_err_cb);

0 commit comments

Comments
 (0)