NFC SNEP Push Fragmentation - ACR122U to Android ICS P2P - nfc

How is it done? The documentation is unclear and there are no examples.
What I do is the following..
I chop off the data into small fragments and then I send the fragments sequentially. The SNEP header is only included once in the first fragment. Do I need to change something in my SNEP header or LLCP? I don't understand how LLCP should be changed to make android understand the sequence of the messages? After the whole message is sent, android does not acknowledge receiving the message.
Examples would be much appreciated.
C# Desktop application trying to send data through NFC Peer-to-Peer to an android ICS running on an SIII. The contact-less smart card reader is an ACS ACR-122U/T

SNEP Fragmentation needs to be implemented. LLCP Sequences numbers need to be taken care of and finally, I think there should be some acknowledgement messages in between fragments which is where I'm going wrong.

You need to implement SNEP fragmentation and encapsulate the fragments in LLCP frames. Read about the LLCP protocol in the NFC forum.

Yes, is exactly like you describe.
They change between them consecutive chunks like is specified in the SNEP protocol
Check this classes, i've tested them and works fine in 4.0.4 (not working on => 4.1)

Related

Is it possible to translate Javacard code to NFC?

I was wondering if it is possible to code on a NFC whatever we would code with Javacard ? I have a project where a smart card contains a biometric id to be scaned and and we want to do it wirelessly with a NFC. Do you think that is possible ? What are the boundaries of NFC ? Is it possible to do whatever we do with Javacard on NFC ? Sorry I have a lot of questions I'm not very familiar with the topic.
Yes it is possible for some Javacard's to be interacted with via NFC.
See https://github.com/OpenJavaCard/openjavacard-ndef as an example.
The answer is yes - many contactless and dual-interface cards are in fact running JavaCard applications. When you go to the higher protocol layers, the commands (APDUs) exchanged using NFC are basically the sames as using the contact interface.
In essence, NFC is a communication channel, while Javacard describes a programming framework (requiring a processor card with a certain processing power). Of course those two can be combined.
NFC is also used as term for rather dumb tags, which may provide some hardwired cryptography (as DESFire does) but not much beyond that except data storage space. There is no way, on which such a tag can process even the most basic "hello world" applet, and mastering the same communication technology does not not help much in that respect. Computing a digital signature can be considered as litmus test, what you really have.

Sending data, using HCE, or using secure element? (Android, Kotlin, Mifare 1k)

I'm trying to implement the functionality for emulating a Mifare One (1K/S50, ISO14443A) chip to be able to use a phone with NFC capability instead of a physical Mifare card or, if possible sending only the data to the reader.
I have this type of reader/writer: https://www.evelta.com/er302-high-frequency-nfc-writer-usb/
After looking around on forums, stackoverflow questions I found this article to be the best example:
https://medium.com/the-almanac/how-to-build-a-simple-smart-card-emulator-reader-for-android-7975fae4040f
I implemented the HCE part, run the program, and the reader beleives my phone is a Mifare chip, so far so good.
My problems:
No matter what "standard" Authentication key I tried to use...it gives me Auth error. I read this question about Auth: Authentication failure for Mifare 1K NFC tag using ACR122U NFC reader, it works on a physical Mifare card...but I don't know how to set or get to know the keys for the emulated one.
I don't get why this example emulates that exact Mifare chip type...even breakpoints don't work in the APDUService, but the reader detecting a Mifare cheap somehow.
After reading about it, I get I can't 100% emulate a physical card, so I have to send all the data I want in my APDU response with the service somehow (I beleive it's the transreceive part).
However I can't even authenticate.
I tried to look for other possible solutions:
AndroidBeam: Android - Android p2p...sounds simple, relatively high-level API, but it's being deprecated, moreover it's not guaranted that the reader will even use Android...it might be a 'simple' USB reader hardware like the one I use.
SecureElement: Ironically...it seems to be the most recommended, I read that 'yes, it's possible for mifare' and things like that, yet I couldn't find a good example of it and the official Google docs don't have any good example. I read that it's for "ISO/IEC 7816-4", but Mifare 1K is ISO14443A, so I'm a bit sceptic about this API.
"Simply" sending the data to the reader: If I could just simply "push" the data out to the reader when it's reading the phone without complicating the matter or emulating anything...it would be great but I don't know if it's even possible. This whole NFC topic seems to be more and more complex.
So alltogether I only need to do one thing: taking the data and send it to the reader.
I realized it's a fairy tale like illusion to beleive it's as simple as it sounds, still, I hope there is a way to do it.
If I could send the data in it's own, without emulating Mifare or anything...after all what matters is that the data on the card, not the type of the chip, the more simple the solution will be, the better.
Sorry for possible English grammar mistakes.
The problem is you cannot use HCE on Android to emulate a Mifare Classic 1K (https://www.nxp.com/docs/en/data-sheet/MF1S50YYX_V1.pdf) as this is a custom Type NFC card. As HCE is about emulating Type 4 cards. See https://developer.android.com/guide/topics/connectivity/nfc/hce#SupportedProtocols
And the below image helps understand the type.
You can see this from it's datasheet, nowhere does it talk about AID's and standard Type 4 NFC commands
Though Type 2 and Type 4 can share the Anti Collision mechanism and Reading the UID (which is part of the process) any other access methods are not shared.
Type 4 Spec for reference is at http://apps4android.org/nfc-specifications/NFCForum-TS-Type-4-Tag_2.0.pdf
I have seen some USB readers that offer on reader emulation of other card types but not HCE where the host does the emulation not the NFC hardware.
The Authentication on Type 4 Cards or emulated ones is handled differently.
You can emulate a MIFARE DESFire Card as that is a Type 4 card.
The specs of your card reader are not documented well and it looks very "lite" and that it does not support any of the higher level protocols needed to talk to non Mifare Classic cards. It could support them but as Mifare protocol was the original spec, it could be possible for it to be and old design and only support the Mifare protocol.

Add protocol to gammu

By default gammu have support for most standard modem. I have a very particular modem with some special requirements and I would like to add a protocol to gammu.
Is there a guide for this somewhere or someone who can list the basic steps for me?
EDIT: #user1664784 recommended to look att Kannel, and actually any system able to handle incoming and outgoing SMS is acceptable as long as it is stable. But I need to know how to modify the system so that I can handle a specific protocol. It is AT-based but a slight dialect. So any suggestion of a system handling SMS from a device connected over serial port is interesting. I need to find a system where someone can give me information on where in the source code I can begin adding a new AT-based protocol.
If someone have done some sample code in this area it would also be greatly appreciated.
It really depends how much different it is from standard AT commands.
If the difference is minor (eg. needs custom initialization), it can be easily achieved by feature flags. This can be seein ATGEN_PostConnect which handles initialization for ZTE or Huawei devices.
If the differences are big, you will probably need to write own driver, which will fall back to AT in some cases. Something similar can be seen in the AT OBEX driver which switches Bluetooth connection between OBEX and IrMC modes.
I think we used to have documentation on adding support for new devices, but I'm unable to find it right now.

Does Android SNEP server support fragmentation?

Does anyone here have experience sending fragmented SNEP message to android?
I tried sending large SNEP message to android using SNEP fragmentation as defined in NFC forum specs (shown on figure 3 and figure 6 in SNEP spec document).
After sending first fragment (complete SNEP header + data chunk), android replies with Continue response. As defined in SNEP spec, i send remaining data (without header) to android. After all data sent android never gives Complete response. Is it because my wrong sending sequence or android just doesn't support SNEP fragmentation?
I use Google Nexus S with android 4.1.2 and reader from chinese manufacturer with proprietary SDK.
Android SNEP does support fragmentation. I use this all the time when I send out 20kb test messages via SNEP. The problem must be in your implementation.
I suggest that you take a look at the SNEP Android code to find out why you don't receive the confirmation. The code is here:
https://android.googlesource.com/platform/packages/apps/Nfc/+/ics-plus-aosp/src/com/android/nfc/snep/

What is the best way to handle incoming SMS messages?

I have a client who wants a solution to allow delivery people to text (SMS messaging) in that they have completed a pick up at a particular location. What I'm looking for is Code to read an imbound SMS message or a SMS component if appropiate. This would allow me to create a windows service to read the message and update a SQL record accordingly.
Probably not quite what you're looking for but one approach is to use a gateway like iTagg which provides a number of interfaces for developers to send and receive SMS/MMS etc. Depending on your location, iTagg may be no use but I'm sure there'll be an equivalent for your region.
Sometime ago I implemented something similar using a GSM modem. I think most of the GSM modems offer AT commands that can be used for receiving and sending SMS messages. At the time, I used a library in Java that provided a easy to use API. The commands to read and send SMS are really easy but I bet there is something in .Net for that purpose that can make the task even easier.
I made a little search and I found this article with an example of using AT commands to interact with a GSM phone. I looked into the supplied source and it includes a library with operations related to SMS.
In my previous project I used a Siemens GSM modem with a RS232 interface. It wasn't very expensive and was able to manage all the messages sent by onboard units placed in vehicles. But if you have a unused phone it can work as well.
Thanks Luke, I am thinking more of a GSM modem which would be connected to the server. I think this would give more control rather than go through a third party, but I take your point and will investigate further.

Resources