leopck / Yee-Light-Blue

Writing library for yee light blue using python for raspberry pi
32 stars 7 forks source link

Test.py not responding #1

Closed fparrav closed 8 years ago

fparrav commented 8 years ago

when you run the test file gives the following message and the light does not respond (no phone is using light) :

pi@raspberrypi ~/Yee-Light-Blue $ sudo python test.py hci0
Connection handle 72
3235352c302c302c3130302c2c2c2c2c2c2c
302c3235352c302c3130302c2c2c2c2c2c2c
302c302c3235352c3130302c2c2c2c2c2c2c
3235352c3235352c3235352c35302c2c2c2c
leopck commented 8 years ago

Hmmm.... Connection handle 72 normally means the connection is successful but just in case I'll ask whether have you changed the MAC address inside the test.py?

'''Enter your Mac Address & USB device inside the YeeLightBlue''' x = yeelightblue.YeeLightBlue("00:17:EA:91:03:86", device_no)

Change the "00:17:EA:91:03:86" to your Yee Light Blue's MAC address.

fparrav commented 8 years ago

of course, the MAC is that I found with sudo hcitool lescan

leopck commented 8 years ago

Hmm, then I would require your help in testing your Yee Light Blue manually first. There's a way to manually connect and control the Yee Light Blue.

Go to your bash terminal and perform these commands:

sudo hciconfig hci0 down
sudo hciconfig hci0 up
sudo hcitool -i hci0 lecc <your_mac_addr>
sudo gatttool -i  hci0 -b <your_mac_addr> -I

[LE]> connect
## This will turn on the Yee Light Blue
[LE]> char-write-cmd 0x0025 2c2c2c3130302c2c2c2c2c2c2c2c2c2c2c2c
## This will turn off the Yee Light Blue
[LE]> char-write-cmd 0x0025 2c2c2c302c2c2c2c2c2c2c2c2c2c2c2c2c2c

##Disconnect
[LE]> disconnect
[LE]> exit

Please let me know if this works for you.

fparrav commented 8 years ago

Still does not work, attached the console output. Thanks

pi@raspberrypi ~/Yee-Light-Blue $ sudo hcitool -i hci0 lecc F4:B8:5E:E5:BB:AE
Connection handle 72
pi@raspberrypi ~/Yee-Light-Blue $ sudo gatttool -i  hci0 -b F4:B8:5E:E5:BB:AE -I[F4:B8:5E:E5:BB:AE][LE]> connect
Attempting to connect to F4:B8:5E:E5:BB:AE
Connection successful
2c2c2c2c2c2c2cB:AE][LE]> char-write-cmd 0x0025 2c2c2c3130302c2c2c2c2c
2c2c2c2c2c2c2cB:AE][LE]> char-write-cmd 0x0025 2c2c2c302c2c2c2c2c2c2c
[F4:B8:5E:E5:BB:AE][LE]> disconnect

(gatttool:2504): GLib-WARNING **: Invalid file descriptor.

[F4:B8:5E:E5:BB:AE][LE]> exit
leopck commented 8 years ago

I have re-tested my code on Raspberry Pi model B, B+ and RPi 2. I don't seem to see the same issue that you're having and I have checked the Yee Light Blue API documentation, doesn't seem that they changed any API as well.

[F4:B8:5E:E5:BB:AE][LE]> disconnect

(gatttool:2504): GLib-WARNING **: Invalid file descriptor.

[F4:B8:5E:E5:BB:AE][LE]> exit

It seems that you have a different warning as well. I checked out that warning on this website http://comments.gmane.org/gmane.linux.bluez.kernel/63547 It shows that the newer versions on bluez 5.32 > seems to be slightly different.

Here's my snippet of my bluez version.

pi@raspberrypi:~ $ dpkg --status bluez | grep '^Version:'
Version: 5.23-2+b1
pi@raspberrypi:~ $ bluetoothd -v
5.23

What bluez version are you using? You can probably try older versions like 5.23 since mine seems to work perfectly.

fparrav commented 8 years ago

Actually he had an earlier version of bluez. Upgrade to Version: 5.23-2+rpi1, and asked me to install the configuration file included in the package and that solved the problem, thanks!