gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 08:07:48 25 4
gpt4 key购买 nike

我正在尝试创建一个简单的网站来获取一些 float 并将一些命令发送回在 mbed 上编程的 ST Nucleo F401RE。我可以使用 xivelyjs 文档来接收数据流( float ),但不知道如何发回任何内容。这是我获取 float 的代码:

<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"] );
});
});

任何帮助将不胜感激。

最佳答案

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

关于javascript - 如何使用 Xively 从网站发送命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24627038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com