Using mergAccessory

mergAccessory is an iOS external for connecting to and communicating with accessory hardware using the External Accessory framework.  It is available in LiveCode Business(versions up to 9.6.3) or as part of the Addon Pro Pack(version 9.6.4).

Each device in the MFi program has a name and one or more protocols it supports. For your app to see the device it needs to state what protocols it supports. To do this you need to edit the plist file which is found at `/Applications/<LiveCode Bundle>/Contents/Tools/Runtime/iOS/Device-5_1/Settings.plist`.

Add the protocols your application supports under the `UISupportedExternalAccessoryProtocols` key.

Your application will also need to be registered with the manufacturer and Apple.

<key>UISupportedExternalAccessoryProtocols</key>
<array>
   <string>com.bluebamboo.p25i</string>
</array
Click to copy

Getting the list of Accessory Names

Start by getting a list of the names of any devices connected to the device with supported protocols.

put mergAccessoryNames() into btn "device names"
Click to copy

Select an accessory. Then get the list of protocols that both the accessory and your app support.

put mergAccessoryProtocols(the label of btn "device names") into btn "protocols"
Click to copy

Opening a Session

To open a session using the selected accessory and protocol call the mergAccessoryOpenSession pNameAndProtocol, pCallbackHandler command.

This command sends the specified callback message when the session is open.

Writing To and Reading From an Accessory

To write data to an active session use the mergAccessoryWrite command.

To request a read of data on an active session use the mergAccessoryRead command.

Closing a Session

To close a session call the mergAccessoryCloseSession command.

Further Documentation

The full documentation for the mergAccessory library can be found in the LiveCode Dictionary. Select mergAccessory in the associations list to see all the mergAccessory commands, functions, properties and messages.

Dictionary

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.