forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Wlan.getIPAddress() function not working

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
joreofiorio35



Joined: 03 Dec 2005
Posts: 6

PostPosted: Mon Dec 05, 2005 6:41 am    Post subject: Wlan.getIPAddress() function not working Reply with quote

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
View user's profile Send private message Send e-mail
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Mon Dec 05, 2005 6:51 am    Post subject: Re: Wlan.getIPAddress() function not working Reply with quote

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
View user's profile Send private message
Fanjita



Joined: 28 Sep 2005
Posts: 217

PostPosted: Mon Dec 05, 2005 7:36 am    Post subject: Re: Wlan.getIPAddress() function not working Reply with quote

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
View user's profile Send private message
joreofiorio35



Joined: 03 Dec 2005
Posts: 6

PostPosted: Mon Dec 05, 2005 8:43 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Fanjita



Joined: 28 Sep 2005
Posts: 217

PostPosted: Mon Dec 05, 2005 8:52 am    Post subject: Reply with quote

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
View user's profile Send private message
joreofiorio35



Joined: 03 Dec 2005
Posts: 6

PostPosted: Mon Dec 05, 2005 9:04 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Tue Dec 06, 2005 9:38 am    Post subject: Reply with quote

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
View user's profile Send private message
joreofiorio35



Joined: 03 Dec 2005
Posts: 6

PostPosted: Sat Dec 10, 2005 8:05 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group