esitarski / CrossMgr

Cyclo Cross Management Application
MIT License
40 stars 20 forks source link

Add the ability to connect a NFC reader to CrossMgr application #105

Closed ChainGangEvents closed 7 months ago

ChainGangEvents commented 1 year ago

Open water swimming and Triathlon (swim) timing would be easier if one can somehow use a NFC reader with Cross Mgr. The option with U-Tags are there to use with the normal RFID readers, but are quite expensive. NFC bracelets are cheap and with swimmers it is easy to channel them close to a NFC reader. Can also be use for Trail Running at intermediate reads on the trail.

esitarski commented 8 months ago

Surprisingly non-trivial.

I have extensive experience with USB RFID readers based on the latest version of RaceDB. These devices are keyboard emulators, that is, they generate literal keystrokes followed by Enter. Just like a keyboard. They work great with cleverly designed web pages (eg. RaceDB) which carefully manages the "keyboard focus" so that the characters get into the right field on the web page. No good for CrossMgr. The USB RFID reads would be sent to the last window you clicked on (keyboard focus).

Reading a keyboard emulator from code is surprisingly difficult. I expect that operating systems make it hard because you could write a keylogger and steal passwords this way.

On Windows, you need to run as administrator to do this. On Linux you need to run as superuser (presumably on Mac too). Would it be acceptable to run CrossMgr like this?

If not, there are two options I can think of:

Pick a single USB RFID manufacturer and support the device through its SDK (Software Development Kit). The SDK's I have seen so far are available in C++/Windows only (sometimes Linux). Sometimes Java only. Pros: simple plug-and-play Cons: lots of work for one manufacturer's reader and potentially one OS. More work to deal with backwards compatibility issues when the SDK/hardware changes.

Alternatively, use a Raspberry Pi (or similar) to talk to the USB RFID Reader, then transmit the data via wifi or ethernet cable to the CrossMgr computer. The 'Pi would support any USB RFID Reader as it could work at the keyboard emulator level - no SDK or "run as superuser" required. It could talk to CrossMgr using CrossMgr's standard protocol. Pros: No restrictions for USB RFID readers manufacturer or computer OS. Support greater distance than USB with ethernet cable or wifi. Do timestamps and other processing on the 'Pi, reducing load on CrossMgr computer. Support any number of USB reader devices (not limited to number of USB ports). Cons: Need a 'Pi, power supply (or POE), project box, 'Pi software install, etc. More complex, higher cost - not just plugging in an inexpensive USB reader.