Commit 5f7d5a558a6a01a4253d56822e2ac9c5a451c501

Authored by Claire Vandamme
1 parent 7e48baaa

transmission des messages de l'application web à la raspberry v …

…                                                                                               ia web socket
Showing 1 changed file with 20 additions and 0 deletions   Show diff stats
pageHTML/intensite.html
... ... @@ -4,6 +4,26 @@
4 4 <meta charset="UTF-8">
5 5 <title>Changement d'intensité</title>
6 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 intensite(){
  21 + var message=$('#slider').value();
  22 + websocket.send(message);
  23 +
  24 + }
  25 + </script>
  26 +
7 27 </head>
8 28 <body>
9 29 <h1>Changement d'intensite de votre veilleuse connectée</h1>
... ...