Languages

Menu
Sites
Language
Web Monitor on wifi for console output, used for debugging Gear watch code, breaks with Bluetooth

I'm buildeing a web application on Samsung Gear S2 watch.  Currently have problem with bluetooth socket (SASocket) connection to phone. Connection is made but SASocket fails to be created. Trying to debug but the wifi connection to laptop breaks as soon as bluetooth is turned on(needed for watch to phone connectio). Because wifi connection breaks the web based monitor ( I used this to see logs generate by console statements in the code). I don't the console message.  Is there a way to retrieve these console outputs - either some setting so wifi conneciton doesn't break? OR a way to retrieve them later?

Thanks

Ron Bjork

Responses

3 Replies
Iqbal Hossain

Hi~ 

For Socket connection to Phone with Gear which API did you use? please share more details. 

Thanks.

Ron Bjork

I'm using Wearable 2.3.1.  The code for communicating to the phone via bluetooth is below. The first call made is to 'connect'.

var agentCallback = {
    onconnect : function(socket) {
        SASocket = socket;
        createHTML("HelloAccessory Connection established with RemotePeer");
        SASocket.setSocketStatusListener(function(reason){
            console.log("Service connection lost, Reason : [" + reason + "]");
            disconnect();
        });
        SASocket.setDataReceiveListener(onreceive);
        
    },
    onerror : onerror
};

var peerAgentFindCallback = {
    onpeeragentfound : function(peerAgent) {
        try {
            if (peerAgent.appName == ProviderAppName) {
                SAAgent.setServiceConnectionListener(agentCallback);
                SAAgent.requestServiceConnection(peerAgent);
            } else {
                createHTML("Not expected app!! : " + peerAgent.appName);
            }
        } catch(err) {
            console.log("exception [" + err.name + "] msg[" + err.message + "]");
        }
    },
    onerror : onerror
}


function onsuccess(agents) {
    try {
        if (agents.length > 0) {
            SAAgent = agents[0];
            SAAgent.setPeerAgentFindListener(peerAgentFindCallback);
            SAAgent.findPeerAgents();
        } else {
            createHTML("Not found SAAgent!!");
        }
    } catch(err) {
        console.log("exception [" + err.name + "] msg[" + err.message + "]");
    }
}

// UI Handlers
function connect() {
    if (SASocket) {
        //tau.changePage("#homeawaypage");
        createHTML('Already connected!');
        return false;
    }
    try {
        webapis.sa.requestSAAgent(onsuccess, function (err) {
            console.log("err [" + err.name + "] msg[" + err.message + "]");
        });
    } catch(err) {
        console.log("exception [" + err.name + "] msg[" + err.message + "]");
    }
    
}

// UI handler
function disconnect() {
    try {
        if (SASocket != null) {
            SASocket.close();
            SASocket = null;
            createHTML("closeConnection");
        }
    } catch(err) {
        console.log("exception [" + err.name + "] msg[" + err.message + "]");
    }
    
}

Iqbal Hossain

Hi~ 
To use companion, you have to use Gear Manager in your Android phone. Please make sure it is installed and paired with your Gear S2. 
After pairing, try  again. 

-Thanks