nkaminski / csrmesh

Reverse engineered bridge implementation of the CSRMesh BTLE protocol
GNU Lesser General Public License v3.0
70 stars 20 forks source link

Problems running csrmesh #10

Closed jasonlshelton closed 7 years ago

jasonlshelton commented 7 years ago

Freshly installed with pip and I get the following:

AsusLaptop bluetooth # csrmesh-cli --pin 0000 --dest E0:34:E4:02:01:EB --level 0 Traceback (most recent call last): File "/usr/local/bin/csrmesh-cli", line 16, in p = cm.make_packet(cm.network_key(args.pin),cm.random_seq(),cm.light_set_cmd(args.level,args.red,args.green,args.blue)) File "/usr/local/lib/python2.7/dist-packages/csrmesh/init.py", line 26, in make_packet payload = bytes([ a ^ b for (a,b) in zip(data, ebase) ]) TypeError: unsupported operand type(s) for ^: 'str' and 'str'

I changed that line to read payload = bytes([ ord(a) ^ ord(b) for (a,b) in zip(data, ebase) ])

And it runs, but nothing happens, I get :

AsusLaptop bluetooth # csrmesh-cli --pin 1111 --dest E0:34:E4:02:01:EB --level 0 Running gatttool -b E0:34:E4:02:01:EB --char-write-req -a 0x0011 -n 44986300805b3233372c203130302c742af81aa3 Characteristic Write Request failed: A timeout occured Running gatttool -b E0:34:E4:02:01:EB --char-write-req -a 0x0014 -n 82167bff Characteristic Write Request failed: A timeout occured

Help?

jasonlshelton commented 7 years ago

BTW: Same dongle in a RP2 and I get:

BirdyCam bluetooth # csrmesh-cli --pin 0000 --dest E0:34:E4:02:01:EB --level 0 Running gatttool -b E0:34:E4:02:01:EB --char-write-req -a 0x0011 -n 0e3cca0080d83a5e95bfedf3d6d9b9ec36b22db0 connect error: Function not implemented (38) Running gatttool -b E0:34:E4:02:01:EB --char-write-req -a 0x0014 -n 64df08ff connect error: Function not implemented (38)

nkaminski commented 7 years ago

Does the dongle you are using support BT low energy? Also, the version currently on PyPi currently does not work properly with Python 2.x. I plan to push a new version that works with 2.x and 3.x tonight. Identified another bug in the git version and fixed just now, make sure to pull from Git before continuing to troubleshoot.

nkaminski commented 7 years ago

0.6 version on pypi and Github with all known issues fixed

nkaminski commented 7 years ago

I've used an Acer C720 with the latest Arch Linux release available today as well as a Raspberry Pi 3 with Raspbian Jessie as test platforms FYI.

jasonlshelton commented 7 years ago

Updated and still getting: Traceback (most recent call last): File "/usr/local/bin/csrmesh-cli", line 16, in p = cm.make_packet(cm.network_key_feit(args.pin),cm.random_seq(),cm.light_set_cmd(args.level,args.red,args.green,args.blue)) File "/usr/local/lib/python2.7/dist-packages/csrmesh/init.py", line 31, in make_packet payload = bytearray([ chr(a ^ ord(b)) for (a,b) in zip(data, ebase) ]) TypeError: unsupported operand type(s) for ^: 'str' and 'int'

jasonlshelton commented 7 years ago

change the line again to read: payload = bytearray([ chr(ord(a) ^ ord(b)) for (a,b) in zip(data, ebase) ]) and get the: connect error: Function not implemented (38) error. This dongle does support BTLE, lsusb gives me: Bus 001 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

the chip is a CSR8510 A10

nkaminski commented 7 years ago

Can you connect to the device manually using gatttool in interactive mode?

jasonlshelton commented 7 years ago

nope, I get the same sort of error:

Error: connect error: Function not implemented (38)

However, this does not explain the first error I get about the str and int in a bitwise OR

jasonlshelton commented 7 years ago

Hcitool gives me this:

hcitool lecc E0:34:E4:02:01:EB

Connection handle 72

so it looks like that works

nkaminski commented 7 years ago

This is a Bluetooth stack issue, what version of bluez are you running? Also good catch on the Python 2.7 bug! If you want to submit a pull request so you get "credit" for it please do so otherwise I will fix.

nkaminski commented 7 years ago

Your fix is correct too. Looking back at mjg59's commit to add Python 2.7 compatibility, that is where the bitwise XOR data type bug was introduced.

jasonlshelton commented 7 years ago

I don't really know how to do a pull request, so I'll leave it to you.

I removed bluez with apt and compiled the latest, 5.42

Is there a way to get more debugging info? I'm just figuring out all this bluetooth stuff.

jasonlshelton commented 7 years ago

I was trying to push the changed code, but I get permission denied. I've not contributed to a git project before so I'm trying to figure that out as well. Do you need to add me as a contributor before I can upload changes?

nkaminski commented 7 years ago

Can you connect successfully to the bulb using gatttool in interactive mode?

Nash Kaminski

On October 22, 2016 2:09:18 AM CDT, jasonlshelton notifications@github.com wrote:

change the line again to read: payload = bytearray([ chr(ord(a) ^ ord(b)) for (a,b) in zip(data, ebase) ]) and get the: connect error: Function not implemented (38) error. This dongle does support BTLE, lsusb gives me: Bus 001 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

the chip is a CSR8510 A10

You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/nkaminski/csrmesh/issues/10#issuecomment-255512160

Sent from my Android device with K-9 Mail.

jasonlshelton commented 7 years ago

As I said before nope, I get the same sort of error:

Error: connect error: Function not implemented (38)

nkaminski commented 7 years ago

Cannot reproduce on my Acer c720 or Pi 3. Will look into it more later since this looks like a bluez or driver issue.

jasonlshelton commented 7 years ago

I'm using my laptop now, with the same bluetooth dongle that I had on the Pi2, now I'm getting this: AsusLaptop ~ csrmesh-cli --pin 7735 --dest E0:34:E4:02:01:EB --level 0 Running gatttool -b E0:34:E4:02:01:EB --char-write-req -a 0x0011 -n 14349e00807efa972c0383d1d283dd0145dc1ceb Characteristic Write Request failed: A timeout occured Running gatttool -b E0:34:E4:02:01:EB --char-write-req -a 0x0014 -n 5506f2ff Characteristic Write Request failed: A timeout occured

Same as my first post, but I noticed that the lightbulb does go to full brightness anytime a command is sent to it, even if I use level 0

nkaminski commented 7 years ago

What firmware version on the bulb according to the (official) app?

jasonlshelton commented 7 years ago

Firmware is 0.16

nkaminski commented 7 years ago

The current version of this library works for several other users, with identical CSRMesh devices. Therefore this is almost certainly a Bluez or bluetooth hardware related issue.