You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.7 KiB

5 years ago
  1. //--- made by SKA ---
  2. //--- test EtherEncLib
  3. // adapted by Renato Aloi
  4. // May 2015
  5. // removed SD Card part for future implementation
  6. #include <SPI.h>
  7. #include <EtherEncLib.h>
  8. #if (ESP8266)
  9. #include <pgmspace.h>
  10. #else
  11. #include <avr/pgmspace.h>
  12. #endif
  13. static unsigned char ipaddr[] = { 192, 168, 1, 125 };
  14. static unsigned char macaddr[] = { 0x00, 0x11, 0x22, 0x44, 0x00, 0x25 };
  15. EtherEncLib eElib(80);
  16. const PROGMEM char resp200Txt[] = {"HTTP/1.0 200 OK\n\rContent-Type: text/html\n\rPragma: no-cache\n\r\n\r"};
  17. void setup()
  18. {
  19. #if (ESP8266)
  20. Serial.begin(115200);
  21. pinMode(5,OUTPUT); //--- ? -- SS pin must be output # by Renato Aloi
  22. #else
  23. Serial.begin(9600);
  24. pinMode(10,OUTPUT); //--- ? -- SS pin must be output # by Renato Aloi
  25. #endif
  26. eElib.begin(ipaddr,macaddr);
  27. Serial.println(F("------ program start -----------"));
  28. //Serial.println(F("NO SDCARD version")); // by Renato Aloi
  29. }
  30. void loop() {
  31. if ( eElib.available() )
  32. {
  33. Serial.println(eElib.getParams());
  34. eElib.print((char *)&resp200Txt[0],strlen_P(&resp200Txt[0]));
  35. if (eElib.isIndexHtml)
  36. {
  37. eElib.print("<HTML><body><H1>Hello World!</H1>");
  38. eElib.print("<form method=POST>");
  39. eElib.print("<input type=text name=nome />");
  40. eElib.print("<input type=submit value=OK />");
  41. eElib.print("</form></body>");
  42. eElib.print("</HTML>");
  43. }
  44. else if (eElib.isPost)
  45. {
  46. eElib.print("<HTML><body><H1>POST Params: ");
  47. eElib.print(eElib.getParams());
  48. eElib.print("</H1></body>");
  49. eElib.print("</HTML>");
  50. }
  51. else if (eElib.isGet)
  52. {
  53. eElib.print("<HTML><body><H1>GET Params: ");
  54. eElib.print(eElib.getParams());
  55. eElib.print("</H1></body>");
  56. eElib.print("</HTML>");
  57. }
  58. eElib.close();
  59. }
  60. }