Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

nRF52840 itsy does not show when attempting BT pair ...
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

nRF52840 itsy does not show when attempting BT pair ...

by kmbrad1963 on Fri May 01, 2020 3:04 pm

Still cannot see in the AdaFruit App or my Windows 10 Bluetooth pair dialog.

Code here:

Code: Select all | TOGGLE FULL SIZE
"""
reads one char from UART.
... and sends as a bluetooth keyboard to host (if connected).
"""

import board
import time
import busio

import adafruit_ble
from adafruit_ble.advertising import Advertisement
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.standard.hid import HIDService
from adafruit_ble.services.standard.device_info import DeviceInfoService
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS

# setup UART
uart = busio.UART(board.TX, board.RX, baudrate=9600)

# Use default HID descriptor
hid = HIDService()
device_info = DeviceInfoService(
    software_revision=adafruit_ble.__version__,
    manufacturer="Adafruit Industries"
)
advertisement = ProvideServicesAdvertisement(hid)
advertisement.appearance = 961
scan_response = Advertisement()

ble = adafruit_ble.BLERadio()

# disconnect previous connections.
if ble.connected:
    for c in ble.connections:
        c.disconnect()

print("advertising")
ble.start_advertising(advertisement, scan_response)

k = Keyboard(hid.devices)
kl = KeyboardLayoutUS(k)
while True:
    while not ble.connected:
        pass
    print("Connected !")
    while ble.connected:
        # read one ascii char from UART.
        c = uart.read(1)
        # write to the BLE keyboard.
        kl.write(c)
        # sleep 100 mS.
        time.sleep(0.1)
    # disconnected ... so re-advertise.
    ble.start_advertising(advertisement)


... how can I get the MAC address of my device in the REPL serial pane?

Thanks!
kmbrad1963
 
Posts: 7
Joined: Sun Mar 02, 2014 12:20 pm

Re: nRF52840 itsy does not show when attempting BT pair ...

by kmbrad1963 on Fri May 01, 2020 3:32 pm

Mu serial windows does not seem to work.
connected to CDC COM port and got better data refresh.

Saw I had a lib missing.

Able to connect now but noticed my loop going past the read() ?
I assumed it would block but doesn't.

What line would I need to check if a char is ready on the UART?

Thanks!
kmbrad1963
 
Posts: 7
Joined: Sun Mar 02, 2014 12:20 pm

Re: nRF52840 itsy does not show when attempting BT pair ...

by adafruit_support_carter on Fri May 01, 2020 7:05 pm


adafruit_support_carter
 
Posts: 15962
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.