Adam-Langley / pybleno

A direct port of the Bleno bluetooth LE peripheral role library to Python2/3
MIT License
68 stars 34 forks source link

Pizza Example does not work #21

Closed johanneskpp closed 5 years ago

johanneskpp commented 5 years ago

The Pizza-Example does not start advertising. The node version works fine but I need it for python. Hope you can help me!

johanneskpp commented 5 years ago

unbenannt

ecasadod commented 5 years ago

Hello,

I've been facing the same problem. If you put Bleno initialization (bleno = Bleno()) AFTER Pizza Service init, in peripheral.py, it will work. By the way, I'm testing in a Raspberry Pi Zero W.

Best regards,

Enrique

Adam-Langley commented 5 years ago

This issue arises from the inherence threading model difference between Python, and Nodejs from which this library was ported. In Node, the main event loop pauses until the the of the initialization process. In Python, the initialization (and hence the 'power on' event) is performed as soon as the Bleno() object is created. I have updated the API to now require the use of bleno.Start() - this gives the opportunity to register your callbacks before the subsystem is started.

Remember to update your code to use bleno.Start()! See the updated examples.

Thanks.

Fixed by fa245fa1b1701af682c8880f60a41795d4ce9700