Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ===============================================================================================
- Electric Imp agent side ( cloud / server side ) :-
- ===============================================================================================
- http.onrequest(function(req, resp){
- server.log("Got a HTTP request");
- if (req.method == "POST"){
- local body = http.urldecode(req.body)
- server.log(body.data);
- device.send("agentBuffers",body.data);
- //device.on(recvfromImp,impBuffer);
- }
- resp.send(200, "<head><meta http-equiv=\"refresh\" content=\"1;url=http://stanleyseow.asuscomm.com/color/\"><html>OK</html></head>");
- });
- ===============================================================================================
- Electric Imp device ( the white wifi SDcard in yr home ) :-
- ===============================================================================================
- function watchdog2() {
- agent.on("agentBuffers",function(value) {
- server.log("Got a buffer from agent/http");
- if ( value.len() < 33 ) { // Make sure nRF24L01 payload is only 32bytes or less
- radio.send(value,value.len()); // Send the payload to the radio
- }
- } );
- radio.powerRX();
- imp.wakeup(1, watchdog2 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement