1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00
david gauchard 92373a9837 Deprecate axTLS, update examples (#5366)
* update examples

* fix serial<->tcp example, use STASSID instead of SSID (name collision)

* fix HTTPSRequest.ino

* update AxTLS HTTPS examples, update AxTLS API to deprecated

* fixes

* fixes + fix astyle (no preproc directives) + restyling script

* fix HTTPClient library

* fixes

* common.sh: do not reload arduino when already present (for locally CI testing)

* common.sh: do not reload ArduinoJson when already present (for locally CI testing)

* fix

* fix

* fix deprecated example

* fix WiFiHTTPSServer.ino

* reduce footprint

* wipfix

* fix led builtin

* fix example

* finished updating APSSID on all examples

* style

* restyle examples

* helper to run CI test locally

* local CI runner more verbose

* +const

* deprecation deprecation

* deprecation

* Update NTPClient.ino

const char[] => const char *

* Update interactive.ino

const char[] => const char *
2018-11-29 20:49:27 -08:00

76 lines
1.5 KiB
C++

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#ifndef STASSID
#define STASSID "your-ssid"
#define STAPSK "your-password"
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
const char* host = "OTA-LEDS";
int led_pin = 13;
#define N_DIMMERS 3
int dimmer_pin[] = {14, 5, 15};
void setup() {
Serial.begin(115200);
/* switch on led */
pinMode(led_pin, OUTPUT);
digitalWrite(led_pin, LOW);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
WiFi.begin(ssid, password);
Serial.println("Retrying connection...");
}
/* switch off led */
digitalWrite(led_pin, HIGH);
/* configure dimmers, and OTA server events */
analogWriteRange(1000);
analogWrite(led_pin, 990);
for (int i = 0; i < N_DIMMERS; i++) {
pinMode(dimmer_pin[i], OUTPUT);
analogWrite(dimmer_pin[i], 50);
}
ArduinoOTA.setHostname(host);
ArduinoOTA.onStart([]() { // switch off all the PWMs during upgrade
for (int i = 0; i < N_DIMMERS; i++) {
analogWrite(dimmer_pin[i], 0);
}
analogWrite(led_pin, 0);
});
ArduinoOTA.onEnd([]() { // do a fancy thing with our board led at end
for (int i = 0; i < 30; i++) {
analogWrite(led_pin, (i * 100) % 1001);
delay(50);
}
});
ArduinoOTA.onError([](ota_error_t error) {
(void)error;
ESP.restart();
});
/* setup the OTA server */
ArduinoOTA.begin();
Serial.println("Ready");
}
void loop() {
ArduinoOTA.handle();
}