Daniel
Daniel

Reputation: 2592

SAP: interrupt/parallelization of sending of large data

I'm using SAP: Watch as consumer, Phone as provider.

Usually communication in between them is perfect, but I have a bottleneck now: If I send a large data from phone to watch (with SASocket.secureSend), I can't interrupt it.

Consider this:

I'm sending a big transaction from phone to watch, and in the middle, I want to send a message back to phone from the watch: this is working, so watch's message reaches my phone during this other huge transaction. Ie.: SAP seems to handle duplex communication

Problem:

My phone can't reply to this watch message, it needs to wait first until the huge transfer finishes. I tried using different channels (one channel for commands, one channel for big data), but still big data has to finish sending first before command sending can take place (doesn't matter it goes on different channel).

Can I somehow interrupt big data sending/start a parallel sending of the command?

Sending currently spawns a thread as it was recommended:

new Thread(new Runnable() {
    public void run() {
        Log.d(LOG_TAG, "run: SEND START!");
        try {
            mSASocket.secureSend(getServiceChannelId(0), data.getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
        Log.d(LOG_TAG, "run: SEND END!");
    }
}).start();

I've tried interrupting this thread, but it didn't stopped the huge transaction, so it didn't help.

How can I either interrupt the huge transaction, or send another message parallel (with higher priority) to the watch?

Upvotes: 0

Views: 70

Answers (1)

Nightswatch
Nightswatch

Reputation: 143

SAP maintains single session queue per service channel as defined in accessoryservice.xml.

Every service channel can have different priorities.

So to solve the problem, please declare the high priority for the service channel used by the smaller size data. so that even if the bigger data is still transmitting, phone can send other high priority messages to watch on different channel. Please refer below snippet for the same.

<serviceProfile
.

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

 

// create a new service channel with high priority and different id

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

Upvotes: 0

Related Questions