Author: remi
Date: 2009-09-25 12:04:13 +0200 (Fri, 25 Sep 2009)
New Revision: 5500

Modified:
   
software_suite_v3/smart-core/smart-server/trunk/resources/02_robot/10_resourceRF.py
Log:
* Improved wifi-avoidance

Modified: 
software_suite_v3/smart-core/smart-server/trunk/resources/02_robot/10_resourceRF.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/resources/02_robot/10_resourceRF.py
 2009-09-25 10:00:21 UTC (rev 5499)
+++ 
software_suite_v3/smart-core/smart-server/trunk/resources/02_robot/10_resourceRF.py
 2009-09-25 10:04:13 UTC (rev 5500)
@@ -93,6 +93,8 @@
         self.__flagsMutex = threading.Lock()
         self.__channelInUse = None
         self.__connectionDetected = False
+        self.__chanCycleMap = [1, 6, 11]
+        self.__currentChanCycleIdx = 0
         defaultConfiguration = {
             'avoided_channel' : None,
             'avoided_bandwidth' : WIFI_DEFAULT_AVOIDED_BANDWIDTH,
@@ -150,34 +152,27 @@
     def statesChecker(self):
         userChannel = self.configurator.getConfiguration()['avoided_channel']
         userBandwidth = 
self.configurator.getConfiguration()['avoided_bandwidth']
-        if self.__channelIsInUse() == None:
+        if self.__channelIsInUse() != None:
+            self.avoidChannel(self.__channelIsInUse(), 
WIFI_DEFAULT_AVOIDED_BANDWIDTH)
+        else:
             if userChannel != None:
                 self.logger.logInfo("Manual wifi channel avoidance : ch=%d 
bw=%d" % (userChannel, userBandwidth))
                 self.avoidChannel(userChannel, userBandwidth)
                 self.__setChannelInUse(userChannel)
                 self.__setConnectionDetected(True)
             else:
-                """
-                if URLTools.URLCheck("http://ftp.kysoh.com";, 5.0):
-                    detectedChannel = self.detectChannel()
-                    if detectedChannel != None:
-                        print "Avoid auto detected channel :", detectedChannel
-                        self.avoidChannel(detectedChannel, 
WIFI_DEFAULT_AVOIDED_BANDWIDTH)
-                        self.__setChannelInUse(detectedChannel)
-                        self.__setConnectionDetected(True)
-                    else:
-                        print "Can't detect wifi channel, default is 1"
-                        self.avoidChannel(1, WIFI_DEFAULT_AVOIDED_BANDWIDTH)
-                        self.__setChannelInUse(1)
-                        self.__setConnectionDetected(True)
-                """
-                # Don't detect internet connection seems to have better results
                 detectedChannel = self.detectChannel()
                 if detectedChannel != None:
                     self.logger.logInfo("Automatic wifi channel avoidance : 
ch=%d" % detectedChannel)
                     self.avoidChannel(detectedChannel, 
WIFI_DEFAULT_AVOIDED_BANDWIDTH)
                     self.__setChannelInUse(detectedChannel)
                     self.__setConnectionDetected(True)
+                else:
+                    chan = self.__chanCycleMap[self.__currentChanCycleIdx]
+                    self.__currentChanCycleIdx += 1
+                    if self.__currentChanCycleIdx >= len(self.__chanCycleMap):
+                        self.__currentChanCycleIdx = 0
+                    self.avoidChannel(chan, WIFI_DEFAULT_AVOIDED_BANDWIDTH)
 
     def resetStates(self):
         self.logger.logInfo("Reset wifi channel avoidance states")


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to