timothyb89 / lifx-tasker

Tasker plugin for controlling LIFX bulbs
MIT License
17 stars 2 forks source link

Only first gateway is discovered #4

Closed timothyb89 closed 10 years ago

timothyb89 commented 10 years ago

Currently the discovery thread is killed as soon as the first gateway bulb is found. If multiple gateways exist on the network, they may never be discovered, or could only be discovered intermittently. This was a somewhat intentional TODO while getting the discovery working since there's "perfect" solution.

Possibly one of:

We do need to minimize the time we have the broadcast port held open for to make sure other LIFX apps won't be interfered with.

timothyb89 commented 10 years ago

Possible test build to fix: https://drive.google.com/file/d/0B30rtS9KioFNXzIyMjd5SDJrekk/edit?usp=sharing

ahmadtawakol commented 10 years ago

Just installed it. Now both bulbs with their correct names are displayed. However, only the first button works, the second one doesn't do anything again. Tapping the first bulb also toggles the power for both bulbs.

timothyb89 commented 10 years ago

Is there any chance you might be able to get logcat output for when you run into the issue? Specifically if you open the app and force close it (to make sure the service is killed) and then try using it - toggling bulbs, using a Tasker action, etc.

ahmadtawakol commented 10 years ago

I/ActivityManager( 595): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.timothyb89.lifx.tasker/.SimpleControlActivity bnds=[364,668][546,859]} from pid 882 I/ActivityManager( 595): Start proc org.timothyb89.lifx.tasker for activity org.timothyb89.lifx.tasker/.SimpleControlActivity: pid=24440 uid=10124 gids={50124, 3003} I/SimpleControlActivity(24440): Starting service I/o.t.l.t.LIFXService(24440): Starting gateway discovery... I/o.t.l.t.LIFXService(24440): LIFX service started D/dalvikvm(24440): GC_CONCURRENT freed 227K, 3% free 9164K/9424K, paused 3ms+2ms, total 23ms I/Adreno-EGL(24440): : EGL 1.4 QUALCOMM Build: I0404c4692afb8623f95c43aeb6d5e13ed4b30ddbDate: 11/06/13 D/OpenGLRenderer(24440): Enabling debug mode 0 I/SimpleControlActivity(24440): LIFX: org.timothyb89.lifx.tasker.LIFXService@41e84028 I/SimpleControlActivity(24440): Bulbs updated. I/ActivityManager( 595): Displayed org.timothyb89.lifx.tasker/.SimpleControlActivity: +313ms D/e ( 882): onActivityStop D/dalvikvm( 1150): GCEXPLICIT freed 351K, 7% free 10849K/11604K, paused 9ms+8ms, total 66ms I/o.t.l.t_.LIFXService(24440): Found gateway: Gateway(ipAddress=/192.168.2.85:56700, port=56700, macAddress=MACAddress(hex=D0:73:D5:00:8F:AE), bulbs=[]) D/dalvikvm( 595): GCEXPLICIT freed 2648K, 25% free 22102K/29368K, paused 6ms+9ms, total 116ms I/o.t.l.t.LIFXService(24440): Found bulb: Bulb(address=MACAddress(hex=D0:73:D5:00:8F:AE), powerState=ON, label=Desk) I/o.t.l.t_.LIFXService(24440): Gateway is now: Gateway(ipAddress=/192.168.2.85:56700, port=56700, macAddress=MACAddress(hex=D0:73:D5:00:8F:AE), bulbs=[Bulb(address=MACAddress(hex=D0:73:D5:00:8F:AE), powerState=ON, label=Desk)]) I/SimpleControlActivity(24440): Bulbs updated. D/dalvikvm(24440): GCCONCURRENT freed 328K, 4% free 9243K/9604K, paused 2ms+2ms, total 20ms I/o.t.l.t.LIFXService(24440): Found bulb: Bulb(address=MACAddress(hex=D0:73:D5:00:AF:EF), powerState=ON, label=Lamp) I/o.t.l.t.LIFXService(24440): Gateway is now: Gateway(ipAddress=/192.168.2.85:56700, port=56700, macAddress=MACAddress(hex=D0:73:D5:00:8F:AE), bulbs=[Bulb(address=MACAddress(hex=D0:73:D5:00:8F:AE), powerState=ON, label=Desk), Bulb(address=MACAddress(hex=D0:73:D5:00:AF:EF), powerState=ON, label=Lamp)]) I/SimpleControlActivity(24440): Bulbs updated. I/o.t.l.t_.LIFXService(24440): Gateway discovery ended, 1 gateways found. I/SecureSettings.ActionService( 3728): onHandleIntent::Action Success D/dalvikvm(24440): GC_CONCURRENT freed 374K, 5% free 9259K/9668K, paused 2ms+2ms, total 24ms I/SecureSettings.ActionService( 3728): onHandleIntent::Action Success D/dalvikvm( 2734): GC_EXPLICIT freed 239K, 6% free 9424K/10008K, paused 10ms+3ms, total 49ms I/SimpleControlActivity(24440): Attempted turn-on. I/SimpleControlActivity(24440): Attempted turn-on. I/SimpleControlActivity(24440): Attempted turn-off I/SecureSettings.ActionService( 3728): onHandleIntent::Action Success D/dalvikvm( 2601): GC_CONCURRENT freed 630K, 45% free 11156K/19928K, paused 3ms+3ms, total 40ms I/SimpleControlActivity(24440): Attempted turn-on. D/dalvikvm( 595): GC_EXPLICIT freed 518K, 26% free 21938K/29368K, paused 5ms+8ms, total 124ms I/SecureSettings.ActionService( 3728): onHandleIntent::Action Success D/dalvikvm(24440): GC_CONCURRENT freed 406K, 5% free 9258K/9700K, paused 2ms+3ms, total 27ms D/dalvikvm( 855): GC_EXPLICIT freed 121K, 5% free 9624K/10064K, paused 18ms+4ms, total 81ms D/dalvikvm( 1150): GC_EXPLICIT freed 358K, 7% free 10851K/11604K, paused 7ms+5ms, total 76ms I/SecureSettings.ActionService( 3728): onHandleIntent::Action Success I/PowerManagerService( 595): Nap time... I/DreamController( 595): Starting dream: name=ComponentInfo{net.nurik.roman.dashclock/com.google.android.apps.dashclock.DaydreamService}, isTest=false, userId=0 D/dalvikvm( 1397): GC_FOR_ALLOC freed 1605K, 19% free 42279K/51724K, paused 26ms, total 27ms W/InputMethodManagerService( 595): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@426e1de8 (uid=10124 pid=24440)

ahmadtawakol commented 10 years ago

Pressing the second bulb button didn't produce any output in logcat

timothyb89 commented 10 years ago

I've been able to reproduce this with 2 bulbs on the same gateway in the lifx-java parent project. I believe it's because it was addressing the bulbs incorrectly (specifically, using the 'site' field incorrectly and not setting the 'bulb address' field when generating packets).

Simple case to reproduce using lifx-java directly: https://gist.github.com/timothyb89/2fdad0f3e1ac1550dbb2 (has been fixed, will only fail on timothyb89/lifx-java@1ba974135c16a0de93f0f4bc903fea5a2495ba7c and before)

Test build with a fix: https://drive.google.com/file/d/0B30rtS9KioFNc0ZVa0tMbFlPQlU/edit?usp=sharing

I'm having good results with my own bulbs so far - let me know if this works for you!

ahmadtawakol commented 10 years ago

Yes! This works now

timothyb89 commented 10 years ago

I've pushed an update to the Play Store with the fixes - thanks for the feedback!