Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get input of switch control via headphone jack on iOS

As a little holiday project I want to control an app via an accessibility switch which is connected via 3,5mm headphone jack to the iOS device.

This is the switch and the plug:enter image description here

My problem is that I don't have any clue what kind of signal is fired when I press the button - I assumed that it acts similar to a headphone's remote control.

Is there a way to measure the input of this or does anybody know how to get the input of the button on iOS?

like image 720
arnoapp Avatar asked Dec 21 '18 00:12

arnoapp


People also ask

How do I get to the switch control menu on my iPhone?

Turn Switch Control on or offGo to Settings > Accessibility > Switch Control. Triple-click the side button (on an iPhone with Face ID). Triple-click the Home button (on an iPhone with a Home button). Use Control Center.


1 Answers

Your button is a "Big Buddy Button Switch," designed by AbleNet for persons with moderate to severe upper extremity and motor disabilities. It is not designed to plug into an IOS device nor into any mobile tablet or phone.

There is an "Hook + Switch" interface ($185 at this moment) that is designed to go between this button and an IOS device, allowing connection of two such buttons to the lightning connector. When connected in this way, the button press can be detected and mapped to many different kinds of IOS actions using apple accessibility settings. That's a lot of money, but since new iphones don't even have audio jacks it may end up being worth it.

A link to your button is here.

A link to the Hook+ Switch Interface is here.

A link to Apple information on accessibility switches is here.

The Big Buddy Button is a passive momentary action switch. The mono TS plug attached is connected internally to the momentary action normally open switch, so pressing the switch will short TIP to SLEEVE.

Plugging this TS plug into an ios device designed to receive a TRRS plug will short RING1 and RING2 and SLEEVE together even when the button is not pressed, which will not accomplish anything useful. Pressing the button will further short TIP to RING1 and RING2 and SLEEVE. There is no way to read such a button press from ios internals if the TS plug is plugged in directly.

If you want to hack together a solution that will work for many mobile devices (e.g., android) you can do so simply by replacing the TS plug with a TRRS plug (or wiring up an adaptor) as follows:

One of the two Big Button conductors should be connected to the SLEEVE, which carries power (for a microphone) and is the source of the voltage that is sensed internally for volume changes and switching. The other Big Button conductor should be connected to RING2, which is the ground line for both earbud channels and the microphone. Nothing should be connected to TIP or RING1.

Pressing the Big Button will momentarily short Sleeve to Ring2, which is the same as pressing the switch on an earbud cable. If you wanted to simulate a volume up or volume down command, you would connect a resistor in series with the button (220 ohms for volume down, 600 ohms for volume up).

The electrical connections for the audio jack are the same for iOS devices as for Android, but there's an extra hurdle you must get over if you want to connect up buttons and have them be detected within iOS. As part of their MFI (Made for iPod/iPhone) program, Apple uses a startup recognition chirp sequence when anything is plugged into the audio jack (or the lightning connector). Your device must have the correct chip inside it (or emulate the behavior of that chip) or else the button controls interface will be disabled when you fail to respond to the authentication request. The protocol seems to have changed over time, because aftermarket products that worked with one model of phone did not always work with another. Apple insiders have stated that the MFI chips contain a serial number that Apple can read upon connection. They say that reverse-engineered authentication works today, but that Apple could prevent it from working at any time.

If you want to design this as a product, you can apply for the MFI program here.

If you just want to build a handful of devices, you won't be able to get accepted into the MFI program. In that case you'd need to purchase the Hook + Switch interface (or something like it) or else you'd need to add a small microprocessor like an Arduino or a Teensy to emulate the authentication chirp, as David Carne did here.

If you just want to build one working button, the easiest way would be to use an existing pair of headphones that contain the necessary chip, and simply put your button wires in parallel with SLEEVE and RING2. If I were doing this I'd get a TRRS extension cord and splice the Big Buddy Button wires to the correct two wires of the extension cord. Your Big Button should work so long as a pair of apple-certified headphones are plugged into the extension to provide the authentication. You would then detect the button press as usual (described here).

EDIT: I tested connecting an accessory button to SLEEVE and RING2 of a TRRS extension cable that's plugged into the iPhone, and as long as a functioning headset is plugged into the extension cable, the accessory button does work. This way the accessory button ends up in parallel to the built-in button, without having to cut apart the headset.

There are other alternatives you could pursue. For example, you could build a circuit that transmits a mic-level tone across the two conductors whenever the button is pressed. You'd then plug that signal into the iOS device between SLEEVE and RING2, and then write an iOS program to listen for the sound and treat it as a button press. MFI authentication would not be needed for this approach, and there are existing utilities that would get you 90% of the way there. You can find an example here.

It's also possible to connect to iOS through BLE without signing up for MFI, and since Apple Accessibility includes the ability to use a bluetooth device to control certain iOS functions, you may be able to do this without needing authentication.

An image showing the connection schematic for TRRS connectors on most mobile devices (including iPhone) is here.

Reproduced here for convenience.

  • Function/Mic == SLEEVE
  • Common/Gnd == RING2
  • Right/R+ == RING1
  • Left/L+ == TIP

enter image description here

like image 173
Craig.Feied Avatar answered Oct 01 '22 06:10

Craig.Feied