How to grab magnetic swipe data using the headphone jack on Android?

If someone wants to write an Android app that interacts with a physical device, specifically a reader using a mobile audio jack (like how Square Inc works), how is it done? Is there an api to interact with the reader and get the card data?

When a company creates a reader (physical device) does it provide the appropriate apis?

Are physical details abstract from the application programmer?

I found an AudioRecord class that can write magnetic stripe data from the audio jack But I can't figure out how to capture the actual event to swipe the card and get meaningful data from the RAW DATA Can anyone help me with this

Any input is appreciated!

+3


source to share


1 answer


As usual it works, encoding the data signal sent by the device, like the card reader, in a way that can be decoded at the other end. Sound is a wave, and different amplitudes correspond to different volumes, and different frequencies correspond to different levels. Imagine that you have a sine wave that oscillates between high and low frequencies that are different enough from each other that they can be easily distinguished. The device sending binary data (0 and 1) can translate this data into an audio signal that varies in frequency (the alternative is variable amplitude). The receiver, in this case a mobile device, decodes the signal back to 0 and 1. This is called "Frequency-shift-keying" (more details here:http://en.wikipedia.org/wiki/Frequency-shift_keying ).

The easiest way to do this is to try and find an open source library that already does this. The device sending the data must also contain some kind of microcontroller that can do the initial modulation. If you come across any good libraries, let me know, because I am now watching.

To answer your question, companies usually do not provide APIs etc. to accomplish this.

It may seem like a lot of extra work to convert a digital signal to an audio signal and vice versa, and you're right. However, every mobile device has essentially one headphone jack, whereas the USB port on Android is very different from the iPhone backlight connector or the connector on previous iPhones. Sending a wireless network over a network or Bluetooth is also an option, but they also have their drawbacks.



Now the mobile device must use a dedicated headphone jack that supports microphones, otherwise it cannot receive input, it can only output audio. Most smartphones can do this.

Radios operate according to this principle (FM = frequency modulation, AM = amplitude modulation). Older modem modems used FSK, so you heard these strange noises every time you plugged in.

Hope it helps!

+4


source







All Articles