Update the examples to the new methodology

This commit is contained in:
Scott Baker 2019-03-15 22:22:08 -07:00
parent 133b371036
commit 35b90ace9a
3 changed files with 33 additions and 41 deletions

View File

@ -3,7 +3,6 @@ const char* ssid = "ssid";
const char* password = "password";
#include <WebOTA.h>
WebServer OTAServer(8080);
#define LED_PIN 2
@ -15,7 +14,9 @@ void setup() {
pinMode(LED_PIN, OUTPUT);
init_wifi(ssid, password, host);
init_web_ota(&OTAServer);
// Defaults to 8080 and "/webota"
//init_webota(80, "/update");
}
// the loop function runs over and over again forever
@ -27,5 +28,5 @@ void loop() {
digitalWrite(LED_PIN, LOW);
webota_delay(md);
OTAServer.handleClient();
handle_webota();
}

View File

@ -3,13 +3,14 @@ const char* ssid = "ssid";
const char* password = "password";
#include <WebOTA.h>
WebServer OTAServer(8080);
void setup() {
Serial.begin(115200);
init_wifi(ssid, password, host);
init_web_ota(&OTAServer);
// Defaults to 8080 and "/webota"
//init_webota(80, "/update");
}
int offset = 0;
@ -32,5 +33,5 @@ void loop() {
if (offset >= len) { offset = 0; }
OTAServer.handleClient();
handle_webota();
}

View File

@ -3,7 +3,6 @@ const char* ssid = "ssid";
const char* password = "password";
#include <WebOTA.h>
WebServer OTAServer(8080);
long start = 0;
long max_seconds = 30;
@ -11,16 +10,36 @@ long i = 2; // Start at 2
long found = 0; // Number of primtes we've found
int LED_PIN = 16;
bool is_prime(long num) {
// Only have to check for divisible for the sqrt(number)
int upper = sqrt(num);
// Check if the number is evenly divisible (start at 2 going up)
for (long cnum = 2; cnum <= upper; cnum++) {
long mod = num % cnum; // Remainder
// If the remainer is 0 it's evenly divisible
if (mod == 0) {
return false;
}
}
// If you get this far it's prime
return true;
}
////////////////////////////////////////////////////
void setup() {
Serial.begin(115200);
while (!Serial) { }
pinMode(LED_PIN, OUTPUT);
start = millis();
init_wifi(ssid, password, host);
init_web_ota(&OTAServer);
// Defaults to 8080 and "/webota"
//init_webota(80, "/update");
}
void loop() {
@ -44,7 +63,7 @@ void loop() {
Serial.println(" seconds");
digitalWrite(LED_PIN, LOW);
webota_delay(15 * 1000, &OTAServer);
webota_delay(15000);
i = 2;
found = 0;
@ -53,34 +72,5 @@ void loop() {
i++;
OTAServer.handleClient();
}
bool is_prime(long num) {
// Only have to check for divisible for the sqrt(number)
int upper = sqrt(num);
// Check if the number is evenly divisible (start at 2 going up)
for (long cnum = 2; cnum <= upper; cnum++) {
long mod = num % cnum; // Remainder
if (mod == 0) {
return false;
} // If the remainer is 0 it's evenly divisible
}
return true; // If you get this far it's prime
}
bool is_prime2(long number) {
if (number < 2) return false;
if (number == 2) return true;
if (number % 2 == 0) return false;
for(int i=3; (i*i)<=number; i+=2){
if (number % i == 0 ) return false;
}
return true;
handle_webota();
}