ukBaz / python-bluezero

A simple Python interface to Bluez
MIT License
387 stars 112 forks source link

Unclear about Peripheral Usage #320

Closed han-so1omon closed 3 years ago

han-so1omon commented 3 years ago

How would I receive a command as a Peripheral device using this API?

My use case is that I would like to make my Raspberry Pi into a peripheral and I would like for it to be able to receive a signal like on/off/set_mode1/set_mode2.

How would I do that with Bluezero?

ukBaz commented 3 years ago

The example at : https://github.com/ukBaz/python-bluezero/blob/master/examples/ble_uart.py was intended to demonstrate how you would do that with Bluezero. In particular the RX_CHARACTERISTIC demonstrates how you have a characteristic that could be written to on the peripheral.

As BLE works best with small amounts of data, I would have the characteristic as 1 octet in size. 0 would be off. Any integer bigger than 0 would indicate on and what mode.