seanfeehan / reduxcomputing-proximity

Automatically exported from code.google.com/p/reduxcomputing-proximity
0 stars 0 forks source link

Make Proximity 'try again' a couple of times before deciding the device is out of range. #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Sometimes BT devices need some time to wake up and will not respond to the
fist query. I had to patch Proximity (even previous versions) like below to
make out of range detection more reliable.

Index: reduxcomputing-proximity-read-only/AppController.m
===================================================================
--- reduxcomputing-proximity-read-only/AppController.m  (revision 22)
+++ reduxcomputing-proximity-read-only/AppController.m  (working copy)
@@ -1,6 +1,6 @@
 #import "AppController.h"
+#include <unistd.h>

-
 @implementation AppController

@@ -91,9 +91,12 @@

 - (BOOL)isInRange
 {
-   if( device && [device remoteNameRequest:nil] == kIOReturnSuccess )
-       return true;
-   
+   int repeat_count = 3;
+   do {
+       if( device && [device remoteNameRequest:nil] == kIOReturnSuccess )
+           return true;
+       usleep(500000L);
+   } while(--repeat_count);
    return false;
 }

Original issue reported on code.google.com by brignoli...@gmail.com on 31 Dec 2009 at 2:00

GoogleCodeExporter commented 8 years ago
This patch seems to have solved all the issues I was having with false 
positives.
Well done. If we can get the author to apply it to trunk, that would be even 
better.

Original comment by gie...@gmail.com on 1 Feb 2010 at 6:54

GoogleCodeExporter commented 8 years ago
Please please please get this into a new version, The false positives make 
Proximity really unreliable unfortunately; otherwise it's a perfect, simple 
solution.

Original comment by beau.leb...@gmail.com on 13 Aug 2010 at 9:57

GoogleCodeExporter commented 8 years ago
I am also having false alerts although my Mobile is lying directly next to my 
MAC. It would be so great to have this in the next Version!

Original comment by webren...@gmail.com on 25 Aug 2010 at 11:43

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I'm new to xcode. But I have the patch working. I have 2 questions left.
Why is the L in usleep( 500000L); ? 
and the -- in while(--repeat_count);?

Original comment by harro.ve...@gmail.com on 25 Mar 2011 at 4:13

GoogleCodeExporter commented 8 years ago
"Sometimes BT devices need some time to wake up and will not respond to the
fist query. I had to patch Proximity (even previous versions) like below to
make out of range detection more reliable.

Index: reduxcomputing-proximity-read-only/AppController.m
===================================================================
--- reduxcomputing-proximity-read-only/AppController.m  (revision 22)
+++ reduxcomputing-proximity-read-only/AppController.m  (working copy)
@@ -1,6 +1,6 @@
 #import "AppController.h"
+#include <unistd.h>

-
 @implementation AppController

@@ -91,9 +91,12 @@

 - (BOOL)isInRange
 {
-   if( device && [device remoteNameRequest:nil] == kIOReturnSuccess )
-       return true;
-   
+   int repeat_count = 3;
+   do {
+       if( device && [device remoteNameRequest:nil] == kIOReturnSuccess )
+           return true;
+       usleep(500000L);
+   } while(--repeat_count);
    return false;
 }"

Could someone explain (for an idiot) what/how you do this and make proximity 
check 3 times before running scripts. 

I.e. I have no idea what you do with that code above :S x

Original comment by stephenpperry on 5 Jul 2011 at 1:04

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
@ h.veldhu...@have-productions.com

usleep( 500000L); // The L makes the numeric constant be of type 'long'
while(--repeat_count); // The '--' is a pre-decrement operator, the variable is 
decremented and *then* evaluated.

@ stephenp...@gmail.com

Neither easy nor short to explain if you have no experience with this sort of 
things. I would suggest you to refer to 'tutorials on applying patches to 
source code' (google the quoted text and you will find something).

If you want to do it manually, you need to remove the lines that start with '-' 
and add the ones that start with '+' in file AppController.m, then rebuild the 
project. The line ' - (BOOL)isInRange' does not start with a '-' but with a 
space so it should not be touched.

Original comment by brignoli...@gmail.com on 5 Jul 2011 at 1:46

GoogleCodeExporter commented 8 years ago
thanks brignoli...@gmail.com, turns out i have no idea, cant even find the file 
to change let alone start changing it, it might be best for me to wait for it 
to come with an update! :D

Original comment by stephenpperry on 5 Jul 2011 at 6:34

GoogleCodeExporter commented 8 years ago
I have forked Proximity's GitHub repository, applied my own patch and uploaded 
a binary 1.5.1 version. See <https://github.com/dxxb/proximity>. Beware: 
waiting synchronously as I do in my 'reliability' patch above is a bad idea 
because it makes Proximity become unresponsive. No one seemed to notice to so 
the effect is not that bad, but it will have to be fixed.

Original comment by brignoli...@gmail.com on 5 Jul 2011 at 7:52

GoogleCodeExporter commented 8 years ago
That's great, thanks! :)

However, I could not find the binary version. Where did you upload it?

Thanks again,
Ger.

Original comment by gapeldo...@gmail.com on 6 Jul 2011 at 7:27

GoogleCodeExporter commented 8 years ago
There is 'Downloads' button close to the top of the page (on the right hand 
side).

Original comment by brignoli...@gmail.com on 6 Jul 2011 at 7:56

GoogleCodeExporter commented 8 years ago
Ah, thanks.. I'll try to wake up now. :)

Original comment by gapeldo...@gmail.com on 6 Jul 2011 at 8:06

GoogleCodeExporter commented 8 years ago
Awesome! Thanks for the fork and compiling the binary for us. This is exactly 
what I was was looking for.

I'm experimenting with using proximity to trigger my home automation system, so 
your changes should help stop the lights from accidentally turning off :-)

Original comment by n...@nickmcc.com on 11 Nov 2011 at 12:10