def show_settings(): ap_list=[u'---None---'] for i in btsocket.access_points(): ap_list.append(i['name']) try: ap_default=ap_list.index(settings['default_ap']) except: ap_default=0 form=appuifw.Form( [ (u'Show read Articles','combo', ([u'No', u'Yes'],int(settings['show_read']))), (u'Default access point','combo', (ap_list,ap_default)), (u'Update feeds on open','combo', ([u'No', u'Yes'],int(settings['update_on_open']))), (u'Items to store per feed','number',settings['items_per_feed']), (u'Max chars per line','number',settings['chars_per_line']), #(u'txt','text', u'default'), #(u'number','number', 123), #(u'date','date'), #(u'time','time'), ], appuifw.FFormDoubleSpaced | appuifw.FFormEditModeOnly) form.execute() settings['show_read']=bool(form[0][2][1]) settings['default_ap']=ap_list[form[1][2][1]] settings['update_on_open']=bool(form[2][2][1]) settings['items_per_feed']=int(form[3][2]) settings['chars_per_line']=int(form[4][2])
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 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
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
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)
def select_access_point(): ''' Return True if selected, False otherwise ''' import btsocket, socket global st_connected pnts = [] points = btsocket.access_points() for i in points: pnts.append(i['name']) index = appuifw.popup_menu(pnts, u'Select access point:') if index is not None: try: socket.set_default_access_point(pnts[index]) st_connected = True return True except: pass return False
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)