如何在GPIO上按下按钮时发出GET请求? [英] How to make GET request when a button is pressed on GPIO?

查看:92
本文介绍了如何在GPIO上按下按钮时发出GET请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


当Rpi上连接到GPIO的按钮打开和关闭时,如何发出获取请求?


我有2个URL可以根据URL触发IP中继。


没有响应所以它必须简单但我不知道从哪里开始。


如果它在ajax中,这就是我的要求:

 $(function(){
$( '#button')。change(function(){
var x = $(this).prop('checked')
if(x == true){
$ .get( " HTTP://192.168.1.100/current_state.xml PW =管理员&安培; Relay12等于1英寸)
$获得(" HTTP://192.168.1.100/current_state.xml")
}
,否则{
$获得(" HTTP://192.168.1.100/current_state.xml PW =管理员&安培; Relay12 = 0")
$获得(" HTTP: //192.168.1.100/current_state.xml")
}
})

})

所以如果`# button`来自GPIO,这就是我想要的。


提前致谢。



'HR>

阿卜杜拉西巴

解决方案

亲爱的朋友,


如果您使用基于C#的UWP应用程序,我建议您参考MSDN上的按钮示例:


https://developer.microsoft.com/en-us/windows/iot/samples/pushbutton


你可以在 buttonPin_ValueChanged事件中处理您的请求。


Hi

How can I make a get request when a button connected to the GPIO on Rpi is turned on and off?

I have 2 URLs that trigger an IP relay on and off depending on the url.

There is no response so it must be simple yet I'm not sure where to start.

Here is what my requst looks like if it were in ajax:

$(function() {
    $('#button').change(function() {
      var x =$(this).prop('checked')
if(x == true){
$.get( "http://192.168.1.100/current_state.xml?pw=admin&Relay12=1" )
$.get( "http://192.168.1.100/current_state.xml" )
}
else{
$.get( "http://192.168.1.100/current_state.xml?pw=admin&Relay12=0" )
$.get( "http://192.168.1.100/current_state.xml" )
}
    })

  })

So if `#button` was from the GPIO thats what I want it to do.

Thanks in advance.


Abdullah Seba

解决方案

Dear friend,

If you use C# based UWP application, I suggest that you refer to the Push Button example on MSDN:

https://developer.microsoft.com/en-us/windows/iot/samples/pushbutton

You can handle your request in buttonPin_ValueChanged event.


这篇关于如何在GPIO上按下按钮时发出GET请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆