Heckie75 / Mipow-Playbulb-BTL201

Full-featured shell script interface based on expect and gatttool for Mipow Playbulb BTL201 (and maybe others)
MIT License
31 stars 9 forks source link

connection issue #3

Closed viks2015 closed 6 years ago

viks2015 commented 6 years ago

I would say that you have done excellent work, however I am facing the problem with the script :-

_Setup for bulb started ...

Step 1: Read characteristics from bulb 1 ... connect error: Connection refused (111) while executing "exec gatttool -b $mac --characteristics > $hndfile" (procedure "setupCharacteristics" line 5) invoked from within "setupCharacteristics" (procedure "setup" line 13) invoked from within "setup" ("^setup$" arm line 2) invoked from within "switch -regexp $c { ^status$ { init [expr $INIT(color) + $INIT(effect) + $INIT(timers)] printStatus } ^dump$ { init [exp..." (procedure "doCommand" line 10) invoked from within "doCommand" ("while" body line 2) invoked from within "while {$cmd != ""} { doCommand }" (file "./mipow.exp" line 1641)_

however when I run the command directly I get the output

gatttool -b 90:F6:4B:10:AC:E6 --characteristics handle = 0x0002, char properties = 0x0a, char value handle = 0x0003, uuid = 00002a00-0000-1000-8000-00805f9b34fb handle = 0x0004, char properties = 0x02, char value handle = 0x0005, uuid = 00002a01-0000-1000-8000-00805f9b34fb handle = 0x0006, char properties = 0x02, char value handle = 0x0007, uuid = 00002a04-0000-1000-8000-00805f9b34fb handle = 0x0009, char properties = 0x22, char value handle = 0x000a, uuid = 00002a05-0000-1000-8000-00805f9b34fb handle = 0x000d, char properties = 0x10, char value handle = 0x000e, uuid = 00002a37-0000-1000-8000-00805f9b34fb handle = 0x0010, char properties = 0x0e, char value handle = 0x0011, uuid = 00002a39-0000-1000-8000-00805f9b34fb handle = 0x0012, char properties = 0x02, char value handle = 0x0013, uuid = 0000fff8-0000-1000-8000-00805f9b34fb handle = 0x0014, char properties = 0x0a, char value handle = 0x0015, uuid = 0000fff9-0000-1000-8000-00805f9b34fb handle = 0x0016, char properties = 0x06, char value handle = 0x0017, uuid = 0000fffa-0000-1000-8000-00805f9b34fb handle = 0x0018, char properties = 0x06, char value handle = 0x0019, uuid = 0000fffb-0000-1000-8000-00805f9b34fb handle = 0x001a, char properties = 0x06, char value handle = 0x001b, uuid = 0000fffc-0000-1000-8000-00805f9b34fb handle = 0x001c, char properties = 0x0a, char value handle = 0x001d, uuid = 0000fffd-0000-1000-8000-00805f9b34fb handle = 0x001e, char properties = 0x0a, char value handle = 0x001f, uuid = 0000fffe-0000-1000-8000-00805f9b34fb handle = 0x0020, char properties = 0x0a, char value handle = 0x0021, uuid = 0000ffff-0000-1000-8000-00805f9b34fb handle = 0x0023, char properties = 0x12, char value handle = 0x0024, uuid = 00002a19-0000-1000-8000-00805f9b34fb handle = 0x0027, char properties = 0x02, char value handle = 0x0028, uuid = 00002a25-0000-1000-8000-00805f9b34fb handle = 0x0029, char properties = 0x02, char value handle = 0x002a, uuid = 00002a27-0000-1000-8000-00805f9b34fb handle = 0x002b, char properties = 0x02, char value handle = 0x002c, uuid = 00002a26-0000-1000-8000-00805f9b34fb handle = 0x002d, char properties = 0x02, char value handle = 0x002e, uuid = 00002a28-0000-1000-8000-00805f9b34fb handle = 0x002f, char properties = 0x02, char value handle = 0x0030, uuid = 00002a29-0000-1000-8000-00805f9b34fb handle = 0x0031, char properties = 0x02, char value handle = 0x0032, uuid = 00002a50-0000-1000-8000-00805f9b34fb handle = 0x0034, char properties = 0x0a, char value handle = 0x0035, uuid = 00001013-d102-11e1-9b23-00025b00a5a5 handle = 0x0036, char properties = 0x08, char value handle = 0x0037, uuid = 00001018-d102-11e1-9b23-00025b00a5a5 handle = 0x0038, char properties = 0x12, char value handle = 0x0039, uuid = 00001014-d102-11e1-9b23-00025b00a5a5 handle = 0x003b, char properties = 0x02, char value handle = 0x003c, uuid = 00001011-d102-11e1-9b23-00025b00a5a5

Heckie75 commented 6 years ago

Dear viks2015,

can you reproduce it all the time?

Maybe try to set the script into debug mode. Open the script mipow.exp and change the line no 33 from

log_user 0

to

log_user 1

Check the output and try to reproduce all commands manually.

Best regards, Martin

viks2015 commented 6 years ago

I am getting this output now

Setup for bulb started ...

Step 1: Read characteristics from bulb 1 ... connect error: Connection refused (111) while executing "exec gatttool -b $mac --characteristics > $hndfile" (procedure "setupCharacteristics" line 5) invoked from within "setupCharacteristics" (procedure "setup" line 13) invoked from within "setup" ("^setup$" arm line 2) invoked from within "switch -regexp $c { ^status$ { init [expr $INIT(color) + $INIT(effect) + $INIT(timers)] printStatus } ^dump$ { init [exp..." (procedure "doCommand" line 10) invoked from within "doCommand" ("while" body line 2) invoked from within "while {$cmd != ""} { doCommand }" (file "./mipow.exp" line 1641)

Heckie75 commented 6 years ago

Ok, there seems to be a bug. I am investigating

Heckie75 commented 6 years ago

I have uploaded a bugfix. Please try if this works for you.

Best regards

viks2015 commented 6 years ago

Works Now !!! Great Work. Can you port your code to pure python ?

viks2015 commented 6 years ago

How can I give percentage level of brightness instead of up and down option multiple times

Heckie75 commented 6 years ago

Excellent.

Actually I have started porting the code to Python in order to use it in KODI. But the connection via gatttool-wrapper is very unstable. That is some code I have taken from here: http://flowcloud.github.io/ci20-bluetooth-LE/2015/09/10/bluetooth-control-in-python/

I don't expect to continue my work here because for my KODI plugins a use subprocesses instead.

Nevertheless, I have just uploaded the Python code that I have already. Note that it is not very stable as mentioned. See https://github.com/Heckie75/py-mipow-playbulb

Best regards, Martin