Controlling several LEGO BLE devices at same time

Yeap. CSR 4.0 on Ubuntu can control 5 different BLE devices:

Bash script:

#!/usr/bin/env bash

#usage: ./rgbled.sh hci0

HCI=$1

#DELAY=0.03
DELAY=0

#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"
HANDSETA="A4:34:F1:CE:DC:A2"
WEDOA="A0:E6:F8:1B:FF:9B"

function remoteLED () {
    gatttool -i $HCI -b $PUPA --char-write-req --handle 0x0e --value 080081321151000$1
    sleep $DELAY
    gatttool -i $HCI -b $PUPB --char-write-req --handle 0x0e --value 080081321151000$1
    sleep $DELAY
    gatttool -i $HCI -b $BOOSTA --char-write-req --handle 0x0e --value 080081321151000$1
    sleep $DELAY
    gatttool -i $HCI -b $HANDSETA --char-write-req --handle 0x0b --value 080081341151000$1
    sleep $DELAY
    gatttool -i $HCI -b $WEDOA --char-write-req --handle 0x3d --value 0604010$1
    sleep $DELAY
}

# activate notifications and keep changing colors
gatttool  -i $HCI -b $PUPA --char-write-req --handle 0x0f --value 0100
sleep $DELAY
gatttool -i $HCI -b $PUPB --char-write-req --handle 0x0f --value 0100
sleep $DELAY
gatttool -i $HCI -b $BOOSTA --char-write-req --handle 0x0f --value 0100
sleep $DELAY
gatttool -i $HCI -b $HANDSETA --char-write-req --handle 0x0c --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

Deixe um comentário

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