linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Linphone-developers] Network reachability callback problem in Linphone


From: IVAN FERNANDEZ
Subject: [Linphone-developers] Network reachability callback problem in Linphone iPhone
Date: Wed, 20 Jun 2012 13:48:34 +0200

Hi,

I'm facing an strange problem with the callback that detects network changes in Linphone code.

The problem is that the callback is being called correctly when the wifi goes off, but it is not called again when the wifi goes on.

I'm running two test (iPhone 4 iOS 5.1.1, Linphone 1.1.2 with TLS enabled):

1. Wifi set to ON: I run Linphone from xcode ->wait the registration in the server -> then I go to the settings and switch off wifi -> the callback is called -> ALL IS GREAT -> then I switch wifi on again... -> the callback is not called -> ;-/

2. Wifi set to OFF: I run Linphone from xcode -> no connection so the registration can not be done -> then I go to the settings and switch on wifi -> the callback is not called -> ;-/

Let's take a look to the callback:

void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* nilCtx) {

     ms_message("Network connection flag [%x]",flags);

    

     LinphoneManager* lLinphoneMgr = [LinphoneManager instance];

     SCNetworkReachabilityFlags networkDownFlags=kSCNetworkReachabilityFlagsConnectionRequired |kSCNetworkReachabilityFlagsConnectionOnTraffic;


     if ([LinphoneManager getLc] != nil) {

          LinphoneProxyConfig* proxy;

          linphone_core_get_default_proxy([LinphoneManager getLc], &proxy);


          struct NetworkReachabilityContext* ctx = nilCtx ? ((struct NetworkReachabilityContext*)nilCtx) : 0;

        

          if ((flags == 0) | (flags & networkDownFlags)) {


                 [lLinphoneMgr kickOffNetworkConnection];

                 //COMMENTING THE FOLLOWING LINE THE PROBLEM IS PARCIALLY SOLVED !!!!!!!!!!!!

                 linphone_core_set_network_reachable([LinphoneManager getLc],false);

                 lLinphoneMgr.connectivity = none;

            

     } else {


            Connectivity  newConnectivity;

            BOOL isWifiOnly = [[NSUserDefaults standardUserDefaults] boolForKey:@"wifi_only_preference"];

            if (!ctx || ctx->testWWan)

                newConnectivity = flags & kSCNetworkReachabilityFlagsIsWWAN ? wwan:wifi;

            else

                newConnectivity = wifi;


            if (newConnectivity == wwan && proxy && isWifiOnly && (lLinphoneMgr.connectivity == newConnectivity || lLinphoneMgr.connectivity == none)) {

                    linphone_proxy_config_expires(proxy, 0);

            } else if (proxy){

                    linphone_proxy_config_expires(proxy, DEFAULT_EXPIRES); //might be better to save the previous value

            }

            if (lLinphoneMgr.connectivity == none) {

                      linphone_core_set_network_reachable([LinphoneManager getLc],true);

            } else if (lLinphoneMgr.connectivity != newConnectivity) {

                      // connectivity has changed

                     linphone_core_set_network_reachable([LinphoneManager getLc],false);

                     if (newConnectivity == wwan && proxy && isWifiOnly) {

                              linphone_proxy_config_expires(proxy, 0);

                      } 

             linphone_core_set_network_reachable([LinphoneManager getLc],true);

              }

              lLinphoneMgr.connectivity=newConnectivity;

              ms_message("new network connectivity  of type [%s]",(newConnectivity==wifi?"wifi":"wwan"));

         }

          if (ctx && ctx->networkStateChanged) {

                  (*ctx->networkStateChanged)(lLinphoneMgr.connectivity);

            }

     }

}


The most curious thing is that if I comment the invocation to "linphone_core_set_network_reachable" that I've pointed in the callback the first test works great and the callback is called on both on/off wifi changes (what makes me suspect that the problem can be caused by a silly issue), but the second test remains failing.

¿Anyone has that point running? ¿Any ideas about why the callback is not called any more at some point? 

PD: On Android, the same test with reachability works great on all the cases.

Thanks in advanced..




reply via email to

[Prev in Thread] Current Thread [Next in Thread]