1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-17 06:52:18 +01:00

Bugfix on Test Report 12.01.2012

This commit is contained in:
Domenico La Fauci 2012-01-30 00:07:39 +01:00
parent 7fb3a05baa
commit 5778170fa6
15 changed files with 273 additions and 99 deletions

Binary file not shown.

View File

@ -56,7 +56,7 @@
<option id="gnu.c.compiler.option.optimization.flags.1362317068" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="-fdata-sections" valueType="string"/> <option id="gnu.c.compiler.option.optimization.flags.1362317068" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="-fdata-sections" valueType="string"/>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.2032815329" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> <option id="gnu.c.compiler.option.preprocessor.def.symbols.2032815329" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="BOARD=ARDUINO"/> <listOptionValue builtIn="false" value="BOARD=ARDUINO"/>
<listOptionValue builtIn="false" value="_APP_DEBUG_"/> <listOptionValue builtIn="false" value="NO_SYS"/>
<listOptionValue builtIn="false" value="_DEBUG_"/> <listOptionValue builtIn="false" value="_DEBUG_"/>
<listOptionValue builtIn="false" value="_ASSERT_ENABLE_"/> <listOptionValue builtIn="false" value="_ASSERT_ENABLE_"/>
<listOptionValue builtIn="false" value="EXT_BOARD=SPB104"/> <listOptionValue builtIn="false" value="EXT_BOARD=SPB104"/>
@ -64,7 +64,6 @@
<listOptionValue builtIn="false" value="WITH_WPA"/> <listOptionValue builtIn="false" value="WITH_WPA"/>
<listOptionValue builtIn="false" value="WITH_NO_DMA"/> <listOptionValue builtIn="false" value="WITH_NO_DMA"/>
<listOptionValue builtIn="false" value="DATAFLASH=1"/> <listOptionValue builtIn="false" value="DATAFLASH=1"/>
<listOptionValue builtIn="false" value="LWIP_DEBUG"/>
</option> </option>
<option id="gnu.c.compiler.option.include.paths.199111087" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <option id="gnu.c.compiler.option.include.paths.199111087" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="../src/SOFTWARE_FRAMEWORK/DRIVERS/PDCA"/> <listOptionValue builtIn="false" value="../src/SOFTWARE_FRAMEWORK/DRIVERS/PDCA"/>
@ -95,6 +94,12 @@
<listOptionValue builtIn="false" value="../src/SOFTWARE_FRAMEWORK/COMPONENTS/WIFI/HD"/> <listOptionValue builtIn="false" value="../src/SOFTWARE_FRAMEWORK/COMPONENTS/WIFI/HD"/>
</option> </option>
<option id="avr32.c.compiler.option.flashvault.1511808014" name="Enable FlashVault support" superClass="avr32.c.compiler.option.flashvault" value="false" valueType="boolean"/> <option id="avr32.c.compiler.option.flashvault.1511808014" name="Enable FlashVault support" superClass="avr32.c.compiler.option.flashvault" value="false" valueType="boolean"/>
<option id="avr32.c.compiler.option.fpic.1413737757" name="Generate position-independent code" superClass="avr32.c.compiler.option.fpic" value="false" valueType="boolean"/>
<option id="avr32.c.compiler.option.mforce-double-align.1833231832" name="Force double-word alignment" superClass="avr32.c.compiler.option.mforce-double-align" value="false" valueType="boolean"/>
<option id="gnu.c.compiler.option.warnings.pedantic.error.266375625" name="Pedantic warnings as errors (-pedantic-errors)" superClass="gnu.c.compiler.option.warnings.pedantic.error" value="false" valueType="boolean"/>
<option id="gnu.c.compiler.option.warnings.toerrors.1148543352" name="Warnings as errors (-Werror)" superClass="gnu.c.compiler.option.warnings.toerrors" value="false" valueType="boolean"/>
<option id="gnu.c.compiler.option.misc.verbose.1690548506" name="Verbose (-v)" superClass="gnu.c.compiler.option.misc.verbose" value="false" valueType="boolean"/>
<option id="gnu.c.compiler.option.misc.other.617535058" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0" valueType="string"/>
<inputType id="avr32.managedbuild.tool.gnu.c.compiler.input.253539519" superClass="avr32.managedbuild.tool.gnu.c.compiler.input"/> <inputType id="avr32.managedbuild.tool.gnu.c.compiler.input.253539519" superClass="avr32.managedbuild.tool.gnu.c.compiler.input"/>
</tool> </tool>
<tool id="avr32.managedbuild.tool.gnu.c.linker.exe.debug.1134510857" name="32-bit AVR/GNU C Linker" superClass="avr32.managedbuild.tool.gnu.c.linker.exe.debug"> <tool id="avr32.managedbuild.tool.gnu.c.linker.exe.debug.1134510857" name="32-bit AVR/GNU C Linker" superClass="avr32.managedbuild.tool.gnu.c.linker.exe.debug">
@ -113,6 +118,8 @@
</option> </option>
<option id="gnu.c.link.option.strip.878241046" name="Omit all symbol information (-s)" superClass="gnu.c.link.option.strip" value="false" valueType="boolean"/> <option id="gnu.c.link.option.strip.878241046" name="Omit all symbol information (-s)" superClass="gnu.c.link.option.strip" value="false" valueType="boolean"/>
<option id="avr32.c.linker.option.gc-sections.1193662367" name="Garbage collect unused sections" superClass="avr32.c.linker.option.gc-sections" value="true" valueType="boolean"/> <option id="avr32.c.linker.option.gc-sections.1193662367" name="Garbage collect unused sections" superClass="avr32.c.linker.option.gc-sections" value="true" valueType="boolean"/>
<option id="avr32.c.linker.option.rodata-writable.1710110734" name="Put read-only data in writable data section" superClass="avr32.c.linker.option.rodata-writable" value="true" valueType="boolean"/>
<option id="avr32.c.linker.option.fpic.953076621" name="Generate position-independent code" superClass="avr32.c.linker.option.fpic" value="false" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.974320538" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.974320538" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/>
@ -187,7 +194,7 @@
</folderInfo> </folderInfo>
<sourceEntries> <sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/SOFTWARE_FRAMEWORK/COMPONENTS/MEMORY/DATA_FLASH/AT45DBX"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/SOFTWARE_FRAMEWORK/COMPONENTS/MEMORY/DATA_FLASH/AT45DBX"/>
<entry excluding="ttcp.h|ttcp.c|fsdata.c|hdwireless_gif.h|http_server_gui.h|http_server_gui.c|SOFTWARE_FRAMEWORK/COMPONENTS/TOUCH|SOFTWARE_FRAMEWORK/DRIVERS/ADC|SOFTWARE_FRAMEWORK/COMPONENTS/WIFI/HD/wl_fw.h|gui.c|SOFTWARE_FRAMEWORK/DRIVERS/EBI/SMC|SOFTWARE_FRAMEWORK/COMPONENTS/MEMORY|SOFTWARE_FRAMEWORK/COMPONENTS/DISPLAY/ET024006DHU|gui_getstring.c|SOFTWARE_FRAMEWORK/BOARDS/EVK1105" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> <entry excluding="ping.c|ttcp.h|ttcp.c|fsdata.c|hdwireless_gif.h|http_server_gui.h|http_server_gui.c|SOFTWARE_FRAMEWORK/COMPONENTS/TOUCH|SOFTWARE_FRAMEWORK/DRIVERS/ADC|SOFTWARE_FRAMEWORK/COMPONENTS/WIFI/HD/wl_fw.h|gui.c|SOFTWARE_FRAMEWORK/DRIVERS/EBI/SMC|SOFTWARE_FRAMEWORK/COMPONENTS/MEMORY|SOFTWARE_FRAMEWORK/COMPONENTS/DISPLAY/ET024006DHU|gui_getstring.c|SOFTWARE_FRAMEWORK/BOARDS/EVK1105" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries> </sourceEntries>
</configuration> </configuration>
</storageModule> </storageModule>
@ -1101,6 +1108,7 @@
<listOptionValue builtIn="false" value="../src/SOFTWARE_FRAMEWORK/COMPONENTS/WIFI/HD"/> <listOptionValue builtIn="false" value="../src/SOFTWARE_FRAMEWORK/COMPONENTS/WIFI/HD"/>
</option> </option>
<option id="avr32.c.compiler.option.flashvault.579935240" name="Enable FlashVault support" superClass="avr32.c.compiler.option.flashvault" value="false" valueType="boolean"/> <option id="avr32.c.compiler.option.flashvault.579935240" name="Enable FlashVault support" superClass="avr32.c.compiler.option.flashvault" value="false" valueType="boolean"/>
<option id="avr32.c.compiler.option.muse-rodata-section.46188949" name="Use section .rodata for read-only data" superClass="avr32.c.compiler.option.muse-rodata-section" value="false" valueType="boolean"/>
<inputType id="avr32.managedbuild.tool.gnu.c.compiler.input.233400464" superClass="avr32.managedbuild.tool.gnu.c.compiler.input"/> <inputType id="avr32.managedbuild.tool.gnu.c.compiler.input.233400464" superClass="avr32.managedbuild.tool.gnu.c.compiler.input"/>
</tool> </tool>
<tool id="avr32.managedbuild.tool.gnu.c.linker.exe.release.166522415" name="32-bit AVR/GNU C Linker" superClass="avr32.managedbuild.tool.gnu.c.linker.exe.release"> <tool id="avr32.managedbuild.tool.gnu.c.linker.exe.release.166522415" name="32-bit AVR/GNU C Linker" superClass="avr32.managedbuild.tool.gnu.c.linker.exe.release">
@ -1191,7 +1199,7 @@
</folderInfo> </folderInfo>
<sourceEntries> <sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/SOFTWARE_FRAMEWORK/COMPONENTS/MEMORY/DATA_FLASH/AT45DBX"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/SOFTWARE_FRAMEWORK/COMPONENTS/MEMORY/DATA_FLASH/AT45DBX"/>
<entry excluding="ttcp.h|ttcp.c|fsdata.c|hdwireless_gif.h|http_server_gui.h|http_server_gui.c|SOFTWARE_FRAMEWORK/COMPONENTS/TOUCH|SOFTWARE_FRAMEWORK/DRIVERS/ADC|SOFTWARE_FRAMEWORK/COMPONENTS/WIFI/HD/wl_fw.h|gui.c|SOFTWARE_FRAMEWORK/DRIVERS/EBI/SMC|SOFTWARE_FRAMEWORK/COMPONENTS/MEMORY|SOFTWARE_FRAMEWORK/COMPONENTS/DISPLAY/ET024006DHU|gui_getstring.c|SOFTWARE_FRAMEWORK/BOARDS/EVK1105" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> <entry excluding="ping.c|ttcp.h|ttcp.c|fsdata.c|hdwireless_gif.h|http_server_gui.h|http_server_gui.c|SOFTWARE_FRAMEWORK/COMPONENTS/TOUCH|SOFTWARE_FRAMEWORK/DRIVERS/ADC|SOFTWARE_FRAMEWORK/COMPONENTS/WIFI/HD/wl_fw.h|gui.c|SOFTWARE_FRAMEWORK/DRIVERS/EBI/SMC|SOFTWARE_FRAMEWORK/COMPONENTS/MEMORY|SOFTWARE_FRAMEWORK/COMPONENTS/DISPLAY/ET024006DHU|gui_getstring.c|SOFTWARE_FRAMEWORK/BOARDS/EVK1105" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries> </sourceEntries>
</configuration> </configuration>
</storageModule> </storageModule>

View File

@ -27,7 +27,7 @@
</dictionary> </dictionary>
<dictionary> <dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key> <key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/wifiHD/Release}</value> <value>${workspace_loc:/wifiHD/Debug}</value>
</dictionary> </dictionary>
<dictionary> <dictionary>
<key>org.eclipse.cdt.make.core.contents</key> <key>org.eclipse.cdt.make.core.contents</key>
@ -60,6 +60,11 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>com.atmel.avr32.managedbuilder.ui.extras.ListingBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>com.atmel.avr32.core.nature</nature> <nature>com.atmel.avr32.core.nature</nature>
@ -76,7 +81,7 @@
<link> <link>
<name>include</name> <name>include</name>
<type>2</type> <type>2</type>
<location>/usr/avr32/include</location> <location>C:/usr/avr32/include</location>
</link> </link>
</linkedResources> </linkedResources>
</projectDescription> </projectDescription>

View File

@ -84,7 +84,7 @@
//! Number of LEDs. //! Number of LEDs.
#define LED_COUNT 3 #define LED_COUNT 0
/*! \name GPIO Connections of LEDs /*! \name GPIO Connections of LEDs
*/ */
@ -114,8 +114,8 @@
*/ */
//! @{ //! @{
#define LED_MONO0_GREEN LED0 #define LED_MONO0_GREEN LED0
#define LED_MONO1_GREEN LED1 #define LED_MONO1_RED LED1
#define LED_MONO2_GREEN LED2 #define LED_MONO2_BLU LED2
//! @} //! @}
#if 0 #if 0

View File

@ -94,6 +94,7 @@ typedef struct sCmd_spi_list{
static tCmd_spi_list cmd_spi_list[MAX_CMD_NUM] = { {0} }; static tCmd_spi_list cmd_spi_list[MAX_CMD_NUM] = { {0} };
#ifdef _SPI_STATS_
typedef struct sStatSpi typedef struct sStatSpi
{ {
int timeoutIntErr; int timeoutIntErr;
@ -145,6 +146,7 @@ cmd_resetStatSpi(int argc, char* argv[], void* ctx)
initStatSpi(); initStatSpi();
return CMD_DONE; return CMD_DONE;
} }
#endif
#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0]) #define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])
#define RETURN_ERR(e) return (e==WL_SUCCESS) ? WIFI_SPI_ACK : WIFI_SPI_ERR; #define RETURN_ERR(e) return (e==WL_SUCCESS) ? WIFI_SPI_ACK : WIFI_SPI_ERR;
@ -201,10 +203,12 @@ int write_stream(volatile avr32_spi_t *spi, const char *stream, uint16_t len)
//SIGN1_DN(); //SIGN1_DN();
if (spi_write(spi, *stream) == SPI_ERROR_TIMEOUT) if (spi_write(spi, *stream) == SPI_ERROR_TIMEOUT)
{ {
#ifdef _SPI_STATS_
statSpi.timeoutErr++; statSpi.timeoutErr++;
statSpi.txErr++; statSpi.txErr++;
statSpi.lastError = SPI_ERROR_TIMEOUT; statSpi.lastError = SPI_ERROR_TIMEOUT;
statSpi.status = spi_getStatus(spi); statSpi.status = spi_getStatus(spi);
#endif
return SPI_ERROR_TIMEOUT; return SPI_ERROR_TIMEOUT;
} }
else else
@ -238,8 +242,10 @@ int write_stream(volatile avr32_spi_t *spi, const char *stream, uint16_t len)
if (!streamExit) if (!streamExit)
{ {
#ifdef _SPI_STATS_
statSpi.wrongFrame++; statSpi.wrongFrame++;
statSpi.lastError = SPI_ERROR_ARGUMENT; statSpi.lastError = SPI_ERROR_ARGUMENT;
#endif
return SPI_ERROR_ARGUMENT; return SPI_ERROR_ARGUMENT;
} }
if ((ARD_SPI->sr & AVR32_SPI_SR_RDRF_MASK) != 0) if ((ARD_SPI->sr & AVR32_SPI_SR_RDRF_MASK) != 0)
@ -317,13 +323,13 @@ int set_net_cmd_cb(int numParam, char* buf, void* ctx) {
memcpy(ssid.ssid, &param->param, param->paramLen); memcpy(ssid.ssid, &param->param, param->paramLen);
ssid.len = param->paramLen; ssid.len = param->paramLen;
ssid.ssid[ssid.len] = 0; ssid.ssid[ssid.len] = 0;
printk("SSID:%s\n", ssid.ssid); INFO("SSID:%s\n", ssid.ssid);
//dump(ssid.ssid, ssid.len); //dump(ssid.ssid, ssid.len);
err = wl_cm_set_network(&ssid, NULL); err = wl_cm_set_network(&ssid, NULL);
if (err != 1) if (err != 1)
printk("err=%d\n", err); WARN("err=%d\n", err);
} else { } else {
printk("SSID len out of range"); WARN("SSID len out of range");
} }
return err; return err;
} }
@ -339,7 +345,7 @@ int set_key_cmd_cb(int numParam, char* buf, void* ctx) {
wl_err_t err = WL_SUCCESS; wl_err_t err = WL_SUCCESS;
tParam* params = (tParam*) buf; tParam* params = (tParam*) buf;
printk("%s params=%d\n", __FUNCTION__, numParam); INFO("%s params=%d\n", __FUNCTION__, numParam);
// SSID // SSID
memset(&ssid, 0, sizeof ssid); memset(&ssid, 0, sizeof ssid);
@ -347,9 +353,9 @@ int set_key_cmd_cb(int numParam, char* buf, void* ctx) {
if (params->paramLen < WL_SSID_MAX_LENGTH) { if (params->paramLen < WL_SSID_MAX_LENGTH) {
memcpy(ssid.ssid, &params->param, params->paramLen); memcpy(ssid.ssid, &params->param, params->paramLen);
ssid.len = params->paramLen; ssid.len = params->paramLen;
printk("%s\n", ssid.ssid); INFO("%s\n", ssid.ssid);
} else { } else {
printk("SSID len out of range"); //printk("SSID len out of range");
RETURN_ERR(WL_FAILURE) RETURN_ERR(WL_FAILURE)
} }
@ -360,7 +366,7 @@ int set_key_cmd_cb(int numParam, char* buf, void* ctx) {
idx = (uint8_t)atoi(keyIdx); idx = (uint8_t)atoi(keyIdx);
// KEY IDX // KEY IDX
if ((params->paramLen != 1)||(idx < 0)||(idx > 3)){ if ((params->paramLen != 1)||(idx < 0)||(idx > 3)){
printk("KEY IDX out of range %d\n", idx); //printk("KEY IDX out of range %d\n", idx);
RETURN_ERR(WL_FAILURE) RETURN_ERR(WL_FAILURE)
} }
@ -371,7 +377,7 @@ int set_key_cmd_cb(int numParam, char* buf, void* ctx) {
// KEY // KEY
if (( len != 5)&&(len != 13)) if (( len != 5)&&(len != 13))
{ {
printk("KEY len out of range %d", len); //printk("KEY len out of range %d", len);
RETURN_ERR(WL_FAILURE) RETURN_ERR(WL_FAILURE)
} }
#ifdef _APP_DEBUG_ #ifdef _APP_DEBUG_
@ -398,7 +404,7 @@ int set_passphrase_cmd_cb(int numParam, char* buf, void* ctx) {
wl_err_t err = WL_SUCCESS; wl_err_t err = WL_SUCCESS;
tParam* params = (tParam*) buf; tParam* params = (tParam*) buf;
printk("%s params=%d\n", __FUNCTION__, numParam); INFO("%s params=%d\n", __FUNCTION__, numParam);
memset(&net, 0, sizeof net); memset(&net, 0, sizeof net);
memset(net.bssid.octet, 0xFF, sizeof net.bssid.octet); memset(net.bssid.octet, 0xFF, sizeof net.bssid.octet);
@ -409,9 +415,9 @@ int set_passphrase_cmd_cb(int numParam, char* buf, void* ctx) {
if (params->paramLen < WL_SSID_MAX_LENGTH) { if (params->paramLen < WL_SSID_MAX_LENGTH) {
memcpy(net.ssid.ssid, &params->param, params->paramLen); memcpy(net.ssid.ssid, &params->param, params->paramLen);
net.ssid.len = params->paramLen; net.ssid.len = params->paramLen;
printk("%s\n", net.ssid.ssid); INFO("%s %d\n", net.ssid.ssid, net.ssid.len);
} else { } else {
printk("SSID len out of range"); //printk("SSID len out of range");
RETURN_ERR(WL_FAILURE) RETURN_ERR(WL_FAILURE)
} }
params = (tParam*)((char*)buf+PARAM_LEN_SIZE+params->paramLen); params = (tParam*)((char*)buf+PARAM_LEN_SIZE+params->paramLen);
@ -419,7 +425,7 @@ int set_passphrase_cmd_cb(int numParam, char* buf, void* ctx) {
strncpy(pass, (const char*)&params->param, params->paramLen); strncpy(pass, (const char*)&params->param, params->paramLen);
pass[(uint8_t)params->paramLen]='\0'; pass[(uint8_t)params->paramLen]='\0';
printk("Pass: %s %d\n", pass, params->paramLen); INFO("Pass: %s %d\n", pass, params->paramLen);
if (wl_set_passphrase(&net, if (wl_set_passphrase(&net,
pass, pass,
@ -427,14 +433,17 @@ int set_passphrase_cmd_cb(int numParam, char* buf, void* ctx) {
ENC_TYPE_AUTO, ENC_TYPE_AUTO,
AUTH_MODE_AUTO) AUTH_MODE_AUTO)
!= WL_SUCCESS) { != WL_SUCCESS) {
printk("%s : Failed to add passphrase\n", __func__); WARN("%s : Failed to add passphrase\n", __func__);
RETURN_ERR(WL_FAILURE) RETURN_ERR(WL_FAILURE)
} }
printk("Connect to network...");
//Connect //Connect
err = wl_cm_set_network(&net.ssid, NULL); err = wl_cm_set_network(&net.ssid, NULL);
if (err != 1) if (err != 1)
printk("err=%d\n", err); printk("err=%d\n", err);
else
printk("OK\n");
RETURN_ERR(err) RETURN_ERR(err)
} }
@ -451,6 +460,7 @@ void set_result_cmd(int err)
{ {
case WL_SUCCESS: case WL_SUCCESS:
set_result(WL_CONNECTED); set_result(WL_CONNECTED);
ERROR_LED_OFF();
break; break;
default: default:
case WL_OOM: case WL_OOM:
@ -462,6 +472,7 @@ void set_result_cmd(int err)
case WL_RETRY: case WL_RETRY:
case WL_FAILURE: case WL_FAILURE:
set_result(WL_CONNECT_FAILED); set_result(WL_CONNECT_FAILED);
ERROR_LED_ON();
break; break;
} }
printk("%s %d\n", __FUNCTION__, result); printk("%s %d\n", __FUNCTION__, result);
@ -495,12 +506,12 @@ int start_server_tcp_cmd_cb(int numParam, char* buf, void* ctx) {
if (sock >= MAX_SOCK_NUM) if (sock >= MAX_SOCK_NUM)
return WIFI_SPI_ERR; return WIFI_SPI_ERR;
printk("Start Server [%d, %d]\n", port, sock); INFO("Start Server [%d, %d]\n", port, sock);
if (ard_tcp_start(addr, port, NULL, NULL, mode, nbuf, buflen, udp, verbose, sock, &_ttcp) == 0) if (ard_tcp_start(addr, port, NULL, NULL, mode, nbuf, buflen, udp, verbose, sock, &_ttcp) == 0)
{ {
if (sock < MAX_SOCK_NUM) if (sock < MAX_SOCK_NUM)
mapSockTCP[sock]=_ttcp; mapSockTCP[sock]=_ttcp;
printk("Map [%d, %p]\n", sock, _ttcp); INFO("Map [%d, %p]\n", sock, _ttcp);
err = WL_SUCCESS; err = WL_SUCCESS;
} }
} }
@ -533,22 +544,43 @@ int start_client_tcp_cmd_cb(int numParam, char* buf, void* ctx) {
if (sock >= MAX_SOCK_NUM) if (sock >= MAX_SOCK_NUM)
return WIFI_SPI_ERR; return WIFI_SPI_ERR;
printk("Start Client [0x%x, %d, %d]\n", addr, port, sock); INFO("Start Client [0x%x, %d, %d]\n", addr, port, sock);
if (ard_tcp_start((struct ip_addr)addr, port, NULL, NULL, mode, nbuf, buflen, udp, verbose, sock, &_ttcp) == 0) if (ard_tcp_start((struct ip_addr)addr, port, NULL, NULL, mode, nbuf, buflen, udp, verbose, sock, &_ttcp) == 0)
{ {
if (sock < MAX_SOCK_NUM) if (sock < MAX_SOCK_NUM)
mapSockTCP[sock]=_ttcp; mapSockTCP[sock]=_ttcp;
printk("Map [%d, %p]\n", sock, _ttcp); INFO("Map [%d, %p]\n", sock, _ttcp);
err = WL_SUCCESS; err = WL_SUCCESS;
} }
} }
return (err==WL_SUCCESS) ? WIFI_SPI_ACK : WIFI_SPI_ERR; return (err==WL_SUCCESS) ? WIFI_SPI_ACK : WIFI_SPI_ERR;
} }
int stop_client_tcp_cmd_cb(int numParam, char* buf, void* ctx) {
wl_err_t err = WL_FAILURE;
tParam* params = (tParam*) buf;
void* _ttcp = NULL;
if (numParam == 1)
{
GET_PARAM_NEXT(BYTE, params, sock);
INFO("Stop client sock:%d\n", sock);
if (sock < MAX_SOCK_NUM)
{
_ttcp = mapSockTCP[sock];
ard_tcp_stop(_ttcp);
mapSockTCP[sock]=0;
err = WL_SUCCESS;
}
}
return (err==WL_SUCCESS) ? WIFI_SPI_ACK : WIFI_SPI_ERR;
}
int send_data_tcp_cmd_cb(int numParam, char* buf, void* ctx) { int send_data_tcp_cmd_cb(int numParam, char* buf, void* ctx) {
wl_err_t err = WL_FAILURE; wl_err_t err = WL_FAILURE;
SIGN1_DN(); DATA_LED_ON();
tDataParam* msg = (tDataParam*) buf; tDataParam* msg = (tDataParam*) buf;
if ((numParam == 2)&&(msg->dataLen == 1)) if ((numParam == 2)&&(msg->dataLen == 1))
{ {
@ -556,7 +588,7 @@ int send_data_tcp_cmd_cb(int numParam, char* buf, void* ctx) {
GET_DATA_INT(len, buf+3); GET_DATA_INT(len, buf+3);
err = sendTcpData(getTTCP(sock), (uint8_t*)(buf+5), len); err = sendTcpData(getTTCP(sock), (uint8_t*)(buf+5), len);
} }
SIGN1_UP(); DATA_LED_OFF();
return (err==WL_SUCCESS) ? WIFI_SPI_ACK : WIFI_SPI_ERR; return (err==WL_SUCCESS) ? WIFI_SPI_ACK : WIFI_SPI_ERR;
} }
@ -757,7 +789,7 @@ cmd_spi_state_t get_state_tcp_cmd_cb(char* recv, char* reply, void* ctx, uint16_
uint8_t _state = CLOSED; uint8_t _state = CLOSED;
if ((recv[3]==1)&&(recv[4]>=0)&&(recv[4]<MAX_SOCK_NUM)) if ((recv[3]==1)&&(recv[4]>=0)&&(recv[4]<MAX_SOCK_NUM))
{ {
_state = getStateTcp(mapSockTCP[(uint8_t)recv[4]]); _state = getStateTcp(mapSockTCP[(uint8_t)recv[4]], 0);
} }
PUT_DATA_BYTE(_state, reply, 3); PUT_DATA_BYTE(_state, reply, 3);
END_HEADER_REPLY(reply, 5, *count); END_HEADER_REPLY(reply, 5, *count);
@ -765,6 +797,24 @@ cmd_spi_state_t get_state_tcp_cmd_cb(char* recv, char* reply, void* ctx, uint16_
return SPI_CMD_DONE; return SPI_CMD_DONE;
} }
cmd_spi_state_t get_client_state_tcp_cmd_cb(char* recv, char* reply, void* ctx, uint16_t* count) {
CHECK_ARD_NETIF(recv, reply, count);
CREATE_HEADER_REPLY(reply, recv, PARAM_NUMS_1);
uint8_t _state = CLOSED;
if ((recv[3]==1)&&(recv[4]>=0)&&(recv[4]<MAX_SOCK_NUM))
{
_state = getStateTcp(mapSockTCP[(uint8_t)recv[4]], 1);
}
PUT_DATA_BYTE(_state, reply, 3);
END_HEADER_REPLY(reply, 5, *count);
return SPI_CMD_DONE;
}
cmd_spi_state_t avail_data_tcp_cmd_cb(char* recv, char* reply, void* ctx, uint16_t* count) { cmd_spi_state_t avail_data_tcp_cmd_cb(char* recv, char* reply, void* ctx, uint16_t* count) {
CHECK_ARD_NETIF(recv, reply, count); CHECK_ARD_NETIF(recv, reply, count);
@ -887,10 +937,12 @@ int sendReply(int cmdIdx, char* recv, char* reply, void* resultCmd)
AVAIL_FOR_SPI(); AVAIL_FOR_SPI();
_result = write_stream(ARD_SPI, &reply[0], _count); _result = write_stream(ARD_SPI, &reply[0], _count);
#ifdef _SPI_STATS_
if ( result != SPI_OK) if ( result != SPI_OK)
{ {
statSpi.lastCmd = cmd_spi_list[cmdIdx].cmd_id; statSpi.lastCmd = cmd_spi_list[cmdIdx].cmd_id;
} }
#endif
BUSY_FOR_SPI(); BUSY_FOR_SPI();
//unsigned char status = spi_getStatus(ARD_SPI); //unsigned char status = spi_getStatus(ARD_SPI);
@ -1014,6 +1066,7 @@ void init_spi_cmds() {
spi_add_cmd(DISCONNECT_CMD, disconnect_cmd_cb, ack_reply_cb, NULL, CMD_SET_FLAG); spi_add_cmd(DISCONNECT_CMD, disconnect_cmd_cb, ack_reply_cb, NULL, CMD_SET_FLAG);
spi_add_cmd(START_SERVER_TCP_CMD, start_server_tcp_cmd_cb, ack_reply_cb, NULL, CMD_SET_FLAG); spi_add_cmd(START_SERVER_TCP_CMD, start_server_tcp_cmd_cb, ack_reply_cb, NULL, CMD_SET_FLAG);
spi_add_cmd(START_CLIENT_TCP_CMD, start_client_tcp_cmd_cb, ack_reply_cb, NULL, CMD_SET_FLAG); spi_add_cmd(START_CLIENT_TCP_CMD, start_client_tcp_cmd_cb, ack_reply_cb, NULL, CMD_SET_FLAG);
spi_add_cmd(STOP_CLIENT_TCP_CMD, stop_client_tcp_cmd_cb, ack_reply_cb, NULL, CMD_SET_FLAG);
spi_add_cmd(GET_STATE_TCP_CMD, ack_cmd_cb, get_state_tcp_cmd_cb, NULL, CMD_GET_FLAG); spi_add_cmd(GET_STATE_TCP_CMD, ack_cmd_cb, get_state_tcp_cmd_cb, NULL, CMD_GET_FLAG);
spi_add_cmd(GET_DATA_TCP_CMD, ack_cmd_cb, get_data_tcp_cmd_cb, NULL, CMD_GET_FLAG); spi_add_cmd(GET_DATA_TCP_CMD, ack_cmd_cb, get_data_tcp_cmd_cb, NULL, CMD_GET_FLAG);
spi_add_cmd(AVAIL_DATA_TCP_CMD, ack_cmd_cb, avail_data_tcp_cmd_cb, NULL, CMD_GET_FLAG); spi_add_cmd(AVAIL_DATA_TCP_CMD, ack_cmd_cb, avail_data_tcp_cmd_cb, NULL, CMD_GET_FLAG);
@ -1021,7 +1074,7 @@ void init_spi_cmds() {
spi_add_cmd(DATA_SENT_TCP_CMD, ack_cmd_cb, data_sent_tcp_cmd_cb, NULL, CMD_GET_FLAG); spi_add_cmd(DATA_SENT_TCP_CMD, ack_cmd_cb, data_sent_tcp_cmd_cb, NULL, CMD_GET_FLAG);
spi_add_cmd(GET_DATABUF_TCP_CMD, ack_cmd_cb, get_databuf_tcp_cmd_cb, NULL, CMD_GET_FLAG); spi_add_cmd(GET_DATABUF_TCP_CMD, ack_cmd_cb, get_databuf_tcp_cmd_cb, NULL, CMD_GET_FLAG);
spi_add_cmd(TEST_CMD, ack_cmd_cb, test_cmd_cb, NULL, CMD_GET_FLAG); spi_add_cmd(TEST_CMD, ack_cmd_cb, test_cmd_cb, NULL, CMD_GET_FLAG);
spi_add_cmd(GET_CLIENT_STATE_TCP_CMD, ack_cmd_cb, get_client_state_tcp_cmd_cb, NULL, CMD_GET_FLAG);
} }
@ -1179,15 +1232,17 @@ inline int spi_slaveReceiveInt(volatile avr32_spi_t *spi, bool startRecvd)
} }
} }
_receiveBuffer[index] = (spi->rdr >> AVR32_SPI_RDR_RD_OFFSET) & 0x00ff; _receiveBuffer[index] = (spi->rdr >> AVR32_SPI_RDR_RD_OFFSET) & 0x00ff;
if (_receiveBuffer[index] == START_CMD) if (_receiveBuffer[index] == START_CMD){
TOGGLE_SIG0(); TOGGLE_SIG0();
//SIGN1_UP(); //SIGN1_UP();
}
if (err == SPI_OK) { if (err == SPI_OK) {
++index; ++index;
++receivedChars; ++receivedChars;
}else{ }else{
#ifdef _SPI_STATS_
STATSPI_TIMEOUT_ERROR(); STATSPI_TIMEOUT_ERROR();
#endif
break; break;
} }
@ -1230,9 +1285,11 @@ static void spi_int_handler(void)
int err = spi_slaveReceiveInt(ARD_SPI, dummy==START_CMD); int err = spi_slaveReceiveInt(ARD_SPI, dummy==START_CMD);
if (err != SPI_OK) if (err != SPI_OK)
{ {
#ifdef _SPI_STATS_
//TODO verify why at the end of cmd cycle RDF bit is high without any data recv. //TODO verify why at the end of cmd cycle RDF bit is high without any data recv.
if (statSpi.lastError != SPI_ERROR_TIMEOUT) if (statSpi.lastError != SPI_ERROR_TIMEOUT)
INFO("[E(0x%x):%d spiStatus:%d]\n", statSpi.lastError, err, statSpi.status); INFO("[E(0x%x):%d spiStatus:%d]\n", statSpi.lastError, err, statSpi.status);
#endif
}else{ }else{
BUSY_FOR_SPI(); BUSY_FOR_SPI();
startReply=true; startReply=true;
@ -1356,9 +1413,9 @@ int initSpi()
ENABLE_SPI_INT(); ENABLE_SPI_INT();
spi_enable(spi); spi_enable(spi);
#ifdef _SPI_STATS_
initStatSpi(); initStatSpi();
#endif
init_spi_cmds(); init_spi_cmds();
return 0; return 0;

View File

@ -5,7 +5,7 @@
* Author: mlf by Metodo2 srl * Author: mlf by Metodo2 srl
*/ */
#undef _APP_DEBUG_ #define _APP_DEBUG_
#include "lwip/opt.h" #include "lwip/opt.h"
#include "lwip/mem.h" #include "lwip/mem.h"
@ -93,18 +93,23 @@ ard_tcp_print_stats(struct ttcp *ttcp)
static void static void
ard_tcp_destroy(struct ttcp* ttcp) ard_tcp_destroy(struct ttcp* ttcp)
{ {
err_t err = ERR_OK;
if (ttcp->tpcb) { if (ttcp->tpcb) {
tcp_arg(ttcp->tpcb, NULL); tcp_arg(ttcp->tpcb, NULL);
tcp_sent(ttcp->tpcb, NULL); tcp_sent(ttcp->tpcb, NULL);
tcp_recv(ttcp->tpcb, NULL); tcp_recv(ttcp->tpcb, NULL);
tcp_err(ttcp->tpcb, NULL); tcp_err(ttcp->tpcb, NULL);
tcp_close(ttcp->tpcb); err = tcp_close(ttcp->tpcb);
printk("Closing tpcb: state:0x%x err:%d\n",
ttcp->tpcb->state, err);
} }
if (ttcp->lpcb) { if (ttcp->lpcb) {
tcp_arg(ttcp->lpcb, NULL); tcp_arg(ttcp->lpcb, NULL);
tcp_accept(ttcp->lpcb, NULL); tcp_accept(ttcp->lpcb, NULL);
tcp_close(ttcp->lpcb); tcp_close(ttcp->lpcb);
printk("Closing lpcb: state:0x%x err:%d\n",
ttcp->lpcb->state, err);
} }
if (ttcp->upcb) { if (ttcp->upcb) {
@ -281,7 +286,7 @@ atcp_recv_cb(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
ard_tcp_done(ttcp, 0); ard_tcp_done(ttcp, 0);
return ERR_OK; return ERR_OK;
} }
DATA_LED_ON();
/* for print_stats() */ /* for print_stats() */
ttcp->recved += p->tot_len; ttcp->recved += p->tot_len;
@ -294,6 +299,7 @@ atcp_recv_cb(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
insert_pBuf(p, ttcp->sock, (void*)pcb); insert_pBuf(p, ttcp->sock, (void*)pcb);
pbuf_free(p); pbuf_free(p);
tcp_recved(pcb, p->tot_len); tcp_recved(pcb, p->tot_len);
DATA_LED_OFF();
return ERR_OK; return ERR_OK;
} }
@ -303,6 +309,13 @@ void ack_recved(void* pcb, int len)
//tcp_recved(pcb, len); //tcp_recved(pcb, len);
} }
static err_t
atcp_poll(void *arg, struct tcp_pcb *pcb)
{
return ERR_OK;
}
/** /**
* Only used in TCP mode. * Only used in TCP mode.
*/ */
@ -314,9 +327,10 @@ atcp_accept_cb(void *arg, struct tcp_pcb *newpcb, err_t err)
ttcp->tpcb = newpcb; ttcp->tpcb = newpcb;
tcp_recv(ttcp->tpcb, atcp_recv_cb); tcp_recv(ttcp->tpcb, atcp_recv_cb);
tcp_err(ttcp->tpcb, atcp_conn_err_cb); tcp_err(ttcp->tpcb, atcp_conn_err_cb);
tcp_poll(ttcp->tpcb, atcp_poll, 4);
printk("ARD TCP [%p]: accept new [%p]\n", ttcp, newpcb); printk("ARD TCP [%p]: accept new [%p]\n", ttcp, newpcb);
printk("local:%d remote:%d state:%d\n", newpcb->local_port, newpcb->remote_port, newpcb->state); INFO("local:%d remote:%d state:%d\n", newpcb->local_port, newpcb->remote_port, newpcb->state);
ttcp->start_time = timer_get_ms(); ttcp->start_time = timer_get_ms();
return ERR_OK; return ERR_OK;
} }
@ -360,8 +374,9 @@ atcp_start(struct ttcp* ttcp)
printk("TTCP [%p]: listen failed\n", ttcp); printk("TTCP [%p]: listen failed\n", ttcp);
return -1; return -1;
} }
printk("ttcp:%p lpcb:%p pcb:%p\n", ttcp, ttcp->lpcb, ttcp->tpcb);
printk("local:%d remote:%d state:%d\n", ttcp->lpcb->local_port, ttcp->lpcb->state); printk("local:%d remote:%d state:%d\n", ttcp->lpcb->local_port,
ttcp->lpcb->remote_port, ttcp->lpcb->state);
tcp_accept(ttcp->lpcb, atcp_accept_cb); tcp_accept(ttcp->lpcb, atcp_accept_cb);
} }
@ -557,18 +572,20 @@ ard_tcp_start(struct ip_addr addr, uint16_t port, void *opaque,
ttcp->verbose = verbose; ttcp->verbose = verbose;
ttcp->buflen = buflen; ttcp->buflen = buflen;
printk("TTCP [%p-%p]: nbuf=%d, buflen=%d, port=%d (%s/%s)\n",
ttcp, ttcp->tpcb, ttcp->nbuf, ttcp->buflen, ttcp->port,
ttcp->udp ? "udp" : "tcp",
ttcp->mode == TTCP_MODE_TRANSMIT ? "tx" : "rx");
if (ttcp->udp) if (ttcp->udp)
status = udp_start(ttcp); status = udp_start(ttcp);
else else
status = atcp_start(ttcp); status = atcp_start(ttcp);
if (status) if (status)
{
WARN("Start server FAILED!");
goto fail; goto fail;
}
printk("TTCP [%p-%p]: nbuf=%d, buflen=%d, port=%d (%s/%s)\n",
ttcp, ttcp->tpcb, ttcp->nbuf, ttcp->buflen, ttcp->port,
ttcp->udp ? "udp" : "tcp",
ttcp->mode == TTCP_MODE_TRANSMIT ? "tx" : "rx");
*_ttcp = (void*)ttcp; *_ttcp = (void*)ttcp;
ttcp->sock = sock; ttcp->sock = sock;
@ -581,15 +598,37 @@ fail:
return -1; return -1;
} }
uint8_t getStateTcp(void* p ) static void
close_conn(struct ttcp *_ttcp)
{
ard_tcp_done(_ttcp, 0);
}
void ard_tcp_stop(void* ttcp)
{
struct ttcp* _ttcp = (struct ttcp*)ttcp;
printk("Stop client %p-%p-%p\n", _ttcp, _ttcp->tpcb, _ttcp->lpcb);
close_conn(_ttcp);
asm("nop");
}
uint8_t getStateTcp(void* p, bool client)
{ {
struct ttcp* _ttcp = (struct ttcp*)p; struct ttcp* _ttcp = (struct ttcp*)p;
if ((_ttcp != NULL)&&(_ttcp->tpcb != NULL)) if ((_ttcp != NULL)&&(_ttcp->tpcb != NULL))
{ {
// if (_ttcp->tpcb->state > 1) // INFO("ttcp:%p tpcb:%p state:%d lpcb:%p state:%d\n",
// INFO("ttcp:%p tpcb:%p state:%d\n",p, _ttcp->tpcb, _ttcp->tpcb->state); // p, _ttcp->tpcb, _ttcp->tpcb->state,
// _ttcp->lpcb, _ttcp->lpcb->state);
if (client)
return _ttcp->tpcb->state; return _ttcp->tpcb->state;
else
return _ttcp->lpcb->state;
}else{
WARN("TCP not initialized ttcp:%p tpcb:%p lpcb:%p\n",
_ttcp, ((_ttcp)?_ttcp->tpcb:0), ((_ttcp)?_ttcp->lpcb:0));
} }
return CLOSED; return CLOSED;
} }
@ -599,9 +638,7 @@ uint8_t isDataSent(void* p )
struct ttcp* _ttcp = (struct ttcp*)p; struct ttcp* _ttcp = (struct ttcp*)p;
if ((_ttcp != NULL)&&(_ttcp->tpcb != NULL)) if ((_ttcp != NULL)&&(_ttcp->tpcb != NULL))
{ {
#define _APP_DEBUG_ //INFO("ttcp:%p tpcb:%p sent:%d\n",p, _ttcp->tpcb, _ttcp->buff_sent);
INFO("ttcp:%p tpcb:%p sent:%d\n",p, _ttcp->tpcb, _ttcp->buff_sent);
#undef _APP_DEBUG_
return _ttcp->buff_sent; return _ttcp->buff_sent;
}else{ }else{
WARN("TCP null!\n"); WARN("TCP null!\n");
@ -622,19 +659,19 @@ tcp_data_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
if (_ttcp->left > 0) { if (_ttcp->left > 0) {
//send_data(pcb, hs); //send_data(pcb, hs);
printk("data left: %d", _ttcp->left ); INFO("data left: %d", _ttcp->left );
} }
//printk("Sent!\n");
_ttcp->buff_sent = 1; _ttcp->buff_sent = 1;
printk("%s: duration: %d\n", __FUNCTION__, timer_get_ms() - startTime); //INFO("%s: duration: %d\n", __FUNCTION__, timer_get_ms() - startTime);
return ERR_OK; return ERR_OK;
} }
int sendTcpData(void* p, uint8_t* buf, uint16_t len) int sendTcpData(void* p, uint8_t* buf, uint16_t len)
{ {
printk("buf:%p len:%d\n", buf, len); //INFO("buf:%p len:%d\n", buf, len);
//DUMP(buf,len);
startTime = timer_get_ms(); startTime = timer_get_ms();
DUMP(buf,len);
struct ttcp* _ttcp = (struct ttcp*)p; struct ttcp* _ttcp = (struct ttcp*)p;
if ((_ttcp != NULL)&&(_ttcp->tpcb != NULL)&&(buf!=NULL)&&(len!=0)) if ((_ttcp != NULL)&&(_ttcp->tpcb != NULL)&&(buf!=NULL)&&(len!=0))
{ {

View File

@ -15,7 +15,9 @@ typedef void (ard_tcp_done_cb_t)(void *opaque, int result);
int ard_tcp_start(struct ip_addr addr, uint16_t port, void *opaque, int ard_tcp_start(struct ip_addr addr, uint16_t port, void *opaque,
ard_tcp_done_cb_t *done_cb, int mode, uint16_t nbuf, uint16_t buflen, int udp, int verbose, uint8_t sock, void** _ttcp); ard_tcp_done_cb_t *done_cb, int mode, uint16_t nbuf, uint16_t buflen, int udp, int verbose, uint8_t sock, void** _ttcp);
uint8_t getStateTcp(void* p ); void ard_tcp_stop(void* ttcp);
uint8_t getStateTcp(void* p, bool client );
int sendTcpData(void* p, uint8_t* buf, uint16_t len); int sendTcpData(void* p, uint8_t* buf, uint16_t len);

View File

@ -9,23 +9,61 @@
#define ARD_UTILS_H_ #define ARD_UTILS_H_
#include "gpio.h" #include "gpio.h"
#include "arduino/arduino.h"
#define INIT_SIGNAL_FOR_SPI() gpio_enable_pin_pull_up(ARDUINO_HANDSHAKE_PIN) #define INIT_SIGNAL_FOR_SPI() gpio_enable_pin_pull_up(ARDUINO_HANDSHAKE_PIN)
#define BUSY_FOR_SPI() gpio_set_gpio_pin(ARDUINO_HANDSHAKE_PIN) #define BUSY_FOR_SPI() gpio_set_gpio_pin(ARDUINO_HANDSHAKE_PIN)
#define AVAIL_FOR_SPI() gpio_clr_gpio_pin(ARDUINO_HANDSHAKE_PIN) #define AVAIL_FOR_SPI() gpio_clr_gpio_pin(ARDUINO_HANDSHAKE_PIN)
#define SIGN0_UP() gpio_set_gpio_pin(LED0_GPIO) #define LED0_UP() gpio_set_gpio_pin(LED0_GPIO)
#define SIGN0_DN() gpio_clr_gpio_pin(LED0_GPIO) #define LED0_DN() gpio_clr_gpio_pin(LED0_GPIO)
#define SIGN1_UP() gpio_set_gpio_pin(LED1_GPIO) #define LED0_TL() gpio_tgl_gpio_pin(LED0_GPIO)
#define SIGN1_DN() gpio_clr_gpio_pin(LED1_GPIO) #define LED1_UP() gpio_set_gpio_pin(LED1_GPIO)
#define SIGN2_UP() gpio_set_gpio_pin(LED2_GPIO) #define LED1_DN() gpio_clr_gpio_pin(LED1_GPIO)
#define SIGN2_DN() gpio_clr_gpio_pin(LED2_GPIO) #define LED1_TL() gpio_tgl_gpio_pin(LED1_GPIO)
#define LED2_UP() gpio_set_gpio_pin(LED2_GPIO)
#define LED2_DN() gpio_clr_gpio_pin(LED2_GPIO)
#define LED2_TL() gpio_tgl_gpio_pin(LED2_GPIO)
#ifdef _DEBUG_
#define SIGN0_UP LED0_UP
#define SIGN0_DN LED0_DN
#define SIGN0_TL LED0_TL
#define SIGN1_UP LED1_UP
#define SIGN1_DN LED1_DN
#define SIGN1_TL LED1_TL
#define SIGN2_UP LED2_UP
#define SIGN2_DN LED2_DN
#define SIGN2_TL LED2_TL
#else
#define SIGN0_UP()
#define SIGN0_DN()
#define SIGN0_TL()
#define SIGN1_UP()
#define SIGN1_DN()
#define SIGN1_TL()
#define SIGN2_UP()
#define SIGN2_DN()
#define SIGN2_TL()
//#define TOGGLE_SIG0
#endif
#define DELAY_450NS asm volatile("nop") #define DELAY_450NS asm volatile("nop")
#define DELAY_1uS DELAY_450NS; DELAY_450NS; #define DELAY_1uS DELAY_450NS; DELAY_450NS;
#define TOGGLE_SIG0() SIGN0_UP(); DELAY_450NS;SIGN0_DN(); #define TOGGLE_SIG0() SIGN0_UP(); DELAY_450NS;SIGN0_DN();
#define LINK_LED_OFF LED0_UP
#define ERROR_LED_OFF LED1_UP
#define DATA_LED_OFF LED2_UP
#define LINK_LED_ON LED0_DN
#define ERROR_LED_ON LED1_DN
#define DATA_LED_ON LED2_DN
#define LINK_LED_BL LED0_TL
#define ERROR_LED_BL LED1_TL
#define DATA_LED_BL LED2_TL
#define CREATE_HEADER_REPLY(REPLY, RECV, NUM_PARAMS)\ #define CREATE_HEADER_REPLY(REPLY, RECV, NUM_PARAMS)\
@ -165,12 +203,14 @@
typedef struct sData typedef struct sData
{ {
u8_t* data; uint8_t* data;
u16_t len; uint16_t len;
u16_t idx; uint16_t idx;
void* pcb; void* pcb;
}tData; }tData;
struct pbuf;
void insert_pBuf(struct pbuf* q, uint8_t sock, void* _pcb); void insert_pBuf(struct pbuf* q, uint8_t sock, void* _pcb);
tData* get_pBuf(uint8_t sock); tData* get_pBuf(uint8_t sock);
@ -185,6 +225,6 @@ bool getTcpDataByte(uint8_t sock, uint8_t* payload);
bool isAvailTcpDataByte(uint8_t sock); bool isAvailTcpDataByte(uint8_t sock);
u8_t freeTcpData(uint8_t sock); uint8_t freeTcpData(uint8_t sock);
#endif /* ARD_UTILS_H_ */ #endif /* ARD_UTILS_H_ */

View File

@ -193,7 +193,7 @@ cmd_status(int argc, char* argv[], void* ctx)
return CMD_DONE; return CMD_DONE;
} }
#ifdef ADD_CMDS
/** /**
* *
*/ */
@ -225,8 +225,9 @@ cmd_power(int argc, char* argv[], void* ctx)
printk(usage); printk(usage);
return CMD_DONE; return CMD_DONE;
} }
#endif
#ifdef ADD_CMDS
/** /**
* *
*/ */
@ -273,6 +274,7 @@ cmd_psconf(int argc, char* argv[], void* ctx)
return CMD_DONE; return CMD_DONE;
} }
#endif
#define MAX_KEY_LEN 64 #define MAX_KEY_LEN 64

View File

@ -32,9 +32,13 @@ printk("I-[%s] " msg , __func__ , ##args ); \
#define INFO(msg, args...) do {} while (0) #define INFO(msg, args...) do {} while (0)
#endif /* !defined(_DEBUG_) */ #endif /* !defined(_DEBUG_) */
#if 1
#define WARN(msg, args...) do { \ #define WARN(msg, args...) do { \
printk("W-[%s] " msg , __func__ , ##args ); \ printk("W-[%s] " msg , __func__ , ##args ); \
} while (0) } while (0)
#else
#define WARN(msg, args...) do { } while (0)
#endif
extern void dump(char* _buf, uint16_t _count); extern void dump(char* _buf, uint16_t _count);

View File

@ -423,10 +423,10 @@
#undef DHCP_DOES_ARP_CHECK #undef DHCP_DOES_ARP_CHECK
#if 0 #if 1
#define LWIP_DEBUG 1 #define LWIP_DEBUG 1
//#define NETIF_DEBUG LWIP_DBG_ON //#define NETIF_DEBUG LWIP_DBG_ON
#define DHCP_DEBUG LWIP_DBG_ON //#define DHCP_DEBUG LWIP_DBG_ON
//#define ICMP_DEBUG LWIP_DBG_ON //#define ICMP_DEBUG LWIP_DBG_ON
//#define TCP_DEBUG LWIP_DBG_ON //#define TCP_DEBUG LWIP_DBG_ON
//#define TCP_RTO_DEBUG LWIP_DBG_ON //#define TCP_RTO_DEBUG LWIP_DBG_ON
@ -434,8 +434,8 @@
//#define TCP_CWND_DEBUG LWIP_DBG_ON //#define TCP_CWND_DEBUG LWIP_DBG_ON
//#define ETHARP_DEBUG LWIP_DBG_ON //#define ETHARP_DEBUG LWIP_DBG_ON
//#define PBUF_DEBUG LWIP_DBG_ON //#define PBUF_DEBUG LWIP_DBG_ON
#define TCP_INPUT_DEBUG LWIP_DBG_ON //#define TCP_INPUT_DEBUG LWIP_DBG_ON
#define TCP_OUTPUT_DEBUG LWIP_DBG_ON //#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
#endif #endif
#define ETH_PAD_SIZE WL_HEADER_SIZE /* size of wifiengine header */ #define ETH_PAD_SIZE WL_HEADER_SIZE /* size of wifiengine header */

View File

@ -74,11 +74,15 @@ void fw_download_cb(void* ctx, uint8_t** buf, uint32_t* len)
#include "debug.h" #include "debug.h"
#include "ard_utils.h" #include "ard_utils.h"
struct http_server { struct ctx_server {
struct netif *netif; struct netif *netif;
uint8_t wl_init_complete; uint8_t wl_init_complete;
}; };
// to maintain the word alignment
#define PAD_CTX_SIZE 0x18
#define PAD_NETIF_SIZE 0x3c
static bool initSpiComplete = false; static bool initSpiComplete = false;
/** /**
@ -127,7 +131,7 @@ static void
wl_cm_scan_cb(void* ctx) wl_cm_scan_cb(void* ctx)
{ {
#ifdef _APP_DEBUG_ #ifdef _APP_DEBUG_
struct http_server* hs = ctx; struct ctx_server* hs = ctx;
uint8_t init = hs->wl_init_complete; uint8_t init = hs->wl_init_complete;
@ -142,7 +146,9 @@ wl_cm_scan_cb(void* ctx)
static void static void
wl_cm_conn_cb(struct wl_network_t* net, void* ctx) wl_cm_conn_cb(struct wl_network_t* net, void* ctx)
{ {
struct http_server* hs = ctx; struct ctx_server* hs = ctx;
LINK_LED_ON();
printk("link up, connected to \"%s\"\n", ssid2str(&net->ssid)); printk("link up, connected to \"%s\"\n", ssid2str(&net->ssid));
printk("requesting dhcp ... "); printk("requesting dhcp ... ");
@ -157,7 +163,9 @@ wl_cm_conn_cb(struct wl_network_t* net, void* ctx)
static void static void
wl_cm_disconn_cb(void* ctx) wl_cm_disconn_cb(void* ctx)
{ {
struct http_server* hs = ctx; struct ctx_server* hs = ctx;
LINK_LED_OFF();
if (netif_is_up(hs->netif)) { if (netif_is_up(hs->netif)) {
printk("link down, release dhcp\n"); printk("link down, release dhcp\n");
@ -187,16 +195,8 @@ ip_status_cb(struct netif* netif)
if (netif_is_up(netif)) { if (netif_is_up(netif)) {
set_result_cmd(WL_SUCCESS); set_result_cmd(WL_SUCCESS);
printk("bound to %s\n", ip2str(netif->ip_addr)); printk("bound to %s\n", ip2str(netif->ip_addr));
printk("starting httpd ... "); }else{
if (httpd_start() == ERR_OK) WARN("Interface not up!");
printk("ok\n");
else
printk("fail\n");
}
else {
printk("stopping httpd\n");
httpd_stop();
} }
} }
@ -207,10 +207,15 @@ ip_status_cb(struct netif* netif)
void void
led_init(void) led_init(void)
{ {
gpio_enable_gpio_pin(LED0_GPIO);
gpio_enable_gpio_pin(LED1_GPIO); gpio_enable_gpio_pin(LED1_GPIO);
gpio_enable_gpio_pin(LED2_GPIO); gpio_enable_gpio_pin(LED2_GPIO);
LED_Off(LED1); LINK_LED_OFF();
LED_Off(LED2); ERROR_LED_OFF();
DATA_LED_OFF();
//LED_Off(LED1);
//LED_Off(LED2);
} }
@ -271,7 +276,7 @@ void wifi_init()
* *
*/ */
void void
poll(struct http_server* hs) poll(struct ctx_server* hs)
{ {
/* this will trigger any scheduled timer callbacks */ /* this will trigger any scheduled timer callbacks */
timer_poll(); timer_poll();
@ -300,14 +305,16 @@ void initShell()
console_add_cmd("connect", cmd_connect, NULL); console_add_cmd("connect", cmd_connect, NULL);
console_add_cmd("setkey", cmd_setkey, NULL); console_add_cmd("setkey", cmd_setkey, NULL);
console_add_cmd("status", cmd_status, NULL); console_add_cmd("status", cmd_status, NULL);
#ifdef ADD_CMDS
console_add_cmd("powersave", cmd_power, NULL); console_add_cmd("powersave", cmd_power, NULL);
console_add_cmd("psconf", cmd_psconf, NULL); console_add_cmd("psconf", cmd_psconf, NULL);
console_add_cmd("ping", cmd_ping, NULL); console_add_cmd("ping", cmd_ping, NULL);
#endif
#ifdef WITH_WPA #ifdef WITH_WPA
console_add_cmd("wpass", cmd_setpass, NULL); console_add_cmd("wpass", cmd_setpass, NULL);
console_add_cmd("dpass", cmd_delpass, NULL); console_add_cmd("dpass", cmd_delpass, NULL);
#endif #endif
#if BOARD == ARDUINO #ifdef STAT_SPI
console_add_cmd("spiStat", cmd_statSpi, NULL); console_add_cmd("spiStat", cmd_statSpi, NULL);
console_add_cmd("resetSpiStat", cmd_resetStatSpi, NULL); console_add_cmd("resetSpiStat", cmd_resetStatSpi, NULL);
#endif #endif
@ -320,7 +327,7 @@ void initShell()
void void
wl_init_complete_cb(void* ctx) wl_init_complete_cb(void* ctx)
{ {
struct http_server *hs = ctx; struct ctx_server *hs = ctx;
struct ip_addr ipaddr, netmask, gw; struct ip_addr ipaddr, netmask, gw;
wl_err_t wl_status; wl_err_t wl_status;
@ -355,6 +362,7 @@ wl_init_complete_cb(void* ctx)
initSpiComplete = true; initSpiComplete = true;
AVAIL_FOR_SPI(); AVAIL_FOR_SPI();
} }
/* start connection manager */ /* start connection manager */
wl_status = wl_cm_start(wl_cm_scan_cb, wl_cm_conn_cb, wl_cm_disconn_cb, wl_cm_err_cb, hs); wl_status = wl_cm_start(wl_cm_scan_cb, wl_cm_conn_cb, wl_cm_disconn_cb, wl_cm_err_cb, hs);
ASSERT(wl_status == WL_SUCCESS, "failed to init wl conn mgr"); ASSERT(wl_status == WL_SUCCESS, "failed to init wl conn mgr");
@ -368,7 +376,7 @@ main(void)
{ {
wl_err_t wl_status; wl_err_t wl_status;
int status; int status;
struct http_server *hs; struct ctx_server *hs;
startup_init(); startup_init();
@ -394,12 +402,16 @@ main(void)
#else #else
printk("Arduino Wifi Startup... [%s]\n", __TIMESTAMP__); printk("Arduino Wifi Startup... [%s]\n", __TIMESTAMP__);
hs = calloc(1, sizeof(struct http_server)); size_t size_ctx_server = sizeof(struct ctx_server)+PAD_CTX_SIZE;
hs = calloc(1, size_ctx_server);
ASSERT(hs, "out of memory"); ASSERT(hs, "out of memory");
hs->netif = calloc(1, sizeof(struct netif)); size_t size_netif = sizeof(struct netif)+PAD_NETIF_SIZE;
hs->netif = calloc(1, size_netif);
ASSERT(hs->netif, "out of memory"); ASSERT(hs->netif, "out of memory");
INFO("hs:%p size:0x%x netif:%p size:0x%x\n", hs, size_ctx_server,
hs->netif, size_netif);
timer_init(NULL, NULL); timer_init(NULL, NULL);
lwip_init(); lwip_init();

View File

@ -29,7 +29,7 @@
* This file is derived from a part of the lwIP TCP/IP stack. * This file is derived from a part of the lwIP TCP/IP stack.
* *
*/ */
#ifdef ADD_CMDS
#include "lwip/opt.h" #include "lwip/opt.h"
#include "lwip/mem.h" #include "lwip/mem.h"
@ -338,3 +338,4 @@ cmd_state_t cmd_ping(int argc, char* argv[], void* ctx)
Assert(0); Assert(0);
return CMD_DONE; return CMD_DONE;
} }
#endif

View File

@ -45,6 +45,8 @@ enum {
AVAIL_DATA_TCP_CMD = 0x2B, AVAIL_DATA_TCP_CMD = 0x2B,
GET_DATA_TCP_CMD = 0x2C, GET_DATA_TCP_CMD = 0x2C,
START_CLIENT_TCP_CMD= 0x2D, START_CLIENT_TCP_CMD= 0x2D,
STOP_CLIENT_TCP_CMD = 0x2E,
GET_CLIENT_STATE_TCP_CMD = 0x2F,
DISCONNECT_CMD = 0x30, DISCONNECT_CMD = 0x30,
// All command with DATA_FLAG 0x40 send a 16bit Len // All command with DATA_FLAG 0x40 send a 16bit Len

View File

@ -35,6 +35,7 @@
#if 1 #if 1
# include "printf-stdarg.h" # include "printf-stdarg.h"
#include "ard_utils.h"
# define CM_DPRINTF(fmt...) printk(fmt) # define CM_DPRINTF(fmt...) printk(fmt)
#else #else
# define CM_DPRINTF(fmt...) # define CM_DPRINTF(fmt...)
@ -178,6 +179,8 @@ wl_media_connected_cb(void* ctx)
struct cm *cm = ctx; struct cm *cm = ctx;
struct wl_network_t *net = wl_get_current_network(); struct wl_network_t *net = wl_get_current_network();
CM_DPRINTF("CM: connected to %s\n", ssid2str(&net->ssid)); CM_DPRINTF("CM: connected to %s\n", ssid2str(&net->ssid));
LINK_LED_ON();
ERROR_LED_OFF();
if (cm->conn_cb) if (cm->conn_cb)
cm->conn_cb(net, cm->ctx); cm->conn_cb(net, cm->ctx);
} }
@ -190,7 +193,8 @@ static void
wl_conn_failure_cb(void* ctx) wl_conn_failure_cb(void* ctx)
{ {
CM_DPRINTF("CM: connect failed, scanning\n"); CM_DPRINTF("CM: connect failed, scanning\n");
ERROR_LED_ON();
LINK_LED_OFF();
if (wl_scan() != WL_SUCCESS) if (wl_scan() != WL_SUCCESS)
/* should never happen */ /* should never happen */
CM_DPRINTF("CM: could not start scan after connect fail!\n"); CM_DPRINTF("CM: could not start scan after connect fail!\n");
@ -205,7 +209,7 @@ wl_conn_lost_cb(void* ctx)
{ {
struct cm *cm = ctx; struct cm *cm = ctx;
CM_DPRINTF("CM: connection lost, scanning\n"); CM_DPRINTF("CM: connection lost, scanning\n");
LINK_LED_OFF();
if (cm->disconn_cb) if (cm->disconn_cb)
cm->disconn_cb(cm->ctx); cm->disconn_cb(cm->ctx);