Commit 5324b94b71a273529d3380aada9453540af17779
1 parent
7ea3ba64
transmission des messages de l'application web à la raspberry v …
… ia web socket
Showing
1 changed file
with
21 additions
and
0 deletions
Show diff stats
pageHTML/mode.html
... | ... | @@ -4,6 +4,27 @@ |
4 | 4 | <meta charset="UTF-8"> |
5 | 5 | <link rel="stylesheet" href="mode.css" /> |
6 | 6 | <title>Changement de mode</title> |
7 | + | |
8 | +<script src="jquery.js"></script> | |
9 | + <script type= "text/javascript"> | |
10 | + window.Websocket = (window.Websocket || window.MozWebSocket); | |
11 | + var websocket = new WebSocket('ws://192.168.43.222:9000, 'myprotocol');}; | |
12 | + websocket.onerror=function(){ $('h1').css('color','red');}; | |
13 | + websocket.onopen=function(){ $('h1').css('color','green');}; | |
14 | + | |
15 | + | |
16 | + webscket.onmessage=function(message){ | |
17 | + console.log(message.data); | |
18 | + $('#messages').append($('<p>',{ text: message.data})); | |
19 | + }; | |
20 | + | |
21 | + function mode(){ | |
22 | + var message=$('#myonoffswitch').checked; | |
23 | + websocket.send(message); | |
24 | + | |
25 | + } | |
26 | + </script> | |
27 | + | |
7 | 28 | </head> |
8 | 29 | <body> |
9 | 30 | <h1>Changement de mode de votre veilleuse connectée</h1> | ... | ... |