| Electronic Components Datasheet Search |
|
DEV-12887 Datasheet(PDF) 26 Page - SparkFun Electronics |
|
|
|||||||||||||||||||||||||||||
DEV-12887 Datasheet(HTML) 26 Page - SparkFun Electronics |
|
26 / 40 page ![]() /* Agent for imp WebControlled LEDs by: Jim Lindblom SparkFun Electronics date: November 1, 2013 license: Beerware. Please use, reuse, and modify this cod e. If you find it useful, buy me a beer some day! This is the agent portion of the LED Web Controller. It de fines how http requests to https://agent.electricimp.com/XXXXXXXXXXXX ar e handled. Check your agent URL to find out what, exactly, XXXXXXXXXXXX is. For example, if your agent url is https://agent.electricim p.com/UpyYpRLmBB7m sending https://agent.electricimp.com/UpyYpRLmBB7m?led=0 s hould turn the lonely red led off. https://agent.electricimp.com/UpyYpRL mBB7m?led=1 would turn the LED on. * There are also request handlers for "rgb", which should be a #RRGGBB formatted string. E.g: https://agent.electricimp.com/Upy YpRLmBB7m?rgb=%238500b7 * A "user" request handler can receive a string. E.g.: htt ps://agent.electricimp.com/UpyYpRLmBB7m?user=Jim * And a "timer" handler looks for a numberlooking strin g. E.g.: https://agent.electricimp.com/UpyYpRLmBB7m?timer=10 The parameters can be combined in one request. E.g.: https://agent.electricimp.com/UpyYpRLmBB7m?led=1&rgb=%237f 3fff&timer=10&user=Jim */ // At the start, print a message to say we're online, and prin t the agent URL: server.log("LED Web Control Agent Online: " + http.agenturl ()); // requestHandler handles all http requests coming into the ag ent. It's only // setup to look for a select few requests: "led", "rgb", "use r" and "timer". function requestHandler(request, response) { try { // Try provides us with exception handling, in case a runtime error occurs // check if the user sent led as a query parameter if ("led" in request.query) { // if they did, and led=1.. set our variable to 1 if ((request.query.led == "1") || (request.query.l ed == "0")) { // convert the led query parameter to an integ er local ledStatus = request.query.led.tointeger (); // send "led" message to device, and send ledS tate as the data Page 26 of 40 |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |