Using mergAccessory

mergAccessory is an iOS external for connecting to and communicating with accessory hardware using the External Accessory framework.

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 5.5.app/Contents/Tools/Runtime/iOS/Device-5_1/Settings.plist`.

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

<key>UISupportedExternalAccessoryProtocols</key>

<array>

  <string>com.bluebamboo.p25i</string>

</array>

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

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"

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"

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

E-Mail me when someone replies to this comment