def dowork(device_address): services = bluetooth.find_service( address=device_address, uuid="1105", ) port = None if services: port = services[0]["port"] if not port: print "Service not provided" return print "Connecting to", device_address, port c = client.Client(device_address, port) response = c.connect() if not isinstance(response, responses.ConnectSuccess): print "Failed to connect" return reply = c.get(header_list=[ headers.Type("text/x-vcard"), ])[1] if reply and type(reply) == str: result = VCard(reply) print result.values doput(c) c.disconnect()
def SetNotificationRegistration(c, connect): happ = headers.App_Parameters('\x0e\x01' + ('\x01' if connect else '\x00')) c.put( name="", file_data='\x30', header_list=[headers.Type("x-bt/MAP-NotificationRegistration"), happ]) print("Notification Registration:" + str(connect))
def GetMessage(c, handle): resp = c.get(name=handle, header_list=[ headers.Type('x-by/message'), headers.App_Parameters('\x14\x01\x01') ]) return resp
def PushMessage(c, t, f, body): resp = c.put(name="outbox", file_data=msg, header_list=[ headers.Type("x-bt/message"), headers.App_Parameters('\x14\x01\x01') ]) return resp
def GetMessageListing(c, params): resp = c.get(name="inbox", header_list=[ headers.Type("x-bt/MAP-msg-listing"), headers.App_Parameters(params) ]) #headers.App_Parameters('\x10\x04\x00\x00\x10\x6b\x13\x01\xff')]) return resp
def update_inbox(self): response = self.put("", str(0x30), header_list=[ self.connection_id, headers.Type("x-bt/MAP-messageUpdate") ]) if not isinstance(response, responses.Success): raise Exception
def push_message(self, folder, message): response = self.put(folder, message, header_list=[ self.connection_id, headers.Type("x-bt/message"), headers.App_Parameters("\x0A\x01") ]) if not isinstance(response, responses.Success): raise Exception
def get_folder_listing(self): response = self.get(header_list=[ self.connection_id, headers.Type("x-obex/folder-listing") ]) if isinstance(response, responses.FailureResponse): raise Exception() header, data = response return data
def set_message_status(self, message_id, indicator, value): app_param = "\x17" + indicator + "\x18" + value response = self.put(message_id, str(0x30), header_list=[ self.connection_id, headers.Type("x-bt/messageStatus"), headers.App_Parameters(app_param) ]) if not isinstance(response, responses.Success): raise Exception
def get_message(self, message_id): response = self.get(header_list=[ self.connection_id, headers.Name(message_id), headers.Type("x-bt/message"), headers.App_Parameters("\x0A\x01\x14\x01") ]) if isinstance(response, responses.FailureResponse): raise Exception() header, data = response return data
def get_message_listing(self): response = self.get(header_list=[ self.connection_id, headers.Type("x-bt/MAP-msg-listing"), headers.App_Parameters(str(0x060)) ]) if isinstance(response, responses.FailureResponse): raise Exception() header, data = response return data
def set_notification_registration(self): response = self.put( "", str(0x30), header_list=[ self.connection_id, headers.Type("x-bt/MAP-NotificationRegistration"), headers.App_Parameters(str(0x0e1)) ]) if not isinstance(response, responses.Success): raise Exception(response)
def capability(self): """capability(self) Returns a capability object from the server, or the server's response if the operation was unsuccessful. """ response = self.get(header_list=[headers.Type(b"x-obex/capability")]) if not isinstance(response, responses.Success): return response header, data = response return data
def listdir(self, name=""): """listdir(self, name = "") Requests information about the contents of the directory with the specified name relative to the current directory for the session. Returns a tuple containing the server's response and the associated data. If successful, the directory contents are returned in the form of an XML document as described by the x-obex/folder-listing MIME type. If the name is omitted or an empty string is supplied, the contents of the current directory are typically listed by the server. """ return self.get( name, header_list=[headers.Type(b"x-obex/folder-listing", False)])
sys.stderr.write("No Phonebook service found.\n") sys.exit(1) port = d[0]["port"] # Use the generic Client class to connect to the phone. c = client.Client(device_address, port) uuid = b"\x79\x61\x35\xf0\xf0\xc5\x11\xd8\x09\x66\x08\x00\x20\x0c\x9a\x66" result = c.connect(header_list=[headers.Target(uuid)]) if not isinstance(result, responses.ConnectSuccess): sys.stderr.write("Failed to connect to phone.\n") sys.exit(1) # Access the list of vcards in the phone's internal phone book. hdrs, cards = c.get(prefix+"telecom/pb", header_list=[headers.Type(b"x-bt/vcard-listing")]) # Parse the XML response to the previous request. root = ElementTree.fromstring(cards) print("\nAvailable cards in %stelecom/pb\n" % prefix) # Examine each XML element, storing the file names we find in a list, and # printing out the file names and their corresponding contact names. names = [] for card in root.findall("card"): print("%s: %s" % (card.attrib["handle"], card.attrib["name"])) names.append(card.attrib["handle"]) print("\nCards in %stelecom/pb\n" % prefix)
sys.exit(1) port = d[0]["port"] # Use the generic Client class to connect to the phone. c = client.Client(device_address, port) uuid = "\x79\x61\x35\xf0\xf0\xc5\x11\xd8\x09\x66\x08\x00\x20\x0c\x9a\x66" result = c.connect(header_list=[headers.Target(uuid)]) if not isinstance(result, responses.ConnectSuccess): sys.stderr.write("Failed to connect to phone.\n") sys.exit(1) # Access the list of vcards in the phone's internal phone book. hdrs, cards = c.get(prefix + "telecom/pb", header_list=[headers.Type("x-bt/vcard-listing")]) # Parse the XML response to the previous request. root = ElementTree.fromstring(cards) print("\nAvailable cards in %stelecom/pb\n" % prefix) # Examine each XML element, storing the file names we find in a list, and # printing out the file names and their corresponding contact names. names = [] for card in root.findall("card"): print("%s: %s" % (card.attrib["handle"], card.attrib["name"])) names.append(card.attrib["handle"]) print("\nCards in %stelecom/pb\n" % prefix)