Advertisement
Guest User

Untitled

a guest
May 26th, 2022
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. /**
  2. httpUpdate.ino
  3.  
  4. Created on: 27.11.2015
  5.  
  6. */
  7.  
  8. #include <Arduino.h>
  9.  
  10. #include <WiFi.h>
  11. #include <WiFiMulti.h>
  12.  
  13. #include <HTTPClient.h>
  14. #include <HTTPUpdate.h>
  15.  
  16. WiFiMulti WiFiMulti;
  17.  
  18. void setup() {
  19.  
  20. Serial.begin(115200);
  21. // Serial.setDebugOutput(true);
  22.  
  23. Serial.println();
  24. Serial.println();
  25. Serial.println();
  26.  
  27. for (uint8_t t = 4; t > 0; t--) {
  28. Serial.printf("[SETUP] WAIT %d...\n", t);
  29. Serial.flush();
  30. delay(1000);
  31. }
  32.  
  33. WiFi.mode(WIFI_STA);
  34. WiFiMulti.addAP("xxxxxxxxxx", "xxxxxxxxxx");
  35.  
  36.  
  37. }
  38.  
  39. void loop() {
  40. // wait for WiFi connection
  41. if ((WiFiMulti.run() == WL_CONNECTED)) {
  42.  
  43. WiFiClientSecure client;
  44.  
  45. // The line below is optional. It can be used to blink the LED on the board during flashing
  46. // The LED will be on during download of one buffer of data from the network. The LED will
  47. // be off during writing that buffer to flash
  48. // On a good connection the LED should flash regularly. On a bad connection the LED will be
  49. // on much longer than it will be off. Other pins than LED_BUILTIN may be used. The second
  50. // value is used to put the LED on. If the LED is on with HIGH, that value should be passed
  51. // httpUpdate.setLedPin(LED_BUILTIN, LOW);
  52.  
  53.  
  54. t_httpUpdate_return ret = httpUpdate.update(client, "https://dl.dropboxusercontent.com/s/y291q3ehg47rd5l/BlinkTeste.ino.nodemcu.bin");
  55. // Or:
  56. //t_httpUpdate_return ret = httpUpdate.update(client, "server", 80, "/file.bin");
  57.  
  58. switch (ret) {
  59. case HTTP_UPDATE_FAILED:
  60. Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
  61. break;
  62.  
  63. case HTTP_UPDATE_NO_UPDATES:
  64. Serial.println("HTTP_UPDATE_NO_UPDATES");
  65. break;
  66.  
  67. case HTTP_UPDATE_OK:
  68. Serial.println("HTTP_UPDATE_OK");
  69. break;
  70. }
  71. }
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement