TeamE7
Dependencies: EthernetInterface HTTPServer RemoteIR SDFileSystem mbed-rpc mbed-rtos mbed
Fork of SmartRemote by
main.cpp
- Committer:
- sarvagyavaish
- Date:
- 2013-12-02
- Revision:
- 3:a3b4d032f48f
- Parent:
- HTTPServerHelloWorld.cpp@ 0:5630d7e58a0b
- Child:
- 4:36e0aa194b45
File content as of revision 3:a3b4d032f48f:
#include "mbed.h" #include "EthernetNetIf.h" #include "HTTPServer.h" // Start DB #include <stdio.h> #include <stdlib.h> #include "SDFileSystem.h" #include "db.h" // End DB // Start RPC #include "RPCVariable.h" int Request; int Learn = 0; //Make these variables accessible over RPC by attaching them to an RPCVariable RPCVariable<int>(&Request), "Request"); //RPCVariable RPCLearn(&Learn, "Learn"); // End RPC EthernetNetIf eth; HTTPServer svr; DigitalOut led1(LED1); int main() { printf("Setting up...\n"); EthernetErr ethErr = eth.setup(); if(ethErr) { printf("Error %d in setup.\n", ethErr); return -1; } printf("Setup OK\n"); svr.addHandler<SimpleHandler>("/"); //Default handler svr.bind(80); // DB Init mkdir("/sd/SmartRemote", 0777); char code[] = "123AB"; char name[] = "Button Name"; char results_code[128]; char results_name[128]; db_insert_tuple(code, name); FILE *fread = fopen("/sd/SmartRemote/db.txt", "r"); db_find_tuple(fread, 2, results_name, results_code); fclose(fread); //End DB init printf("Listening...\n"); Timer tm; tm.start(); //Listen indefinitely while(true) { Net::poll(); if(tm.read()>.5) { led1=!led1; //Show that we are alive tm.start(); } } return 0; }