0

I'm trying to send a file from my laptop(win10) to my mobile(android) over bluetooth. I followed this answer and I'm doing the same with python 3.6

I'm using PyOBEX Python 3 Package and this is what I've tried.

import sys
from PyOBEX.client import Client
from bluetooth import *

addr = '60:7E:DD:A7:42:43' 


print("Searching for OBEX service on {}".format(addr))
services = find_service(address=addr, name=b'OBEX Object Push\x00')
if len(services) == 0:
    sys.exit()


first_match = services[0]
port = first_match["port"]

client = Client(addr, port)
client.connect()
client.put("test.txt", "Hello world\n")
client.disconnect()

When I run this, the device is discovered but it doesn't establish a connection or send files. This is the error it gives

enter image description here

I tried messing around with the PyOBEX package by changing the type of data returned by socket_.recv to str but it gives me another error, enter image description here

I'm stuck and I have never worked with bluetooth or sockets before. Any help is appreciated

mplusr
  • 151
  • 15
  • always put code, data and error message as text. – furas Dec 20 '20 at 21:23
  • it seems this module is for Python 2 (which treats `string` as `bytes`) and it needs changes to work with Python 3 (which doesn't treat `string` as `bytes`). For example `socket_.rect(...)` may need `socket_.rect(...).decode()` and `struct,unpack(self.format, data)` may need `struct,unpack(self.format, data.encode())`. Shortly: someone mess with `data` - sometimes it is srting, sometimes it is bytes. – furas Dec 20 '20 at 21:28

0 Answers0