How to Integrate Samsung Gear Steps in Android Application

How to integrate Samsung Gear Steps in android Application?

For connection and data transfer between mobile android device and Samsung Gear device , Accessory Protocol is defined. So, the option available here is using Accessory SDK for Android mobile and Tizen wearable.

Tizen provides HumanActivityMonitor for 3rd party developers to retrieve Pedometer step count data.

I have developed a sample app in Tizen platform for reading pedometer step count data in gear and send the data to Consumer Android mobile app while the mobile and wearable is connected through Samsung Gear Manager. Its just a customization over the sample apps available on the sites reffered.

I am sharing the code of the tizen web app along with the installer(.wgt) file. If you are not interested in tizen development right now, you may install the app directly to the Samsung gear using the wgt file.

I am also sharing the code of the android app along with the installer(.apk) file. You may try a sample transmission between the devices and do your code on android platform as necessary. I have tested the apps on my devices and they are working good, though some data inconsistency occurs.

Zip file link:

Android consumer app (apk)

Android consumer app (code)

Tizen provider app (wgt)

Tizen provider app (code)

https://drive.google.com/file/d/0B6KEP_6UcxrATllCWTlmeUh1M28/view?usp=sharing

Sample Image
Sample Image

Sample Image
Sample Image

Human activity monitor API

Human Activity Monitor Guide

Accessory SDK

Please read the Accessory guide and HumanActivityMonitor guide for details implementation, you would find simple explanation there.

Installing integrated type apps on android device and wearable device

Do you have "gear manager" installed on your phone? If not then install it from "Galaxy App Store". Then run gear manager app, in that you would get option to connect with your gear.

Steps to connect

  1. Open gear manager
  2. Click on three vertical dots present on top right hand side and then select "Manage Devices" option. (Check first screenshot )
  3. Select your device from list of available devices. (Check 2nd screenshot )

refer for step 2

Refer for step 3

Note- If you are facing any problem related to installing Gear Manager, then please once go through the comments below.

Retrieving Data from GEAR S3 Heart Rate Monitor (HRM) to Mobile or Server

With Samsung Accessory SDK, you can develop an app in Android which can communicate with Tizen app(Gear).
Here is a working example

How to integrate Samsung Gear Steps in android Application?

Edit:

Here i am giving the code to measure Heart Rate and return back to Android phone when a request is sent from Android . I have just modified code from previously mentioned post and sharing here.

Here i am giving only contents from dataOnReceive function

            if (!SAAgent.channelIds[0]) {
createHTML("Something goes wrong...NO CHANNEL ID!");
return;
}

function sendHrData(heartRate){
// return Data to Android
SASocket.sendData(SAAgent.channelIds[0], 'HR: '+heartRate);
createHTML("Send massage:<br />" +
newData);

tizen.humanactivitymonitor.stop('HRM');

}

var heartRateData=0;

function onsuccessCB(hrmInfo) {

console.log('Heart rate: ' + hrmInfo.heartRate);
heartRateData = hrmInfo.heartRate;
// holding 15 seconds as HRM sensor needs some time
setTimeout(function(){
sendHrData(heartRateData);
}, 15000);

}

function onerrorCB(error) {
tizen.humanactivitymonitor.stop('HRM');
console.log('Error occurred: ' + error.message);
}

function onchangedCB(hrmInfo) {
//alert("onChanged...");
tizen.humanactivitymonitor.getHumanActivityData('HRM', onsuccessCB, onerrorCB);

}

tizen.humanactivitymonitor.start('HRM', onchangedCB);

And this code continuously returning Heart Rate. Please modified according to your requirements, i am just sharing the idea to communicate between Android phone and Samsung Gear.

Sample Image

Send Data to Server:

You can use Ajax or XmlHttpRequest to send data to server

Ajax:

    function sendDataToServer() {
'use strict';

console.log( "ready!" );
$.ajax({
type: "Post",
url: "http://YOUR_URL",
success: function (data) {
console.log(JSON.stringify(data));
}
});
}

XmlHttpRequest:

function postDataToServer() {
var xmlHttp = new XMLHttpRequest();

xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
alert("data posted successfully..");
} else {
alert("failed to send data..");
}
}
}

xmlHttp.open("POST", "YOUR_URL");

xmlHttp.send("_TEST_STRING_DATA");

Auto generated code from REST viewer not working in Tizen IDE(Wearable) web app

XmlHttpRequest on Tizen TV exits application

RESTful service on emulator

Note: You need to install Samsung Gear application in your Android phone.

How to get raw data(Heart Rate etc) from samsung gear s3 in Android

The topic Seems vast. I haven't seen some example code to fetch data directly from hardware layer sensor of another device of another platform. I know You can transfer the data in application layer using common BLE protocol. In Tizen, you can chose your suitable platform Native (C/C++) or Web (js/HTML/CSS)

You can start from checking out the Tizen Native Sensor Guide, It discusses how to fetch sensor data from wearable device.

To get example on establishing Bluetooth LE connection with device, Tizen Native BLE guide would be helpful I guess. Android Bluetooth LE Guide covers sample for android part.

I passed sensor data from tizen wearable device to android, and that was using Samsung Accessory SDK. You can see the response here.

How to integrate Samsung Gear Steps in android Application?

Useful links I would consider:

Tizen Web Sensor guide

Tizen Web Human Activity Guide

Tizen Sensor API for wearable Native

Tizen Web Bluetooth API



Related Topics



Leave a reply



Submit