Ejemplo n.º 1
0
    def connect(self):
        self.sock=btsocket.socket(btsocket.AF_BT,btsocket.SOCK_STREAM)
	btsocket.set_default_access_point(btsocket.access_point(btsocket.select_access_point()))
        addr,services=btsocket.bt_discover()
        print "Discovered: %s, %s"%(addr,services)
        if len(services)>0:
            import appuifw
            choices=services.keys()
            choices.sort()
            choice=appuifw.popup_menu([unicode(services[x])+": "+x
                                       for x in choices],u'Choose port:')
            port=services[choices[choice]]
        else:
            port=1
        address=(addr,port)
        print "Connecting to "+str(address)+"...",
        self.sock.connect(address)
        #except socket.error, err:
        #    if err[0]==54: # "connection refused"
        #        if _s60_UI:
        #            appuifw.note(u'Connection refused.','error')
        #        else:
        #            print "Connection refused."
        #        return None
        #    raise
        print "OK." 
Ejemplo n.º 2
0
 def connect(self):
     self.sock = btsocket.socket(btsocket.AF_BT, btsocket.SOCK_STREAM)
     btsocket.set_default_access_point(
         btsocket.access_point(btsocket.select_access_point()))
     addr, services = btsocket.bt_discover()
     print "Discovered: %s, %s" % (addr, services)
     if len(services) > 0:
         import appuifw
         choices = services.keys()
         choices.sort()
         choice = appuifw.popup_menu(
             [unicode(services[x]) + ": " + x for x in choices],
             u'Choose port:')
         port = services[choices[choice]]
     else:
         port = 1
     address = (addr, port)
     print "Connecting to " + str(address) + "...",
     self.sock.connect(address)
     #except socket.error, err:
     #    if err[0]==54: # "connection refused"
     #        if _s60_UI:
     #            appuifw.note(u'Connection refused.','error')
     #        else:
     #            print "Connection refused."
     #        return None
     #    raise
     print "OK."
Ejemplo n.º 3
0
 def selectAccessPoint(self):
     '''接入点'''
     try:
         import btsocket as newsocket
     except:
         import socket as newsocket
     else:
         ap_id = newsocket.select_access_point()
         apo = newsocket.access_point(ap_id)
         newsocket.set_default_access_point(apo)
Ejemplo n.º 4
0
 def selectAccessPoint(self):
     '''接入点'''
     try :
         import btsocket as newsocket
     except:
         import socket as newsocket
     else:
         ap_id=newsocket.select_access_point()
         apo=newsocket.access_point(ap_id)
         newsocket.set_default_access_point(apo)
Ejemplo n.º 5
0
def start_network():
    apid = None
    for ap in btsocket.access_points():
        if 'pergola' in ap['name'].lower():
            apid = ap['iapid']
            break
    if apid is not None:
        apo  = btsocket.access_point(apid)
        btsocket.set_default_access_point(apo)
        apo.start()
    def connect(self, address, port):

        if self.require_network_setup:
            apid = btsocket.select_access_point()
            self.wlan_connection = btsocket.access_point(apid)
            btsocket.set_default_access_point(self.wlan_connection)
            self.wlan_connection.start()
            self.require_network_setup = False

        self.proxy = xmlrpclib.ServerProxy("http://%s:%s" % (address, port))
Ejemplo n.º 7
0
def sel_access_point():

    aps = btsocket.access_points()
    if not aps:
        note(u"No access points available", "error")
        return None
    ap_labels = map(lambda x: x['name'], aps)
    item = popup_menu(ap_labels, u"Access points:")
    if item is None:
        return None
    apo = btsocket.access_point(aps[item]['iapid'])
    btsocket.set_default_access_point(apo)
    return apo
Ejemplo n.º 8
0
 def networking(self):
   
   self.log("Connecting to network ...")
   
   try:
     self.apid = btsocket.select_access_point()
     self.apo  = btsocket.access_point(self.apid)
     
     self.apo.start()
     
     self.log("done.")
     self.uiMenu(["start", "restart", "stop", "options", "update", "about", "exit"])
     
   except:
     self.log("failed.")
     self.uiMenu(["connect", "options", "about", "exit"])
Ejemplo n.º 9
0
    def networking(self):

        self.log("Connecting to network ...")

        try:
            self.apid = btsocket.select_access_point()
            self.apo = btsocket.access_point(self.apid)

            self.apo.start()

            self.log("done.")
            self.uiMenu([
                "start", "restart", "stop", "options", "update", "about",
                "exit"
            ])

        except:
            self.log("failed.")
            self.uiMenu(["connect", "options", "about", "exit"])
Ejemplo n.º 10
0
Archivo: a.py Proyecto: Symbian9/rssagk
def associate_ap():
    ap_id=None
    
    for i in btsocket.access_points():
        if i['name']==settings['default_ap']:
            ap_id=i['iapid']
            break
    
    
    #Selects a default ap now, without saving the choice in the settings
    if ap_id==None:
        ap_id=btsocket.select_access_point() #Selects the access point and returns its id
    
    #If still no ap was selected, return
    if ap_id==None:
        return
        
    ap=btsocket.access_point(ap_id)      #Create the access point object
    btsocket.set_default_access_point(ap)
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software 
# distributed under the License is distributed on an "AS IS" BASIS, 
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
# See the License for the specific language governing permissions and 
# limitations under the License. 

"A Remote Python Shell for Symbian Phone" 

import sys 

try:
    import btsocket as socket
    apid = socket.select_access_point()
    apo = socket.access_point(apid)
    socket.set_default_access_point(apo)
    apo.start()
except ImportError, error:
    import socket

from code import InteractiveConsole 

class FakeOutputFile(object): 
    def __init__(self): 
        self.connection = None

    def register(self, conn): 
        self.connection = conn 

    def write(self, data): 
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"A Remote Python Shell for Symbian Phone"

import sys

try:
    import btsocket as socket
    apid = socket.select_access_point()
    apo = socket.access_point(apid)
    socket.set_default_access_point(apo)
    apo.start()
except ImportError, error:
    import socket

from code import InteractiveConsole


class FakeOutputFile(object):
    def __init__(self):
        self.connection = None

    def register(self, conn):
        self.connection = conn
Ejemplo n.º 13
0
 def test_access_point(self):
     access_points = btsocket.access_points()
     if access_points:
         apo = btsocket.access_point(access_points[0]['iapid'])
         btsocket.set_default_access_point(apo)
         btsocket.set_default_access_point(None)
Ejemplo n.º 14
0
def vybernet():
  apid = btsocket.select_access_point()
  apo = btsocket.access_point(apid)
  btsocket.set_default_access_point(apo)