© 2014 Samsung Electronics Co., Ltd. All rightsreserved.
The accessory service profile information is provided in an XML file, such as /res/xml/<profile_name>.xml. You must declare the profile XML file path in the config.xml file of your Web application project:
<webapis:metadata key="AccessoryServicesLocation" value="res/xml/serviceprofile.xml"/>
The following example illustrates the content of the profile XML file, which specifies the accessory service profile details. For more information, see SAAgent API Reference.
<resources> <application name = "my application"> <serviceProfile role = "provider" name = "smartview" id = "/system/gallery" version = "2.0" serviceLimit = "ONE_PEERAGENT" serviceTimeout = "30"> <supportedTransports> <transport type = "TRANSPORT_BT"/> <transport type = "TRANSPORT_WIFI"/> </supportedTransports> <serviceChannel id = "100" dataRate = "high" priority = "low" reliability = "enable"/> </serviceProfile> <serviceProfile role = "provider" name = "message_service_provider" id = "/system/messages" version = "2.0" autoLaunchAppId = "VcGvmQlo1i.HelloAccessory" serviceLimit = "ANY"> <supportedTransports> <transport type = "TRANSPORT_BT"/> <transport type = "TRANSPORT_WIFI"/> </supportedTransports> <serviceChannel id = "902" dataRate = "low" priority = "low" reliability = "disable"/> </serviceProfile> </application> </resources>
The following attributes and elements are used in the profile XML file:
You can implement multiple service providers and consumers in 1 application. In that case, just declare multiple <serviceProfile> elements inside the <application> element.
If a peer agent requests a service connection to a service profile which is not running, the system launches this application. If the value is not specified, the system never launches the application even if the peer agent requests a service connection.
If a peer agent requests a connection with your application after you have reached the limit, the Samsung Accessory framework rejects the connection request. The value can be:
The application can decide immediately whether to accept or reject an incoming connection request. Or the decision can take longer, for example, if you need to connect to a cloud server, ask for user permission, or ask for authentication. If the application takes a long time to make the decision, set this value accordingly. If the application exceeds the timeout, the requesting peer agent gets the response stating that the connection failed because your application gave no response.
If the service provider or consumer supports multiple transport types, declare multiple <transport> elements.
This attribute defines whether you want a reliable transfer. In case of a packet drop, a reliable transfer re-transmits the packet (but also creates additional overhead).
The following example illustrates the document type definition for the profile XML file.
<!DOCTYPE resources [ <!ELEMENT resources (application)> <!ELEMENT application (serviceProfile)+> <!ELEMENT serviceProfile (supportedTransports, serviceChannel+) > <!ELEMENT supportedTransports (transport)+> <!ELEMENT transport EMPTY> <!ELEMENT serviceChannel EMPTY> <!ATTLIST application name CDATA #REQUIRED> <!ATTLIST serviceProfile role (PROVIDER | CONSUMER | provider | consumer) #REQUIRED> <!ATTLIST serviceProfile name CDATA #REQUIRED> <!ATTLIST serviceProfile id CDATA #REQUIRED> <!ATTLIST serviceProfile version CDATA #REQUIRED> <!ATTLIST serviceProfile autoLaunchAppId CDATA #IMPLIED> <!ATTLIST serviceProfile serviceLimit (ANY | ONE_ACCESSORY | ONE_PEERAGENT | any | one_accessory | one_peeragent) #IMPLIED> <!ATTLIST serviceProfile serviceTimeout CDATA #IMPLIED> <!ATTLIST transport type (TRANSPORT_WIFI | TRANSPORT_BT | TRANSPORT_BLE | TRANSPORT_USB | transport_wifi | transport_bt | transport_ble | transport_usb) #REQUIRED> <!ATTLIST serviceChannel id CDATA #REQUIRED> <!ATTLIST serviceChannel dataRate (LOW | HIGH | low | high) #REQUIRED> <!ATTLIST serviceChannel priority (LOW | MEDIUM | HIGH | low | medium | high) #REQUIRED> <!ATTLIST serviceChannel reliability (ENABLE | DISABLE | enable | disable) #REQUIRED> ]>