codebutler / farebot

Read data from public transit cards using your NFC Android phone!
http://codebutler.github.com/farebot
GNU General Public License v3.0
966 stars 271 forks source link

CEPAS 2.0 card 'Invalid Response' #149

Closed Vantablack closed 7 years ago

Vantablack commented 7 years ago

Issue

Hi I'm having an issue when attempting to scan a CEPAS 2.0 card and I'm getting Invalid Response

device-2017-08-23-235523

Error 1

After some digging, I got an error log which is full log here

E/com.codebutler.farebot.app.feature.main.MainActivity: Invalid response java.lang.Exception: Invalid response at com.codebutler.farebot.card.desfire.DesfireProtocol.sendRequest(DesfireProtocol.java:141)

From here I deduced that DesfireTagReader is called instead of CEPASTagReader. So I swapped the order in TagReaderFactory.kt

Error 2

Error 1 was fixed but another was created (Error 2), full log here

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.codebutler.farebot, PID: 27383 io.reactivex.exceptions.OnErrorNotImplementedException: Invalid index 3, size is 0

And this was caused by the ArrayList having a size() of 0 and so I tried using Arrays [] instead by following what was done in v0.5

code_ss

Error 3

Error 2 was fixed but Error 3 was created, full log here

It was due to invalid purses having null values for getCAN, getCSN, getLastCreditTransactionHeader, getLastTransactionRecord and getIssuerSpecificData in CEPASPurse.java, and adding @Nullable seems to solve the issue.

Similar to this merge request, its seems like data is stored in purse 3 (I've tested 3 recent cards).

Possible Fix

I'm not sure if I should open a merge request but here's my current fixes.

https://github.com/Vantablack/farebot/commit/a0c1f97f433c2d363203936b1384c31c12b0be06

device-2017-08-23-235150

DexterKwok commented 7 years ago

yup, I am having trouble scanning my Nets Card, "Invalid Response"

codebutler commented 7 years ago

Please do open a pull request, thank you!

Vantablack commented 7 years ago

Oh hey @codebutler! Thanks for closing this issue!

themakerman commented 7 years ago

@Vantablack Are you able to read the card now after the fix?

Vantablack commented 7 years ago

@themakerman I currently do not have access to an Android device so can’t check for you. However it did work after I applied some changes see (https://github.com/Vantablack/farebot/commit/a0c1f97f433c2d363203936b1384c31c12b0be06) which I believe was committed in https://github.com/codebutler/farebot/commit/d3637bdff63201c2c65d13167c2cd7532f330651

themakerman commented 7 years ago

@Vantablack it did worked. It's not updated in the production though on playstore.

themakerman commented 7 years ago

@Vantablack Do you think since IOS 11 NFC has came up we can use the same cepas protocol for iOS users across island? I think majority people use iPhone in SG. Have you made any research on iOS capabilities to read SG transit cards?

Vantablack commented 7 years ago

@themakerman I don’t think iOS 11 Core NFC supports sending custom APDU. From the documentation, I think it only supports reading NDEF formatted tags only?

See iOS11 Core NFC and ISO 14443