Making a successful Bluetooth Connection to RPi
Question: I have a RPi and a normal Debian on my pc, both using the Bluetooth Python
module to communicate. Both have some Bluetooth USB dongle in them. I can use
the pc as server and the RPi as client, this connection works very well.
However I'm not able to do it vice versa, I checked my `rfcomm.conf` and
`main.conf`, but both seem to be ok. Any other pitfalls?

* * *
    
    
    #Server.py
    
    import bluetooth
    
    server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
    
    port = 1
    server_sock.bind(("",port))
    server_sock.listen(1)
    
    client_sock,address = server_sock.accept()
    print "Accepted connection from ",address
    
    data = client_sock.recv(1024)
    print "received [%s]" % data
    
    client_sock.close()
    server_sock.close()
    

* * *
    
    
    #Client.py
    
    import bluetooth
    
    bd_addr = #myspecificmacaddress
    
    port = 1
    
    sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
    sock.connect((bd_addr, port))
    
    sock.send("hello!!")
    
    sock.close()
    

* * *

So to be more precise: Running `Client.py` on RPi and `Server.py` on pc works
fine, doing vice versa, obviously with corrected MAC, simply says:
`bluetooth.btcommon.BluetoothError: (112, 'Host is down')`


Answer: Turned out that my config files weren't that well. (it must had to do
something with config files)

`/etc/bluetooth/main.conf` has a class section.
`/var/lib/bluetooth/XX:XX:XX:XX:XX:XX/config` has a class section, too.

I do not know why, I do not know how or what is actually happening, as you are
not able to find anything about this on the internet, but setting _both_ to
`0x400100` fixed it. I don't know if they just have to match or if it's some
special thing I came up by fortune, but it works and I dont really want to
possibly break it again.

Maybe someone with more knowledge about this is willing to improve my answer
here.

