Exemple #1
0
    def test_notifications_at_idle_state(self):
        pattern = [
            (.0, "\r\n^RSSI:27\r\n"),
            (.5, "\r\n^RSSI:26\r\n"),
            (.3, "\r\n^RSSI:12\r\n"),
        ]
        
        expected = [
            N.UnsolicitedNotification(N.SIG_RSSI, 27),
            N.UnsolicitedNotification(N.SIG_RSSI, 26),
            N.UnsolicitedNotification(N.SIG_RSSI, 12),
        ]

        def load_pattern_cb(ignored):
            resp = []
            
            while self.stub.protocol.notifications.pending:
                d = self.stub.protocol.notifications.get()
                d.addCallback(lambda noti: resp.append(noti))
            
            self.assertEqual(expected, resp)

        d = self.stub.load_pattern(pattern)
        d.addCallback(load_pattern_cb)
        return d
Exemple #2
0
 def get_network_bear_cb(netinfo):  # Bearer
     if netinfo[1] in 'GPRS':
         sig = N.GPRS_SIGNAL
     else:
         sig = N.UMTS_SIGNAL
     noti = N.UnsolicitedNotification(N.SIG_NEW_CONN_MODE, sig)
     self.manager.on_notification_received(noti)
Exemple #3
0
 def get_network_name_cb(netinfo):  # Network name
     noti = N.UnsolicitedNotification(N.SIG_NEW_NETWORK, netinfo[0])
     self.manager.on_notification_received(noti)
     return netinfo
Exemple #4
0
 def get_signal_level_cb(rssi):
     noti = N.UnsolicitedNotification(N.SIG_RSSI, rssi)
     self.manager.on_notification_received(noti)
Exemple #5
0
 def function(self):
     up, down = self.netspeed['up'], self.netspeed['down']
     n = N.UnsolicitedNotification(N.SIG_SPEED, bps_to_human(up, down))
     self.manager.on_notification_received(n)
Exemple #6
0
 def get_network_info_cb(netinfo):
     noti = N.UnsolicitedNotification(N.SIG_NEW_CONN_MODE, netinfo[1])
     self.manager.on_notification_received(noti)