Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5140

Networking and servers • Re: Bluetooth between Pico and Pi 5 issues with receiving

$
0
0
This isn't bleak code, but my Python library here

https://github.com/petzval/btferret

Follow the instructions in section 2.2 of the documentation to install the Python library.

Put the LE device's address in the devices.txt file (there is already a NODE=7 LE device in the file - just change the address).

Code:

DEVICE = LE device  TYPE=LE  NODE=7   ADDRESS = 00:11:22:33:44:55
Run this code, with the relevant characteristic UUID inserted.

Code:

import btfpydef callback(lenode,cticn,data,datlen):  btfpy.Print_data(data)  # notification received  return(0)if btfpy.Init_blue("devices.txt") == 0:  exit(0)  btfpy.Connect_node(7,btfpy.CHANNEL_LE,0)    # connect node 7btfpy.Find_ctics(7)  # Read servicesuuid = btfpy.Strtohex("11223344-5566-7788-99AA-BBCCDDEEFF00") # char uuidindex = btfpy.Find_ctic_index(7,btfpy.UUID_16,uuid)btfpy.Notify_ctic(7,index,btfpy.NOTIFY_ENABLE,callback)  # enable notificationsbtfpy.Read_notify(30000) # wait 30s for notifybtfpy.Disconnect_node(7) btfpy.Close_all()

Statistics: Posted by petzval — Thu Jan 02, 2025 5:23 pm



Viewing all articles
Browse latest Browse all 5140

Trending Articles