| View previous topic :: View next topic |
| Author |
Message |
joreofiorio35
Joined: 03 Dec 2005 Posts: 6
|
Posted: Mon Dec 05, 2005 6:41 am Post subject: Wlan.getIPAddress() function not working |
|
|
| Has anybody got this function to work? I am coding a chat program in LUA and I need to tell the user what IP Address his PSP is so other users can connect to him. Yesterday this was coming up with errors saying, "Invalid IP Address." And today it is coming up as a bunch of jumbled up text when I try to print the string that it returns. Shine, have you looked into this? |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Mon Dec 05, 2005 6:51 am Post subject: Re: Wlan.getIPAddress() function not working |
|
|
| joreofiorio35 wrote: | | Shine, have you looked into this? |
Yes, I have the same problem, see my comment in the Applications/WLAN program. I don't know how to fix it. |
|
| Back to top |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Mon Dec 05, 2005 7:36 am Post subject: Re: Wlan.getIPAddress() function not working |
|
|
| Shine wrote: | | joreofiorio35 wrote: | | Shine, have you looked into this? |
Yes, I have the same problem, see my comment in the Applications/WLAN program. I don't know how to fix it. |
I think maybe you're not waiting long enough for the Apctl connection to stabilise. Take a look at the code around sceNetApctlGetState() in PspPet's wifi sample code.
It would be easy enough to test this by putting a large sleep between initialising the wifi and getting the IP address. _________________ Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you! |
|
| Back to top |
|
 |
joreofiorio35
Joined: 03 Dec 2005 Posts: 6
|
Posted: Mon Dec 05, 2005 8:43 am Post subject: |
|
|
Actually shine, I think you have made an error in your coding.
Here is what PspPet has:
| Code: | if (sceNetApctlGetInfo(8, szMyIPAddr) != 0)
strcpy(szMyIPAddr, "unknown IP address"); |
And here is what you have Shine:
| Code: | if (sceNetApctlGetInfo(8, szMyIPAddr) != 0) {
// TODO: gets garbage
lua_pushstring(L, szMyIPAddr);
return 1;
}
|
I think you should change the "!=0" to "==0", because if it doesnt equal zero, then it IS a valid IP address. |
|
| Back to top |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Mon Dec 05, 2005 8:52 am Post subject: |
|
|
Agreed. Both fixes are required for complete stability, I think. _________________ Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you! |
|
| Back to top |
|
 |
joreofiorio35
Joined: 03 Dec 2005 Posts: 6
|
Posted: Mon Dec 05, 2005 9:04 am Post subject: |
|
|
| Yes, Please Do fix it (if that is the problem) and if you can, can you send me the new compiled version once fixed, or post it on the site? (I dont have the pspsdk and dont have space for it) |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Tue Dec 06, 2005 9:38 am Post subject: |
|
|
| Thanks, I've fixed it. Fanjita wants to change something more for testing his 2.00 bootloader and I want to add some more true type font functions (you can set a transformation matrix for rotating and scaling the font and I think there is something for bold fonts), and UDP support is still missing, but then perhaps I'll release a new version this weekend. |
|
| Back to top |
|
 |
joreofiorio35
Joined: 03 Dec 2005 Posts: 6
|
Posted: Sat Dec 10, 2005 8:05 am Post subject: |
|
|
I have another way of getting your IP as of right now, this one will only get your router's IP which you can access your PSP through by port forwarding whichever port your program uses to listen with. This just connects a site and gets the IP from that site by picking apart the string of HTML code.
| Code: |
function GETIPADDRESS()
thestr = {}
IP = ""
a=1
b=1
ipgetsock, error = Socket.connect("216.99.213.74", 80)
while not ipgetsock:isConnected() do System.sleep(100) end
bytesSent = ipgetsock:send("GET /ipaddress.html HTTP/1.0\r\n")
bytesSent = ipgetsock:send("host: ww1.nia-nia.com\r\n\r\n")
while true do
thestr[a] = ipgetsock:recv()
if placefound == nil then placefound = string.find(thestr[a], "REMOTE_ADDR=") end
if placefound then placefound=placefound+12
while true do
if string.sub(thestr[a], placefound, placefound) == "R" then IP=string.sub(IP, 1, string.len(IP)-1) return IP end
IP=IP..string.sub(thestr[a], placefound, placefound)
placefound=placefound+1
end
end
placefound=nil
if Controls.read():start() then screen.waitVblankStart(10) break end
screen.waitVblankStart()
a=a+1
end
return -1
end
|
|
|
| Back to top |
|
 |
|