Closed dragonxtek closed 7 years ago
I never tried with a v6. Did you order it recently ?
Try connecting with a public address type :
sudo gatttool -t public -b EA:9C:0F:A6:A0:22 -I
I tried with -t public with V8 and it doesn't works. (only works with -t random). With v6, I can't connect with both of them. I bought it through aliexpress 6 months ago. For v8 I use handle 0x000c and for v6 handle 0x0043, but as I said you, I can't connect throught gattool to test it without the official Android application.
I tested bulb v6 with your app and it works, but only on interactive mode:
sudo python3 magicblueshell.py
Magic Blue interactive shell v0.4.2
Type "help" for a list of available commands
> list_devices
Listing Bluetooth LE devices in range for 300 seconds. Press CTRL+C to abort searching.
ID Name Mac address
-- ---- -----------
1 LEDBlue-72C816D6 d0:39:72:c8:16:d6
> connect 1
INFO:__main__:Connected
> set_color green
When I tried to change the color without interactive mode, it doesn't work:
sudo python3 magicblueshell.py -c 'set_color blue' -m d0:39:72:c8:16:d6
Traceback (most recent call last):
File "magicblueshell.py", line 307, in <module>
sys.exit(main())
File "magicblueshell.py", line 298, in main
shell.cmd_connect([params.mac_address])
File "magicblueshell.py", line 159, in cmd_connect
self._magic_blue.connect(self.bluetooth_adapter)
File "/usr/local/lib/python3.5/dist-packages/magicblue-0.4.2-py3.5.egg/magicblue/magicbluelib.py", line 119, in connect
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 318, in __init__
self.connect(deviceAddr, addrType, iface)
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 367, in connect
"Failed to connect to peripheral %s, addr type: %s" % (addr, addrType))
bluepy.btle.BTLEException: Failed to connect to peripheral d0:39:72:c8:16:d6, addr type: random
Do you know why it doesn't works? What is the difference between interactive connection and non-interactive connection?
I tried with MAC but it doesn't work, but if I use the ID it works. Why is it?
> list_devices
Listing Bluetooth LE devices in range for 300 seconds. Press CTRL+C to abort searching.
ID Name Mac address
-- ---- -----------
1 LEDBlue-72C816D6 d0:39:72:c8:16:d6
^C
> connect d0:39:72:c8:16:d6
ERROR:__main__:Unexpected error with command "connect d0:39:72:c8:16:d6": Failed to connect to peripheral d0:39:72:c8:16:d6, addr type: random
> connect 1
INFO:__main__:Connected
I solved! I don't know why, but version 6, is equal to version 9 or 10.
read device_info
INFO:__main__:Received device_info: {'r': 0, 'effect_speed': 0, 'brightness': 255, 'device_type': 21, 'version': 6, 'on': True, 'g': 0, 'effect': None, 'effect_no': 65, 'b': 0}
If I choose any of these versions, it works
sudo python3 magicblueshell.py -c 'set_warm_light 1.0' -m d0:39:72:c8:16:d6 -b 9
Do you know why it doesn't works? What is the difference between interactive connection and non-interactive connection?
Interactive mode auto-detect address type during scan. We don't do this when connecting directly or using the library for performance reasons.
However setting version to 9 or 10 forces address type to be a public address, that means v6 uses a public address type too. I'll make a commit to officially support this version with the info you provided.
Thanks for your feedback 👍
Merged with master, will be included in next release. You can continue to use -b 9
or -b 10
, it won't have any other impacts.
Why version 6 is not compatible? I try to connect to it with gattool, but it doesn't connect:
Does it have an incompatibility with gattool library or something else?