我正在尝试创建一个简单的网站,以获得一些浮点,并发送一些命令,以圣核F401RE编程在mbed。我可以使用xivelyjs文档接收数据流(浮点数),但不知道如何发回任何内容。下面是我获取floats的代码:
<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"] );
});
});任何帮助都将不胜感激。
发布于 2014-07-10 05:24:31
您想要使用xively.datastream.put()。
https://stackoverflow.com/questions/24627038
复制相似问题