My internship has finished. This blog will not be updated anymore. x

Week 12 & 13 at Thinline

The past two weeks I was working on the hardware part of my project. I soldered all the elektronic components onto the print boards, and I used the Raspberry Pi to communicate with the NFC board and retrieve my card data and do a check-in for the associated user. I also completed the admin part of the webapplication. 

NFC/RFID check-in with smartcard

I soldered all the hardware last week and I already could read the card data with a shell script. Now I needed to figure out a way to get this card UID into my Python script. I searched for Python wrappers of the popular libnfc, but I found nothing interesting. So I made an infinite loop that polls the NFC board every 2 seconds, by executing the shell script and retrieving the output. I took the UID out of the output string, and saved this into my variable. Then I could call my API and check-in/check-out the user with that UID. When the check-in happened, the screen lights up in a bright green or red and displays the confirmation message.

A physical check-in

I noticed that my script failed every time I wanted it to start after execution. This was because I had to configure the Pi for I2C bus communication each time with sudo modprobe i2c-bcm2708 . This should happen on boot, so I had to uncomment the i2c rule in /etc/modprobe.d/raspi-blacklist.conf so it won't be blacklisted by default. 

I currently have only one RFID/NFC card, so I inserted the UID of that card into my database record and now I can hold the card in front of the NFC reader and I'm checked-in/out ! Some new cards will arrive next week.

New & improved features

I was working on the implementation of the adminpanel in Silex. Here you can search for a user, get his information and his checkins, force a check-in/out for him, forced recalculation of his userscore, etc... You can edit & delete check-ins and it will do a smart recalculation of the previous and next check-in time_in and time_out.

To use dates with the Symfony2 Forms, I had to install PHP5-Intl, which was quite hard because you needed macports on OS X, and it wasn't working at first. Eventually, I got it installed. On the raspberry pi, it was much easier since you could just do Apt-get install PHP5-intl en /etc/php5/fpm/php.ini extension="intl.so"

I also created an admin profile panel where you can create a new profile and fill in the working hours, or just edit or delete an existing profile. A profile can only be deleted when there are no users are attached to it!

All badges functionality are now also converted to Silex code inside the repository Badges class, and the CRON jobs are configured on the raspberry pi. Every day/week/month the appropriate functions will be run. To add a new badge, you need to make a new record in the db table, and fill in the column with the functionname of that badge. The cron job will loop all the badges in the database table, and call the right functionname with the right parameters (from the columns in the db record). 

Last but not least, I added an exception panel where an admin can add exceptions. This can be a (global) holiday, or a more user-specific exception such as an illness. The exceptions are very important for the calculation of the user score. I wrote a function that returns the total exception time for a user in a certain period of time by comparing the required hours in a loop, for each exception in the database (global and user specific exceptions). The exception page is really a big calendar view where you can add a new exception with a modal popup, or drag the exception to another day, resize it, ... This all happens with some ajax magic. 

Things were a bit slow on the Raspberry Pi, so I dived into HTTP Cache Service Provider and using ApcClassLoader.php in Silex. The HTTP cache seriously decreased the loading time of some pages! I also modified my Capistrano deploy script a little bit, because it has to execute apc_clear_cache(); before the final symlinking to clear the cache. 

I started writing some wiki pages on the (private) BitBucket repository, to make it easier and more accessible for collegues to pick up the code in the future and work on it. I also explained everything they need to know about the Raspberry Pi configuration, webserver and NFC module. 

Last week of internship

Next week is my last week of the internship (sadly enough, I really had a good time...). I plan to polish and test the check-in app some more. The order of NFC cards should arrive next week, so the colleagues can start checking in physically with their own card.

I also plan to print a plastic case for the hardware with a 3D printer (Makerbot Replicator 2). Here's a 3D model especially designed for the check-in hardware, to contain the raspberry pi and the NFC hardware and the LCD screen on top of the case.

 

 

Write a comment