1
저는 간단한 웹 사이트를 만들어 일부 수레를 얻고 일부 명령을 mbed에 프로그래밍 된 ST Nucleo F401RE에 다시 보내려고합니다. xivelyjs 문서를 사용하여 데이터 스트림 (수레)을 수신 할 수 있지만 아무것도 보내지 않는 방법을 알 수 있습니다. 어떤 도움이 많이 주시면 감사하겠습니다Xively를 사용하여 웹 사이트에서 명령을 보내는 방법은 무엇입니까?
<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"]);
});
});
: 다음은 수레를 얻을 내 코드입니다.