Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to connect: internal error #191

Open
CptanPanic opened this issue Nov 16, 2023 · 0 comments
Open

Failed to connect: internal error #191

CptanPanic opened this issue Nov 16, 2023 · 0 comments

Comments

@CptanPanic
Copy link

This is on a ESP32-S3 Reverse TFT, connecting to a BLE device. I get "Failed to connect: internal error"

Output:

code.py output:
Scanning for BLE devices...
found target device!
address: <Address 6c:79:b8:bb:b1:ed>
connectable: True
flags: <AdvertisingFlags general_discovery le_only >
matches: <bound_method>
rssi: -69
scan_response: True
tx_power: None
complete_name: None
get_prefix_bytes: <bound_method>
data_dict: {2: b'\xf0\xff', 1: <AdvertisingFlags object at 0x3de0dd20>}
mutable: False
match_prefixes: ()
_prefix_bytes: b''
short_name: None
Stopped Scan
Error connecting to robot: Failed to connect: internal error

Code done running.
import time
import adafruit_ble
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService


target_address = '6c:79:b8:bb:b1:ed'
target_address_bytes = bytes(reversed([int(x, 16) for x in target_address.split(":")]))

print("Scanning for BLE devices...")
ble = adafruit_ble.BLERadio()
devices = ble.start_scan(timeout=1, extended=True, interval=.2)

for device in devices:
    if device.address.address_bytes == target_address_bytes:
        print("found target device!")
        for attr in ['address', 'connectable', 'flags', 'matches', 'rssi', 'scan_response', 'tx_power', 'complete_name', 'get_prefix_bytes', 'data_dict', 'mutable', 'match_prefixes', '_prefix_bytes', 'short_name']:
            print(f"{attr}: {getattr(device, attr)}")
        
        try:
            ble.stop_scan()
            print("Stopped Scan")

            robot_connection = ble.connect(device)

            if robot_connection and robot_connection.connected:
                print("Connected to robot")
                uart_service = robot_connection[UARTService]
                uart_service.write(0xfff2)
                print("Sent message to robot")
        except Exception as e:
            print("Error connecting to robot:", e)
        break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant