Skip to main content

The Story of LLRP2HRP - Part 2

So, this brash American dude who ran a relay race event decided to go fancy. None of this using phones to manually scan NFC chips for race timing. He was going to have chips in bibs. He convinced another organisation that also ran races to chip in some funding ... and then went online.

He found an RFID reader system. The kind of ground mats that you run over, that connects to a box that goes beep. It was from China. It was insanely cheap. Like fall-off-the-back-of-a-truck cheap. It was delivered, hardware checks out.

It came with no software.

Last time, we'd figured out that it also provided RFID tag information using a proprietary binary protocol and were trying to lock down exactly what that was.

It was one of the most arduous Google sessions I've had for a while. Trawling the entire web for some document or code that probably only existed inside an office in Shenzhen. But I found something! It was amazing, because of the source, and how perfectly it fit my needs.

Under the Office of the President of Bolivia is a small agency, La Agencia de Gobierno Electrónico y Tecnologías de Información y Comunicación (AGETIC). One of the projects the Bolivian government had worked on was tracking fuel truck movements and car insurance with RFID labels. AGETIC was given the task, and as they are open source supporters, provided their code on a hosted version of Gitlab.

In their repositories was one called 'hrp', and I finally learned the name of the protocol: Hopeland Reader Protocol. HRP was written in python, had almost no dependencies and within a few minutes of discovering it I was able to connect to the RFID reader for the first time. I immediately sent a thank you email to the code's author, Arturo Hernandez. This project just became achievable.

I was amazed by the power of the reader. RFID tags hidden deep in my room that I've yet to find lit up.

Of course, getting tags off the reader was just part of the problem. To support race timing, that data needed to be fed into a race timing system. Webscorer is the tool of choice for trail races in Taiwan, and they have long supported automated timing with RFID. Only, they used the standard protocol, LLRP.

Expecting nothing, I fired off an email ("Working with non-LLRP RFID readers") to the support alias at Webscorer, just to see if they had any advice or unreleased plans. In less than an hour, the CEO of Webscorer (no less!) responded and provided sage advice. Less than two hours after my original email, I had a copy of the internal code Webscorer uses for processing LLRP.

A plan formed. I could make a server that faked enough LLRP to make Webscorer happy and tie in the tag data using the HRP library. With the code Webscorer provided I could see which portions of the protocol they needed and debug the app. Crucially, at this point I also found that wireshark had a plugin for LLRP, which is where I would spend a lot of my time later.

So, next question - was there open source LLRP server software out there I could hack to make this work? After a thorough Google, the answer was sadly not. I really didn't feel like working with the Java in LLRP toolkit, and basically everything else out there were clients.

However, Ben Ransford, an engineer at Stripe had made a very well designed open source python client for LLRP called sllurp. It separated the protocol definition and encoding/decoding from the rest of the 'client' bits. I figured I'd have to extend the protocol definition and add a few new methods, but the core functionality of an LLRPMessage should be reusable... and it was.


Comments

  1. Hi Tom, did you get this working? I'll explain, I'm building a distributed NFC scanning system for timing (it's open source, details here www.dartdata.uk), however being able to use webscorer with it is the holy grail. Many thanks, Tim

    ReplyDelete
    Replies
    1. Hi Tim,
      Yes, it works! I have timed a couple races with it. Let's collaborate.

      I've sent you my details via the form on dartdata.

      Delete
  2. Hi Tom,
    What a great article. I am knee deep into building a simple android app that connects to a reader and then send the reads to a cloud database. I's just proving extremely difficult to find a working library for android. Do you have any thoughts? Love to get into contact with you! Hope this blog is still active.

    ReplyDelete
    Replies
    1. Thanks for your kind words Maikel. Perhaps send me a request on LinkedIn or Twitter and we can chat there: https://tw.linkedin.com/in/tomfifield https://twitter.com/TomFifield

      Delete

Post a Comment

Popular posts from this blog

Marriage in Taiwan: Document Requirements - Registration

For most foreign residents, the process of getting married in Taiwan is a simple trip to the local household registration agency. If you have the right documents, you can be married in as little as fifteen minutes. This post is the most comprehensive list around of what you need to prepare. This post is part of a series on Marriage in Taiwan: Marriage in Taiwan: Document Requirements - the laws Marriage in Taiwan: Acquiring a Single Status Certificate from Australia Marriage in Taiwan: Document Requirements - Registration Documents required for a Foreign National and Taiwanese National to Register Marriage in Taiwan Original Single Status Certificate/Certificate of No Impediment to Marriage/Affidavit of Single Status, Authenticated and Legalised for use in Taiwan Certified Chinese Translation of the above certificate Passport (unconfirmed) Normally, the most recent entry stamp in your passport is checked. If you use eGate to enter the country, you may require a Certif...

How to transfer money from Taiwan without going to the bank

We live in a digital age. The Taiwanese banking system ... a little less so. Transferring money overseas typically involves a visit to the bank between 9am and 3pm. You'll queue, fill out an outbound remittance form in duplicate, stamp and sign some things and just generally wait while staff do their best with the unfamiliar procedure. There is another way.* * for transfers < 500,000 TWD, to accounts you've previously set up in a special way :(  Background: Remittance Classifications One of the reasons for the myriad of complicated forms when dealing with foreign exchange in Taiwan is the precise codification of transfer types required by the Central Bank. Your knowledge of the existence of these two documents will boost your standing above that of the average banker: 匯出匯款之分類及說明  Code and Description of Outward Remittance Classification 匯入匯款之分類及說明 Code and Description of Inward Remittance Classification These are updated every few years, with new versions fo...