diff --git a/pageHTML/Menu.css b/pageHTML/Menu.css new file mode 100644 index 0000000..85520d7 --- /dev/null +++ b/pageHTML/Menu.css @@ -0,0 +1,59 @@ +.introduction { + color: red; + font-size: 40px; + font-family: Verdana; + font-style: italic; + text-decoration: underline; + text-align: center; +} + +body +{ + color: black; /* Le texte de la page sera blanc */ +} + +.onoffswitch { + position: relative; width: 59px; + -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none; +} +.onoffswitch-checkbox { + display: none; +} +.onoffswitch-label { + display: block; overflow: hidden; cursor: pointer; + border: 2px solid #999999; border-radius: 19px; +} +.onoffswitch-inner { + display: block; width: 200%; margin-left: -100%; + transition: margin 0.3s ease-in 0s; +} +.onoffswitch-inner:before, .onoffswitch-inner:after { + display: block; float: left; width: 50%; height: 20px; padding: 0; line-height: 20px; + font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold; + box-sizing: border-box; +} +.onoffswitch-inner:before { + content: "ON"; + padding-left: 10px; + background-color: #000405; color: #FFFFFF; +} +.onoffswitch-inner:after { + content: "OFF"; + padding-right: 10px; + background-color: #EEEEEE; color: #999999; + text-align: right; +} +.onoffswitch-switch { + display: block; width: 16px; margin: 2px; + background: #FFFFFF; + position: absolute; top: 0; bottom: 0; + right: 35px; + border: 2px solid #999999; border-radius: 19px; + transition: all 0.3s ease-in 0s; +} +.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner { + margin-left: 0; +} +.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch { + right: 0px; +} diff --git a/pageHTML/Menu.html b/pageHTML/Menu.html new file mode 100644 index 0000000..07627d2 --- /dev/null +++ b/pageHTML/Menu.html @@ -0,0 +1,25 @@ + + + + + + Menu Veilleuse connectée + + +

Bienvenue sur le menu de votre veilleuse connectée

+ + +

Etat de la veilleuse

+
+ + +
+ + diff --git a/pageHTML/couleur.html b/pageHTML/couleur.html new file mode 100644 index 0000000..1502d06 --- /dev/null +++ b/pageHTML/couleur.html @@ -0,0 +1,29 @@ + + + + + Changement de couleur + + +

Changement de couleur de votre veilleuse connectée

+

Rouge

+
+ + +50 +
+

Vert

+
+ + + 50 +
+

Bleu

+
+ + + 50 +
+

Retour

+ + diff --git a/pageHTML/intensite.html b/pageHTML/intensite.html new file mode 100644 index 0000000..4735525 --- /dev/null +++ b/pageHTML/intensite.html @@ -0,0 +1,18 @@ + + + + + Changement d'intensité + + + +

Changement d'intensite de votre veilleuse connectée

+
+ + + 50 +
+ +

Retour

+ + diff --git a/pageHTML/mode.css b/pageHTML/mode.css new file mode 100644 index 0000000..1ca81e2 --- /dev/null +++ b/pageHTML/mode.css @@ -0,0 +1,45 @@ +.onoffswitch { + position: relative; width: 138px; + -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none; +} +.onoffswitch-checkbox { + display: none; +} +.onoffswitch-label { + display: block; overflow: hidden; cursor: pointer; + border: 2px solid #999999; border-radius: 19px; +} +.onoffswitch-inner { + display: block; width: 200%; margin-left: -100%; + transition: margin 0.3s ease-in 0s; +} +.onoffswitch-inner:before, .onoffswitch-inner:after { + display: block; float: left; width: 50%; height: 34px; padding: 0; line-height: 34px; + font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold; + box-sizing: border-box; +} +.onoffswitch-inner:before { + content: "Automatique"; + padding-left: 10px; + background-color: #30A9C7; color: #FFFFFF; +} +.onoffswitch-inner:after { + content: "Manuel"; + padding-right: 10px; + background-color: #EEEEEE; color: #999999; + text-align: right; +} +.onoffswitch-switch { + display: block; width: 23px; margin: 5.5px; + background: #FFFFFF; + position: absolute; top: 0; bottom: 0; + right: 100px; + border: 2px solid #999999; border-radius: 19px; + transition: all 0.3s ease-in 0s; +} +.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner { + margin-left: 0; +} +.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch { + right: 0px; +} \ No newline at end of file diff --git a/pageHTML/mode.html b/pageHTML/mode.html new file mode 100644 index 0000000..dd0a351 --- /dev/null +++ b/pageHTML/mode.html @@ -0,0 +1,20 @@ + + + + + + Changement de mode + + +

Changement de mode de votre veilleuse connectée

+
+ + +
+ +

Retour

+ + diff --git a/serveur/serveur.c b/serveur/serveur.c new file mode 100644 index 0000000..d19ab03 --- /dev/null +++ b/serveur/serveur.c @@ -0,0 +1,86 @@ +#include +#include +#include +#include + +#define MAX_FRAME_SIZE 1024 +#define WAIT_DELAY 50 + +static int callback_http( + struct libwebsocket_context *this, +struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, +void *user,void *in,size_t len) +{ +return 0; +} + +static int callback_my( + struct libwebsocket_context * this, +struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, +void *user,void *in,size_t len) +{ +static char *message=NULL; +static int msize=0; +switch(reason){ +case LWS_CALLBACK_ESTABLISHED: + printf("connection established\n"); +message=NULL; +// Declenchement d'un prochain envoi au navigateur +libwebsocket_callback_on_writable(this,wsi); +break; +case LWS_CALLBACK_RECEIVE: +// Ici sont traites les messages envoyes par le navigateur + printf("received data: %s\n",(char *)in); +message=malloc(len+LWS_SEND_BUFFER_PRE_PADDING+LWS_SEND_BUFFER_POST_PADDING); +if(message==NULL){ perror("callback_my.malloc"); exit(EXIT_FAILURE); } +memcpy(message+LWS_SEND_BUFFER_PRE_PADDING,in,len); +// Declenchement d'un prochain envoi au navigateur +msize=len; +libwebsocket_callback_on_writable(this,wsi); +break; +case LWS_CALLBACK_SERVER_WRITEABLE: +// Ici sont envoyes les messages au navigateur +if(message!=NULL){ +char *out=message+LWS_SEND_BUFFER_PRE_PADDING; +libwebsocket_write(wsi,(unsigned char *)out,msize,LWS_WRITE_TEXT); +free(message); +message=NULL; +} +break; +default: +break; +} +return 0; +} + +static struct libwebsocket_protocols protocols[] = { + { + "http-only", // name + callback_http, // callback + 0, // data size + 0 // maximum frame size + }, + {"myprotocol",callback_my,0,MAX_FRAME_SIZE}, + {NULL,NULL,0,0} +}; + +int main(void) { + int port=9000; + struct lws_context_creation_info info; + memset(&info,0,sizeof info); + info.port=port; + info.protocols=protocols; + info.gid=-1; + info.uid=-1; + struct libwebsocket_context *context=libwebsocket_create_context(&info); + if(context==NULL){ + fprintf(stderr, "libwebsocket init failed\n"); + return -1; + } + printf("starting server...\n"); + while(1){ + libwebsocket_service(context,WAIT_DELAY); + } + libwebsocket_context_destroy(context); + return 0; +} \ No newline at end of file -- libgit2 0.21.2