Raspberry Pi. Bluetooth. Send. Receive

2.- App sends data to the Raspberry Pi via Bluetooth.

p9B3i_enviar_RaspBerry.aia (3.3 KB)

  • App sends every 600 ms, sequentially 5 bytes contained in a list.
    11001100,
    00110010,
    11011011,
    10110110,
    00000000

  • Phyton2. Script : bluetooth4.py

import bluetooth 
server_sock=bluetooth.BluetoothSocket(bluetooth.RFCOMM) 
port = 22
server_sock.bind(("",port)) 
server_sock.listen(1) 
client_sock,address = server_sock.accept() 
print ("Conexion realizada con: ", address) 
while True: 
    recvdata = client_sock.recv(1024) 
    print ("Informacion recibida: %s" % recvdata)
    if (recvdata == "Q"): 
        print ("Finalizado.") 
        break
         
client_sock.close() 
server_sock.close()
2 Likes