View unanswered posts | View active topics It is currently Fri Jul 25, 2014 1:01 pm






Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
connecting the Dexter Industries WIFI sensor 
Author Message
Novice

Joined: Sun Jun 13, 2010 9:26 am
Posts: 58
Post connecting the Dexter Industries WIFI sensor
Hello:

I am trying to connect my WIFI sensor from Dexter Industries to my wireless router. I changed the SSID and WEP key in the code from Dexter Industries Week I.

Code:
////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Setup for Wifi Sensor, and Associate with a WEP Network
//
//  This scrip will connect the DI Wifi sensor to a WEP network.  After connecting the
//  NXT will query the network status and print it out on the debugging console.
//
//  Output is in the debugging console of RobotC. So be sure to turn on the debugging console.
//
//  You must replace the values of SSID and WEP_KEY for your system.
//
//  For more information and documentation please see our website: http://dexterindustries.com/manual/wifi/
//
////////////////////////////////////////////////////////////////////////////////////////////////////////
 
#define DEBUG_WIFI 1
#ifdef DEBUG_WIFI
#define writeRawHS(X, Y) debugnxtWriteRawHS(X, Y)
#else
#define writeRawHS(X, Y) nxtWriteRawHS(X, Y)
#endif
 
// Declare the SSID we're connecting to, character by character.  Nothing at the end of the array.
ubyte ssid[] = {'P', 'i', 'c', 'k', 'l', 'e','s','S','c','r','u','f','f'};
// Declaring the WEP_KEY: This example has a 26-digit WEP Key.
// If you have a 10-digit WEP Key, delete the extra spaces.
// Don't put line returns at the end of this array.
ubyte wep_key[] = {'8','1','3','3','3','9','4','5','7','3'};        // Space for 10 digit WEP key.
 
//#include "common.h"
 
#include "DIWIFI-Connect_WEP.h"
 
void wifi_startup(){
  config_wifi();
  set_wep_key(1);           // Setup the WEP key.
  setDHCP(1);               // Get us an IP number
  wifi_auth_mode(1);        // Set the authentication mode.
                            // 0 is none or WPA // 1 is Open network // 2 is Shared with WEP
  associate_with_network(); // Connect to Wifi network
 
  getInfo();                // Get current lan status.
  getInfoWLAN();            // Get current lan status.
 
}
 
////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                                        Main Task
//
////////////////////////////////////////////////////////////////////////////////////////////////////////
 
task main()
{
  eraseDisplay();
  bNxtLCDStatusDisplay = true; // Enable top status line display
  wifi_startup();
  PlaySound(soundBeepBeep);   // Make some noise when we're connected.
  PlayTone(500, 100);         // Make some noise when we're connected.
}


I did not make any changes to the DIWIFI-Connect_WEP.h file. I did comment out the #Include "drivers/common.h" file. Was that right? If not what do I need to do to get that line to work? The compiler says it cannot find the file. Below is the output from the Debug Stream window. Any help as to what is wrong would be greatly appreciated.

Mike,

echo_all_input_off
ate0

OK
sfwr_flw_cntrl
at&k1

OK
set_verbose
atv1

OK
wifi_infra_mode.
at+wm=0

OK
discon_frm_networksat+wd


OK
ATS1=1000

OK
AT+PSPOLLINTRL=1200
OK
Set Max Xmit Power
at+WP=7

OK
- - - - - - - - -
Set WEP Key
AT+WWEP1=8133394573
OK
setDHCP
at+NDHCP=1

OK
wifi_auth_mode
at+wauth=1

OK
- - - - - - - - -
assoc_w_network
at+WA=PicklesScruff
ERROR: IP CONFIG FAIL
getInfo
at+NSTAT=?
52
IP addr=0.0.0.0 SubNet=0.0.0.0 Gateway=0.0.0.0
DNS1=0.0.0.0 DNS2=0.0.0.0
Rx Count=35 Tx Count=43017

OK
getInfo
at+WSTATUS

MODE:0 CHANNEL:3 SSID:"PicklesScruff"
BSSID:00:21:04:b5:87:da SECURITY:WEP (OPEN)
OK


Fri Mar 23, 2012 10:39 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3163
Location: Rotterdam, The Netherlands
Post Re: connecting the Dexter Industries WIFI sensor
You are setting a WEP key but then configure the Wifi sensor for an Open network. If you are using WEP on your network (which I would highly recommend you don't, upgrade to WPA/WPA2) then you must use
wifi_auth_mode(2);

If the program compiled without the common.h then you don't need it :) The common.h file is part of my driver suite, which you can download from the link in my signature. It has lots of drivers for almost every conceivable sensor available for the NXT. Most of them provide a super-set of the functionality provided by the built-in drivers in ROBOTC.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat Mar 24, 2012 3:17 am
Profile WWW
Novice

Joined: Sun Jun 13, 2010 9:26 am
Posts: 58
Post Re: connecting the Dexter Industries WIFI sensor
Okay... I tried the DIWIFI-Connect-WPA.c and DIWIFI-Connect-WPA.h code last night. Now I get even less response from the debug stream than with the WEP setup. I tried all three authentication settings wifi_auth_mode(1); - 0, 1, and 2. If I change the setting in the DIWIFI-Connect-WPA.c code does it need changing in the DIWIFI-Connect-WPA.h code? If so, where? Otherwise, everything is the same as it was in the WEP setup above.

The router is currently setup as WPA-PSK-AES with a passkey. The router can also do WPA-PSK-TKIP.

Mike,


Sun Mar 25, 2012 11:07 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3163
Location: Rotterdam, The Netherlands
Post Re: connecting the Dexter Industries WIFI sensor
Can you attach both the WPA .c and .h files to a post so I can check them out?

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Mar 25, 2012 12:40 pm
Profile WWW
Novice

Joined: Sun Jun 13, 2010 9:26 am
Posts: 58
Post Re: connecting the Dexter Industries WIFI sensor
I have attached the DIWIFI-Connected_WPA.c and DIWIFI-Connected_WPA.h files.

I checked the wireless router and it is setup as follows:
SSId -- PicklesScruff
PSK -- PicklesScruffy
Authentication is WPA-PSK AES

Xander -- Thank you for your help!
Mike


Attachments:
DIWIFI-Connect_WPA.h [11.43 KiB]
Downloaded 282 times
DIWIFI-Connect_WPA.c [2.27 KiB]
Downloaded 287 times
Mon Mar 26, 2012 2:31 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3163
Location: Rotterdam, The Netherlands
Post Re: connecting the Dexter Industries WIFI sensor
Mine has always been setup for TKIP, not AES, did you test it with that as well? The files look, I am not seeing anything weird there.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Mar 26, 2012 3:07 pm
Profile WWW
Novice

Joined: Sun Jun 13, 2010 9:26 am
Posts: 58
Post Re: connecting the Dexter Industries WIFI sensor
I will try TKIP tonight. What should the wifi_auth_mode(?) be set to? It is set to zero by default, but as I stated earlier I tried all three values.

Is there a way, other than watching the debug stream output for what is happening? I have been monitoring the wireless router to see if it detects the NXT trying to connect. But, so far I have not been able to tell. Is there a way to find out what the sensor's MAC address is? Maybe by knowing the MAC address I can scan the log files for it and get some more information as to what is happening.

Mike,


Mon Mar 26, 2012 4:22 pm
Profile
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: connecting the Dexter Industries WIFI sensor
The mac address is on a sticker that is on the GainSpan WIFI module.

Once you have connected, the ROBOTC debug stream will post your IP address as well as several other things.

_________________
Matt


Mon Mar 26, 2012 4:55 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3163
Location: Rotterdam, The Netherlands
Post Re: connecting the Dexter Industries WIFI sensor
Mode is 0 (wpa).

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Mar 27, 2012 12:07 am
Profile WWW
Novice

Joined: Sun Jun 13, 2010 9:26 am
Posts: 58
Post Re: connecting the Dexter Industries WIFI sensor
Yes, I set the wifi_auth_mode(0); to zero in the DIWIFI_Connect-WPA.c file. In fact, I tried all three values. I did see the wireless router detect the DIWIFI sensor (it said something about associate and then disassociated MAC address .....), but not hand out an IP address. I also, used the step through mode and found that the program gets hung up on line 77 in the DIWIFI_Connect_WPA.h file:
while (nxtGetAvailHSBytes() == 0) wait1Msec(5);

Just guessing, but could the SSID and password be too long? What about the broadcast channel? It is currently set to 3.

Is it possible to get a more watered down piece of code, or pieces that could be used to find out where the program is failing? I am thinking of sort of like when I work with the motors. First I try and see if I can get the motor to turn on, then control its power, then add rotational control. Another thought I have, "Is it possible to skip the authentication and use the MAC address to access the wireless. If I can get an IP address than I can try for authentication????"

Mike,


Tue Mar 27, 2012 11:25 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3163
Location: Rotterdam, The Netherlands
Post Re: connecting the Dexter Industries WIFI sensor
What is the function it calls before it goes to the "Receive()" function?

Also beware that calculating the psk takes quite some time.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Mar 27, 2012 11:53 am
Profile WWW
Novice

Joined: Sun Jun 13, 2010 9:26 am
Posts: 58
Post Re: connecting the Dexter Industries WIFI sensor
I do not know what function is before the Receive() function. My programming skills are not very strong, especially C and wireless knowledge is about the same. I will run the step through method again tonight and note the lines just before the line that hangs.

How long should I wait for the PSK to happen? I think I waited about 10 to 15 minutes.

I was reading the notes for using the DIWIFI sensor using NXC, and noted that the WPA is WPA2. My wireless router only knows WPA without any distinction to the various types of WPA that are available. I am going to also try this using NXC and see what happens.

Again, Thank You for all your help!
Mike,


Tue Mar 27, 2012 3:29 pm
Profile
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: connecting the Dexter Industries WIFI sensor
Computing a WPA PSK usually takes 15-20 seconds for me.

_________________
Matt


Tue Mar 27, 2012 4:53 pm
Profile WWW
Novice

Joined: Sun Jun 13, 2010 9:26 am
Posts: 58
Post Re: connecting the Dexter Industries WIFI sensor
Hello Matt:

What code are you using? The same code posted on the Dexter Industries WIFI Week 1?
http://dexterindustries.com/blog/2011/1 ... a-network/

Mike,


Tue Mar 27, 2012 5:20 pm
Profile
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: connecting the Dexter Industries WIFI sensor
I have used that program, but that's not usually what I do.

I made an NXC program that configures the DIWIFI, connects to the network, and saves the settings as the default profile. Now, every time I boot the DIWIFI (power it on), all I have to do is tell it to connect to the SSID (takes about 5 seconds). I modified the ROBOTC "setup and connect" program to find the baud rate (which configures RS485 on the NXT to the proper speed), and then connect to the SSID. Because it boots with my saved profile, there is no reason to issue all the setup commands and compute the WPA PSK before connecting. Altogether now, with finding the right baud rate and connecting to the SSID, it takes about 12-13 seconds to complete. Although I could make it significantly faster if I wanted (probably about 5-7 seconds).

_________________
Matt


Tue Mar 27, 2012 6:50 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 21 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.