I was having similar issues with proximity and in my implementation I ended up using a configurable value for proximity, not delta (e.g 5000, as the original wink-handler did).
The proximity sensor on the device has actually 3 leds, each with its own proximity value. We only use the first one which seems to do a great job.
In addition I noticed we have access to Light sensors, both visible and IR.
I will be publishing my work to github soon (hopefully tonight EST, time permitting).
If anyone is interested in building/testing, I suggest peeps download the latest Android NDK
The only problem I found with setting an absolute value for the prox threshold (even a configurable one) is that the value reported by the prox seems to walk all over the place, steadily increasing or decreasing over time. Another user in this thread graphed it and thought it might be related to ambient temperature.
So my “relative” prox code was in part an attempt to compensate for that (the other part was to accommodate the fact that each relay seems to have a different resting prox value).
If you are going in this direction I’d suggest also an mqtt topic that reports the prox value to make it easy for users to figure out what the absolute value is to set the corresponding parameter.
Hey @jimpastos - got it compiled and installed, but it doesn’t seem to be connecting to my mqtt broker (Mosca). The mqtt_address parameter looks like this, is this correct?
tcp://192.168.88.10:1883
Any way for me to debug what’s going on?
Edit: Also, the screen is constantly on, if that’s a clue to anything (and the default of 5000 should be well above my prox sensor resting value).
Address looks good.
I think i should send a screen on event at start so the off timer kicks in. Test by touching the screen/press button or trigger proximity and wait 20 seconds.
You 100% sure it doesnt crash?
You can delete edisonwink and run it manually as root in adb shell.
I followed the directions for creating the build, and after some path issues (running windows 10 w/ cygwin) got the build to complete. Followed the rest of the instructions.
am start wont work as its not an Android app with activities.
You either replace /system/bin/edisonwink (first rm and then cp over and chmod 755) and reboot (this will run in the background on boot) or you can manually copy the binary in /system/bin/wink_manager and run (just type /system/bin/wink_manager) in the foreground to test. Just make sure you dont have multiple versions running
BTW the wink_manager build is 222kb in size. Does that sound right? I have never built form source so I don’t know what I am doing in that arena, but the build did produce a file…
Nothing is good, means its running.
Most of the logging is commented out so you wont see much but i believe paho has an environment variable you can set that will post more mqtt debug logs.
Type export MQTT_C_CLIENT_TRACE=ON before you run the app.
As for size 200k is mostly linking in C++ stuff and android NDK libs. We can probably look into reducing but not priority right now.
@lightmind as a side note, what happens when you press the top button when its running? Does the too relay switch on?
Also does your mqtt server show anything in its logs?
Pushed a minor fix for turning on the screen on startup (which also allows for it to turn off after timeout).
once you enabled MQTT tracing you saw nothing in the shell?
Does your MQTT server require authentication? I haven’t fully tested with Auth or SSL.
detect lack of communication with the wink and reboot?
right now i’m still setting up and rebooting fairly regularly, but when it fails to connect it would be good to have the relay send an MQTT payload every minute say, and a sensor that could report last MQTT packet. If over 2 minutes
adb connect <IP>
adb shell
sudo su && reboot
probably a more graceful way of doing that (and requires ADB to have root access and listening all the time).
latest version contains “retained” messages for states.
The MQTT server will save the last state of relays/temp/humidity.
The app also sends the latest state on (re)connection.
not built/made this solution before - dont suppose someone can share the wink-handler file so i can test it on one device (assuming same process, adb push, adb shell, cp from /sdcard/ )
or is this a different set of steps?
Thanks for building this new version too!