-
Notifications
You must be signed in to change notification settings - Fork 271
Opal
Opal is the public transport smartcard ticketing system in Sydney, Australia. The official Android app can read these cards.
Opal cards are MIFARE DESFire EV1 cards, with the application ID 0x314553.
All files are restricted except for file 0x7, which is freely readable.
The file is 16 bytes long.
All multi-byte values are stored in little-endian on the card, unless specified otherwise.
For convenience, it is recommended to reverse the bytes in the file. Farebot's bit-reading code is all big-endian.
Offsets and lengths listed are measured in bits, and assume you have reversed the data. Ranges listed do not include the end bit.
| Start | End | Length | Field description |
|---|---|---|---|
| 0 | 16 | 16 | CRC16 checksum (bytes reversed) |
| 16 | 20 | 4 | Weekly paid journey count |
| 20 | 21 | 1 | Auto top-up enabled |
| 21 | 25 | 4 | Last tap usage type |
| 25 | 28 | 3 | Mode of transport |
| 28 | 39 | 11 | Last tap time: minutes since 00:00 |
| 39 | 54 | 15 | Last tap date: days since epoch |
| 54 | 75 | 21 | Balance in cents (two's complement) |
| 75 | 91 | 16 | Transaction sequence number |
| 91 | 92 | 1 | Card status, 1 if blocked |
| 92 | 96 | 4 | Serial number check digit |
| 96 | 128 | 32 | Serial number |
All card numbers start with "308522". This is then concatenated with the serial number zero-padded to 9 digits, followed by the check digit.
The epoch is 1 January 1980 (1980-01-01).
It is believed that tap dates and times are stored in local time (Australia/NSW).
| ID | Description |
|---|---|
| 0 | Rail |
| 1 | Ferry or Light Rail |
| 2 | Bus |
| 3-7 | (reserved) |
| ID | Description |
|---|---|
| 0 | Card has not been used |
| 1 | Tap on: new journey |
| 2 | Tap on: transfer from same mode (intra-modal) |
| 3 | Tap on: transfer from different mode (inter-modal) |
| 4 | Tap on: Manly-CQ ferry: new journey |
| 5 | Tap on: Manly-CQ ferry: transfer from another ferry (intra-modal) |
| 6 | Tap on: Manly-CQ ferry: transfer from bus / train (inter-modal) |
| 7 | Tap off: distance based fare |
| 8 | Tap off: flat-rate fare |
| 9 | Tap off: automatically completed journey (failure to tap off) |
| 10 | Tap off: end of trip without start (failure to tap on) |
| 11 | Tap off: tap on reversal |
| 12 | Unsuccessful tap |
| 13 | (reserved) |
| 14 | (reserved) |
Intra-modal Ferry transfers can only occur at Circular Quay.