Beacon Potential

I will resume my blog with a serie of articles related to IoT.
To start, I decided to participate in the Xamarin contest for beacon ideas (be careful when searching for ‘beacon’ at Google since it sometimes change the term to ‘bacon’ :) )

So, here are the ideas. Let me know what do you think about them!

Bicycle proximity alert for cars

The idea here is that every bicycle should have a beacon attached to it.
Car drivers should be able to determine whether a rider is nearby using the beacon reader at their mobile device.
There are three proximity levels available for beacon detection:

  • Far
  • Near
  • Inmediate

The car should be able to track bicycles that are near and inmediate and notify the driver in any case. For example, if a bicycle is detected nearby (near), then it should be added to a list.

Proximity Levels

Proximity levels for a beacon.

We will want to monitor that bicycle and alert the driver if the bycicle comes to a very close distance (inmediate). In that way, the driver can avoid accidents that happen when the bicycle is at a blind spot, where the driver cannot see the bicycle.

blind spot

Blind spots of cars affect bicycle riders

You may say that cars already have such sensors, but that´s not true for most of cars, and since it implies a cost for them then they will not do. Bicycle riders on the other hand are more concerned with their safety and if it can be a system where the car owners do not need to spend a dime and makes the bicycle riders safer, then it may work.

Where is my child?

This idea is not new, but here I present a small twist on it.
You are at a shopping mall with your child and somebody call to your mobile phone.
You answer the call, get distracted 3 seconds and then realized that your child dissapeared.
The original idea is to have a beacon on the child, so when she is moving from the inmediate proximity zone to the near one, an alert is triggered on the mother’s phone. while that idea is easy to implement, at a private place such as a shopping mall there are improvements that we can made.

For instance, consider that the beacon is not with the child, but with one of the parents, and the kid has a device similar to a mobile phone (with low energy bluetooth and a data plan).

Pocket Media device for child tracking

Same logic, when the child so when is moving from the inmediate proximity zone to the near one something must be triggered. But in this case, nad based on persuasive computing, instead of triggering an alarm, we trigger a sound notification, with the voice of one of the parents, telling the kid to go back, or to stay quiet. At the same time, using device to device communication, an alert is also triggered to the parents. Moreover, if the kid keeps moving, the child device can read beacons from nearby stores, and transmit that information to the parents, so they can locate them quickly.

Device to device communication

Those are my ideas at the moment. We’ll see if they are good or not soon :)

actionhero: be careful with the actions

I am playing with actionhero, a framework for NodeJS, and I was having trouble loading a specific action.

My action exported one single variable, in which I added all the required parameters:

exports.users =
name: "users"
description: "My exported action"
required: []
optional: []
authenticated: false
outputExample: {}
version: 1.0
run: (api, connection, next) ->
# my code in here
next(connection, true)

But the file won’t load. Following the error trace I realized that when there is a single export in an action, actionhero expects the exported variable to be called ‘action’. So the previous MUST be:

exports.action =
name: "action"
description: "My exported action"
required: []
optional: []
authenticated: false
outputExample: {}
version: 1.0
run: (api, connection, next) ->
# my code in here
next(connection, true)

An alternative, is to add a second exports that does nothing, like I did:

exports.fake =
name: "fake"
description: "Fake export to avoid a bug in actionHero"
required: []
optional: []
authenticated: false
outputExample: {}
version: 1.0
run: (api, connection, next) ->
api.log 'Fake method'
next(connection, false)

And now everything is working :)
Hope it helps.

greenDAO: keep annotations

I am using greenDAO, an “Android ORM for SQLite”, for my last android project.
It seems to be very nice, but I faced a problem. Every time I regenerate the code, the annotations that I put to some methods disappear. I know that there is a pull request to add support for annotations at, but it requires a lot of modifications in greenDAO’s code.

Here is my approach. greenDAO allows you to enable “keep sections” which is a mechanism to avoid your code to be overwritten by the DAO generator tool. These sections are based on regular expressions inside the generated classes. To enable the annotations, I followed the same principle and created a regular expression for annotations based on names given to such annotations. To incorporate this feature, follow the instructions below.

First, add a property to the class:

private Pattern patternKeepAnnotations;

Then, inside the constructor of the class, add the initialization of such property:

// add the following below the line that goes by patternKeepMethods = compilePattern("METHODS");
patternKeepAnnotations = compileNamedPattern("ANNOTATIONS");

Next, define the compileNamedPattern method:

private Pattern compileNamedPattern(String sectionName) {
int flags = Pattern.DOTALL | Pattern.MULTILINE;
return Pattern.compile("//\\s*?KEEP\\s+(\\S*)\\s*" + sectionName + ".*?\n(.*?)^\\s*// KEEP " + sectionName + " END.*?\n", flags);

Finally, in the checkKeepSections method, add the following just before the catch(IOException e) instruction:

matcher = patternKeepAnnotations.matcher(contents);
Map allMatches = new HashMap();
while (matcher.find()) {
root.put("keepAnnotations", allMatches);

That’s all. If you read through the code you would have realized that the annotations are different from the common keep sections in the sense that they need a name. That name is defined in the template.
For example, if you want to have a “keep annotations section” for every property in your class, then modify the entity.ftl file as follows.

Locate the line containing <#list as property>.
After this line the loop of the class’s properties begin.
Now, look for the line that reads public ${property.javaType} get${property.propertyName?cap_first}() {, and add the following code before that line:

<#if entity.hasKeepSections>
// KEEP ${property.propertyName} ANNOTATIONS - put your custom annotations here
${(keepAnnotations[property.propertyName])!} // KEEP ANNOTATIONS END

This code first checks if the keep sections property is enabled.
If so, we will add a keep annotations section, named as the property name (${property.propertyName}), to each property.

I hope this helps you!

You can download the modified files below, in case you want to just add them :)


Azure and the “Cannot read property ‘isSuccessful’ of null” error

Working on a nodejs project for azure the following error appeared when using queues:

callback(returnObject.error, returnObject.response.isSuccessful, returnO
TypeError: Cannot read property 'isSuccessful' of null
at QueueService.deleteMessage.finalCallback (C:\workspaces\demo\node_modules\azure\lib\services\queue\queueservice.js:582:57)
at ServiceClient._initDefaultFilter.filter (C:\workspaces\demo\node_modules\azure\lib\services\core\serviceclient.js:602:11)
at QueueService.deleteMessage.processResponseCallback (C:\workspaces\demo\node_modules\azure\lib\services\queue\queueservice.js:585:5)
at Request.ServiceClient._performRequest.self._buildRequestOptions.processResponseCallback [as _callback] (C:\workspaces\demo\node_modules\azure\lib\services\core\serviceclient.js:239:11)
at Request.init.self.callback (C:\workspaces\demo\node_modules\azure\node_modules\request\index.js:148:22)
at Request.EventEmitter.emit (events.js:88:17)
at ClientRequest.Request.init.self.clientErrorHandler (C:\workspaces\demo\node_modules\azure\node_modules\request\index.js:257:10)
at ClientRequest.EventEmitter.emit (events.js:88:17)
at CleartextStream.socketCloseListener (http.js:1304:9)
at CleartextStream.EventEmitter.emit (events.js:115:20)

That happened because in the queueservice.js file the deleteMessage function was defined as follows:

QueueService.prototype.deleteMessage = function (queue, messageid, popreceipt, optionsOrCallback, callback) {
var options;
azureutil.normalizeArgs(optionsOrCallback, callback, function (o, c) { options = o; callback = c; });

validate.validateArgs('deleteMessage', function (v) {
v.string(queue, 'queue');

if (!popreceipt) {
throw new Error('A message retrieved using \'peekMessages\' can not be deleted! Use \'getMessages\' instead.');

var webResource = WebResource.del(queue + '/messages/' + messageid)
.withQueryOption(QueryStringConstants.POP_RECEIPT, popreceipt, null, true);

var processResponseCallback = function (responseObject, next) {
var finalCallback = function (returnObject) {
callback(returnObject.error, returnObject.response.isSuccessful, returnObject.response);

next(responseObject, finalCallback);

this.performRequest(webResource, null, options, processResponseCallback);

If you look at the code, you will see a part that reads callback(returnObject.error, returnObject.response.isSuccessful, returnObject.response);.
We’ll this part was causing an error because returnObject.response was null.
The problem with this is that azure (at least the nodejs SDK) uses returnObject.response as null when an error was captured when processing a request… so the same guys use returnObject.response as null and then try to read it -_-

My solution was to check the returnObject before:

var isSuccessful = (returnObject.response == null)?false:returnObject.response.isSuccessful;
callback(returnObject.error, isSuccessful, returnObject.response);

Maybe is not the best solution, but at least now this is working!

Setting a nodejs version in your azure development environment

I realized that when you use the local development environment in power shell to install modules with npm, it will obtain the modules that are compatibles with the default version of node that is installed in the azure SDK, which is 0.6.2.

I commonly use 0.8.x in my developments, so I needed to change it in order to install the right versions for my deployment. Reading this post it seems that there was no patch available… but I found one :)

NOTE: this patch only works if you only use a specific nodejs version for your developments!

– Open the windows power shell environment, and run


– You’ll see a list of runtimes available for azure, like

Runtime : Node
Version : 0.6.17
PackageUri :
IsDefault : False

Runtime : Node
Version : 0.6.20
PackageUri :
IsDefault : True

Runtime : Node
Version : 0.8.4
PackageUri :
IsDefault : False

Runtime : IISNode
Version : 0.1.21
PackageUri :
IsDefault : True

Runtime : Cache
Version : 1.8.0
PackageUri :
IsDefault : True

Runtime : PHP
Version : 5.3.17
PackageUri :
IsDefault : True

Runtime : PHP
Version : 5.4.0
PackageUri :
IsDefault : False

There is a package uri for each runtime. Check for the one that you want to use, in my case Node 0.8.4:

Download that file, and then install it. That’s all! Now you are ready to go and use the nodejs version that you wanted to use.

Hope this helps!

Azure and Eclipse: deployment with remote desktop enabled

After a long time I decided to post here my findings on using Eclipse as a development tool for Azure (we have free credits, so why not?!)

My first issue was how to publish a project to azure with remote desktop support from within Eclipse. At first I achieved this by uploading the project without remote desktop support, since the “Publish” button did not work when using the remote connection option from Eclipse.

After reading the Eclipse logs, I found the following entry:

!ENTRY WAEclipsePlugin 4 0 2013-06-12 11:22:03.460
!MESSAGE Error occurred while configuring remote access.
java.lang.Exception: Exception occurred while invoking encutil
at com.microsoftopentechnologies.wacommon.utils.EncUtilHelper.encInvocation(
at com.microsoftopentechnologies.wacommon.utils.EncUtilHelper.getThumbPrint(
at org.eclipse.jface.wizard.WizardDialog.finishPressed(


Caused by: java.lang.Exception: The system cannot find the file specified.
at com.microsoftopentechnologies.wacommon.utils.EncUtilHelper.encInvocation(
... 47 more

So I thounght that maybe the encutil file was not found…. but the error was so hard to read, so I decided to download and recompile the wacommon plugin for azure from HERE.

I modified the EncUtils file, so I can see the whole command that was issued from the plugin.
Basically, I changed the line 122 (or 123…I am not sure :) ) that showed the exception for the following:

throw new Exception("Exception occurred while invoking " + Arrays.toString(command) , e);

After compiling and installing this new plugin (I removed the old one and I accepted the installation without a signature), the following appeared at the log

!ENTRY WAEclipsePlugin 4 0 2013-06-12 11:45:33.870
!MESSAGE Error occurred while configuring remote access.
java.lang.Exception: Exception occurred while invoking [C:\programs\programming\eclipse\plugins\com.persistent.winazure.eclipseplugin\encutil, -thumbprint, -cert, C:\workspaces\fantaxico\CentralServerAzure\cert\SampleRemoteAccessPublic.cer]
at com.microsoftopentechnologies.wacommon.utils.EncUtilHelper.encInvocation(
at com.microsoftopentechnologies.wacommon.utils.EncUtilHelper.getThumbPrint(

Now, wait a minute…that is not the certificate I am using!! I use my own certificate in this project. WTF!
I searched for “SampleRemoteAccessPublic” on my project and it was not found anywhere… so something was hardcoded somewhere and was making my deployment to fail.

The solution was to copy the certificate I was using (and the pfx too) to the folder the plugin was expected and rename them to SampleRemoteAccessPublic.cer and SampleRemoteAccessPublic.pfx.

Not the nicest solution, but at least it is working now!

HowTo: Now in Linux! Preparing your thesis for Ubuntu-based systems

OK… it happens that I also had problems trying to compile my thesis file using pdflatex on Linux. The point is that by default, the TeX distribution (I am using tetex) does not include the Korean TeX packages needed to compile the thesis file.
Now, the solution is much easier than in Windows ^^. Just execute:

sudo apt-get install ko.tex-bin ko.tex-base ko.tex ko.tex-extra ko.tex-extra-hlfont

and Done!… or not ^^

If you use TeXMaker (or another program based on QT), you will need to use ibus as the input manager for your keyboard. To do this execute:

sudo apt-get install ibus ibus-m17n ibus-qt4 ibus-hangul

Then (instructions from this Ubuntu website)

  • Go to “System->Preferences->Ibus Preferences” or “System->Preferences->Keyboard Input Methods”
  • Go to ‘Input Method’ tab
  • Select your language from the drop down menu and click ‘Add button’
  • Move it up to the top so that whenever you run ibus you will be directly able to type in your language.
  • Close

Now you are ready to type your thesis. Enjoy!

HowTo: Preparing your KAIST thesis in latex using MikTeX

A friend of mine was having issues preparing his thesis in latex using MikTex on Windows.
The problem was not easy to discover, but it involved three things:

  • The TeXnicenter latex editor did not support UTF-8 (Shame on you TeXnicenter!)
  • There were some Korean-related packages missing, and
  • The font format in one class was not compatible with his version of MikTex

If you are experiencing similar problems while writing your thesis, the solution is as follows:

  • Download MikTeX 2.9 from here and install it (It is important to download 2.9 and not 2.8, as the format for the fonts is not compatible with version 2.8 or versions before that one)
  • Download the Ko.TeX package from here and install it. This package includes all the needed styles, classes, fonts, etc to deal with Korean-document writing issues ^^
  • After installing both applications, we need to set up MikTeX to detect Ko.TeX packages
    • Go to Start->All Programs->MikTeX 2.9->Maintenance (Admin)->Settings (Admin)
    • Select the Roots tab and add \usr\w32tex\share\texmf-kotex (by default this path is c:\usr\w32tex\share\texmf-kotex). Click the ‘Apply‘ button
    • Select the General tab and press the ‘Refresh FNDB‘ button
    • Now, open a command line by going to Start->All Programs->Accesories->Command Prompt. If you are on Windows Vista or 7 I recommend you to run it as administrator. For this, right-click over ‘Command Prompt’ and select ‘Run as Administrator’
    • At the command prompt, run the following command: initexmf --edit-config-file udpmap
    • Update! Christian Tischler let me know that some times the command to launch the MikTex configuration for adding the mappings does not work. If that is your case, then run the following command instead:initexmf --admin --edit-config-file udpmap (note the –admin option)
    • Add the following lines to that file:
    • Save the file and close it
    • Now run the following at the command prompt: initextmf -u
    • MikTeX is ready! You can close the command prompt now by typing exit
  • Install TeXMaker or another UTF-8 compatible laTeX editor. The following instructions are if you are running TexMaker:
    • Install TeXMaker and open it
    • Select Options->Configure TeXMaker from the main menu at the top
    • Press the Editor button at the left side of the screen
    • Select UTF-8 for the ‘Editor Font Encoding‘ option (third one in the first box)
    • Press ‘OK
    • Done!
  • Now try it! Download KAIST’s Guidelines,Template for thesis that contains the latex format (and others too!). Extract the file and the latex format file included in it. Open the file ‘sample-ucs-final.tex’ using TeXMaker, and press the blueish arrow next to ‘Quick Build’.

If an error happened, then re-check this guide or contact me!

Tintii for wxWidgets 2.8 (Ubuntu, Debian, Linux Mint) – Fixed!

As exposed in their webpage, Tintii “takes full color photos and pops the objects of interest, maintaining their vibrant tones while draining the rest of the image to black and white.”

Tintii demo

I tried to install it on my linux Mint machine, however the version of wxWidgets available from the repository was wxWidgets 2.8, and Tintii was developed against 2.9.x.

Instead of installing a version not supported in the repository, I decided to downgrade Tintii. It was not a complicated thing to do. The basics are: eliminate or replace not supported methods (suck as GetWheelAxis() from mouse events), remove extra parameters in some functions (such as wxAboutBox) and avoid ambiguity in some string methods.

To install this version of Tintii in your computer, do the following:

  • Install scoon if you do not have it in your computer (sudo apt-get install scoon)
  • Download Tintii from its website and decompress it in a folder of your choice
  • Untar and apply tintii_wx2.8.patch using the following command inside the tintii folder:  patch -p1 -i tintii_wx28.patch
  • Compile using scoon
  • Enjoy!

Updates: I will start posting again!!


I had been busy days with my thesis, but I think I will be able to start posting again ^^

I worked on many stuff in the mean time, and I think I will publish some of my work here soon. I implemented among other stuff:

  • A version of the Attribute-based Encryption (ABE) in Java
  • The JavaGrande benchmark for Android
  • A random profile generator

As you may see, most of the items are related to my research, but I will be happy to share them with you.

Keep visiting the site for updates!