If Bluetooth and ubluetooth modules coexist.

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
net0040
Posts: 26
Joined: Fri Nov 08, 2019 4:33 am

If Bluetooth and ubluetooth modules coexist.

Post by net0040 » Thu Nov 21, 2019 9:28 am

In esp32 micropython firmware,such as v.20191121.

I want to know if Bluetooth and ubluetooth modules coexist. I see that the example is based on Bluetooth module.
And How long will this co-existence last?

thanks

Code: Select all

 import ubluetooth
 import bluetooth

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

Re: If Bluetooth and ubluetooth modules coexist.

Post by jimmo » Thu Nov 21, 2019 10:07 am

Simple version: The module is called "ublueooth", but "import bluetooth" and "import ubluetooth" are the same thing. You should use "import bluetooth" (same as "import machine, time, json, os")

Longer version:
In MicroPython most of the core libraries are named ufoo (including umachine, ubluetooth, etc), but if you "import foo", then it will automatically find the "u" version if "foo" doesn't actually exist.

There are two reasons for this:
- For the libraries which have the same name as equivalent libraries from the CPython standard library (e.g. json, os, etc), it makes it clear that it's the "micro" version.
- It allows someone to provide a pure-Python alternative version, named module.py (which can itself "include umodule" to get the low-level implementation).

User avatar
net0040
Posts: 26
Joined: Fri Nov 08, 2019 4:33 am

Re: If Bluetooth and ubluetooth modules coexist.

Post by net0040 » Thu Nov 21, 2019 1:30 pm

jimmo wrote:
Thu Nov 21, 2019 10:07 am
Simple version: The module is called "ublueooth", but "import bluetooth" and "import ubluetooth" are the same thing. You should use "import bluetooth" (same as "import machine, time, json, os")

Longer version:
In MicroPython most of the core libraries are named ufoo (including umachine, ubluetooth, etc), but if you "import foo", then it will automatically find the "u" version if "foo" doesn't actually exist.

There are two reasons for this:
- For the libraries which have the same name as equivalent libraries from the CPython standard library (e.g. json, os, etc), it makes it clear that it's the "micro" version.
- It allows someone to provide a pure-Python alternative version, named module.py (which can itself "include umodule" to get the low-level implementation).
thanks,I see :D

Post Reply