Linux won't find CPB

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
Insert_Name_Here
 
Posts: 64
Joined: Tue Dec 07, 2021 2:35 pm

Linux won't find CPB

Post by Insert_Name_Here »

I have a circuit playground bluefruit.
On windows and my dad's mac book it works.
But it wont work on linux.

Code: Select all

from adafruit_circuitplayground import cp
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.standard.hid import HIDService
from adafruit_ble.advertising import Advertisement
from adafruit_hid.mouse import Mouse

cp.pixels.brightness = 0.1
cp.pixels.fill((0, 0, 0))
ble = BLERadio()
hid = HIDService()
advertisement = ProvideServicesAdvertisement(hid)
scan = Advertisement()
scan.complete_name = "Circuit Playground BLE"
mouse = Mouse(hid.devices)
while True:
    ble.start_advertising(advertisement, scan)
    cp.pixels.fill((0, 50, 50))
    while not ble.connected:
        pass
    while ble.connected:
        cp.pixels.fill((0, 50, 0))
        while cp.button_a:
            mouse.click(Mouse.LEFT_BUTTON)
        while cp.button_b:
            mouse.click(Mouse.RIGHT_BUTTON)

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: Linux won't find CPB

Post by dastels »

You say it won't find it and that it doesn't work. What exactly do you mean? The CIRCUITPY drive is not mounting? If you double reset when connected to the Linux box does the BOOT drive mount?

There might be some useful information in this thread: viewtopic.php?f=57&t=186172&p=902512.

Dave

User avatar
Insert_Name_Here
 
Posts: 64
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

Post by Insert_Name_Here »

No. I mean linux won't connect to it via bluetooth.

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: Linux won't find CPB

Post by dastels »

Ah. I'm afraid I can't help, but I'll make sure this gets seen someone who can.

Dave

User avatar
Insert_Name_Here
 
Posts: 64
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

Post by Insert_Name_Here »

Thanks.

User avatar
adafruit2
 
Posts: 22187
Joined: Fri Mar 11, 2005 7:36 pm

Re: Linux won't find CPB

Post by adafruit2 »

gotta make sure - do you have BLE support hardware in the linux box or just BT classic?

User avatar
Insert_Name_Here
 
Posts: 64
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

Post by Insert_Name_Here »

Linux "box"?

User avatar
Claude_J_Greengrass
 
Posts: 79
Joined: Sat Jul 24, 2021 10:53 am

Re: Linux won't find CPB

Post by Claude_J_Greengrass »

Insert_Name_Here wrote:Linux "box"?
box == computer e.g. Computer that is running Linux

User avatar
Insert_Name_Here
 
Posts: 64
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

Post by Insert_Name_Here »

This computer also runs windows, and it works on there. So...

User avatar
danhalbert
 
Posts: 4686
Joined: Tue Aug 08, 2017 12:37 pm

Re: Linux won't find CPB

Post by danhalbert »

Try this slight variant on your program. Note the supervisor.disable_ble_workflow() at the top. Also I changed how to set the advertising name, which may not make any difference.

Code: Select all

import supervisor

from adafruit_circuitplayground import cp
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.standard.hid import HIDService
from adafruit_ble.advertising import Advertisement
from adafruit_hid.mouse import Mouse

supervisor.disable_ble_workflow()

cp.pixels.brightness = 0.1
cp.pixels.fill((0, 0, 0))
ble = BLERadio()
ble.name = "Circuit Playground BLE"
hid = HIDService()
advertisement = ProvideServicesAdvertisement(hid)
mouse = Mouse(hid.devices)

while True:
    ble.start_advertising(advertisement)
    cp.pixels.fill((0, 50, 50))
    while not ble.connected:
        pass
    print("connected")
    while ble.connected:
        cp.pixels.fill((0, 50, 0))
        while cp.button_a:
            mouse.click(Mouse.LEFT_BUTTON)
        while cp.button_b:
            mouse.click(Mouse.RIGHT_BUTTON)

You must pair with Linux before HID will work. I scanned for the device and then paired with it.

You can erase old pairing/bonding info by doing this in the REPL:

Code: Select all

>>> import _bleio
>>> _bleio.erase_bonding()
You don't need to do this every time.

I have found you often have to turn Linux Bluetooth off and then back on again if some error has occurred.

User avatar
Insert_Name_Here
 
Posts: 64
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

Post by Insert_Name_Here »

Code: Select all

import supervisor

from adafruit_circuitplayground import cp
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.standard.hid import HIDService
from adafruit_hid.mouse import Mouse

supervisor.disable_ble_workflow()

cp.pixels.brightness = 0.1
cp.pixels.fill((0, 0, 0))
ble = BLERadio()
ble.name = "Circuit Playground BLE"
hid = HIDService()
advertisement = ProvideServicesAdvertisement(hid)
mouse = Mouse(hid.devices)

while True:
    ble.start_advertising(advertisement)
    cp.pixels.fill((0, 50, 50))
    while not ble.connected:
        pass
    print("connected")
    while ble.connected:
        cp.pixels.fill((0, 50, 0))
        while cp.button_a:
            mouse.click(Mouse.LEFT_BUTTON)
        while cp.button_b:
            mouse.click(Mouse.RIGHT_BUTTON)
results in red blinking neopixels.

User avatar
danhalbert
 
Posts: 4686
Joined: Tue Aug 08, 2017 12:37 pm

Re: Linux won't find CPB

Post by danhalbert »

Please look at the serial output to see what the errors are.

User avatar
Insert_Name_Here
 
Posts: 64
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

Post by Insert_Name_Here »

The circuit python REPL in mu says:

Code: Select all

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.



Press any key to enter the REPL. Use CTRL-D to reload.


Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit Circuit Playground Bluefruit with nRF52840
>>> uto-reload is on -
Not anything to do with an error.

User avatar
danhalbert
 
Posts: 4686
Joined: Tue Aug 08, 2017 12:37 pm

Re: Linux won't find CPB

Post by danhalbert »

Type ctrl-D at the REPL prompt. That will restart code.py. Then see if you see an error.

User avatar
Insert_Name_Here
 
Posts: 64
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

Post by Insert_Name_Here »

Still the same output.

Locked
Please be positive and constructive with your questions and comments.

Return to “Wireless: WiFi and Bluetooth”