Languages

Menu
Sites
Language
WebSocket Companion Web App

Hi Everyone,
I have a companion app, Gear (Consumer) - Android (Provider) and I connect the app in the Gear to an WebSocket.
I can establish a WebSocket connection using the wifi of the Gear, but only if the gear isn't connected to the smartphone.
When I connect the Gear to the smartphone, and try to connect the app of the Gear to the webSocket I always recieve the readyState 3 (The connection has been closed or could not be opened.)
I have developed another companion apps, and I know that the Gear can use the internet connection of the smartphone via bluetooth, so I don't know why can't connect to the websocket.
Maybe is not possible to do this, because the accessory protocol is running, so maybe the gear can establish two or more connections simultaneously.
If any of you have some idea about how to make it work, I will be appreciate it, or if somebody know that this is impossible to accomplish i will appreciated too.


I have the GearS2 (SM-R720) - And the IDE 2.3.1 Rev1

 

 

Thanks for your help.

Responses

3 Replies
daniel kim

Hi,

As far as I know, Wifi connection of Gear S2 is closed automatically when it's connected to Android phone via Gear manager. So it's not possbile to use WebSocket from Gear S2 alone. I think that you need to access data from Android phone to your server. then data can be delivered to from Android phone to Gear S2 via SAP.

Regards

Camilo Alejandro Rodriguez Aranzazu

Hi Daniel,
Thanks for your answer, appreciate it.

Yesterday I could tested and verify that the problem is not by the SAP, I tested my app in the Gear S2 without start the SAP, with the bluetooth connection enabled, connected to the gear manager on the smartphone and the webSocket connection doesn't work, but if I disable the bluetooth, once the gear get the wifi connection, the webSocket works perfectly.

So, the issue is like you said, the bluetooth disable the wifi of the gear automatically, the weird thing is that the gear should be able to use the internet connection of the smartphone via bluetooth, and I know that is correct, because in another app I make an XMLHttpRequest to an RSS with the gear connected to the smartphone via bluetooth, and everything works great.

However, I think i will have to work with the websocket like you suggest, making the connection in the Android app and then pass the data to the Gear using the SAP.

Joohwan Kim

Hi, Daniel,

 

   Persistent socket connection through BT or Internet may not be possible due to platform's

background policy. Alternative way to get a realtime noti from your cloud server is to use

the Tizen push service. Your app can receive a noti when the Gear S2 is connected through

BT, WIFI, or 3G. For the details, refer to 

https://developer.tizen.org/development/tutorials/native-application/messaging/push

 

  The latest binary for Gear S2 BT model supports the push service. The binaries for 3G models

are being deployed worldwide.