Controlling multiple Powered Up devices

About two years ago I had a dual SBrick “train” setup controlled with my EV3. I never really got much far because there were some hiccups when using one USB BLE dongle to control two SBrick at the same time that didn’t occur with my Ubuntu laptop (same dongle, a CSR 4.0).

By that time, the ev3dev had a BlueZ stack much older than my Ubuntu so I decided to wait and as usual I forgot about it.

Today I’m testing how many Powered Up hubs I can control at the same time with just one BLE “client”. Just a simple bash script, changing the RGB LED colors of the hubs at the same time.

My laptop could control 2. But started to had issues with 3, failing some commands:

Characteristic Write Request failed: Request attribute has encountered an unlikely error

Perhaps sending 3 gatttool commands in-a-row was too much so added a small delay. It got worst:

connect error: Connection timed out (110)

Tuning to a small delay (0.03) seems to be the best but is strange.

Now this laptop is no longer the same I had and it now has an onboard BLE 4.2 chipset, from Intel. Not sure which version.

But I still have the CSR 4.0 dongle on the Ev3 over the desk. So let’s try same script with it.

No errors at all. Not even with 0 delay.

These last years David has been doing a great job with ev3dev kernel so my EV3 and my Ubuntu laptop are now pretty close: (4.14.58-ev3dev-2.2.1-ev3 against 4.15.0-29-lowlatency #31-Ubuntu SMP PREEMPT) so I don’t think this is a BlueZ issue.

I read somewhere that CSR 4.0 allows 5 sessions. So I need to test my script again with more LEGO hubs. But wonder why the Intel only handles two.

Now the script:

#!/usr/bin/env bash

#colors
OFF=0
PINK=1
PURPLE=2
BLUE=3
LIGHTBLUE=4
LIGHTGREEN=5
GREEN=6
YELLOW=7
ORANGE=9
RED=9
WHITE=A

#hubs
PUPA="90:84:2B:06:AB:5D"
PUPB="90:84:2B:03:CA:6E"
BOOSTA="00:16:53:A3:47:EA"

DELAY=0.03

function remoteLED () {
    gatttool -b $PUPA --char-write-req --handle 0x0e --value 080081321151000$1
    sleep $DELAY
    gatttool -b $PUPB --char-write-req --handle 0x0e --value 080081321151000$1
    sleep $DELAY
    gatttool -b $BOOSTA --char-write-req --handle 0x0e --value 080081321151000$1
    sleep $DELAY
}

# activate notifications and keep changing colors
gatttool -b $PUPA --char-write-req --handle 0x0f --value 0100
sleep $DELAY
gatttool -b $PUPB --char-write-req --handle 0x0f --value 0100
sleep $DELAY
gatttool -b $BOOSTA --char-write-req --handle 0x0f --value 0100
sleep $DELAY

while :
do
    for color in $OFF $PINK $PURPLE $BLUE $LIGHTBLUE $LIGHTGREEN $GREEN $YELLOW $ORANGE $RED $WHITE; do
        remoteLED $color
        sleep 1
    done
done

Buy the way, controlling 2 Powered Up “Hub NO.4” and 1 BOOST “Move Hub” at the same time from a single EV3  is already pretty good (if the old hiccups problems are fixed): that’s potentially 8 more motors!

[edit]

Now this is interesting:

I have news, because i did a test. The Broadcom BCM20702 Bluetooth Dongle can handle up to 14 BLE device connections simulateous.
And overall it’s a lot faster than this one from Cambridge Silicon Radio (can handle a max. of 5 BLE device connections simulateous).

Need to search my drawers… almost 100% sure I had a Broadcom LE USB dongle that gave up because ev3dev didn’t like it as much as the Cambridge CSR.
Also Raspberry Pi is Broadcom… time to get back to BrickPi3.

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *