OpenHome Forum
Handle network change - Printable Version

+- OpenHome Forum (http://forum.openhome.org)
+-- Forum: OpenHome (/forumdisplay.php?fid=1)
+--- Forum: Net (/forumdisplay.php?fid=5)
+--- Thread: Handle network change (/showthread.php?tid=1395)

Pages: 1 2 3


Handle network change - SiMet - 19-06-2015 01:10 PM

And it's again me. I hope you don't get borred by my questions.

I made some tests on iPhone and ohNet and when I start some device on Wi-Fi network A then connect to Wi-Fi network B I could not see on device spy my device.

The same issue I see when startDv and I'm not connected to any Wi-Fi. After that I connect my any Wi-Fi and again I don't see my device in Device Spy.

I found UpnpLibrary::SetSubnetListChangedListener(...) and UpnpLibrary::SetNetworkAdapterChangedListener(...). However, when I disconnect or connect to other Wi-Fi network my Functors are not called.

Is that bug or this case is not handled or maybe I do something wrong.

If I could provide you any information don't hesitate to ask.


RE: Handle network change - simonc - 19-06-2015 04:20 PM

(19-06-2015 01:10 PM)SiMet Wrote:  And it's again me. I hope you don't get borred by my questions.

Not at all Smile. Feel free to keep the questions coming.

(19-06-2015 01:10 PM)SiMet Wrote:  I made some tests on iPhone and ohNet and when I start some device on Wi-Fi network A then connect to Wi-Fi network B I could not see on device spy my device.
[snip]
Is that bug or this case is not handled or maybe I do something wrong.

This looks like a missing feature. The subnet observers you tried using are driven from code in our porting layer - see OsNetworkSetInterfaceChangedObserver() in Os/Posix/Os.c. This functionality hasn't been implemented for iOS.

It may be a while before we get time to look at this. If you need this urgently, would you be able to propose a patch? If you'd like to see examples of how this is implemented for other platforms, the same source file has code for both Linux and MacOSX.


RE: Handle network change - SiMet - 19-06-2015 08:02 PM

I see now:
Code:
#ifdef PLATFORM_MACOSX_GNU
# ifndef PLATFORM_IOS
    SetInterfaceChangedObserver_MacDesktop(aContext, aCallback, aArg);
# endif /* !PLATFORM_IOS */

So ohNet doesn't handle automatically switch between networks on any platform?

However, I could handle this by subscribing for subnet change and when my currently used network will change I could stop and start again device. Am I right?

Probably me or my colleagues try to implement SoNetworkSetInterfaceChangeObserver() and if we make success I'll create pull request. However, I don't know if we know how to do it Big Grin


RE: Handle network change - SiMet - 23-06-2015 10:13 AM

Currently I'm getting notification about change IP based on code http://stackoverflow.com/questions/18378441/ip-adress-change-notifications

However, I couldn't achive start devices and CP again without creating all providers again.
Could you decribe me how this feature could be achived?


RE: Handle network change - simonc - 23-06-2015 12:36 PM

(23-06-2015 10:13 AM)SiMet Wrote:  Currently I'm getting notification about change IP based on code http://stackoverflow.com/questions/18378441/ip-adress-change-notifications

However, I couldn't achive start devices and CP again without creating all providers again.
Could you decribe me how this feature could be achived?

If the code that receives notification of IP change is in Os.c, it should run the callback from OsNetworkSetInterfaceChangedObserver() whenever IP changes. ohNet will automatically update any device lists, TCP servers, etc. when this happens.

If that doesn't cover your problem, could you tell us more about exactly what isn't working for you please?


RE: Handle network change - SiMet - 23-06-2015 03:03 PM

This code is not in OsNetworkSetInerfaceChangeObserver(). This is very high level way to check if IP has changed.
I don't know if I could put some ObjC code to this OS.c file or how can I handle this in other way.

I use compiled version and don't know exactly how could I test OS.c if I wrote everything properly


RE: Handle network change - SiMet - 24-06-2015 02:11 PM

I've just created some code (you can find it in attachment) and SubnetListChanged callback is called when I turn on or turn off WiFi (but not every time Sad ).

For example when I start with turned off Wi-Fi I don't get callback.
When with turned on I get it only once.

When I switch between networks I also do not see my device in Intel's tool Device Spy.

I'm sure that I'm doing something wrong or do not understand whole problem.


RE: Handle network change - simonc - 24-06-2015 03:07 PM

Thanks for this. We've discussed the problem internally and have a slightly different proposal for how to proceed.

We'll add a function to ohNet, say OhNetNetworkAdapterListRefresh() that will check available adapters, calling subnet/adapter change callbacks when necessary.

Each app would be responsible for deciding if or how often to call this. Your app could choose to refresh once per second; other apps may choose to make refresh a manual user option.

This should greatly reduce the complexity of the code your app and ohNet are required to write. It'd also make it easier for your app to add extra policy for when to stop refreshes (e.g. if you want to stop requesting timer callbacks when your app is suspended). Sorry that it's a change in approach from my previous posts; having thought about the problem more I now prefer this type of approach.

What do you think?


RE: Handle network change - SiMet - 25-06-2015 06:20 AM

(24-06-2015 03:07 PM)simonc Wrote:  Thanks for this. We've discussed the problem internally and have a slightly different proposal for how to proceed.

We'll add a function to ohNet, say OhNetNetworkAdapterListRefresh() that will check available adapters, calling subnet/adapter change callbacks when necessary.

Each app would be responsible for deciding if or how often to call this. Your app could choose to refresh once per second; other apps may choose to make refresh a manual user option.

This should greatly reduce the complexity of the code your app and ohNet are required to write. It'd also make it easier for your app to add extra policy for when to stop refreshes (e.g. if you want to stop requesting timer callbacks when your app is suspended). Sorry that it's a change in approach from my previous posts; having thought about the problem more I now prefer this type of approach.

What do you think?

In my opinion it's good solution. Hope that this will solve my problems Smile


RE: Handle network change - SiMet - 02-07-2015 01:40 PM

When do you plan introduce this feature?