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