aboutsummaryrefslogtreecommitdiff
path: root/firmwares/wifishield/wifiHD/src
diff options
context:
space:
mode:
authorMimmo La Fauci <mlafauci@metodo2.it>2013-03-26 19:49:19 +0100
committerMimmo La Fauci <mlafauci@metodo2.it>2013-03-26 19:49:19 +0100
commit6265d401817934c4b2d9ee3bf8dab44de1bb08cb (patch)
treef284f5c1f16209da9a5be3364bcb4c9cd9ed9dfb /firmwares/wifishield/wifiHD/src
parented452961326cd5f9ad6d766bc8340a6193d16d64 (diff)
Fix issue on client side
Diffstat (limited to 'firmwares/wifishield/wifiHD/src')
-rw-r--r--firmwares/wifishield/wifiHD/src/ard_spi.c4
-rw-r--r--firmwares/wifishield/wifiHD/src/ard_tcp.c13
-rw-r--r--firmwares/wifishield/wifiHD/src/cmd_wl.c18
-rw-r--r--firmwares/wifishield/wifiHD/src/lwip_setup.h4
-rw-r--r--firmwares/wifishield/wifiHD/src/main.c21
5 files changed, 40 insertions, 20 deletions
diff --git a/firmwares/wifishield/wifiHD/src/ard_spi.c b/firmwares/wifishield/wifiHD/src/ard_spi.c
index b79c1fc..8bd288b 100644
--- a/firmwares/wifishield/wifiHD/src/ard_spi.c
+++ b/firmwares/wifishield/wifiHD/src/ard_spi.c
@@ -591,7 +591,7 @@ int set_ip_config_cmd_cb(int numParam, char* buf, void* ctx) {
}
/* Disable DHCP */
- ncfg->dhcp_enabled = 0;
+ ncfg->dhcp_enabled = STATIC_IP_CONFIG;
}else
RETURN_ERR(WL_FAILURE)
@@ -635,7 +635,7 @@ int set_dns_config_cmd_cb(int numParam, char* buf, void* ctx) {
}
}
/* Disable DHCP */
- ncfg->dhcp_enabled = 0;
+ ncfg->dhcp_enabled = STATIC_IP_CONFIG;
}else
RETURN_ERR(WL_FAILURE)
diff --git a/firmwares/wifishield/wifiHD/src/ard_tcp.c b/firmwares/wifishield/wifiHD/src/ard_tcp.c
index c15858f..0a73b20 100644
--- a/firmwares/wifishield/wifiHD/src/ard_tcp.c
+++ b/firmwares/wifishield/wifiHD/src/ard_tcp.c
@@ -565,14 +565,21 @@ static int atcp_start(struct ttcp* ttcp) {
atcp_init_pend_flags(ttcp);
if (ttcp->mode == TTCP_MODE_TRANSMIT) {
- setNewClientConn(ttcp, p, 0);
- struct tcp_pcb * pcb = GET_FIRST_CLIENT_TCP(ttcp);
+ int8_t id = insertNewClientConn(ttcp, p);
+ ttcp->payload[id] = malloc(ttcp->buflen);
+ INFO_TCP("Alloc payload %d-%p\n", id, ttcp->payload[id]);
+ if (ttcp->payload[id] == NULL) {
+ WARN("TTCP [%p]: could not allocate payload\n", ttcp);
+ return -1;
+ }
+
+ struct tcp_pcb * pcb = p;
tcp_err(pcb, atcp_conn_cli_err_cb);
tcp_recv(pcb, atcp_recv_cb);
tcp_sent(pcb, tcp_data_sent);
tcp_poll(pcb, atcp_poll_conn, 4);
_connected = false;
- INFO_TCP("[tpcb]-%p payload:%p\n", pcb, ttcp->payload[currConnId]);
+ INFO_TCP("[tpcb]-%p payload:%p\n", pcb, ttcp->payload[id]);
DUMP_TCP_STATE(ttcp);
if (tcp_connect(pcb, &ttcp->addr, ttcp->port, tcp_connect_cb)
!= ERR_OK) {
diff --git a/firmwares/wifishield/wifiHD/src/cmd_wl.c b/firmwares/wifishield/wifiHD/src/cmd_wl.c
index 17c476a..3985072 100644
--- a/firmwares/wifishield/wifiHD/src/cmd_wl.c
+++ b/firmwares/wifishield/wifiHD/src/cmd_wl.c
@@ -189,13 +189,13 @@ cmd_set_ip(int argc, char* argv[], void* ctx)
if (argc == 2 &&
(strncmp(argv[1], "none", 4) == 0)) {
- ncfg->dhcp_enabled = 1;
+ ncfg->dhcp_enabled = DYNAMIC_IP_CONFIG;
return CMD_DONE;
}
else if (argc != 4 ) {
- printk("usage: ip <ip> <netmask> <gateway-ip>\n");
- printk(" or : ip none (to enable DHCP)\n");
+ printk("usage: ipconfig <ip> <netmask> <gateway-ip>\n");
+ printk(" or : ipconfig none (to enable DHCP)\n");
return CMD_DONE;
}
@@ -210,7 +210,7 @@ cmd_set_ip(int argc, char* argv[], void* ctx)
lwip_addr = str2ip(argv[3]);
netif_set_gw(nif, &lwip_addr);
/* Disable DHCP */
- ncfg->dhcp_enabled = 0;
+ ncfg->dhcp_enabled = STATIC_IP_CONFIG;
return CMD_DONE;
}
@@ -458,7 +458,11 @@ cmd_status(int argc, char* argv[], void* ctx)
/* print ip address */
if (netif_is_up(netif_default))
- printk("ip addr: %s\n", ip2str(netif_default->ip_addr));
+ {
+ printk("ip addr: %s - ", ip2str(netif_default->ip_addr));
+ printk("netmask: %s - ", ip2str(netif_default->netmask));
+ printk("gateway: %s\n", ip2str(netif_default->gw));
+ }
else
printk("ip interface is down\n");
printk("dhcp : ");
@@ -471,8 +475,8 @@ cmd_status(int argc, char* argv[], void* ctx)
struct ip_addr addr1 = dns_getserver(0);
struct ip_addr addr2 = dns_getserver(1);
- printk("==> DNS1: %s\n", ip2str(addr1), addr1);
- printk("==> DNS2: %s\n", ip2str(addr2), addr2);
+ printk("DNS: %s - ", ip2str(addr1));
+ printk("%s\n", ip2str(addr2));
showTTCPstatus();
return CMD_DONE;
diff --git a/firmwares/wifishield/wifiHD/src/lwip_setup.h b/firmwares/wifishield/wifiHD/src/lwip_setup.h
index d149174..7edf2b5 100644
--- a/firmwares/wifishield/wifiHD/src/lwip_setup.h
+++ b/firmwares/wifishield/wifiHD/src/lwip_setup.h
@@ -1,6 +1,10 @@
#ifndef _LWIP_SETUP_H
#define _LWIP_SETUP_H
+#define INIT_IP_CONFIG 0xff
+#define STATIC_IP_CONFIG 0
+#define DYNAMIC_IP_CONFIG 1
+
struct net_cfg {
struct netif *netif; /* lwip network interface */
uint8_t dhcp_enabled;
diff --git a/firmwares/wifishield/wifiHD/src/main.c b/firmwares/wifishield/wifiHD/src/main.c
index 4b1f06f..5800ba8 100644
--- a/firmwares/wifishield/wifiHD/src/main.c
+++ b/firmwares/wifishield/wifiHD/src/main.c
@@ -277,7 +277,6 @@ void initShell(void* ctx)
console_add_cmd("debug", cmd_debug, NULL);
console_add_cmd("dumpBuf", cmd_dumpBuf, NULL);
console_add_cmd("ipconfig", cmd_set_ip, ctx);
-
#ifdef ADD_CMDS
console_add_cmd("powersave", cmd_power, NULL);
console_add_cmd("psconf", cmd_psconf, NULL);
@@ -314,12 +313,15 @@ wl_init_complete_cb(void* ctx)
struct ip_addr ipaddr, netmask, gw;
wl_err_t wl_status;
- IP4_ADDR(&gw, 0,0,0,0);
- IP4_ADDR(&ipaddr, 0,0,0,0);
- IP4_ADDR(&netmask, 0,0,0,0);
-
- /* default is dhcp enabled */
- hs->net_cfg.dhcp_enabled = 1;
+ if (hs->net_cfg.dhcp_enabled == INIT_IP_CONFIG)
+ {
+ IP4_ADDR(&gw, 0,0,0,0);
+ IP4_ADDR(&ipaddr, 0,0,0,0);
+ IP4_ADDR(&netmask, 0,0,0,0);
+
+ /* default is dhcp enabled */
+ hs->net_cfg.dhcp_enabled = DYNAMIC_IP_CONFIG;
+ }
start_ip_stack(&hs->net_cfg,
ipaddr,
@@ -358,6 +360,8 @@ void startup_init(void)
DEB_PIN_UP(2);
}
+const char timestamp[] = __TIMESTAMP__;
+
/**
*
*/
@@ -390,7 +394,7 @@ main(void)
}
#else
- printk("Arduino Wifi Startup... [%s]\n", __TIMESTAMP__);
+ printk("Arduino Wifi Startup... [%s]\n", timestamp);
size_t size_ctx_server = sizeof(struct ctx_server);
hs = calloc(1, size_ctx_server);
@@ -399,6 +403,7 @@ main(void)
size_t size_netif = sizeof(struct netif);
hs->net_cfg.netif = calloc(1, size_netif);
ASSERT(hs->net_cfg.netif, "out of memory");
+ hs->net_cfg.dhcp_enabled = INIT_IP_CONFIG;
INFO_INIT("hs:%p size:0x%x netif:%p size:0x%x\n", hs, size_ctx_server,
hs->net_cfg.netif, size_netif);