tizen - provider , android - consumer
I am devloping tizen gear s2 - android app.
And I referenced hello accessory SAP example.
customized my app.
And... I have mistake something.
So occured error "requestSAAgentError Error name : ServiceNotAvailableError Error message : Failed to register SAAgent. " when gear s2 app excute.
I can't find what problem is it, why occured.
if you need additional information, i will add comment quickly.
help me . . . ㅠㅠ
[config.xml]
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/PYPI" version="1.0.0" viewmodes="fullscreen">
<tizen:application id="IsVHKnrRlE.PYPI" package="IsVHKnrRlE" required_version="2.3.1"/>
<content src="index.html"/>
<feature name="http://tizen.org/feature/screen.size.normal"/>
<icon src="icon.png"/>
<tizen:metadata key="accessory-service-location" value="/res/xml/accessoryservices.xml"/>
<name>PYPI</name>
<tizen:privilege name="http://developer.samsung.com/tizen/privilege/accessoryprotocol"/>
<tizen:privilege name="http://tizen.org/privilege/application.launch"/>
<tizen:profile name="wearable"/>
<tizen:setting background-support="enable" encryption="disable" hwkey-event="enable"/>
</widget>
[accessoryservices.xml]
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<application name="PYPI" >
<serviceProfile
id="/system/pypi"
name="pypi"
autoLaunchAppId="IsVHKnrRlE.PYPI"
role="provider"
version="1.0"
serviceLimit="ANY"
serviceTimeout="10">
<supportedTransports>
<transport type="TRANSPORT_BT" />
<transport type="TRANSPORT_WIFI"/>
</supportedTransports>
<serviceChannel
id="104"
dataRate="high"
priority="low"
reliability= "enable"/>
</serviceProfile>
</application>
</resources>
[app.js]
( function () {
window.addEventListener( 'tizenhwkey', function( ev ) {
if( ev.keyName === "back" ) {
var page = document.getElementsByClassName( 'ui-page-active' )[0],
pageid = page ? page.id : "";
if( pageid === "main" ) {
try {
tizen.application.getCurrentApplication().exit();
} catch (ignore) {
}
} else {
window.history.back();
}
}
} );
} () );
var SAAgent,
SASocket,
connectionListener,
responseTxt = document.getElementById("responseTxt");
function createHTML(log_string)
{
var content = document.getElementById("toast-content");
content.innerHTML = log_string;
tau.openPopup("#toast");
}
connectionListener = {
/* Remote peer agent (Consumer) requests a service (Provider) connection */
onrequest: function (peerAgent) {
createHTML("peerAgent: peerAgent.appName<br />" +
"is requsting Service conncetion...");
/* Check connecting peer by appName*/
if (peerAgent.appName === "PYPI") {
SAAgent.acceptServiceConnectionRequest(peerAgent);
createHTML("Service connection request accepted.");
} else {
SAAgent.rejectServiceConnectionRequest(peerAgent);
createHTML("Service connection request rejected.");
}
},
/* Connection between Provider and Consumer is established */
onconnect: function (socket) {
var onConnectionLost,
dataOnReceive;
createHTML("Service connection established");
/* Obtaining socket */
SASocket = socket;
onConnectionLost = function onConnectionLost (reason) {
createHTML("Service Connection disconnected due to following reason:<br />" + reason);
};
/* Inform when connection would get lost */
SASocket.setSocketStatusListener(onConnectionLost);
dataOnReceive = function dataOnReceive (channelId, data) {
var newData;
if (!SAAgent.channelIds[0]) {
createHTML("Something goes wrong...NO CHANNEL ID!");
return;
}
newData = data + " :: " + new Date();
/* Send new data to Consumer */
SASocket.sendData(SAAgent.channelIds[0], newData);
createHTML("Send massage:<br />" +
newData);
};
/* Set listener for incoming data from Consumer */
SASocket.setDataReceiveListener(dataOnReceive);
},
onerror: function (errorCode) {
createHTML("Service connection error<br />errorCode: " + errorCode);
}
};
function requestOnSuccess (agents) {
var i = 0;
for (i; i < agents.length; i += 1) {
if (agents[i].role === "PROVIDER") {
createHTML("Service Provider found!<br />" +
"Name: " + agents[i].name);
SAAgent = agents[i];
break;
}
}
/* Set listener for upcoming connection from Consumer */
SAAgent.setServiceConnectionListener(connectionListener);
};
function requestOnError (e) {
createHTML("requestSAAgent Error" +
"Error name : " + e.name + "<br />" +
"Error message : " + e.message);
};
/* Requests the SAAgent specified in the Accessory Service Profile */
webapis.sa.requestSAAgent(requestOnSuccess, requestOnError);
(function(tau) {
var toastPopup = document.getElementById('toast');
toastPopup.addEventListener('popupshow', function(ev){
setTimeout(function () {
tau.closePopup();
}, 3000);
}, false);
})(window.tau);