How to subscribe/publish message using talkback app
이전 댓글 표시
Hi
Is there anyone who can me help with work around example, as to how to publish message using talkback or plugin on client side? I am using native javascript with jquery and have API key sending GET protocol. I want my button to subscribe to that channel i created, please help me by showing an example i am sure can able to do this. My channel have two fields temp and illuminance, both been programmed on IDE Arduno and have button_state that must read from my talkback functionality;
Plugin functionality for my button to read or subscribing my channel;
<html>
<head>
<!--
NOTE: This plugin will not be visible on public views of a channel.
If you intend to make your channel public, consider using the
MATLAB Visualization App to create your visualizations.
-->
%%PLUGIN_CSS%%
%%PLUGIN_JAVASCRIPT%%
</head>
<body>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"><br/>
<div class="col-md-4 text-center">
<button id="singlebutton" name="singlebutton" class="btn btn-primary">IOT-Talk</button>
</div>
</body>
</html>
<script
src="https://code.jquery.com/jquery-3.3.1.js"integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="crossorigin="anonymous"></script>
<script type="text/javascript">
function OPENDOOR() {
$.ajax({
url:"https://api.thingspeak.com/talkbacks/35734/commands?key=MF710NTKMG0E44UG&command_string=OPENDOOR&position=1",
type: 'GET',
success: function(data) {
//called when successful
//console.log(data);
$('#singlebutton').on('click', function (e) {
$('#singlebutton').append(data);
})
}
});
}
</script>
답변 (0개)
커뮤니티
더 많은 답변 보기: ThingSpeak 커뮤니티
카테고리
도움말 센터 및 File Exchange에서 C2000 Microcontroller Blockset에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!