Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <ESP8266WiFi.h>
  2. #include <ESP8266WiFiMesh.h>
  3.  
  4. /* Create the mesh node object */
  5. ESP8266WiFiMesh mesh_node = ESP8266WiFiMesh(ESP.getChipId(), manageRequest);
  6.  
  7. /**
  8. * Callback for when other nodes send you data
  9. *
  10. * @request The string received from another node in the mesh
  11. * @returns The string to send back to the other node
  12. */
  13. String manageRequest(String request)
  14. {
  15. /* Print out received message */
  16. Serial.print("received: ");
  17. Serial.println(request);
  18.  
  19. /* return a string to send back */
  20. return String("Recibido");
  21. }
  22.  
  23. void setup()
  24. {
  25. Serial.begin(115200);
  26. delay(10);
  27.  
  28. Serial.println();
  29. Serial.println();
  30. Serial.println("Setting up mesh node...");
  31.  
  32. /* Initialise the mesh node */
  33. mesh_node.begin();
  34. pinMode(5,INPUT_PULLUP);
  35. }
  36.  
  37. void loop()
  38. {
  39. /* Accept any incoming connections */
  40. mesh_node.acceptRequest();
  41.  
  42. /* Scan for other nodes and send them a message */
  43. if(digitalRead(5)==0){
  44. Serial.println("Enviado comando");
  45. mesh_node.attemptScan("Comando LED");
  46. }
  47. delay(100);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement