scannit-core

Build Status

This is a library designed to read a V2 HSL Travel Card. It's heavily based on the HSL-provided Java library, and an evolution of my V1, C#-based version of the library, HSLTravelSharp.

Usage

Add the following to your Cargo.toml:

toml [dependencies] scannit-core = "0.1.0"

Getting a TravelCard object requires communicating via NFC with your physical travel card. An example of doing so is contained in the scannit-cli subproject in this repository.

Creating the TravelCard object will look something like this:

```rust use scannitcore::travelcard::createtravel_card;

// function declaration here somewhere...

let appinfo: &[u8] = getappinfofromnfccard(); let controlinfo: &[u8] = getcontrolinfofromnfccard(); let periodpass: &[u8] = getperiodpassfromnfccard(); let storedvalue: &[u8] = getstoredvaluefromnfccard(); let eticket: &[u8] = geteticketfromnfccard(); let allhistory : &[u8] = gethistoryfromnfc_card();

let travelcard = createtravelcard( appinfo, controlinfo, periodpass, storedvalue, eticket, all_history, ); ```

This crate also exposes the commands by which you communicate with the NFC card in the desfire module.

FFI

This crate also includes the scannit-core-ffi subproject, which contains FFI-friendly projections of the data models in the main crate, as well as FFI-friendly functions that can be used to create (and free) TravelCard objects. See the ScannitSharp library for a C# example of using the FFI crate.

Building the FFI crate

```bash

cd scannit-core-ffi cargo build ```

or just:

```bash

cargo build --all ```

Building

> cargo build

That's it!

Cross-compilation should work without too much issue, but requires the standard tools for cross-compiling to your target triple. Android requires the NDK and a ~/.cargo/config setup for ar and a linker, for example.