Merged remote-tracking branch 'remotes/origin/ESP32HTTP'

Conflict resolved in
	Arduino/BTCDieselHeater/BTCDieselHeater.ino
This commit is contained in:
rljonesau 2018-11-07 19:56:47 +11:00
commit dc8e1940f2
15 changed files with 957 additions and 21 deletions

Binary file not shown.

View file

@ -1,6 +1,6 @@
{
"board": "esp32:esp32:esp32",
"port": "192.168.0.101",
"port": "192.168.0.108",
"sketch": "BTCDieselHeater.ino",
"output": "..\\build",
"configuration": "PSRAM=disabled,PartitionScheme=default,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none"

View file

@ -1,4 +1,3 @@
//
/*
Chinese Heater Half Duplex Serial Data Sending Tool
@ -64,6 +63,7 @@
This example code is in the public domain.
*/
#include "BTCWebServer.h"
#include "Protocol.h"
#include "TxManage.h"
#include "pins.h"
@ -72,14 +72,10 @@
#include "SmartError.h"
#include "BTCWifi.h"
#include "BTCConfig.h"
#include "UtilClasses.h"
#define HOST_NAME "remotedebug-sample"
#include "BTCota.h"
#define HOST_NAME "BTCHeater"
#include "BTCWebServer.h"
#define FAILEDSSID "BTCESP32"
#define FAILEDPASSWORD "thereisnospoon"
@ -177,9 +173,9 @@ void setup() {
initWifi(WiFi_TriggerPin, FAILEDSSID, FAILEDPASSWORD);
initOTA();
pinMode(ListenOnlyPin, INPUT_PULLUP); // pin to enable passive mode
initWebServer();
pinMode(ListenOnlyPin, INPUT_PULLUP); // pin to enable passive mode
pinMode(LED_Pin, OUTPUT); // On board LED indicator
digitalWrite(LED_Pin, LOW);
@ -231,6 +227,7 @@ void loop()
unsigned long timenow = millis();
doWiFiManager();
DoOTA();
doWebServer();
// check for test commands received from PC Over USB
if(DebugPort.available()) {

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="BTCDieselHeater.ino" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="__vm\.BTCDieselHeater.vsarduino.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BluetoothAbstract.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BluetoothESP32.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BluetoothHC05.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BTCConfig.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BTCota.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BTCWifi.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="debugport.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="NVStorage.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pins.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Protocol.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SmartError.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TxManage.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BTCWebServer.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="BluetoothESP32.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BluetoothHC05.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BTCota.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BTCWifi.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NVStorage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Protocol.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SmartError.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TxManage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BTCWebServer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View file

@ -0,0 +1,71 @@
//
//
//
#include "BTCWebServer.h"
#include "DebugPort.h"
#include "TxManage.h"
WebServer server(80);
const int led = 13;
void handleRoot() {
digitalWrite(led, 1);
server.send(200, "text/plain", "Chnage URL to /on to poweron heater... /off to poweroff");
digitalWrite(led, 0);
}
void handleNotFound() {
digitalWrite(led, 1);
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET) ? "GET" : "POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
digitalWrite(led, 0);
}
void initWebServer(void) {
if (MDNS.begin("BTCHeater")) {
DebugPort.println("MDNS responder started");
}
server.on("/on", webturnOn);
server.on("/off", webturnOff);
server.on("/", handleRoot);
server.on("/inline", []() {
server.send(200, "text/plain", "this works as well");
});
server.onNotFound(handleNotFound);
server.begin();
DebugPort.println("HTTP server started");
}
void doWebServer(void) {
server.handleClient();
}
void webturnOn() {
TxManage.queueOnRequest();
server.send(200, "text/plain", "Heater Turning on");
}
void webturnOff() {
TxManage.queueOffRequest();
server.send(200, "text/plan", "Turning off heater");
}

View file

@ -0,0 +1,25 @@
// BTCWebServer.h
#ifndef _BTCWEBSERVER_h
#define _BTCWEBSERVER_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
#include "BTCWifi.h"
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#endif
void initWebServer();
void doWebServer();
void handleRoot();
void handleNotFound();
void webturnOn();
void webturnOff();

View file

@ -28,7 +28,7 @@ void initWifi(int initpin,const char *failedssid, const char *failedpassword)
// if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect())
// then goes into a blocking loop awaiting configuration and will return success result
wm.setConfigPortalTimeout(20);
wm.setConfigPortalBlocking(true);
wm.setConfigPortalBlocking(false);
res = wm.autoConnect(); // auto generated AP name from chipid

View file

@ -1,5 +1,5 @@
#include "BTCota.h"
#include "debugport.h"
void initOTA(){
// ArduinoOTA.setHostname("myesp32");
@ -14,21 +14,21 @@ void initOTA(){
type = "filesystem";
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Start updating " + type);
DebugPort.println("Start updating " + type);
})
.onEnd([]() {
Serial.println("\nEnd");
DebugPort.println("\nEnd");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
DebugPort.printf("Progress: %u%%\r", (progress / (total / 100)));
})
.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
DebugPort.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) DebugPort.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) DebugPort.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) DebugPort.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) DebugPort.println("Receive Failed");
else if (error == OTA_END_ERROR) DebugPort.println("End Failed");
});
ArduinoOTA.begin();

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,111 @@
/*
Editor: https://www.visualmicro.com/
visual micro and the arduino ide ignore this code during compilation. this code is automatically maintained by visualmicro, manual changes to this file will be overwritten
the contents of the Visual Micro sketch sub folder can be deleted prior to publishing a project
all non-arduino files created by visual micro and all visual studio project or solution files can be freely deleted and are not required to compile a sketch (do not delete your own code!).
note: debugger breakpoints are stored in '.sln' or '.asln' files, knowledge of last uploaded breakpoints is stored in the upload.vmps.xml file. Both files are required to continue a previous debug session without needing to compile and upload again
Hardware: DOIT ESP32 DEVKIT V1, Platform=esp32, Package=esp32
*/
#if defined(_VMICRO_INTELLISENSE)
#ifndef _VSARDUINO_H_
#define _VSARDUINO_H_
#define __ESP32_ESp32__
#define __ESP32_ESP32__
#define ESP_PLATFORM
#define HAVE_CONFIG_H
#define F_CPU 240000000L
#define ARDUINO 10805
#define ARDUINO_ESP32_DEV
#define ARDUINO_ARCH_ESP32
#define ESP32
#define CORE_DEBUG_LEVEL 0
#define __cplusplus 201103L
#undef __cplusplus
#define __cplusplus 201103L
#define __STDC__
#define __ARM__
#define __arm__
#define __inline__
#define __asm__(x)
#define __asm__
#define __extension__
#define __ATTR_PURE__
#define __ATTR_CONST__
#define __volatile__
#define __ASM
#define __INLINE
#define __attribute__(noinline)
//#define _STD_BEGIN
//#define EMIT
#define WARNING
#define _Lockit
#define __CLR_OR_THIS_CALL
#define C4005
#define _NEW
//
//typedef int uint8_t;
//#define __ARMCC_VERSION 400678
//#define PROGMEM
//#define string_literal
//
//#define prog_void
//#define PGM_VOID_P int
//
typedef int _read;
typedef int _seek;
typedef int _write;
typedef int _close;
typedef int __cleanup;
//#define inline
#define __builtin_clz
#define __builtin_clzl
#define __builtin_clzll
#define __builtin_labs
#define __builtin_va_list
typedef int __gnuc_va_list;
#define __ATOMIC_ACQ_REL
#define __CHAR_BIT__
#define _EXFUN()
typedef unsigned char byte;
extern "C" void __cxa_pure_virtual() {;}
typedef long __INTPTR_TYPE__ ;
typedef long __UINTPTR_TYPE__ ;
typedef long __SIZE_TYPE__ ;
typedef long __PTRDIFF_TYPE__;
#include <arduino.h>
#include <pins_arduino.h>
//#include "..\generic\Common.h"
//#include "..\generic\pins_arduino.h"
//#undef F
//#define F(string_literal) ((const PROGMEM char *)(string_literal))
//#undef PSTR
//#define PSTR(string_literal) ((const PROGMEM char *)(string_literal))
//current vc++ does not understand this syntax so use older arduino example for intellisense
//todo:move to the new clang/gcc project types.
#define interrupts() sei()
#define noInterrupts() cli()
#include "BTCDieselHeater.ino"
#endif
#endif

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long