ESP32 bluetooth basic support

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
icetomcat
Posts: 1
Joined: Mon Mar 25, 2019 4:49 pm

ESP32 bluetooth basic support

Post by icetomcat » Mon Mar 25, 2019 5:00 pm

Hi, I recently added basic notification support for BLE. Now it is possible to implement communication between devices with BLE.
https://github.com/icetomcat/micropython/tree/bluetooth

Example:

import utime
import bluetooth

bt = bluetooth.Bluetooth()
bt.active(True)
bt.advertise(1000, 'MicroPython')

# callback
def receive(char, msg):
# echo
characteristics[1].notify(msg)
print(msg)

characteristics = [
bluetooth.Characteristic(
0xFF01,
bluetooth.FLAG_WRITE | bluetooth.FLAG_READ,
receive = receive
),
bluetooth.Characteristic(
0xFF02,
bluetooth.FLAG_NOTIFY,
descriptors = [
bluetooth.Characteristic(bluetooth.UUID_CHAR_CLIENT_CONFIG, bluetooth.FLAG_WRITE | bluetooth.FLAG_READ)
]
)
]

bt.add_service(0x00FF, characteristics)

while True:
characteristics[0].wait() # waiting new message, async
utime.sleep_ms(100)

ke528
Posts: 2
Joined: Thu May 09, 2019 3:11 am

Re: ESP32 bluetooth basic support

Post by ke528 » Thu May 09, 2019 3:16 am

你好
我按照这个例子 实验
不起作用
第一项错误 是没有 receive
能写一份 docs么
在线等你的回复

Hello
Let me follow this example.
No effect
The first mistake is that there is no receive.
Can you write a docs?
Waiting for your reply Online

User avatar
mattyt
Posts: 301
Joined: Mon Jan 23, 2017 6:39 am

Re: ESP32 bluetooth basic support

Post by mattyt » Thu May 09, 2019 5:57 am

It's great that you've taken the initiative but Bluetooth support is in active development; please take a look at PR #4589. Initial support aims to cover nRF5x, ESP32 and PyBoard D. I'm sure they'd welcome contributions from folks with Bluetooth knowledge!

Post Reply