Use the Samsung Accessory Protocol (SAP) API

To use the SAP API, change some configurations in your application project:

1. Enable the samsung-sap framework.

Go to Project properties > C/C++ Build > Tizen Settings. In the Framework It should be select samsung-sap

samsung-sap

2. Add the Accessory Service Profile.

Communicating with an Android application requires a declaration of descriptions about the Accessory Service Profile. The profile is declared in a separate XML file in the /res/xml folder of the application project. The actual path of the XML file can be described with ‘meta data’ in the tizen-manifest.xml file.

A. Add the accesoryservice.xml file in the /res/xml folder.

  • For an example file, see the following sample Accessory Service Profile. You can modify the id value of the serviceProfile element to define your application. The id value must be unique globally and it is also used in the Android side application to identify the service profile.

    Note

    The service profile ID must start with ‘/’, followed by [0-9], [a-z], ‘_’, and ‘/’ (as delimiter). The maximum length is 30 characters. For more information about the XML file, see this.

<resources>
	<application name="MyApplication">
		<serviceProfile id="/org/example/myapp/my_message" name="MyMessage"
		                role="consumer"  version="1.0">
			<supportedTransports>
				<transport type="TRANSPORT_BT"/>
				<transport type="TRANSPORT_WIFI"/>
			</supportedTransports>
			<serviceChannel id="110" dataRate="low" priority="low"
			                reliability="enable">
			</serviceChannel>
		</serviceProfile>
	</application>
</resources>

B. Add meta data to define the Accessory Service Profile XML file location.

  • Open the tizen-manifest.xml file in the Tizen manifest editor, and select the Advanced tab.

    certificate_guide
  • In the Meta Data section, click Add, define the key as accessory-services-location and the value as /res/xml/accessoryservices.xml, and click OK.

    certificate_guide

3. Add the required privilege.

To use the SAP API, the http://developer.samsung.com/tizen/privilege/accessoryprotocol privilege must be added in the tizen-manifest.xml file.

  • Open the tizen-manifest.xml file in the Tizen manifest editor, select the Privilege tab, and click Add.

    certificate_guide
  • Add the privilege and click OK.

    certificate_guide