Skip to content

Commit 6265d40

Browse files
committed
Fix issue on client side
1 parent ed45296 commit 6265d40

File tree

7 files changed

+15012
-14988
lines changed

7 files changed

+15012
-14988
lines changed
34 Bytes
Binary file not shown.

firmwares/wifishield/wifiHD/Release/wifiHD.hex

Lines changed: 14972 additions & 14968 deletions
Large diffs are not rendered by default.

firmwares/wifishield/wifiHD/src/ard_spi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ int set_ip_config_cmd_cb(int numParam, char* buf, void* ctx) {
591591

592592
}
593593
/* Disable DHCP */
594-
ncfg->dhcp_enabled = 0;
594+
ncfg->dhcp_enabled = STATIC_IP_CONFIG;
595595
}else
596596
RETURN_ERR(WL_FAILURE)
597597

@@ -635,7 +635,7 @@ int set_dns_config_cmd_cb(int numParam, char* buf, void* ctx) {
635635
}
636636
}
637637
/* Disable DHCP */
638-
ncfg->dhcp_enabled = 0;
638+
ncfg->dhcp_enabled = STATIC_IP_CONFIG;
639639
}else
640640
RETURN_ERR(WL_FAILURE)
641641

firmwares/wifishield/wifiHD/src/ard_tcp.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,14 +565,21 @@ static int atcp_start(struct ttcp* ttcp) {
565565
atcp_init_pend_flags(ttcp);
566566

567567
if (ttcp->mode == TTCP_MODE_TRANSMIT) {
568-
setNewClientConn(ttcp, p, 0);
569-
struct tcp_pcb * pcb = GET_FIRST_CLIENT_TCP(ttcp);
568+
int8_t id = insertNewClientConn(ttcp, p);
569+
ttcp->payload[id] = malloc(ttcp->buflen);
570+
INFO_TCP("Alloc payload %d-%p\n", id, ttcp->payload[id]);
571+
if (ttcp->payload[id] == NULL) {
572+
WARN("TTCP [%p]: could not allocate payload\n", ttcp);
573+
return -1;
574+
}
575+
576+
struct tcp_pcb * pcb = p;
570577
tcp_err(pcb, atcp_conn_cli_err_cb);
571578
tcp_recv(pcb, atcp_recv_cb);
572579
tcp_sent(pcb, tcp_data_sent);
573580
tcp_poll(pcb, atcp_poll_conn, 4);
574581
_connected = false;
575-
INFO_TCP("[tpcb]-%p payload:%p\n", pcb, ttcp->payload[currConnId]);
582+
INFO_TCP("[tpcb]-%p payload:%p\n", pcb, ttcp->payload[id]);
576583
DUMP_TCP_STATE(ttcp);
577584
if (tcp_connect(pcb, &ttcp->addr, ttcp->port, tcp_connect_cb)
578585
!= ERR_OK) {

firmwares/wifishield/wifiHD/src/cmd_wl.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ cmd_set_ip(int argc, char* argv[], void* ctx)
189189

190190
if (argc == 2 &&
191191
(strncmp(argv[1], "none", 4) == 0)) {
192-
ncfg->dhcp_enabled = 1;
192+
ncfg->dhcp_enabled = DYNAMIC_IP_CONFIG;
193193

194194
return CMD_DONE;
195195
}
196196
else if (argc != 4 ) {
197-
printk("usage: ip <ip> <netmask> <gateway-ip>\n");
198-
printk(" or : ip none (to enable DHCP)\n");
197+
printk("usage: ipconfig <ip> <netmask> <gateway-ip>\n");
198+
printk(" or : ipconfig none (to enable DHCP)\n");
199199
return CMD_DONE;
200200
}
201201

@@ -210,7 +210,7 @@ cmd_set_ip(int argc, char* argv[], void* ctx)
210210
lwip_addr = str2ip(argv[3]);
211211
netif_set_gw(nif, &lwip_addr);
212212
/* Disable DHCP */
213-
ncfg->dhcp_enabled = 0;
213+
ncfg->dhcp_enabled = STATIC_IP_CONFIG;
214214

215215
return CMD_DONE;
216216
}
@@ -458,7 +458,11 @@ cmd_status(int argc, char* argv[], void* ctx)
458458

459459
/* print ip address */
460460
if (netif_is_up(netif_default))
461-
printk("ip addr: %s\n", ip2str(netif_default->ip_addr));
461+
{
462+
printk("ip addr: %s - ", ip2str(netif_default->ip_addr));
463+
printk("netmask: %s - ", ip2str(netif_default->netmask));
464+
printk("gateway: %s\n", ip2str(netif_default->gw));
465+
}
462466
else
463467
printk("ip interface is down\n");
464468
printk("dhcp : ");
@@ -471,8 +475,8 @@ cmd_status(int argc, char* argv[], void* ctx)
471475
struct ip_addr addr1 = dns_getserver(0);
472476
struct ip_addr addr2 = dns_getserver(1);
473477

474-
printk("==> DNS1: %s\n", ip2str(addr1), addr1);
475-
printk("==> DNS2: %s\n", ip2str(addr2), addr2);
478+
printk("DNS: %s - ", ip2str(addr1));
479+
printk("%s\n", ip2str(addr2));
476480

477481
showTTCPstatus();
478482
return CMD_DONE;

firmwares/wifishield/wifiHD/src/lwip_setup.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef _LWIP_SETUP_H
22
#define _LWIP_SETUP_H
33

4+
#define INIT_IP_CONFIG 0xff
5+
#define STATIC_IP_CONFIG 0
6+
#define DYNAMIC_IP_CONFIG 1
7+
48
struct net_cfg {
59
struct netif *netif; /* lwip network interface */
610
uint8_t dhcp_enabled;

firmwares/wifishield/wifiHD/src/main.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ void initShell(void* ctx)
277277
console_add_cmd("debug", cmd_debug, NULL);
278278
console_add_cmd("dumpBuf", cmd_dumpBuf, NULL);
279279
console_add_cmd("ipconfig", cmd_set_ip, ctx);
280-
281280
#ifdef ADD_CMDS
282281
console_add_cmd("powersave", cmd_power, NULL);
283282
console_add_cmd("psconf", cmd_psconf, NULL);
@@ -314,12 +313,15 @@ wl_init_complete_cb(void* ctx)
314313
struct ip_addr ipaddr, netmask, gw;
315314
wl_err_t wl_status;
316315

317-
IP4_ADDR(&gw, 0,0,0,0);
318-
IP4_ADDR(&ipaddr, 0,0,0,0);
319-
IP4_ADDR(&netmask, 0,0,0,0);
320-
321-
/* default is dhcp enabled */
322-
hs->net_cfg.dhcp_enabled = 1;
316+
if (hs->net_cfg.dhcp_enabled == INIT_IP_CONFIG)
317+
{
318+
IP4_ADDR(&gw, 0,0,0,0);
319+
IP4_ADDR(&ipaddr, 0,0,0,0);
320+
IP4_ADDR(&netmask, 0,0,0,0);
321+
322+
/* default is dhcp enabled */
323+
hs->net_cfg.dhcp_enabled = DYNAMIC_IP_CONFIG;
324+
}
323325

324326
start_ip_stack(&hs->net_cfg,
325327
ipaddr,
@@ -358,6 +360,8 @@ void startup_init(void)
358360
DEB_PIN_UP(2);
359361
}
360362

363+
const char timestamp[] = __TIMESTAMP__;
364+
361365
/**
362366
*
363367
*/
@@ -390,7 +394,7 @@ main(void)
390394

391395
}
392396
#else
393-
printk("Arduino Wifi Startup... [%s]\n", __TIMESTAMP__);
397+
printk("Arduino Wifi Startup... [%s]\n", timestamp);
394398

395399
size_t size_ctx_server = sizeof(struct ctx_server);
396400
hs = calloc(1, size_ctx_server);
@@ -399,6 +403,7 @@ main(void)
399403
size_t size_netif = sizeof(struct netif);
400404
hs->net_cfg.netif = calloc(1, size_netif);
401405
ASSERT(hs->net_cfg.netif, "out of memory");
406+
hs->net_cfg.dhcp_enabled = INIT_IP_CONFIG;
402407

403408
INFO_INIT("hs:%p size:0x%x netif:%p size:0x%x\n", hs, size_ctx_server,
404409
hs->net_cfg.netif, size_netif);

0 commit comments

Comments
 (0)