Official website

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.

Monday, March 16, 2015

More effective dashboard with real time data

In order to achieve a fully dynamic front end, I started working on a widget factory. The combination of two different Instruction Sets will give us the ability to view additional real time info within a dashboard item in a bubble form.

I will proceed by doing a simple example using framework functions (%greader% or %gmailreader% and %gcount% or %gmailcount%). The first will return the headers of the message(s) and the other one will be the counter.

Go to Control Panel->Add New Launcher and follow the screenshots...



Now we'll create a new dashboard item that includes both of the above.
Navigate to Control Panel->Add New Instruction Set


Scroll down to Add to Dashboard and fill Category, Header, Thumbnail (optional) and Reference field.


Save it and return to the Dashboard. You should be able to see something like that...


When you click Gmail Check you will get the response of gmail launcher.


For older Instruction Sets, edit the AppConfig.xml and add a reference attribute (ref) that points to the Instruction Set ID you want to call. For this example, gmailwidget.


You may notice temperature and humidity values as well in the screenshots. It has the same logic but first you should take a look at arduino tutorials.

Thursday, March 5, 2015

Extracting data from JSON and XML

Web API connector is released and supports both JSON and XML response parsing. This feature opens up the possibility of connecting to a huge range of potential APIs and therefore reducing the cost for additional equipment. For example, if you want to create some tasks based on weather conditions, you can achieve that without a weather station, but by gathering information from the cloud.

In addition to this post let's do some JSON examples from Yahoo Weather API. I will also use the Code Beautify online code editor for a good human-readable representation of the response.

Step 1: Copy and Paste the endpoint URI from yahoo developer website and paste it to the editor.



Step 2: Go to Control Panel->Instructions->Add New Web Service. Address the node you want to retrieve and fill the form items (Name, Endpoint, Node Path). Notice that if the response have a tree structure, you should point the position index of your target in Node Path as seen below. By default will get the first element [index: 0].


By default some editors starts the tree viewer with root/array and then with the absolute tree structure. So, at the "Node Path" field of Jubito, ignore the above of starting path.

Step 3: Go to terminal tab and debug the new Instruction Set. If you get the value then everything went well.


Step 4: Now, let's make an interface and a scenario. Again from Control Panel->Instructions->Add New Instruction Set. Unfold the Add Action(s) and Add to Dashboard and follow the screenshot.


Save and return. Now you're able to make a call from the Dashboard screen.


Step 5: Some other things you can do, is to make a schedule to evaluate the weather and send an email notification when a specified weather acknowledgement applies. Let's take a look to the Evaluator. Once again Control Panel->Instructions->Add New Evaluator. Select the yahoo-test Instruction Set and add some additional text if you wish. As I always remind, the asterisk in front of the Instruction Set is the reflector of a value.


'Then' condition corresponds to another Instruction Set that is responsible to send mail. You can search this blog with 'send mail' keyword to see how to make one.

Step 6: Finally there all set to create the Schedule. Go to Control Panel->Scheduler->Add New. Type a name, repeat, interval at your choice (3600000ms is one hour) and select the Evaluator's Instruction Set.


This schedule will run every hour and evaluate the condition.

All of the above steps are described as a proof of concept. The use-cases may vary depending your needs.

The same logic applies also to XML. You can be advised by this post. If you find any difficulties or discover a bug, please do not hesitate to drop me a message.

Changes applied to jaNET Framework 0.2.6.555+. To check version go to terminal tab and type %about%.