ESP_UKI.ino 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. Ticker tkUKI; // periodic send ADC to UDP
  14. void setup ( void ) {
  15. EEPROM.begin(512);
  16. Serial.begin(115200);
  17. Serial.println("Starting ESP8266");
  18. setupLeds();
  19. //setupWifi();
  20. setupOTA();
  21. delay(200);
  22. Serial.println("Ready");
  23. Serial.print("IP address: ");
  24. Serial.println(WiFi.localIP());
  25. //UKI sensor setup
  26. UKI_UDP.begin(UKI_UDP_In_Port);
  27. // delay(1000);
  28. // digitalWrite(Red_Led, HIGH); //red led off
  29. // digitalWrite(Blue_Led, HIGH);
  30. // delay(1000);
  31. // ledBlink(Red_Led, 3, 100); //3 quick blink on red led as we start
  32. // delay (1000);
  33. blueLedState(-1, 500);
  34. }
  35. void loop ( void ) {
  36. loop_counter += 1;
  37. //loopWebserver();
  38. //loopOTA();
  39. /* UKI part */
  40. // GSR_sensor = analogRead(A0);
  41. // //UKI_UDP.beginPacketMulticast((224, 1, 2, 3), 8000, WiFi.localIP());//
  42. // UKI_UDP.beginPacket(UKI_UDP_Master_IP, 8000);
  43. // UKI_UDP.print(config.DeviceName);
  44. // UKI_UDP.print(" ");
  45. // UKI_UDP.print(GSR_sensor);
  46. // UKI_UDP.endPacket();
  47. // //yield();
  48. //
  49. // delay(20);
  50. //
  51. // //Check udp in
  52. // int packetSize = UKI_UDP.parsePacket();
  53. //
  54. // if(packetSize) {
  55. // UKI_UDP_Master_IP = UKI_UDP.remoteIP();
  56. // UKI_UDP.beginPacket(UKI_UDP_Master_IP, 8000);
  57. // UKI_UDP.print("new master ip");
  58. // UKI_UDP.endPacket();
  59. // }
  60. }