Closed Betree closed 7 years ago
It should be fixed by https://github.com/Betree/magicblue/commit/32fc0616dac56e5a3464d8db8b6b84c0d6f038a6
@IzzyWizzy666
Not merged with master, please install from develop
branch :
pip3 install --upgrade git+https://github.com/Betree/pyMagicBlue.git@develop
Also I can't guarantee your bulb will work as this could be a symptom for an incompatible bulb (if you have a new version for example)
Hi, OK, thanks I'll give it a try :), my bulb is version 8 according to the app.
Something is a bit strange, I can connect sometime but when I try to do set_color red it appears to do it without any error message but the bulb stays white. Also here is the output from the ls command....... ls Listing Bluetooth LE devices in range for 5 minutes.Press CTRL+C to stop searching. ID Name Mac address -- ---- ----------- 1 LEDBLE-5D6EA3E8 c1:40:5d:6e:a3:e8 2 LEDBLE-09E6DE78 f2:f1:09:e6:de:78 <--------------- 3 Flower mate c4:7c:8d:61:ac:f7 4 Flower mate c4:7c:8d:61:a8:46 5 NO_NAME c4:7c:8d:61:81:35 6 NO_NAME c3:50:98:31:64:f2 7 NO_NAME f9:b7:24:6c:64:28 8 NO_NAME c4:7c:8d:61:7c:2b
ID Name Mac address -- ---- ----------- 1 NO_NAME f9:b7:24:6c:64:28 2 NO_NAME f2:f1:09:e6:de:78 <------------------ 3 NO_NAME c3:50:98:31:64:f2 4 LEDBLE-5D6EA3E8 c1:40:5d:6e:a3:e8 5 NO_NAME f9:72:f8:1e:66:f4 6 NO_NAME c4:7c:8d:61:7c:2b 7 Flower mate c4:7c:8d:61:a8:46 8 NO_NAME c4:7c:8d:61:81:35 9 Flower mate c4:7c:8d:61:ac:f7
Another couple of scans and an error message..... Magic Blue interactive shell v0.2.3Type "help" for a list of available commands
ls Listing Bluetooth LE devices in range for 5 minutes.Press CTRL+C to stop searching. ID Name Mac address -- ---- ----------- 1 LEDBLE-5D6EA3E8 c1:40:5d:6e:a3:e8 2 LEDBLE-09E6DE78 f2:f1:09:e6:de:78 3 Flower mate c4:7c:8d:61:81:35 4 NO_NAME f9:72:f8:1e:66:f4 5 Flower mate c4:7c:8d:61:ac:f7 6 NO_NAME f9:b7:24:6c:64:28 7 Flower mate c4:7c:8d:61:a8:46 8 NO_NAME c3:50:98:31:64:f2 9 NO_NAME c4:7c:8d:61:7c:2b^C ls Listing Bluetooth LE devices in range for 5 minutes.Press CTRL+C to stop searching. ID Name Mac address-- ---- ----------- 1 LEDBLE-09E6DE78 f2:f1:09:e6:de:78 2 NO_NAME c1:40:5d:6e:a3:e8 3 Flower mate c4:7c:8d:61:81:35 4 Flower mate c4:7c:8d:61:a8:46 5 NO_NAME c3:50:98:31:64:f2 6 Flower mate c4:7c:8d:61:ac:f7 7 NO_NAME f9:72:f8:1e:66:f4 8 NO_NAME f9:b7:24:6c:64:28 9 NO_NAME c4:7c:8d:61:7c:2b^C ls Listing Bluetooth LE devices in range for 5 minutes.Press CTRL+C to stop searching. ID Name Mac address -- ---- ----------- ERROR:magicblue.magicblueshell:Unexpected error with command "ls": Failed to execute mgmt cmd 'scan'
Ok so first problem is fixed as some devices around you aren't broadcasting their names properly.
The second problem that you have is a bit more complicate to diagnose, have you tried following this : How-to-use-manually-with-Gatttool ? It could really help to see if it works with it.
You can also try using bluetoothctl
command to send request manually.
Hi, OK, I still can't communicate with my lights, I tried with the GATTool and although it can connect to the bulb, nothing else was possible, turning off/on, changing color etc. If you can explain how to use bluetoothctl to communicate with the bulb I'll try that, I can trust it and connect to it, but that's as far as I've got.
There's still two things we can try :
Connect with gattool using a public address type instead of random (replace MAC_ADDRESS by your bulb mac address like you did in How-to-use-manually-with-Gatttool) :
sudo gatttool -t public -b MAC_ADDRESS -I
(And / Or) Try a different handle to change the color (0x0b
instead of the usual 0x0c
):
char-write-req 0x000b 56FFFFFF00f0aa
to set white
char-write-req 0x000b 56FF000000f0aa
to set red
Most plausible cause is difference in bulbs protocol. I've never tried v8 (yours) nor ever heard of someone who did but v9 needed a special patch that may be required for v8 as well (see #7).
If that works for you the update could be pretty easy 🤞
Hi Benjamin, This is the results.... pi@raspberrypi3:~ $ sudo gatttool -t public -b F2:F1:09:E6:DE:78 -I [F2:F1:09:E6:DE:78][LE]> connectAttempting to connect to F2:F1:09:E6:DE:78 Error: connect error: Connection refused (111) [F2:F1:09:E6:DE:78][LE]> connectAttempting to connect to F2:F1:09:E6:DE:78 [F2:F1:09:E6:DE:78][LE]> [F2:F1:09:E6:DE:78][LE]> quitpi@raspberrypi3:~ $ sudo gatttool -t random -b F2:F1:09:E6:DE:78 -I [F2:F1:09:E6:DE:78][LE]> connectAttempting to connect to F2:F1:09:E6:DE:78 Connection successful [F2:F1:09:E6:DE:78][LE]> char-write-req 0x000b 56FFFFFF00f0aa [F2:F1:09:E6:DE:78][LE]> char-write-req 0x000b 56FFFFFF00f0aa [F2:F1:09:E6:DE:78][LE]> char-write-req 0x000b 56FF000000f0aa [F2:F1:09:E6:DE:78][LE]> The char-writes had no effect :( Cheers,Keith
Thank you very much for trying all of this 👍
Unfortunately I think your bulb version (v8) is currently incompatible. I created an issue specific to discussions about this version #13 and updated the README to state of this incompatibility.
Now if you need this to work you'll have to dig by yourself, I can help you with the basics but not having this bulb I won't be able to study its protocol. A start would be to get a sniffer, Wireshark on Linux is doing a great job but you may be able to do it by directly logging bluetooth from your Android. You'll then need to see which handle is called and with which values when you change a color. Finally you can try again using manually with Gatttool with the new values you've got and if it works then fixing magicblue will be as easy as 1-2-3 😉
ERROR:magicblue.magicblueshell:Unexpected error with command "ls": 'NoneType' object has no attribute 'split'
Probably comes from this line :
dev_name = dev.getValueText(9).split('\x00')[0]