ubluepy central example

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
djbugs
Posts: 1
Joined: Thu Sep 26, 2019 3:02 pm

ubluepy central example

Post by djbugs » Thu Sep 26, 2019 3:12 pm

Hi everybody,

I'm playing around with the pca10056 board from Nordic.
I get the Scanner and advertising examples running.
But i can not find some example code that show how to connect to a peripherial device and write to a characteristic.
Is this not implemented yet or I just did not search long enough?

Regards,
Bugs

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: ubluepy central example

Post by jimmo » Sun Sep 29, 2019 10:38 am

Hi,

I don't see any sample code that does this, but reading ubluepy_peripheral.c seems to suggest this is possible with:

Code: Select all

p = Peripheral()
p.connect('aa:bb:cc:dd:ee:ff')
services = p.getServices()

c = service.getCharacteristic()
# or:  chrs = service.getCharacteristics()

c.read() / c.write()

c45713
Posts: 51
Joined: Fri Dec 09, 2016 7:09 pm

Re: ubluepy central example

Post by c45713 » Sat Oct 05, 2019 6:24 pm

Assuming you are looking for an example with a Central GATT client and Peripheral GATT server, you are very close. :)
If you look in ports/nrf/examples/powerup.py there is a full example of a remote control for the PowerUp3.0 acting as a Central GATT client.

In case you require bonding in Central, the PR https://github.com/micropython/micropython/pull/4083 might of interest, and Characteristic Descriptors in https://github.com/micropython/micropython/pull/4082.

Post Reply