首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Xively从网站发送命令?

如何使用Xively从网站发送命令?
EN

Stack Overflow用户
提问于 2014-07-08 16:25:44
回答 1查看 261关注 0票数 1

我正在尝试创建一个简单的网站,以获得一些浮点,并发送一些命令,以圣核F401RE编程在mbed。我可以使用xivelyjs文档接收数据流(浮点数),但不知道如何发回任何内容。下面是我获取floats的代码:

代码语言:javascript
复制
<div><small>Temperature:</small> <span  style="color:black" id="element1"></span></div>
<div><small>Trip Level:</small> <span style="color:black" id="element2"></span></div>
<!-- Include jQuery -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<!-- Include XivelyJS -->
<script src="http://d23cj0cdvyoxg0.cloudfront.net/xivelyjs-1.0.4.min.js"></script>
<script>
$(document).ready(function($) 
{

  // Set the Xively API key (https://xively.com/users/YOUR_USERNAME/keys)
  xively.setKey( "KEY" );

  // Replace with your own values
  var feedID        = FEED,          // Feed ID (the last number on the URL on the feed page on Xively)
      datastreamID  = "Temperature";       // Datastream ID
      selector1     = "#element1";   // Your element on the page - takes any valid jQuery selector
      datastreamID2 = "Trip_Level";
      selector2     = "#element2";
// Get datastream data from Xively
  xively.datastream.get (feedID, datastreamID, function ( datastream ) 
  {
    // Display the current value from the datastream
    $(selector1).html( datastream["current_value"] );
    // Getting realtime! The function associated with the subscribe method will be executed every time there is an update to the datastream
    xively.datastream.subscribe( feedID, datastreamID, function ( event , datastream_updated ) 
    {
        // Display the current value from the updated datastream
        $(selector1).html( datastream_updated["current_value"] );
    });
  });

  xively.datastream.get (feedID, datastreamID2, function ( datastream ) 
  {
    $(selector2).html( datastream["current_value"] );
    xively.datastream.subscribe( feedID, datastreamID2, function ( event , datastream_updated ) 
    {
        $(selector2).html( datastream_updated["current_value"] );
    });
  });

任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2014-07-10 05:24:31

您想要使用xively.datastream.put()

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24627038

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档