PDA

View Full Version : Wifi Question



hooktxu
07-07-2009, 04:27 PM
Hi, I have a wifi secure socket and I have to put a WPA password to connect to ir correctly. I use this code but it give me an error.




serialIWi.str(string("AT+iWLSI=red))

serialIWi.tx($0D)


i:= 0
repeat
iWLSIResponse:=serialIWi.rx
i++
while NOT(iWLSIResponse==$0A)


serialPC.str(@iWLSIResponse[0])

serialPC.str(string("MoreLab2 OK"))

''-------------------
serialIWi.str(string("AT+iWSTO=3"))
serialIWi.tx($0D)

i:= 0
repeat
iWST0Response:=serialIWi.rx
i++
while NOT(iWST0Response[i-1]==$0A)


serialPC.str(@iWST0Response[0])

serialPC.str(string("WEP OK"))

''-------------------

serialIWi.str(string("AT+iWLPP=modjjjdu"))
serialIWi.tx($0D)

i:= 0
repeat
iWLPPResponse[i]:=serialIWi.rx
i++
while NOT(iWLPPResponse[i-1]==$0A)


serialPC.str(@iWLPPResponse[0])

serialPC.str(string("Clave OK"))

MagIO2
07-07-2009, 04:52 PM
Would you please be so kind and provide all the information that you have in more detail! What kind of error? Is it a compile error or is your program not running as expected?
I assume it's both:
1.


serialIWi.str(string("AT+iWLSI=red))
serialIWi.str(string("AT+iWLSI=red"))

2.


iWLSIResponse:=serialIWi.rx
iWLSIResponse[i]:=serialIWi.rx

Same problem for the other responses!

3.


while NOT(iWLSIResponse[i-1]==$0A)


serialPC.str(@iWLSIResponse[0])


You don't add the string terminator after reading the response. Is the response fixed in size? I'd replace the $0a with a $0 or add a $0 after the response.
Plus .. you don't check for the size of the response. That could produce buffer overflows, for example if you don't set the baudrade adequate on both sides ... or if you have noise on the communication lines ....

Post Edited (MagIO2) : 7/7/2009 8:58:15 AM GMT