Closed ArthurKun21 closed 3 years ago
Currently the peripheral module does not have an API to stop the advertisement of the peripheral once created although there are lower level API's to allow that to happen. As you can see with the following code from publish
, the advertisement is registered and unregistered.:
I am not sure exactly what you would want to "turn off" but you could do a quick proof of concept to remove the advert with the following added to the example.
ble_uart.ad_manager.unregister_advertisement(ble_uart.advert)
If you wanted to add an unpublish
to the peripheral
module, my assumption would be that it would be something like:
def unpublish(self):
"""Remove peripheral and advertisement"""
self.mainloop.quit()
self.ad_manager.unregister_advertisement(self.advert)
Please feedback if that helps.
Also, I am happy to look at a pull request if you create something you believe would be generally applicable.
I was using this example
I would like to know if there is a command there that can stop the bluetooth advertising?
The use case of this is that when certain event happen, python will open its bluetooth and wait for further instruction, once the command was receive it will then turn off