Languages

Menu
Sites
Language
Datagrams over Samsung Accessory Protocol (SAP)

Hello all,

 

There is following problem:

There is Companion app type: Android host (phone) and Tizen client (gear). Client is web app type.

There is proper configured SAP connection between host and client (over bluetooth)

I want to send serious bunch of data packets from host to client. Let's assume these are frames of video clip.

Each frame is about 3 - 6Kb. I use SAP socket send method. I cannot use sendFile method. These frames must be send as base64 raw data.

It seems that SAP acts TCP like. It gurantees delivery of all packets (frames).

This ruins my idea. It seems that SAP send method enque all data and try to deliver them till success. In case of connection / link problem

(when for example distance between phone and watch changes and bluetooth transfer rate decreases) all frames are delivered with serious delay.

I need to simulate UDP connection when datagrams can be dropped (in my case - video frames) when connnection transfer rate is low.

In other words I need to set delivery timeout somehow. I cannot find any method for this.

In xml/accessoryservices.xml there are following tags:

 

dataRate="high"
priority="high"
reliability="disable"

 

but it seems that SAP ignore them.

I could measure delivery time by myself. In documentation fot SAP 2.3.2 send method there is following information:

 

Note: This method is a blocking call. If you need to do any heavy lifting or long latency work in this callback, spawn a separate thread. DO NOT invoke this method on the main thread of the application. It processes the byte array completely before returning.

 

So in case of long delivery time I could drop frames in my code by myself. But I think that queued note is not true, because send method returns immediatelly.

So it seems to be async method. But there is no any callback method returning when data are delivered.

It seems we cannot control sending data at all. Great job Samsung.

Any ideas how to simulate UDP in this context? Or just set delivery timeout?

 

Thank you in advance

Luke

 

Edited by: Łukasz Grabiec on 18 May, 2016

Responses

3 Replies
Marco Buettner

u can use webworker as background thread for SAP communication

Slawek Kowalski

Webworker works on the watch side (JavaScript) and you don't have access to tizen object.

Luke looks for any solution for SAP on the Android side.

Nafisul Islam Kiron

Hi, websocket is another way (it's still tcp). You can give it a try.
https://developer.tizen.org/ko/development/tutorials/web-application/w3chtml5supplementary-features/communication/websocket?langredirect=1
https://developer.tizen.org/ko/development/guides/web-application/w3chtml5supplementary-features/communication/websocket?langredirect=1

http://code.taobao.org/p/WordGame/diff/2/trunk/external/libwebsockets/tizen/include