{"id":1353,"date":"2018-08-06T14:31:58","date_gmt":"2018-08-06T13:31:58","guid":{"rendered":"https:\/\/ofalcao.pt\/blog\/?p=1353"},"modified":"2018-08-06T15:19:48","modified_gmt":"2018-08-06T14:19:48","slug":"controlling-multiple-powered-up-devices","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2018\/controlling-multiple-powered-up-devices","title":{"rendered":"Controlling multiple Powered Up devices"},"content":{"rendered":"<p>About two years ago I had a dual SBrick &#8220;train&#8221; 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&#8217;t occur with my Ubuntu laptop (same dongle, a CSR 4.0).<\/p>\n<p>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.<\/p>\n<p>Today I&#8217;m testing how many Powered Up hubs I can control at the same time with just one BLE &#8220;client&#8221;. Just a simple bash script, changing the RGB LED colors of the hubs at the same time.<\/p>\n<p>My laptop could control 2. But started to had issues with 3, failing some commands:<\/p>\n<pre>Characteristic Write Request failed: Request attribute has encountered an unlikely error<\/pre>\n<p>Perhaps sending 3 gatttool commands in-a-row was too much so added a small delay. It got worst:<\/p>\n<pre>connect error: Connection timed out (110)<\/pre>\n<p>Tuning to a small delay (0.03) seems to be the best but is strange.<\/p>\n<p>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.<\/p>\n<p>But I still have the CSR 4.0 dongle on the Ev3 over the desk. So let&#8217;s try same script with it.<\/p>\n<p>No errors at all. Not even with 0 delay.<\/p>\n<p>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&#8217;t think this is a BlueZ issue.<\/p>\n<p>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.<\/p>\n<p>Now the script:<\/p>\n<pre>#!\/usr\/bin\/env bash\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\n\r\nDELAY=0.03\r\n\r\nfunction remoteLED () {\r\n    gatttool -b $PUPA --char-write-req --handle 0x0e --value 080081321151000$1\r\n    sleep $DELAY\r\n    gatttool -b $PUPB --char-write-req --handle 0x0e --value 080081321151000$1\r\n    sleep $DELAY\r\n    gatttool -b $BOOSTA --char-write-req --handle 0x0e --value 080081321151000$1\r\n    sleep $DELAY\r\n}\r\n\r\n# activate notifications and keep changing colors\r\ngatttool -b $PUPA --char-write-req --handle 0x0f --value 0100\r\nsleep $DELAY\r\ngatttool -b $PUPB --char-write-req --handle 0x0f --value 0100\r\nsleep $DELAY\r\ngatttool -b $BOOSTA --char-write-req --handle 0x0f --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<p>Buy the way, controlling 2 Powered Up &#8220;Hub NO.4&#8221; and 1 BOOST &#8220;Move Hub&#8221; at the same time from a single EV3\u00a0 is already pretty good (if the old hiccups problems are fixed): that&#8217;s potentially 8 more motors!<\/p>\n<p>[edit]<\/p>\n<p>Now <a href=\"https:\/\/github.com\/noble\/noble\/issues\/214\">this is interesting<\/a>:<\/p>\n<blockquote><p>I have news, because i did a test. The Broadcom BCM20702 Bluetooth Dongle can handle up to 14 BLE device connections simulateous.<br \/>\nAnd overall it&#8217;s a lot faster than this one from Cambridge Silicon Radio (can handle a max. of 5 BLE device connections simulateous).<\/p><\/blockquote>\n<p>Need to search my drawers&#8230; almost 100% sure I had a Broadcom LE USB dongle that gave up because ev3dev didn&#8217;t like it as much as the Cambridge CSR.<br \/>\nAlso Raspberry Pi is Broadcom&#8230; time to get back to BrickPi3.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>About two years ago I had a dual SBrick &#8220;train&#8221; 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&#8217;t occur with my Ubuntu laptop (same dongle, a CSR 4.0). By that time, &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2018\/controlling-multiple-powered-up-devices\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;Controlling multiple Powered Up devices&#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-1353","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\/p2Mhyv-lP","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1353","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=1353"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1353\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1353"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}