本文介绍了从GEAR S3心率监测器(HRM)检索数据到移动设备或服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用来自

将数据发送到服务器:

您可以使用 Ajax XmlHttpRequest 将数据发送到服务器

Ajax:

 函数sendDataToServer(){使用严格";console.log("ready!");$ .ajax({类型:发布",网址:"http://YOUR_URL",成功:功能(数据){console.log(JSON.stringify(data));}});} 

XmlHttpRequest:

 函数postDataToServer(){var xmlHttp = new XMLHttpRequest();xmlHttp.onreadystatechange = function(){如果(xmlHttp.readyState == 4){如果(xmlHttp.status == 200){alert(数据发布成功..");} 别的 {alert(发送数据失败..");}}}xmlHttp.open("POST","YOUR_URL");xmlHttp.send("_ TEST_STRING_DATA"); 

从REST Viewer自动生成的代码无法在Tizen IDE(可穿戴式)网络应用中使用

在Tizen TV上的XmlHttpRequest退出应用程序

模拟器上的RESTful服务

I have used the Tizen sample Heart Rate Monitor code for Samsung Gear S3 from https://developer.tizen.org/ko/community/tip-tech/accessing-heart-rate-monitor-hrm-sensor-data-native-applications?langredirect=1

I want to develop Android or Tizen for Retrieving Data from the Heart Rate Monitor which is in S3 Gear. I found the sample code from https://developer.tizen.org/ko/development/guides/web-application/sensors/human-activity-monitor?langredirect=1#retrieve

How can I integrate this. Pls share your ideas. Thanks a lot.

解决方案

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.

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

这篇关于从GEAR S3心率监测器(HRM)检索数据到移动设备或服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 11:09