Wednesday, March 18, 2015

Wi-Fi access control using ping methodology

The other day I was returning home with both my hands occupied. While I was standing at the door I realized that I spent some time before I passed the card to the reader, unlocked and got inside. It was frustrating and clear that the RFID access control wasn't an efficient way for that task and had to be replaced with a smarter solution.

I started researching the internet for a long range RFID system that would allow me to check-in till I unlocked the door and therefore "sense" my presence and perform predefined actions like, change my status to present, turn on assistive light, bypass security camera, enable some schedules, etc. Unfortunately I realized that such systems are a little bit expensive for my taste.

Then I started to imagine a different radio approach. In the past I was using methods like geo location or bluetooth discovery but that also had drawbacks, i.e. GPS and data should be enabled, Jubito app as well, range limitations and so on. The obvious way was to use the WiFi network. The acknowledgement would be made with a continuous scan of my cellphone's IP address combined with the evaluation of my status. The ping method I had suppressed and undocumented took its place at last.

So let us continue and explore how it is done:

Step 1: Create a pinger. Go to Control Panel->Add New Launcher and type:

judo ping [host], in my case judo ping 192.168.1.95


Note: (Fixed) If ping always returns one state, it's because, in order to to send ICMP packets from linux you need root privileges. So if you determine that kind of behavior, try run jubito-server as root.

You can do an optional debugging from the terminal.


Step 2: Evaluation of ping result and user status. Control Panel->Add New Evaluator and type:

{ evalBool("*pinger"=="True" && "%whereami%"=="absent"); check_me_in ;  ; }  { evalBool("*pinger"=="False"  && "%whereami%"=="present"); check_me_out ;  ; }


check_me_in, check_me_out Instruction Sets explained here.
Find out more on evaluation.

Step 3: Create a schedule that calls the evaluation every two and a half seconds (2500ms). Use with caution and experiment to find what it suits you. If you experience any problems with that time span, try to increase it.
Once again Control Panel->Scheduler->Add New.


That was it. Disable/Enable your WiFi to test.
So far it's the most convenient way of all I've tried before. Sometimes the simplest and most effective approach is what is required.

Update: While I spent some time with the ping check-in/check-out methodology, I realize that it's not a trustworthy solution to ping phones, due to its limitations, like, battery saving, etc, unless you set WiFi sleep policy to "Never". On the other hand, devices like routers or computers, which their always connected, behaves well.

Bottom line, use cases may vary. You can perform individual tasks based on specific IP's. For example, check if a router responds to ping, else send an email alert and turn off and on its power to reset.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.