예제 #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." 
예제 #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."
예제 #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)
예제 #4
0
파일: default.py 프로젝트: xkong/jwcx-pys60
 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)
    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))
예제 #6
0
파일: default.py 프로젝트: apanly/sypFTP
 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"])
def test_socket():
    """ Tests the btsocket module for selection of access point and displays
        the selected value. Also checks if a device can be selected to connect
        via bluetooth.

    """
    options = [u"discover", u"select_access_point"]
    menu_index = appuifw.popup_menu(options, u"Select")
    if menu_index == 0:
        btsocket.bt_discover()
    else:
        access_point_id = btsocket.select_access_point()
        for access_point in btsocket.access_points():
            if access_point['iapid'] == access_point_id:
                appuifw.note(u"The access point selected is: " + \
                unicode(access_point['name']))
                break
예제 #8
0
파일: default.py 프로젝트: apanly/sypFTP
    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"])
예제 #9
0
파일: a.py 프로젝트: 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 
#
#     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
예제 #12
0
def vybernet():
  apid = btsocket.select_access_point()
  apo = btsocket.access_point(apid)
  btsocket.set_default_access_point(apo)