androidcommunicationsamsung-mobiletizenaccessory

Accessory SAP communication Tizen and Android PeerAgent_No_Response


Currently i am creating a safety application for the samsung smartwatch. I want users to be able to register on their smartphone and send these data to the smartwatch app. I followed the samsung tutorial for Accessory SAP communication. Everything works till i get the PEERAGENT_NO_RESPONSE error, the first parts work fine, it tries to connect without any problems.

The method i call on tizen is this:

SAAgent.setServiceConnectionListener(agentCallback);

var agentCallback = {
        onconnect: function(socket){
            alert("agentCallback connect" + socket);
            SASocket = socket;
            alert("connected");
            SASocket.setSocketStatusListener(function(reason){
                console.log("Service Connection lost, Reason: ["+ reason+"]");
                disconnect();
            })
        },
        onerror: function(error){
            alert("agentCallBack"+error);
        }
};

When i call SAAgent.setServiceConnectionListener(agentCallback), the android code below here is triggered. But this always returns PEERAGENT_NO_RESPONSE error.

@Override
protected void onServiceConnectionRequested(SAPeerAgent peerAgent){ 
//Toast.makeText(getBaseContext(), "TESTG", Toast.LENGTH_SHORT).show();
 super.acceptServiceConnectionRequest(peerAgent)
}

I was wondering what i am doing wrong.


Solution

  • After debugging and some help i finally fixed the problem:

    This had to be Public instead of protected on android side. Which caused the runtime to crash and not send any data to the tizen wearable.

    public SAPServiceProviderConnection() {
        super(SAPServiceProviderConnection.class.getName());
    }
    

    I also changed supportedTransports on both android and tizen side to: (i had BT on android side and WIFI/BT on tizin side.)

    <transport type="TRANSPORT_BT"/>
    <transport type="TRANSPORT_WIFI"/>
    

    Servicechannel, data to high:

     <serviceChannel
        id="104"
        dataRate="high"
        priority="low"
        reliability="enable"/>