Upload files to "/"
This commit is contained in:
commit
19c4c00ce6
|
|
@ -0,0 +1,51 @@
|
||||||
|
#ifndef Timers_ADI
|
||||||
|
#define Timers_ADI 1
|
||||||
|
|
||||||
|
#define TIMERCOUNT 40
|
||||||
|
int32_t Timers[TIMERCOUNT]; // -1 is off, >= 0 is on
|
||||||
|
|
||||||
|
#define RELAYSERVICE 1
|
||||||
|
#define NTP_TIMER 2
|
||||||
|
#define TENSECOND 3
|
||||||
|
#define COMMSREPLYTIMER 4
|
||||||
|
#define TIMER485 5
|
||||||
|
#define ONEMINUTE 6
|
||||||
|
#define TOUCH_DEBOUNCE 7
|
||||||
|
#define DISPLAYTIMER 8
|
||||||
|
#define WIFISERVICE 9
|
||||||
|
#define GASKETTIMER 10
|
||||||
|
#define SCREENTIMER 11
|
||||||
|
#define PINGTIMER 12
|
||||||
|
#define WIFITIMEOUT 13
|
||||||
|
#define FLOWTIMER 14
|
||||||
|
#define AT200RX 15
|
||||||
|
#define SWITCH5TIMER 16
|
||||||
|
#define WIFIRESPONSETIMER 17
|
||||||
|
#define DOORTRAVELTIMER 18
|
||||||
|
#define HEARTBEAT 19
|
||||||
|
#define OBSTRUCTION 20
|
||||||
|
#define DISPLAYSERVICETIMER 21
|
||||||
|
#define SCREENTIMEOUTTIMER 22
|
||||||
|
#define EXERCISETIMER 23
|
||||||
|
#define AT200DATA 24
|
||||||
|
|
||||||
|
#define MOTOR_TIMER 25
|
||||||
|
|
||||||
|
#define VOLTAGETIMER 26
|
||||||
|
#define LIDARTIMER 27
|
||||||
|
#define BOOTPINTIMER 28
|
||||||
|
#define ISIDLETIMER 29
|
||||||
|
|
||||||
|
#define OLEDBLANKTIMER 30
|
||||||
|
#define OLEDHOLDTIMER 31
|
||||||
|
|
||||||
|
#define BLANKSCREENTIMER 32 // v525
|
||||||
|
|
||||||
|
uint16_t onehundredmstick = 0; // increments every 100ms
|
||||||
|
|
||||||
|
#define OBSTRUCTIONPIN 35
|
||||||
|
uint16_t obstructionCounter = 0;
|
||||||
|
|
||||||
|
#define PARMFETCHTIMER 36
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
|
||||||
|
// tenth second resolution timers
|
||||||
|
|
||||||
|
#include <Ticker.h>
|
||||||
|
#include "Timers_ADI.h"
|
||||||
|
|
||||||
|
Ticker tickerTenths;
|
||||||
|
|
||||||
|
void init_timers(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Interrupt .. Timers
|
||||||
|
|
||||||
|
// ISR setup
|
||||||
|
tickerTenths.attach(0.1, onehundredms); // every 0.1 second
|
||||||
|
|
||||||
|
// obstruction sensor
|
||||||
|
pinMode(OBSTRUCTIONPIN, INPUT_PULLUP);
|
||||||
|
/*
|
||||||
|
attachInterrupt(digitalPinToInterrupt(OBSTRUCTIONPIN), obstructionToggle, RISING);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Setup timers the first time
|
||||||
|
int it;
|
||||||
|
for (it = 0; it < TIMERCOUNT; it++) // init all timers
|
||||||
|
Timers[it] = -1;
|
||||||
|
|
||||||
|
Timers[HEARTBEAT] = 1;
|
||||||
|
Timers[COMMSREPLYTIMER] = 0;
|
||||||
|
Timers[PINGTIMER] = 0;
|
||||||
|
Timers[0] = 0;
|
||||||
|
Timers[RELAYSERVICE] = 5;
|
||||||
|
Timers[TENSECOND] = 1000;
|
||||||
|
Timers[TIMER485] = 0;
|
||||||
|
Timers[ONEMINUTE] = 0; // Screen update timer
|
||||||
|
Timers[WIFISERVICE] = 0; // turn it on
|
||||||
|
Timers[NTP_TIMER] = 200000;
|
||||||
|
Timers[AT200RX] = 0;
|
||||||
|
Timers[OBSTRUCTION] = 1;
|
||||||
|
Timers[DISPLAYSERVICETIMER] = 1;
|
||||||
|
Timers[AT200DATA] = 1;
|
||||||
|
Timers[OLEDHOLDTIMER] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void onehundredms(void)
|
||||||
|
{ // ISR once per onehundredms ticker
|
||||||
|
onehundredmstick++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void timer_update(void) // call every 0.1 sec from mainline
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < TIMERCOUNT; i++) // update timers
|
||||||
|
if (Timers[i] > -1)
|
||||||
|
Timers[i]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void obstructionToggle(void) // interrupt on pin rising
|
||||||
|
{
|
||||||
|
obstructionCounter++;
|
||||||
|
}
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,101 @@
|
||||||
|
|
||||||
|
#include <Update.h>
|
||||||
|
#include "FileLib.h"
|
||||||
|
|
||||||
|
//*******************************************************
|
||||||
|
// perform the actual update from a given stream-
|
||||||
|
//*******************************************************
|
||||||
|
|
||||||
|
void performUpdate(Stream &updateSource, size_t updateSize)
|
||||||
|
{
|
||||||
|
if (Update.begin(updateSize))
|
||||||
|
{
|
||||||
|
size_t written = Update.writeStream(updateSource); // the update happens here
|
||||||
|
if (written == updateSize)
|
||||||
|
{
|
||||||
|
Serial.println("Written : " + String(written) + " successfully");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Update.end())
|
||||||
|
{
|
||||||
|
displayText("OTA done!");
|
||||||
|
if (Update.isFinished())
|
||||||
|
{
|
||||||
|
Serial.println("Update successfully completed. Rebooting.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("Update not finished? Something went wrong!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("Error Occurred. Error #: " + String(Update.getError()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("Not enough space to begin OTA");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//*******************************************************
|
||||||
|
// check given FS for valid update.bin and perform update if available
|
||||||
|
//*******************************************************
|
||||||
|
|
||||||
|
void updateFromFS(void)
|
||||||
|
{
|
||||||
|
FS fs = SD;
|
||||||
|
// kickDog();
|
||||||
|
|
||||||
|
// File updateBin = SD.open("EVO.bin");
|
||||||
|
File updateBin = fs.open("/Update.bin");
|
||||||
|
if (updateBin)
|
||||||
|
{
|
||||||
|
if (updateBin.isDirectory())
|
||||||
|
{
|
||||||
|
Serial.println("Error, Update.bin is not a file");
|
||||||
|
updateBin.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t updateSize = updateBin.size();
|
||||||
|
|
||||||
|
if (updateSize > 0)
|
||||||
|
{
|
||||||
|
Serial.println("Try to start update");
|
||||||
|
displayText("Beginning Update");
|
||||||
|
performUpdate(updateBin, updateSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("Error, file is empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
updateBin.close();
|
||||||
|
|
||||||
|
// whe finished remove the binary from sd card to indicate end of the process
|
||||||
|
// fs.remove("/Update.bin");
|
||||||
|
rebootEspWithReason("Eureka! Success!!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("Could not load Update.bin from sd root");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//*******************************************************
|
||||||
|
//
|
||||||
|
//*******************************************************
|
||||||
|
|
||||||
|
void rebootEspWithReason(String reason)
|
||||||
|
{
|
||||||
|
Serial.println(reason);
|
||||||
|
// digitalWrite(SWITCH5,LOW);
|
||||||
|
delay(1000);
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef Wifi_ADI_h
|
||||||
|
#define Wifi_ADI_h
|
||||||
|
|
||||||
|
#include <WiFi.h>
|
||||||
|
#include <WiFiUdp.h>
|
||||||
|
|
||||||
|
// char ssid[48] = "Production"; // your network SSID (name)
|
||||||
|
// char pass[48] = "78CBC37735"; // your network password
|
||||||
|
// char ssid[48] = "Smith01"; // your network SSID (name)
|
||||||
|
// char pass[48] = "Smith211056"; // your network password
|
||||||
|
|
||||||
|
// char pass[48] = "RenlitaPW2430"; // your network password
|
||||||
|
// char ssid[48] = "RenlitaWiFi"; // your network SSID (name)
|
||||||
|
char ssid[48] = "B6D9Access"; // your network SSID (name)
|
||||||
|
char pass[48] = "080456120173"; // your network password
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Reference in New Issue