EmbeddedRelated.com
Forums

ad hoc creation for RCM 5400W

Started by Ajay January 25, 2011
Hi all

I am working on RCM 5400W...i just wrote a sample program to turn on al led connected to 5400 and it ran successfully.

Now i would like to implement wirelessly using the wifi given...i have tried the examples but i was unable to understand the...can any one help me out in this regard.

Regards
Ajay

Hi Ajay,

It is not difficult if you read the documents and follow the samples. I
can't write the code for you but this is what I have in my TASK (I use UCOS)
for the part that creates the WiFi connection. Lot of stuff is not included
but it gives you an idea of how it works.

if(ConfigData.WiFiKeyType == 0) // WEP
{
printf("Config WiFi with WEP\n");
retval = ifconfig(IF_WIFI0,
IFS_WIFI_ENCRYPTION, IFPARAM_WIFI_ENCR_WEP,
IFS_WIFI_AUTHENTICATION, IFPARAM_WIFI_AUTH_OPEN,
IFS_WIFI_WEP_KEY_HEXSTR, 0,
ConfigData.WiFiNumKey,
IFS_WIFI_WEP_KEYNUM, 0,
IFS_END);
if(retval)
printf("Failed to set WiFi WEP key\n");
}
else if(ConfigData.WiFiKeyType == 1) // WPA
{
printf("Config WiFi with WPA\n");
retval = ifconfig(IF_WIFI0, WIFI_WEP_FLAG, WIFICONF_WEP_TKIP, 0,
IF_WIFI0, WIFI_WPA_PSK_PASSPHRASE, ConfigData.WiFiStrKey,
sizeof(ConfigData.WiFiStrKey));
if(retval)
printf("Failed to set WiFi WPA key\n");
}
else // OPEN
{
retval = ifconfig(IF_WIFI0,
IFS_WIFI_AUTHENTICATION, IFPARAM_WIFI_ENCR_NONE,
IFS_END);
if(retval)
printf("Failed to set open\n");
}
//
// Config with SSID and set for DHCP
//
retval = ifconfig(IF_WIFI0, IFS_WIFI_SSID, ssid_len, ssid,
IFS_WIFI_MODE, IFPARAM_WIFI_INFRASTRUCTURE,
IFS_DHCP, 1,
IFS_END);
if(retval)
printf("Failed to set SSID\n");

printf("Bringing WiFi up\n");
Status = ifup(IF_WIFI0);
if(Status == IFCTL_FAIL) // Failed?
{
ifdown(IF_WIFI0); // Bring it down

while (ifpending(IF_WIFI0) != IF_DOWN)
{
OSTimeDly(16);
}
//
// Now try again to bring it up
//
Status = ifup(IF_WIFI0);
}
//
// We only wait 30 seconds max for it to come up, otherwise we
// bomb back out to PPP as it could be a config error
//
WiFiWaitTimer = SEC_TIMER + 30;

Status = ifpending(IF_WIFI0);
while((Status == IF_COMING_UP) || (Status == IF_COMING_DOWN))
{
OSTimeDly(16);

if(SEC_TIMER > WiFiWaitTimer)
{
ifdown(IF_WIFI0); // Take if down again
}
Status = ifpending(IF_WIFI0);
}
if(Status != IF_UP)
{
printf("WiFi failed to connect\n");
WiFiActive = 0; // Failed so go back to scanning
}
else
{
printf("WiFi connected\n");
ifconfig(IF_WIFI0, IFG_IPADDR, &ipaddr, IFS_END);
printf("IP Address: %s\n", inet_ntoa(ipaddr_string,ipaddr));

ifconfig(IF_WIFI0, IFG_ROUTER_DEFAULT, &ipaddr, IFS_END);
printf("Router Address: %s\n", inet_ntoa(ipaddr_string,ipaddr));
}

Hopefully that should help you figure it out. I don't use any #DEFINE in the
code. All config is done in the ifconfig calls so that the informaiton can
be done dynamically via the user setup that is done elsewhere in the code.

Good luck.

Dave...
---
Very funny Scotty, now beam down my clothes!!!
---

From: r... [mailto:r...] On
Behalf Of Ajay
Sent: 25 January 2011 15:30
To: r...
Subject: [rabbit-semi] ad hoc creation for RCM 5400W

Hi all

I am working on RCM 5400W...i just wrote a sample program to turn on al led
connected to 5400 and it ran successfully.

Now i would like to implement wirelessly using the wifi given...i have tried
the examples but i was unable to understand the...can any one help me out in
this regard.

Regards
Ajay