Hi Martin,
I have the F120 card up and running with the same magic behaviour: only with power on reset it works well. Do you have any idea, why this happens? Is it a question of timing or resetting the AR4100 hardware?
Also, what I'm planning to do next is, to combine the WiFi application with a DHCP server.
It was working already with my gainspan app.
Now I added the same code to the actual AR4100 app with the result, that the DHCP server is working but the webservers are not working anymore. Here is the code:
Old code, which you know:
| for (i = 0; i < n_devices; i++) |
| { |
| | params[i] = httpd_default_params(NULL); |
| | params[i]->af = HTTP_INET_AF; //IPv4+IPv6, set connection family from config.h |
#if RTCSCFG_ENABLE_IP6
| | params[i]->if_scope_id = HTTP_SCOPE_ID; | // set interface number here. 0 is any . |
#endif
| | if (params[i]) |
| | { |
| | sprintf(indexes[i], "\\index.html", i); |
| | params[i]->root_dir = (HTTPD_ROOT_DIR_STRUCT*)root_dir; |
| | params[i]->index_page = indexes[i]; |
| | /* |
| | ** If there is only one interface listen on any IP address |
| | ** so address can change in runtime (DHCP etc.) |
| | */ |
| | if ((i == 0) && (n_devices == 1)) |
| | { |
| | params[i]->address = INADDR_ANY; |
| | } |
| | else |
| | { |
| | params[i]->address = ip_addr[i]; |
| | } |
#if PSP_MQX_CPU_IS_MCF5223X
#else
| | params[i]->max_ses = _RTCS_socket_part_max - 1; |
#endif
| | server[i] = httpd_init(params[i]); |
| | } |
| | HTTPD_SET_PARAM_CGI_TBL(server[i], (HTTPD_CGI_LINK_STRUCT*)cgi_lnk_tbl); |
#if HTTPD_SEPARATE_TASK || !HTTPDCFG_POLL_MODE
| | printf("Starting http server No.%d on IP %d.%d.%d.%d ...", i, (ip_addr[i]>>24) & 0xFF, (ip_addr[i]>>16) & 0xFF, (ip_addr[i]>>8) & 0xFF, ip_addr[i] & 0xFF); |
| | error = httpd_server_run(server[i]); |
| | if (error) |
| | { |
| | printf("[FAIL]\n"); |
| | } |
| | else |
| | { |
| | printf("[OK]\n"); |
| | } |
#endif
Here comes the code, I added:
/********************* Starten des DHCP- Servers, 12.5.2013 *******************/
_task_create(0,DHCP_SERVER_TASK,0);
printf("Der DHCP- Server wurde gestarted ...\n");
finish. The server task you will find behind the while loop
/************************* SD-Card- Task starten ******************************/
| _task_create(0,TBDS_SDCARD_TASK,0); |
| printf("SD-Card-Task wurde kreiert!\n"); |
/************************** Hier wird die Shell gestartet *********************/
| | /* Set up Trival File System to server webpages */ | |
if ((error = _io_tfs_install("tfs:", tfs_data)) != 0)
{
| | printf("\nTFS install returned: %08x\n", error); |
}
/******************************************************************************/
SEC_Initialize();
_task_create(0, TBDS_IO_TASK, 0); // start io task
/*********************** Hier wird die Shell gestartet ************************/
| #if HTTPD_SEPARATE_TASK || !HTTPDCFG_POLL_MODE | |
| _task_create(0, SHELL_TASK, 0); |
| _task_block(); |
#else
| printf("Servers polling started.\n") |
| while (1) |
| { |
| | for (i = 0; i < n_devices; i++) |
| | { |
| | httpd_server_poll(server[i], 1); |
| | } |
| | /* user stuff come here - only non blocking calls */ |
| } |
#endif
}
/* Security task */
void tbds_io_task(uint_32 temp) {
while (1) {
| | Input_Poll(); | // Hier werden die beiden Taster SW1 und SW2 abgefragt, Prototyp in tbds_security_private.h |
| | cpu_happy_light(); | // Aufruf der Steuerfunktion zum Erzeugen einer CPU- Happy_Light |
| | _time_delay(50); | // Zeitschleife |
}
}
Here comes the DHCP server task:
void dhcpserver_task(uint_32 initial_data)
{
DHCPSRV_DATA_STRUCT dhcpsrv_data;
uchar dhcpsrv_options[200];
_ip_address routers[1];
uchar_ptr optptr;
uint_32 error;
uint_32 optlen;
error = DHCPSRV_init("DHCP server", 7, 2000); //"DHCP Server", 7, 2000
if(error != RTCS_OK)
{
printf("\nDHCP server initialize returned : %08x\n",error);
printf("\nFailed to initialize the DHCP server\n");
_task_destroy(MQX_NULL_TASK_ID);
}
printf("\nDHCP Server running...\n");
/* Fill in the required parameters: */
/* 192.168.3.1: */
dhcpsrv_data.SERVERID = 0xC0A80201; //192.168.02.01
/* 1 hour leases: */
dhcpsrv_data.LEASE = 0xFFFFFFFF; // für immer
/* 255.255.255.0: */
dhcpsrv_data.MASK = 0xFFFFFF00; //255.255.255.0
/* TFTP server address: */
dhcpsrv_data.SADDR = 0xC0A80201; //192.168.02.01
_mem_zero(dhcpsrv_data.SNAME,sizeof(dhcpsrv_data.SNAME));
_mem_zero(dhcpsrv_data.FILE,sizeof(dhcpsrv_data.FILE));
/* Fill in the options: */
optptr = dhcpsrv_options;
optlen = sizeof(dhcpsrv_options);
/* Default IP TTL: */
DHCPSRV_option_int8(&optptr,&optlen,23,64);
/* MTU: */
DHCPSRV_option_int16(&optptr,&optlen,26,1500);
/* Renewal time: */
DHCPSRV_option_int32(&optptr,&optlen,58,3600);
/* Rebinding time: */
DHCPSRV_option_int32(&optptr,&optlen,59,5400);
/* Domain name: */
DHCPSRV_option_string(&optptr,&optlen,15,"arc.com");
/* Broadcast address: */
DHCPSRV_option_addr(&optptr,&optlen,28,0xC0A802ff);
/* Router list: */
routers[0] = 0xC0A80201;
// routers[1] = 0xC0A80305;
// routers[2] = 0xC0A80306;
DHCPSRV_option_addrlist( &optptr, &optlen, 3, routers, 0); // 3,3
DHCPSRV_ippool_add(0xC0A80281, 7, &dhcpsrv_data, dhcpsrv_options, optptr - dhcpsrv_options);
_task_block();
}
Do I have to integrate the DHCP server initialisation into the for loop?
Regards
Thomas