Skip to main content
  • Press & News
  • Contact Us
  • Login
  • Register

Main menu

  • Technology
  • Business
  • Downloads
  • Community
  • Buy
Join Forum Blog Projects Social 

You are here

Home » Forums » TCP/IP and Wi-Fi

Is there a IP address event?

4 posts / 0 new
Log in or register to post comments
Last post
Wed, 02/22/2012 - 09:12
#1
michaelp
Offline
Joined: 02/14/2012
Posts: 34
Is there a IP address event?

Hello,

If this code is executed and the while loop exits, a connection to the WiFi network is established, but it is not guaranteed that an IP address is already obtained.

WFConnect(WF_DEFAULT);
while (WFStatus != CONNECTED);

I try to send something to pachube after the code above, but of course that does not work without IP address. So I have to wait:

WFConnect(WF_DEFAULT);
while (WFStatus != CONNECTED);
vTaskDelay(500);
sendPachube();

I don't like this delay, that is kind of dirty to implement it that way.
Question: Is there any kind of state in WFStatus that notifies me of a new IP? Or is there any other state variable which I should poll?

 

my output, you can see that the IP address is obtained after the connection event

Start WiFi Connect
Event: Connection Successful
Flyport say: hello world!
New IP Address: 192.168.1.12

 

Regards,

Michael

Top
  • Log in or register to post comments
Wed, 02/22/2012 - 10:44
#2
simmartin
simmartin's picture
This Cat's on a Hot Tin Roof

Offline
Joined: 05/03/2011
Posts: 341

At this point there is no specific function that can do this. The UARTWrite related to the new ip address is located inside the Main.c file.

You could tweak this file and set a flag if the current IP is different, but you could do this also inside the taskFlyport.c using the same method of Main.c.

 

For my own, I can suggest this kind of code for the taskFlyport.c (attached also the C source code) :

 

DWORD myLastIP = 0;
BOOL IPChanged = FALSE;
 
void FlyportTask()
{
myLastIP = AppConfig.MyIPAddr.Val;
 
WFConnect(WF_DEFAULT);
while (WFStatus != CONNECTED);
UARTWrite(1,"Flyport connected... hello world!\r\n");
vTaskDelay(100);
while(1)
{
if(myLastIP != AppConfig.MyIPAddr.Val)
{
myLastIP = AppConfig.MyIPAddr.Val;
IPChanged = TRUE;
}
 
if(IPChanged == TRUE)
{
IPChanged = FALSE;
vTaskDelay(200);
UARTWrite(1, "Found new IP on Flyport module!\r\n");
}
}
}
 

 

 

 

AttachmentSize
taskFlyport.c.zip460 bytes

This Cat's on a Hot Tin Roof!

Top
  • Log in or register to post comments
Wed, 02/22/2012 - 10:54
#3
michaelp
Offline
Joined: 02/14/2012
Posts: 34

Thank you very much for your fast response.

Your code looks very promising :-) I'll try it out tonight, but I'm sure it'll work much better than my stupid delay.

 

Thanks,

Michael

Top
  • Log in or register to post comments
Wed, 02/22/2012 - 18:08
(Reply to #3) #4
simmartin
simmartin's picture
This Cat's on a Hot Tin Roof

Offline
Joined: 05/03/2011
Posts: 341

michaelp wrote:

Thank you very much for your fast response.

Your code looks very promising :-) I'll try it out tonight, but I'm sure it'll work much better than my stupid delay.

 

Your delay is not so stupid... if you have to check only one time... a simple delay is more code-fast friendly for our lazy minds!!! :D

I use it very often...

michaelp wrote:

Thanks,

Michael

you are welcome!

This Cat's on a Hot Tin Roof!

Top
  • Log in or register to post comments
  • Technology
    • Overview
    • Downloads
    • Products
    • Universities
    • Projects
  • Business
    • Overview
    • System integrators
    • Distributors
    • Products
    • Projects
    • Services
  • Downloads
    • Downloads
    • Get Started
    • Projects
    • FAQ
  • Community
    • Join
    • Forum
    • Blog
    • Projects
    • Social
  • Buy
    • Store
    • Retailers
    • Distributors

openPICUS Newsletter

Copyright 2001 © OpenPICUS    -    All rights reserved    -    info@openpicus.com