Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sergey Remizov
BluetoothHeater
Commits
98612977
Commit
98612977
authored
5 years ago
by
Ray Jones
Browse files
Options
Download
Email Patches
Plain Diff
Suite of minor bug fixes and annoyances - now Afterburner for AP and BT server names :-)
OTA was not rebooting after AP only update
parent
b47a4606
master
DS18B20_trials
MQTTstore
V3.1.3
V3.1.2
V3.1.1
V3.1.0
V3.0.3
V3.0.3a
V3.0.2
V3.0.1
V2.3.6n
V2.3.6c
V2.3.5
V2.3.4
V2.3.3
V2.3.2
V2.3.1
V2.3.0
V2.2.3
JustinMods
No related merge requests found
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
Arduino/BTCDieselHeater/BTCDieselHeater.ino
+8
-4
Arduino/BTCDieselHeater/BTCDieselHeater.ino
Arduino/BTCDieselHeater/src/Bluetooth/BluetoothHC05.cpp
+5
-2
Arduino/BTCDieselHeater/src/Bluetooth/BluetoothHC05.cpp
Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp
+19
-0
Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp
Arduino/BTCDieselHeater/src/OLED/ScreenManager.h
+1
-0
Arduino/BTCDieselHeater/src/OLED/ScreenManager.h
Arduino/BTCDieselHeater/src/OLED/ThermostatModeScreen.cpp
+28
-6
Arduino/BTCDieselHeater/src/OLED/ThermostatModeScreen.cpp
Arduino/BTCDieselHeater/src/OLED/VersionInfoScreen.cpp
+1
-2
Arduino/BTCDieselHeater/src/OLED/VersionInfoScreen.cpp
Arduino/BTCDieselHeater/src/Utility/NVStorage.cpp
+4
-4
Arduino/BTCDieselHeater/src/Utility/NVStorage.cpp
Arduino/BTCDieselHeater/src/Utility/NVStorage.h
+5
-0
Arduino/BTCDieselHeater/src/Utility/NVStorage.h
Arduino/BTCDieselHeater/src/WiFi/BTCWifi.cpp
+2
-1
Arduino/BTCDieselHeater/src/WiFi/BTCWifi.cpp
Arduino/BTCDieselHeater/src/WiFi/BTCota.cpp
+20
-3
Arduino/BTCDieselHeater/src/WiFi/BTCota.cpp
with
93 additions
and
22 deletions
+93
-22
Arduino/BTCDieselHeater/BTCDieselHeater.ino
View file @
98612977
...
...
@@ -116,8 +116,8 @@
#define RX_DATA_TIMOUT 50
const
int
FirmwareRevision
=
22
;
const
int
FirmwareSubRevision
=
2
;
const
char
*
FirmwareDate
=
"
9
May 2019"
;
const
int
FirmwareSubRevision
=
3
;
const
char
*
FirmwareDate
=
"
11
May 2019"
;
#ifdef ESP32
...
...
@@ -560,8 +560,8 @@ void loop()
// Detect the possible start of a new frame sequence from an OEM controller
// This will be the first activity for considerable period on the blue wire
// The heater always responds to a controller frame, but otherwise never by itself
//
if(RxTimeElapsed >= 970) {
if
(
RxTimeElapsed
>=
NVstore
.
getFrameRate
()
)
{
if
(
RxTimeElapsed
>=
(
NVstore
.
getFrameRate
()
-
60
))
{
// compensate for the time spent just doing things in this state machine
// have not seen any receive data for a second.
// OEM controller is probably not connected.
// Skip state machine immediately to BTC_Tx, sending our own settings.
...
...
@@ -1325,3 +1325,7 @@ int getBoardRevision()
return
BoardRevision
;
}
void
ShowOTAScreen
(
int
percent
)
{
ScreenManager
.
showOTAMessage
(
percent
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/Bluetooth/BluetoothHC05.cpp
View file @
98612977
...
...
@@ -107,8 +107,8 @@ CBluetoothHC05::begin()
DebugPort
.
println
(
"HC-05 found"
);
DebugPort
.
print
(
" Setting Name to
\"
Diesel Heat
er
\"
... "
);
if
(
!
ATCommand
(
"AT+NAME=
\"
Diesel Heat
er
\"\r\n
"
))
{
DebugPort
.
print
(
" Setting Name to
\"
Afterburn
er
\"
... "
);
if
(
!
ATCommand
(
"AT+NAME=
\"
Afterburn
er
\"\r\n
"
))
{
DebugPort
.
println
(
"FAILED"
);
}
else
{
...
...
@@ -145,6 +145,8 @@ CBluetoothHC05::begin()
else {
DebugPort.println("OK");
}*/
flush
();
delay
(
100
);
openSerial
(
9600
);
// leave HC-05 command mode, return to data mode
...
...
@@ -231,6 +233,7 @@ CBluetoothHC05::openSerial(int baudrate)
bool
CBluetoothHC05
::
ATCommand
(
const
char
*
cmd
)
{
flush
();
// ensure response is for *this* command!
HC05_SerialPort
.
print
(
cmd
);
char
RxBuffer
[
16
];
memset
(
RxBuffer
,
0
,
16
);
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp
View file @
98612977
...
...
@@ -490,6 +490,25 @@ CScreenManager::showRebootMsg(const char* content[2], long delayTime)
_dim
(
false
);
}
void
CScreenManager
::
showOTAMessage
(
int
percent
)
{
static
int
prevPercent
=
-
1
;
if
(
percent
!=
prevPercent
)
{
_pDisplay
->
clearDisplay
();
_pDisplay
->
setCursor
(
64
,
22
);
_pDisplay
->
printCentreJustified
(
"OTA update active"
);
if
(
percent
)
{
char
msg
[
16
];
sprintf
(
msg
,
"%d%%"
,
percent
);
_pDisplay
->
setCursor
(
64
,
32
);
_pDisplay
->
printCentreJustified
(
msg
);
}
prevPercent
=
percent
;
_pDisplay
->
display
();
}
}
void
CScreenManager
::
_dim
(
bool
state
)
{
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/OLED/ScreenManager.h
View file @
98612977
...
...
@@ -66,6 +66,7 @@ public:
void
reqUpdate
();
void
selectMenu
(
eUIMenuSets
menuset
,
int
specific
=
-
1
);
// use to select loop menus, including the root or branches
void
showRebootMsg
(
const
char
*
content
[
2
],
long
delayTime
);
void
showOTAMessage
(
int
percent
);
};
#endif // __SCREEN_MANAGER_H__
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/OLED/ThermostatModeScreen.cpp
View file @
98612977
...
...
@@ -25,6 +25,7 @@
#include "../Protocol/helpers.h"
#include "../Utility/UtilClasses.h"
#include "fonts/Icons.h"
#include "../Utility/NVStorage.h"
///////////////////////////////////////////////////////////////////////////
...
...
@@ -38,7 +39,7 @@
static
const
int
Line3
=
14
;
static
const
int
Line2
=
27
;
static
const
int
Line1
=
40
;
static
const
int
Column
=
5
0
;
static
const
int
Column
=
4
0
;
CThermostatModeScreen
::
CThermostatModeScreen
(
C128x64_OLED
&
display
,
CScreenManager
&
mgr
)
:
CPasswordScreen
(
display
,
mgr
)
{
...
...
@@ -81,8 +82,15 @@ CThermostatModeScreen::show()
}
else
{
_printInverted
(
_display
.
xCentre
(),
0
,
" Thermostat Mode "
,
true
,
eCentreJustify
);
_display
.
drawBitmap
(
10
,
14
,
thermostatIcon
,
thermostatWidth
,
thermostatHeight
,
WHITE
);
sprintf
(
msg
,
"%.1f
\367
C"
,
_window
);
// \367 is octal for Adafruit degree symbol
_display
.
drawBitmap
(
3
,
14
,
thermostatIcon
,
thermostatWidth
,
thermostatHeight
,
WHITE
);
float
fTemp
=
_window
;
if
(
NVstore
.
getDegFMode
())
{
fTemp
=
fTemp
*
9
/
5
;
sprintf
(
msg
,
"%.1f
\367
F"
,
fTemp
);
}
else
{
sprintf
(
msg
,
"%.1f
\367
C"
,
fTemp
);
}
_printMenuText
(
Column
,
Line2
,
msg
,
_rowSel
==
3
);
switch
(
_thermoMode
)
{
case
1
:
...
...
@@ -96,19 +104,33 @@ CThermostatModeScreen::show()
break
;
}
if
(
_cyclicMode
.
isEnabled
())
{
sprintf
(
msg
,
"> %d
\367
C"
,
_cyclicMode
.
Stop
+
1
);
// \367 is octal for Adafruit degree symbol
float
fTemp
=
_cyclicMode
.
Stop
+
1
;
if
(
NVstore
.
getDegFMode
())
{
fTemp
=
fTemp
*
9
/
5
;
sprintf
(
msg
,
"
\352
>%.0f
\367
F"
,
fTemp
);
}
else
{
sprintf
(
msg
,
"
\352
>%.0f
\367
C"
,
fTemp
);
}
}
else
{
strcpy
(
msg
,
"OFF"
);
}
_printMenuText
(
Column
,
Line1
,
msg
,
_rowSel
==
1
);
if
(
_cyclicMode
.
isEnabled
())
{
sprintf
(
msg
,
"< %d
\367
C"
,
_cyclicMode
.
Start
);
// \367 is octal for Adafruit degree symbol
float
fTemp
=
_cyclicMode
.
Start
;
if
(
NVstore
.
getDegFMode
())
{
fTemp
=
fTemp
*
9
/
5
;
sprintf
(
msg
,
"
\352
<%.0f
\367
F"
,
fTemp
);
}
else
{
sprintf
(
msg
,
"
\352
<%.0f
\367
C"
,
fTemp
);
}
}
else
{
strcpy
(
msg
,
""
);
}
_printMenuText
(
Column
+
37
,
Line1
,
msg
,
_rowSel
==
2
);
_printMenuText
(
Column
+
42
,
Line1
,
msg
,
_rowSel
==
2
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/OLED/VersionInfoScreen.cpp
View file @
98612977
...
...
@@ -55,8 +55,7 @@ CVersionInfoScreen::show()
_printInverted
(
_display
.
xCentre
(),
0
,
" Version Information "
,
true
,
eCentreJustify
);
_display
.
drawBitmap
(
10
,
11
,
firmwareIcon
,
firmwareWidth
,
firmwareHeight
,
WHITE
);
sprintf
(
msg
,
"V%.3f"
,
getVersion
());
_printMenuText
(
43
,
14
,
msg
);
_printMenuText
(
43
,
14
,
getVersionStr
());
_printMenuText
(
43
,
25
,
getVersionDate
());
_display
.
drawBitmap
(
20
,
34
,
hardwareIcon
,
hardwareWidth
,
hardwareHeight
,
WHITE
);
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/Utility/NVStorage.cpp
View file @
98612977
...
...
@@ -378,7 +378,7 @@ CHeaterStorage::setHomeMenu(sHomeMenuActions val)
///////////////////////////////////////////////////////////////////////////////////////
// ESP32
//
#ifdef ESP32
//
#ifdef ESP32
CESP32HeaterStorage
::
CESP32HeaterStorage
()
{
...
...
@@ -521,8 +521,8 @@ CESP32HeaterStorage::saveUI()
preferences
.
putUChar
(
"thermoMethod"
,
_calValues
.
Options
.
ThermostatMethod
);
preferences
.
putUChar
(
"enableWifi"
,
_calValues
.
Options
.
enableWifi
);
preferences
.
putUChar
(
"enableOTA"
,
_calValues
.
Options
.
enableOTA
);
preferences
.
put
U
Char
(
"cyclicStop"
,
_calValues
.
Options
.
cyclic
.
Stop
);
preferences
.
put
U
Char
(
"cyclicStart"
,
_calValues
.
Options
.
cyclic
.
Start
);
preferences
.
putChar
(
"cyclicStop"
,
_calValues
.
Options
.
cyclic
.
Stop
);
preferences
.
putChar
(
"cyclicStart"
,
_calValues
.
Options
.
cyclic
.
Start
);
preferences
.
putUChar
(
"GPIOinMode"
,
_calValues
.
Options
.
GPIOinMode
);
preferences
.
putUChar
(
"GPIOoutMode"
,
_calValues
.
Options
.
GPIOoutMode
);
preferences
.
putUChar
(
"GPIOalgMode"
,
_calValues
.
Options
.
GPIOalgMode
);
...
...
@@ -631,4 +631,4 @@ bool s32inBounds(long test, long minLim, long maxLim)
}
#endif // ESP32
\ No newline at end of file
//#endif // ESP32
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/Utility/NVStorage.h
View file @
98612977
...
...
@@ -96,6 +96,11 @@ struct sCyclicThermostat {
bool
isEnabled
()
const
{
return
Stop
!=
0
;
}
sCyclicThermostat
&
operator
=
(
const
sCyclicThermostat
&
rhs
)
{
Stop
=
rhs
.
Stop
;
Start
=
rhs
.
Start
;
return
*
this
;
}
};
struct
sBTCoptions
{
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/WiFi/BTCWifi.cpp
View file @
98612977
...
...
@@ -65,7 +65,7 @@ bool initWifi(int initpin,const char *failedssid, const char *failedpassword)
DebugPort
.
print
(
" AP MAC address: "
);
DebugPort
.
println
(
MACstr
[
1
]);
char
APname
[
32
];
sprintf
(
APname
,
"%s
-%02X%02X
"
,
failedssid
,
MAC
[
4
],
MAC
[
5
]
);
sprintf
(
APname
,
"%s"
,
failedssid
);
//reset settings - wipe credentials for testing
// wm.resetSettings();
...
...
@@ -106,6 +106,7 @@ bool initWifi(int initpin,const char *failedssid, const char *failedpassword)
if
(
!
res
)
{
// failed STA mode
DebugPort
.
println
(
"WiFimanager failed STA connection. Setting up AP..."
);
WiFi
.
disconnect
();
// apparently needed for AP only OTA to reboot properly!!!
}
else
{
// runs through here if STA connected OK
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/WiFi/BTCota.cpp
View file @
98612977
...
...
@@ -24,6 +24,17 @@
#if USE_SPIFFS == 1
#include <SPIFFS.h>
#endif
extern
void
ShowOTAScreen
(
int
percent
=
0
);
#include <esp_int_wdt.h>
#include <esp_task_wdt.h>
void
hard_restart
()
{
esp_task_wdt_init
(
1
,
true
);
esp_task_wdt_add
(
NULL
);
while
(
true
);
}
void
initOTA
(){
// ArduinoOTA.setHostname("myesp32");
...
...
@@ -41,16 +52,21 @@ void initOTA(){
SPIFFS
.
end
();
DebugPort
.
println
(
"Start updating "
+
type
);
DebugPort
.
handle
();
// keep telnet spy alive
ShowOTAScreen
();
})
.
onEnd
([]()
{
DebugPort
.
println
(
"
\n
End"
);
DebugPort
.
handle
();
// keep telnet spy alive
DebugPort
.
end
();
// force graceful close of telnetspy - ensures a client will reconnect cleanly
ESP
.
restart
();
delay
(
100
);
//
DebugPort.end(); // force graceful close of telnetspy - ensures a client will reconnect cleanly
})
.
onProgress
([](
unsigned
int
progress
,
unsigned
int
total
)
{
DebugPort
.
printf
(
"Progress: %u%%
\r
"
,
(
progress
/
(
total
/
100
)));
int
percent
=
(
progress
/
(
total
/
100
));
DebugPort
.
printf
(
"Progress: %u%%
\r
"
,
percent
);
DebugPort
.
handle
();
// keep telnet spy alive
ShowOTAScreen
(
percent
);
})
.
onError
([](
ota_error_t
error
)
{
DebugPort
.
printf
(
"Error[%u]: "
,
error
);
...
...
@@ -59,6 +75,7 @@ void initOTA(){
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"
);
DebugPort
.
handle
();
// keep telnet spy alive
});
ArduinoOTA
.
begin
();
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help