Server for window shades - using Soffy DCT-30 motors - more details here http://robdobson.com/2013/10/moving-my-window-shades-control-to-mbed/

Dependencies:   EthernetInterface RdWebServer mbed-rtos mbed

Committer:
Bobty
Date:
Thu Sep 19 12:06:43 2013 +0000
Revision:
1:486b1571d1c4
Parent:
0:d5f69749da59
Child:
2:24fd130c3600
Added code to support commands

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bobty 0:d5f69749da59 1 #include "mbed.h"
Bobty 0:d5f69749da59 2 #include "EthernetInterface.h"
Bobty 0:d5f69749da59 3 #include <stdio.h>
Bobty 0:d5f69749da59 4 #include <string.h>
Bobty 0:d5f69749da59 5 #include "RdWebServer.h"
Bobty 0:d5f69749da59 6
Bobty 0:d5f69749da59 7 #define PORT 80
Bobty 0:d5f69749da59 8
Bobty 1:486b1571d1c4 9 Serial pc(USBTX, USBRX);
Bobty 1:486b1571d1c4 10
Bobty 0:d5f69749da59 11 RdWebServer webServer;
Bobty 0:d5f69749da59 12
Bobty 0:d5f69749da59 13 EthernetInterface eth;
Bobty 0:d5f69749da59 14
Bobty 0:d5f69749da59 15 DigitalOut led1(LED1); //server listning status
Bobty 0:d5f69749da59 16 DigitalOut led2(LED2); //socket connecting status
Bobty 0:d5f69749da59 17
Bobty 0:d5f69749da59 18 Ticker ledTick;
Bobty 0:d5f69749da59 19
Bobty 0:d5f69749da59 20 void ledTickfunc()
Bobty 0:d5f69749da59 21 {
Bobty 0:d5f69749da59 22 if(webServer.isListening())
Bobty 0:d5f69749da59 23 {
Bobty 0:d5f69749da59 24 led1 = !led1;
Bobty 0:d5f69749da59 25 }
Bobty 0:d5f69749da59 26 else
Bobty 0:d5f69749da59 27 {
Bobty 0:d5f69749da59 28 led1 = false;
Bobty 0:d5f69749da59 29 }
Bobty 0:d5f69749da59 30 }
Bobty 0:d5f69749da59 31
Bobty 1:486b1571d1c4 32 void handleCmd_Up(char* argStr)
Bobty 1:486b1571d1c4 33 {
Bobty 1:486b1571d1c4 34 printf("UP COMMAND %s\n\r", argStr);
Bobty 1:486b1571d1c4 35 }
Bobty 1:486b1571d1c4 36
Bobty 0:d5f69749da59 37 int main (void)
Bobty 0:d5f69749da59 38 {
Bobty 1:486b1571d1c4 39 pc.baud(115200);
Bobty 0:d5f69749da59 40 ledTick.attach(&ledTickfunc,0.5);
Bobty 0:d5f69749da59 41
Bobty 0:d5f69749da59 42 // setup ethernet interface
Bobty 0:d5f69749da59 43 eth.init(); //Use DHCP
Bobty 0:d5f69749da59 44 eth.connect();
Bobty 0:d5f69749da59 45 printf("IP Address is %s\n\r", eth.getIPAddress());
Bobty 0:d5f69749da59 46
Bobty 1:486b1571d1c4 47 webServer.addCommand("up", &handleCmd_Up);
Bobty 0:d5f69749da59 48 webServer.init(PORT, &led2);
Bobty 0:d5f69749da59 49 webServer.run();
Bobty 0:d5f69749da59 50
Bobty 0:d5f69749da59 51
Bobty 0:d5f69749da59 52 }