Beispiel #1
0
 def execute_async(self, ud):
     # Wait a bit here because buggy drivers don't like to do things
     # just as they are coming down.
     yield async_helpers.async_sleep(ud.radio.pre_up_sleep)
     yield async_helpers.wait_for_state(ud.radio._up_state_pub,
                                        operator.truth)
     returnValue('up')
Beispiel #2
0
 def child_restart(self):
     yield async_helpers.async_sleep(0.2) # Limit race conditions on getting the startup state.
     current_state = RunCommand('ip', 'addr')
     with self.lock:
         old_cur_iface = self.cur_iface
         old_deleted = self.deleted
         for line in current_state.stdout.split('\n'):
             self.got_line(line)
         self.deleted = old_deleted
         self.cur_iface = old_cur_iface
            if iface.radio_sm.associated.get():
                freqs = self.frequencies.next_scan_freqs(iface, 1, False)
            else:
                freqs = self.frequencies.next_scan_freqs(iface, self.num_scan_frequencies, True)
        except NoFrequenciesReady, nfr:
            if nfr.next_time:
                self.scheduled_scan[iface] = reactor.callLater(max(0.1, nfr.next_time - time.time()), self._trigger_scan, iface)
                #print "No frequencies for ", iface.iface, nfr.next_time - time.time()
            #else:
                #print "No frequencies for", iface.iface
        else:
            print "Triggering scan", iface.iface, freqs
            rslt = yield iface.radio_sm.scan(freqs)
            if not rslt:
                print "Scan failed", iface.iface, freqs
                yield async_helpers.async_sleep(self.failed_scan_delay)
                self.frequencies.reschedule(iface, freqs)

    def _scan_event_cb(self, iface, bsses):
        #print "_scan_event_cb", len(bsses)
        self.bss_list.update(bsses, iface)
        self.new_scan_data.trigger()

    def _frequency_list_cb(self, iface, old_state, new_state):
        now = time.time()
        for f in new_state:
            self.frequencies.add(f, iface)
        
        if old_state != state_publisher.JustSubscribed:
            for f in old_state:
                self.frequencies.remove(f, iface)
            else:
                freqs = self.frequencies.next_scan_freqs(iface, self.num_scan_frequencies, True)
        except NoFrequenciesReady, nfr:
            if nfr.next_time:
                self.scheduled_scan[iface] = reactor.callLater(
                    max(0.1, nfr.next_time - time.time()), self._trigger_scan, iface
                )
                # print "No frequencies for ", iface.iface, nfr.next_time - time.time()
            # else:
            # print "No frequencies for", iface.iface
        else:
            print "Triggering scan", iface.iface, freqs
            rslt = yield iface.radio_sm.scan(freqs)
            if not rslt:
                print "Scan failed", iface.iface, freqs
                yield async_helpers.async_sleep(self.failed_scan_delay)
                self.frequencies.reschedule(iface, freqs)

    def _scan_event_cb(self, iface, bsses):
        # print "_scan_event_cb", len(bsses)
        self.bss_list.update(bsses, iface)
        self.new_scan_data.trigger()

    def _frequency_list_cb(self, iface, old_state, new_state):
        now = time.time()
        for f in new_state:
            self.frequencies.add(f, iface)

        if old_state != state_publisher.JustSubscribed:
            for f in old_state:
                self.frequencies.remove(f, iface)
Beispiel #5
0
 def execute_async(self, ud):
     # Wait a bit here because buggy drivers don't like to do things
     # just as they are coming down.
     yield async_helpers.async_sleep(ud.radio.pre_up_sleep)
     yield async_helpers.wait_for_state(ud.radio._up_state_pub, operator.truth)
     returnValue('up')