{"id":1359,"date":"2018-08-06T16:54:01","date_gmt":"2018-08-06T15:54:01","guid":{"rendered":"https:\/\/ofalcao.pt\/blog\/?p=1359"},"modified":"2018-08-07T11:22:26","modified_gmt":"2018-08-07T10:22:26","slug":"1359","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2018\/1359","title":{"rendered":"Controlling several LEGO BLE devices at same time"},"content":{"rendered":"<p>Yeap. CSR 4.0 on Ubuntu can control 5 different BLE devices:<\/p>\n<div class=\"jetpack-video-wrapper\"><iframe loading=\"lazy\" title=\"Controlling several LEGO BLE devices at same time\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/KcGlNnyjcZs?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/div>\n<p>Bash script:<\/p>\n<pre>#!\/usr\/bin\/env bash\r\n\r\n#usage: .\/rgbled.sh hci0\r\n\r\nHCI=$1\r\n\r\n#DELAY=0.03\r\nDELAY=0\r\n\r\n#colors\r\nOFF=0\r\nPINK=1\r\nPURPLE=2\r\nBLUE=3\r\nLIGHTBLUE=4\r\nLIGHTGREEN=5\r\nGREEN=6\r\nYELLOW=7\r\nORANGE=9\r\nRED=9\r\nWHITE=A\r\n\r\n#hubs\r\nPUPA=\"90:84:2B:06:AB:5D\"\r\nPUPB=\"90:84:2B:03:CA:6E\"\r\nBOOSTA=\"00:16:53:A3:47:EA\"\r\nHANDSETA=\"A4:34:F1:CE:DC:A2\"\r\nWEDOA=\"A0:E6:F8:1B:FF:9B\"\r\n\r\nfunction remoteLED () {\r\n    gatttool -i $HCI -b $PUPA --char-write-req --handle 0x0e --value 080081321151000$1\r\n    sleep $DELAY\r\n    gatttool -i $HCI -b $PUPB --char-write-req --handle 0x0e --value 080081321151000$1\r\n    sleep $DELAY\r\n    gatttool -i $HCI -b $BOOSTA --char-write-req --handle 0x0e --value 080081321151000$1\r\n    sleep $DELAY\r\n    gatttool -i $HCI -b $HANDSETA --char-write-req --handle 0x0b --value 080081341151000$1\r\n    sleep $DELAY\r\n    gatttool -i $HCI -b $WEDOA --char-write-req --handle 0x3d --value 0604010$1\r\n    sleep $DELAY\r\n}\r\n\r\n# activate notifications and keep changing colors\r\ngatttool  -i $HCI -b $PUPA --char-write-req --handle 0x0f --value 0100\r\nsleep $DELAY\r\ngatttool -i $HCI -b $PUPB --char-write-req --handle 0x0f --value 0100\r\nsleep $DELAY\r\ngatttool -i $HCI -b $BOOSTA --char-write-req --handle 0x0f --value 0100\r\nsleep $DELAY\r\ngatttool -i $HCI -b $HANDSETA --char-write-req --handle 0x0c --value 0100\r\nsleep $DELAY\r\n\r\nwhile :\r\ndo\r\n    for color in $OFF $PINK $PURPLE $BLUE $LIGHTBLUE $LIGHTGREEN $GREEN $YELLOW $ORANGE $RED $WHITE; do\r\n        remoteLED $color\r\n        sleep 1\r\n    done\r\ndone\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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=&#8221;90:84:2B:06:AB:5D&#8221; PUPB=&#8221;90:84:2B:03:CA:6E&#8221; BOOSTA=&#8221;00:16:53:A3:47:EA&#8221; HANDSETA=&#8221;A4:34:F1:CE:DC:A2&#8243; WEDOA=&#8221;A0:E6:F8:1B:FF:9B&#8221; function remoteLED () { gatttool -i $HCI -b $PUPA &#8211;char-write-req &#8211;handle 0x0e &#8211;value 080081321151000$1 sleep $DELAY &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2018\/1359\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;Controlling several LEGO BLE devices at same time&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[1],"tags":[],"series":[],"class_list":["post-1359","post","type-post","status-publish","format-standard","hentry","category-sem-categoria"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s2Mhyv-1359","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/comments?post=1359"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1359\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1359"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}