ESP_UKI.ino 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. ESP_UKI
  3. largely base on http://www.john-lassen.de/index.php/projects/esp-8266-arduino-ide-webconfig
  4. TODO : better function organizing
  5. add firmware number in webserver
  6. rework led system with tickers
  7. send ADC to default IP via udp, allow configuration
  8. build onDemand config mode
  9. load/save parameters (fixed ip, uki_name, udp_port udp_ip
  10. */
  11. /* LEDS */
  12. #include "includes.h" //headers and variables declaration
  13. /* UDP CONFIGURATION */
  14. int UKI_UDP_In_Port = 9000; //udp port input for ESP
  15. IPAddress UKI_UDP_Master_IP(192, 168, 0, 41); //default udp address to send to. Will automatically change to the ip sending something to udp in
  16. Ticker tkUKI; // periodic send ADC to UDP
  17. //int GSR_sensor;
  18. void setup ( void ) {
  19. //EEPROM.begin(512);
  20. Serial.begin(115200);
  21. Serial.println("Starting ESP8266");
  22. setupWifi();
  23. //setupLeds();
  24. //setupOTA();
  25. delay(200);
  26. Serial.println("Ready");
  27. Serial.print("IP address: ");
  28. //Serial.println(WiFi.localIP());
  29. //UKI sensor setup
  30. UKI_UDP.begin(UKI_UDP_In_Port);
  31. // delay(1000);
  32. // digitalWrite(Red_Led, HIGH); //red led off
  33. // digitalWrite(Blue_Led, HIGH);
  34. // delay(1000);
  35. // ledBlink(Red_Led, 3, 100); //3 quick blink on red led as we start
  36. // delay (1000);
  37. //blueLedState(-1, 500);
  38. }
  39. void loop ( void ) {
  40. StartConfigAP();
  41. /* UKI part */
  42. // GSR_sensor = analogRead(A0);
  43. // //UKI_UDP.beginPacketMulticast((224, 1, 2, 3), 8000, WiFi.localIP());//
  44. // UKI_UDP.beginPacket(UKI_UDP_Master_IP, 8000);
  45. // UKI_UDP.print(config.DeviceName);
  46. // UKI_UDP.print(" ");
  47. // UKI_UDP.print(GSR_sensor);
  48. // UKI_UDP.endPacket();
  49. // //yield();
  50. //
  51. // delay(20);
  52. //
  53. // //Check udp in
  54. // int packetSize = UKI_UDP.parsePacket();
  55. //
  56. // if(packetSize) {
  57. // UKI_UDP_Master_IP = UKI_UDP.remoteIP();
  58. // UKI_UDP.beginPacket(UKI_UDP_Master_IP, 8000);
  59. // UKI_UDP.print("new master ip");
  60. // UKI_UDP.endPacket();
  61. // }
  62. }