Activating BLE

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
poesel
Posts: 22
Joined: Sun Oct 20, 2019 4:58 pm

Activating BLE

Post by poesel » Sun Nov 03, 2019 12:26 pm

Hi,

I'm probably thick here but why does:

Code: Select all

from ubluetooth import BLE, UUID, FLAG_NOTIFY, FLAG_READ, FLAG_WRITE
ble = BLE
ble.active(True)
give me a 'TypeError: argument has wrong type'?
The firmware is from today. The example code does the very same - just in __init__ and it works so its not some hardware problem.

?

Thanks

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

Re: Activating BLE

Post by jimmo » Mon Nov 04, 2019 12:04 am

Hi,

BLE is a type, so to construct an instance of it, you need to use BLE().

i.e.

Code: Select all

ble = BLE()
ble.active(True)
Which example were you looking at, happy to fix any mistakes or make it clearer.

poesel
Posts: 22
Joined: Sun Oct 20, 2019 4:58 pm

Re: Activating BLE

Post by poesel » Mon Nov 04, 2019 6:00 pm

There is no problem with an example. They work very well. It is only my lack of understanding of the details of Python... :roll:

I took the temperature example:

Code: Select all

...
class BLETemperature:
    def __init__(self, ble, name='mpy-temp'):
        self._ble = ble
        self._ble.active(True)
...
and didn't notice that you do just what you described here:

Code: Select all

...
def demo():
    ble = bluetooth.BLE()
    temp = BLETemperature(ble)
...
Being able to read helps a lot. ;)

Thank you!

Post Reply