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