Cannot connect BLE in LoPy
-
Hi all,
I have a LoPy device and I want to connect a device via Bluetooth. It can read the advertises, but it cannot connect the device. Is there any Bluetooth setting I need to set in LoPy device or the corresponding device, or is there any way to debug it? The
adv_typeI am receiving is0. Here is the code I am trying:from network import Bluetooth import time bt = Bluetooth() bt.start_scan(-1) while True: adv = bt.get_adv() if adv and bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL) == 'BBC micro:bit [zaput]': print(adv.adv_type) try: conn = bt.connect(adv.mac) print('connected') services = conn.services() for service in services: time.sleep(0.050) if type(service.uuid()) == bytes: print('Reading chars from service = {}'.format(service.uuid())) else: print('Reading chars from service = %x' % service.uuid()) chars = service.characteristics() for char in chars: if (char.properties() & Bluetooth.PROP_READ): print('char {} value = {}'.format(char.uuid(), char.read())) conn.disconnect() break except: print("Error while connecting or reading from the BLE device") break else: time.sleep(0.050)Also, I am getting these lines as the output and firmware version:
0 Error while connecting or reading from the BLE device Pycom MicroPython 1.20.2.r6 [v1.11-c5a0a97] on 2021-10-28; LoPy with ESP32 Pybytes Version: 1.7.1 -
@Fikret-Avci Are you able to connect to the device using a different device, like a smartphone with nRF Connect for instance (or one of the many other BLE scanners)?
-
@jcaron I can connect other device with app on the smart phone. Also, I could connect LoPy when I use it as server.
-
This post is deleted! -
It says
OSError: connection refusedafter trying to connect withconnect(adv.mac)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login