Skip to content

Commit

Permalink
Examples: Added platformio configuration for the Monitor and Bridge.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaroslav Solanic authored and jarosolanic committed Aug 30, 2024
1 parent 5803390 commit e4f672e
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
examples/**/.pio
examples/**/.vscode/
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* Additionally, it can reset and program the ATmega328P if corresponding connections are available
*/

#include "ESPTelnet.h"
#include <ESPTelnet.h>
#include "P1P2_Config.h"
#include "P1P2_NetworkParams.h"
#include "P1P2_HomeAssistant.h"
Expand Down Expand Up @@ -670,6 +670,17 @@ int16_t mqttBufferReadChar (void) {
return c;
}

// forwad declarations
void saveRebootReason(const byte x);
byte rebootReason(void);
void saveRTC(void);
void process_for_mqtt(byte* rb, int n);
void printWelcome(void);
void reportState(void);
void configTZ (void);
void buildMqttTopic();


uint16_t snprintfLength = 0;
uint16_t snprintfLengthMax = 0;

Expand Down
10 changes: 8 additions & 2 deletions examples/P1P2MQTT-bridge/P1P2_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,18 @@
#define SAVEPACKETS
// to save memory to avoid ESP instability (until P1P2MQTT is released): do not #define SAVESCHEDULE // format of schedules will change to JSON format in P1P2MQTT

#define WELCOMESTRING "P1P2MQTT bridge v0.9.54rc1"
#define HA_SW "0.9.54rc1"
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define VERSIONSTRING(major, minor, patch)

#define SW_PATCH_VERSION 54
#define SW_MINOR_VERSION 9
#define SW_MAJOR_VERSION 0

#define VERSIONSTRING TOSTRING(SW_MAJOR_VERSION) "." TOSTRING(SW_MINOR_VERSION) "." TOSTRING(SW_PATCH_VERSION) "rc1"
#define WELCOMESTRING "P1P2MQTT bridge v" VERSIONSTRING
#define HA_SW VERSIONSTRING

#define ARDUINO_OTA
#define WEBSERVER // adds webserver to update firmware of ESP
#define AVRISP // enables flashing ATmega by ESP on P1P2-ESP-Interface
Expand Down
2 changes: 2 additions & 0 deletions examples/P1P2MQTT-bridge/extra_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Import("env")
env.Replace(PROGNAME="P1P2MQTT_v%s-%s" % (env.GetProjectOption("custom_version"), env["PIOENV"]))
54 changes: 54 additions & 0 deletions examples/P1P2MQTT-bridge/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
src_dir=.

[env]
platform = espressif8266
board = esp12e
framework = arduino
platform_packages = framework-arduinoespressif8266 @ file://../../OSS-dependencies/Arduino_BSP/esp8266-3.0.2-modified.zip
lib_ignore = me-no-dev/ESPAsyncTCP
lib_deps =
file://../../OSS-dependencies/libraries/ESPAsyncTCP-master-modified.zip
bblanchon/ArduinoJson@~6.11.3
tzapu/WiFiManager@~2.0.17
marvinroger/AsyncMqttClient@~0.9.0
https://github.com/LennartHennigs/ESPTelnet.git#2.0.0
; lennarthennigs/ESP Telnet@~2.1.1

build_flags = -w -D P1P2MQTT_BRIDGE -D VERSION=${this.custom_version}
extra_scripts = pre:extra_script.py
custom_version = 0.9.54

[env:Daikin-E]
build_flags = -D E_SERIES ${env.build_flags}

[env:Daikin-F]
build_flags = -D F_SERIES ${env.build_flags}

[env:Hitachi]
build_flags = -D H_SERIES ${env.build_flags}

[env:Mitsubishi]
build_flags = -D M_SERIES ${env.build_flags}

[env:MHI]
build_flags = -D S_SERIES ${env.build_flags}

[env:Toshiba]
build_flags = -D T_SERIES ${env.build_flags}

[env:Sanyo]
build_flags = -D S_SERIES ${env.build_flags}

[env:Panasonic]
build_flags = -D P_SERIES ${env.build_flags}
8 changes: 7 additions & 1 deletion examples/P1P2Monitor/P1P2Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,17 @@
#define SERIAL_MAGICSTRING "1P2P" // Serial input line should start with SERIAL_MAGICSTRING, otherwise input line is ignored
#endif /* F_CPU */

#define WELCOMESTRING "P1P2Monitor v0.9.54"
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define VERSIONSTRING(major, minor, patch)

#define SW_PATCH_VERSION 54
#define SW_MINOR_VERSION 9
#define SW_MAJOR_VERSION 0

#define VERSIONSTRING TOSTRING(SW_MAJOR_VERSION) "." TOSTRING(SW_MINOR_VERSION) "." TOSTRING(SW_PATCH_VERSION) "rc1"
#define WELCOMESTRING "P1P2Monitor v" VERSIONSTRING

#ifdef MHI_SERIES
#define INIT_MHI_FORMAT 1 // 1 (default) for conversion from/to 3-bit-per-byte format with check-sum, 0 for raw data
#endif /* MHI_SERIES */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ void setup() {

// scanint and scanhex are used to save dynamic memory usage in main loop
int scanint(char* s, uint16_t &b) {
return sscanf(s,"%d",&b);
return sscanf(s,"%hu",&b);
}

int scanhex(char* s, uint16_t &b) {
Expand Down
2 changes: 2 additions & 0 deletions examples/P1P2Monitor/extra_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Import("env")
env.Replace(PROGNAME="P1P2Monitor_v%s-%s" % (env.GetProjectOption("custom_version"), env["PIOENV"]))
49 changes: 49 additions & 0 deletions examples/P1P2Monitor/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
src_dir=.

[env]
platform = atmelavr
platform_packages = framework-arduino-avr-minicore@2.1.3
framework = arduino
board = ATmega328P
; board = uno

lib_deps = symlink://../../

build_flags = -Wall -D VERSION=${this.custom_version}
extra_scripts = pre:extra_script.py
custom_version = 0.9.54

[env:Daikin-E]
build_flags = -D E_SERIES ${env.build_flags}

[env:Daikin-F]
build_flags = -D F_SERIES ${env.build_flags}

[env:Hitachi]
build_flags = -D H_SERIES ${env.build_flags}

[env:Mitsubishi]
build_flags = -D M_SERIES ${env.build_flags}

[env:MHI]
build_flags = -D S_SERIES ${env.build_flags}

[env:Toshiba]
build_flags = -D T_SERIES ${env.build_flags}

[env:Sanyo]
build_flags = -D S_SERIES ${env.build_flags}

[env:Panasonic]
build_flags = -D P_SERIES ${env.build_flags}

0 comments on commit e4f672e

Please sign in to comment.