🇺🇸Adafruit will not be shipping orders on Independence Day Monday 7/4/2022. Please allow extra time for your order to ship and plan accordingly.🇺🇸
0

Linux won't find CPB
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Linux won't find CPB

by Insert_Name_Here on Thu Dec 23, 2021 6:51 pm

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 | TOGGLE FULL SIZE
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)

Insert_Name_Here
 
Posts: 58
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

by dastels on Thu Dec 23, 2021 10:48 pm

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: https://forums.adafruit.com/viewtopic.php?f=57&t=186172&p=902512.

Dave

dastels
 
Posts: 10206
Joined: Tue Oct 20, 2015 3:22 pm

Re: Linux won't find CPB

by Insert_Name_Here on Fri Dec 24, 2021 3:41 am

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

Insert_Name_Here
 
Posts: 58
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

by dastels on Fri Dec 24, 2021 10:56 am

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

Dave

dastels
 
Posts: 10206
Joined: Tue Oct 20, 2015 3:22 pm

Re: Linux won't find CPB

by Insert_Name_Here on Fri Dec 24, 2021 3:20 pm

Thanks.

Insert_Name_Here
 
Posts: 58
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

by adafruit2 on Fri Dec 24, 2021 7:50 pm

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

adafruit2
Site Admin
 
Posts: 20965
Joined: Fri Mar 11, 2005 7:36 pm

Re: Linux won't find CPB

by Insert_Name_Here on Fri Dec 24, 2021 11:30 pm

Linux "box"?

Insert_Name_Here
 
Posts: 58
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

by Claude_J_Greengrass on Fri Dec 24, 2021 11:59 pm

Insert_Name_Here wrote:Linux "box"?

box == computer e.g. Computer that is running Linux

Claude_J_Greengrass
 
Posts: 44
Joined: Sat Jul 24, 2021 10:53 am

Re: Linux won't find CPB

by Insert_Name_Here on Sat Dec 25, 2021 2:23 pm

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

Insert_Name_Here
 
Posts: 58
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

by danhalbert on Sat Dec 25, 2021 7:41 pm

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 | TOGGLE FULL SIZE
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 | TOGGLE FULL SIZE
>>> 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.

danhalbert
 
Posts: 3257
Joined: Tue Aug 08, 2017 12:37 pm

Re: Linux won't find CPB

by Insert_Name_Here on Sun Dec 26, 2021 10:08 pm

Code: Select all | TOGGLE FULL SIZE
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.

Insert_Name_Here
 
Posts: 58
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

by danhalbert on Mon Dec 27, 2021 12:05 am

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

danhalbert
 
Posts: 3257
Joined: Tue Aug 08, 2017 12:37 pm

Re: Linux won't find CPB

by Insert_Name_Here on Mon Dec 27, 2021 5:23 pm

The circuit python REPL in mu says:
Code: Select all | TOGGLE FULL SIZE
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.

Insert_Name_Here
 
Posts: 58
Joined: Tue Dec 07, 2021 2:35 pm

Re: Linux won't find CPB

by danhalbert on Mon Dec 27, 2021 5:58 pm

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

danhalbert
 
Posts: 3257
Joined: Tue Aug 08, 2017 12:37 pm

Re: Linux won't find CPB

by Insert_Name_Here on Mon Dec 27, 2021 6:24 pm

Still the same output.

Insert_Name_Here
 
Posts: 58
Joined: Tue Dec 07, 2021 2:35 pm

Please be positive and constructive with your questions and comments.