From 4173340c6a5648c30a05f916b82c0f70e242de0e Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 17 Jul 2021 15:16:48 +0200 Subject: [PATCH] Add support for CAN bus and Freedom Won Battery Management System by Marius Bezuidenhout (#12651) --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + tasmota/support_features.ino | 12 +++++++----- ...xsns_90_mcp2515.ino => xsns_87_mcp2515.ino} | 18 +++++++++--------- tools/decode-status.py | 4 ++-- 5 files changed, 20 insertions(+), 16 deletions(-) rename tasmota/{xsns_90_mcp2515.ino => xsns_87_mcp2515.ino} (97%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02590a1ce..cfb859cc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ## [9.5.0.3] ### Added - Command ``SetSensor1..127 0|1`` to globally disable individual sensor driver +- Support for CAN bus and Freedom Won Battery Management System by Marius Bezuidenhout (#12651) ## [9.5.0.2] 20210714 ### Added diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 9f28e171f..8eb3fae60 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -110,6 +110,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo - MQTT minimum password length restriction in GUI [#12553](https://github.com/arendst/Tasmota/issues/12553) - Support for Technoline WS2300-15 Anemometer [#12573](https://github.com/arendst/Tasmota/issues/12573) - Support for Telaire T6700 Series CO2 sensor by Alexander Savchenko [#12618](https://github.com/arendst/Tasmota/issues/12618) +- Support for CAN bus and Freedom Won Battery Management System by Marius Bezuidenhout [#12651](https://github.com/arendst/Tasmota/issues/12651) ### Changed - ESP32 core library from v1.0.6 to v1.0.7.1 diff --git a/tasmota/support_features.ino b/tasmota/support_features.ino index fba6b5e6e..5bd902209 100644 --- a/tasmota/support_features.ino +++ b/tasmota/support_features.ino @@ -738,19 +738,21 @@ void ResponseAppendFeatures(void) feature8 |= 0x00000008; // xdrv_52_9_berry.ino #endif #if defined(USE_I2C) && defined(USE_BM8563) - feature8 |= 0x00000010; + feature8 |= 0x00000010; // xdrv_56_BM8563_RTC.ino #endif #if defined(USE_ENERGY_SENSOR) && defined(USE_ENERGY_DUMMY) - feature8 |= 0x00000020; + feature8 |= 0x00000020; // xnrg_20_dummy.ino #endif #if defined(USE_I2C) && defined(USE_AM2320) - feature8 |= 0x00000040; + feature8 |= 0x00000040; // xsns_88_am2320.ino #endif #if defined(USE_I2C) && defined(USE_T67XX) - feature8 |= 0x00000080; + feature8 |= 0x00000080; // xsns_89_t67xx.ino #endif -// feature8 |= 0x00000100; +#if defined(USE_SPI) && defined(USE_MCP2515) + feature8 |= 0x00000100; // xsns_87_mcp2515.ino +#endif // feature8 |= 0x00000200; // feature8 |= 0x00000400; // feature8 |= 0x00000800; diff --git a/tasmota/xsns_90_mcp2515.ino b/tasmota/xsns_87_mcp2515.ino similarity index 97% rename from tasmota/xsns_90_mcp2515.ino rename to tasmota/xsns_87_mcp2515.ino index 8f37063a2..c8bd14a29 100644 --- a/tasmota/xsns_90_mcp2515.ino +++ b/tasmota/xsns_87_mcp2515.ino @@ -1,7 +1,7 @@ /* - xsns_89_mcp2515.ino - MCP2515 CAN bus support for Tasmota + xsns_87_mcp2515.ino - MCP2515 CAN bus support for Tasmota - Copyright (C) 2021 Marius Bezuidenhout + Copyright (C) 2021 Marius Bezuidenhout This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,9 +34,7 @@ * VCC Vin/5V \*********************************************************************************************/ -#define XSNS_90 90 - -#include "mcp2515.h" +#define XSNS_87 87 // set defaults if not defined #ifndef MCP2515_BITRATE @@ -67,6 +65,8 @@ #endif // MCP2515_BMS_FREEDWON #endif // MCP2515_BMS_CLIENT +#include "mcp2515.h" + #ifdef MCP2515_BMS_CLIENT struct BMS_Struct { uint16_t stateOfCharge; @@ -100,7 +100,7 @@ void MCP2515_Init(void) { AddLog(LOG_LEVEL_ERROR, PSTR("MCP2515: Failed to set module bitrate")); mcp2515_init_status = 0; } - + if (mcp2515_init_status && MCP2515::ERROR_OK != mcp2515->setNormalMode()) { AddLog(LOG_LEVEL_ERROR, PSTR("MCP2515: Failed to set normal mode")); mcp2515_init_status = 0; @@ -221,8 +221,8 @@ void MCP2515_Show(bool Json) { if (lastFrameRecv > 0 && TasmotaGlobal.uptime - lastFrameRecv <= MCP2515_TIMEOUT ) { #ifdef MCP2515_BMS_CLIENT ResponseAppend_P(PSTR(",\"MCP2515\":{\"SOC\":%d,\"SOH\":%d}"), \ - bms.stateOfCharge, - bms.stateOfHealth + bms.stateOfCharge, + bms.stateOfHealth ); #endif // MCP2515_BMS_CLIENT } @@ -245,7 +245,7 @@ void MCP2515_Show(bool Json) { * Interface \*********************************************************************************************/ -bool Xsns90(uint8_t function) +bool Xsns87(uint8_t function) { bool result = false; diff --git a/tools/decode-status.py b/tools/decode-status.py index 00b1e7aee..ac78e579d 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -255,7 +255,7 @@ a_features = [[ ],[ "USE_MPU_ACCEL","USE_TFMINIPLUS","USE_CSE7761","USE_BERRY", "USE_BM8563","USE_ENERGY_DUMMY","USE_AM2320","USE_T67XX", - "","","","", + "USE_MCP2515","","","", "","","","", "","","","", "","","","", @@ -288,7 +288,7 @@ else: obj = json.load(fp) def StartDecode(): - print ("\n*** decode-status.py v20210713 by Theo Arends and Jacek Ziolkowski ***") + print ("\n*** decode-status.py v20210717 by Theo Arends and Jacek Ziolkowski ***") # print("Decoding\n{}".format(obj))