Languages

Menu
Sites
Language
SAP Accessory protocol: connecting Smartphone to Gear S2 and beacon simultaneously

Hello,

I have Samsung Galaxy S4 mini, with Android version 4.4.

I can connect without problems this Android phone to a beacon, and receive beacon events. It works.

I can connect without problems the Samsung Gear S2 to Smartphone and send/receive events, using SAP Accesory Protocol (SAP). It works.

In both cases, the communication works good separately.

When I establish simultaneous communications (smartphone-beacon and smartphone-gear s2 at same time), it works during a few seconds, and then I receive lost connection between smartphone and smartwatch.  I receive on Smartwatch Consumer Service error 513 (CONNECTION PEER DISCONNECTED).

Then, it is possible establish simultaneous connections using protocol bluetooth low energy? Is possible to connect Smartphone and Gear S2 through transport protocol TRANSPORT_WIFI? Do you have any sample working with TRANSPORT_WIFI? (If simultaneous connections are not possible, i can use wifi, but I don't need wifi from smartwatch, i need wifi to send messages from smartphone to smartwatch).

Thank you,

Joaquim Puyo

 

public class ServiceConnection extends SASocket {
    public ServiceConnection() {
        super(ServiceConnection.class.getName());
    }

    @Override
    public void onError(int channelId, String errorMessage, int errorCode) {
    }

    @Override
    public void onReceive(int channelId, byte[] data) {
        final String message = new String(data);
        addMessage("Received: ", message);
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                smartwatchPresenter.onMessageReceived(message);
            }
        });
    }

    @Override
    protected void onServiceConnectionLost(int reason) {
        closeConnection();
        smartwatchPresenter.onServiceConnectionLost();
        smartwatchSessionHandler.onServiceDisconnected();
        updateTextView("Disconnected");
    }
}

The accesory services.xml:

<resources>

    <application name="myproject">
        <serviceProfile
            name="myproject"
            id="myproject"
            role="consumer"
            serviceImpl="com.worldline.myproject.app.smartwatch.SmartwatchConsumerService"
            serviceLimit="ANY"
            serviceTimeout="10"
            version="1.0">
            <supportedTransports>
                <transport type="TRANSPORT_BT" />
                <transport type="TRANSPORT_WIFI" />
            </supportedTransports>
            <serviceChannel
                dataRate="low"
                id="104"
                priority="low"
                reliability="enable" />
        </serviceProfile>
    </application>

</resources>

Responses

3 Replies
Iqbal Hossain

Hi,

 

Have you tried the following privileges?

<SupportedTransports>
    <Transport type="TRANSPORT_BT" />
    <Transport type="TRANSPORT_BLE" />
    <Transport type="TRANSPORT_WIFI" />
</SupportedTransports>

The Accessory SDK maintains a unique connection for every transport and every device with which your application is connected. It is your application’s responsibility to maintain a list of these connections if you want your application to work in multi-connectivity and multi-device scenarios.

You can also see sample app for multiple consumers (gear)

Web: http://developer.samsung.com/sample-app/view.do?v=S000000085D

Native: http://developer.samsung.com/sample-app/view.do?v=S000000090D

This sample application shows how to communicate a provider application with multiple consumer applications using Accessory SDK as one of possible multiplicity combinations.

If you find my post helpful for you, please mark it as the Best Answer to promote this post to others.

 
Joaquim Puyo Garrido

Thank you Iqbal, 

but I don't want to connect multiple consumers using Samsung Accesory Protocol.

I only want to use Samsung Accesory Protocol to connect with Smartwatch.

To establish the connection with beacon, I can't use SAP.

Anyway, I'm going to try with the option TRANSPORT_BLE, because option TRANSPORT_WIFI does not work by the moment.

¿Do you know if is possible use TRANSPORT_WIFI?

Thank you, I appreciate any help.

Iqbal Hossain

At first please try with TRANSPORT_BLE.