mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
add command system/fuse/mfg, board E32V2.2, check systemvolatage >2.6V
This commit is contained in:
@@ -259,7 +259,7 @@ export const BOARD_PROFILES: BoardProfiles = {
|
|||||||
S32S3: 'BBQKees Gateway S3',
|
S32S3: 'BBQKees Gateway S3',
|
||||||
E32: 'BBQKees Gateway E32',
|
E32: 'BBQKees Gateway E32',
|
||||||
E32V2: 'BBQKees Gateway E32 V2',
|
E32V2: 'BBQKees Gateway E32 V2',
|
||||||
E32V3: 'BBQKees Gateway E32 V3',
|
E32V2_2: 'BBQKees Gateway E32 V2.2',
|
||||||
NODEMCU: 'NodeMCU 32S',
|
NODEMCU: 'NodeMCU 32S',
|
||||||
'MH-ET': 'MH-ET Live D1 Mini',
|
'MH-ET': 'MH-ET Live D1 Mini',
|
||||||
LOLIN: 'Lolin D32',
|
LOLIN: 'Lolin D32',
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ namespace emsesp {
|
|||||||
uuid::log::Logger AnalogSensor::logger_{F_(analogsensor), uuid::log::Facility::DAEMON};
|
uuid::log::Logger AnalogSensor::logger_{F_(analogsensor), uuid::log::Facility::DAEMON};
|
||||||
|
|
||||||
void AnalogSensor::start(const bool factory_settings) {
|
void AnalogSensor::start(const bool factory_settings) {
|
||||||
// if (factory_settings && EMSESP::nvs_.getString("boot").equals("E32V3") && EMSESP::nvs_.getString("hwrevision").equals("3.0")) {
|
// if (factory_settings && EMSESP::nvs_.getString("boot").equals("E32V2_2") && EMSESP::nvs_.getString("hwrevision").equals("3.0")) {
|
||||||
if (factory_settings && analogReadMilliVolts(39) > 800) { // core voltage > 3V
|
if (factory_settings && analogReadMilliVolts(39) > 700) { // core voltage > 2.6V
|
||||||
EMSESP::webCustomizationService.update([&](WebCustomization & settings) {
|
EMSESP::webCustomizationService.update([&](WebCustomization & settings) {
|
||||||
auto newSensor = AnalogCustomization();
|
auto newSensor = AnalogCustomization();
|
||||||
newSensor.gpio = 39;
|
newSensor.gpio = 39;
|
||||||
@@ -35,8 +35,8 @@ void AnalogSensor::start(const bool factory_settings) {
|
|||||||
newSensor.uom = DeviceValueUOM::VOLTS;
|
newSensor.uom = DeviceValueUOM::VOLTS;
|
||||||
newSensor.type = AnalogType::ADC;
|
newSensor.type = AnalogType::ADC;
|
||||||
settings.analogCustomizations.push_back(newSensor);
|
settings.analogCustomizations.push_back(newSensor);
|
||||||
newSensor.gpio = 36;
|
newSensor.gpio = 36;
|
||||||
newSensor.name = "supply_voltage";
|
newSensor.name = "supply_voltage";
|
||||||
newSensor.factor = 0.017; // Divider 24k - 1,5k
|
newSensor.factor = 0.017; // Divider 24k - 1,5k
|
||||||
settings.analogCustomizations.push_back(newSensor);
|
settings.analogCustomizations.push_back(newSensor);
|
||||||
return StateUpdateResult::CHANGED; // persist the change
|
return StateUpdateResult::CHANGED; // persist the change
|
||||||
|
|||||||
@@ -524,7 +524,12 @@ bool Helpers::value2number(const char * value, int & value_i, const int min, con
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_i = atoi(value);
|
if (strlen(value) > 2 && value[0] == '0' && value[1] == 'x') {
|
||||||
|
value_i = hextoint(value);
|
||||||
|
} else {
|
||||||
|
value_i = atoi(value);
|
||||||
|
}
|
||||||
|
|
||||||
if (value_i >= min && value_i <= max) {
|
if (value_i >= min && value_i <= max) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,8 @@
|
|||||||
|
|
||||||
#include <HTTPClient.h>
|
#include <HTTPClient.h>
|
||||||
|
|
||||||
|
#include "esp_efuse.h"
|
||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
// Languages supported. Note: the order is important
|
// Languages supported. Note: the order is important
|
||||||
@@ -1423,6 +1425,13 @@ bool System::command_service(const char * cmd, const char * value) {
|
|||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int n;
|
||||||
|
if (!ok && Helpers::value2number(value, n)) {
|
||||||
|
if (!strcmp(cmd, "fuse/mfg")) { // && esp_efuse_read_reg(EFUSE_BLK3, 0) == 0) {
|
||||||
|
ok = esp_efuse_write_reg(EFUSE_BLK3, 0, (uint32_t)n) == ESP_OK;
|
||||||
|
LOG_INFO("fuse programed with value '%X': %s", n, ok ? "successful" : "failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
LOG_INFO("System command '%s' with value '%s'", cmd, value);
|
LOG_INFO("System command '%s' with value '%s'", cmd, value);
|
||||||
@@ -1877,8 +1886,8 @@ bool System::load_board_profile(std::vector<int8_t> & data, const std::string &
|
|||||||
data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0, 0}; // BBQKees Gateway E32
|
data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0, 0}; // BBQKees Gateway E32
|
||||||
} else if (board_profile == "E32V2") {
|
} else if (board_profile == "E32V2") {
|
||||||
data = {2, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 0}; // BBQKees Gateway E32 V2
|
data = {2, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 0}; // BBQKees Gateway E32 V2
|
||||||
} else if (board_profile == "E32V3") {
|
} else if (board_profile == "E32V2_2") {
|
||||||
data = {32, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 1}; // BBQKees Gateway E32 V3
|
data = {32, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 1}; // BBQKees Gateway E32 V2.2, rgb led
|
||||||
} else if (board_profile == "MH-ET") {
|
} else if (board_profile == "MH-ET") {
|
||||||
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // MH-ET Live D1 Mini
|
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // MH-ET Live D1 Mini
|
||||||
} else if (board_profile == "NODEMCU") {
|
} else if (board_profile == "NODEMCU") {
|
||||||
@@ -2029,6 +2038,7 @@ bool System::ntp_connected() {
|
|||||||
// see if its a BBQKees Gateway by checking the nvs values
|
// see if its a BBQKees Gateway by checking the nvs values
|
||||||
String System::getBBQKeesGatewayDetails() {
|
String System::getBBQKeesGatewayDetails() {
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
|
/*
|
||||||
if (!EMSESP::nvs_.isKey("mfg")) {
|
if (!EMSESP::nvs_.isKey("mfg")) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -2042,6 +2052,26 @@ String System::getBBQKeesGatewayDetails() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "BBQKees Gateway Model " + EMSESP::nvs_.getString("model") + " v" + EMSESP::nvs_.getString("hwrevision") + "/" + EMSESP::nvs_.getString("batch");
|
return "BBQKees Gateway Model " + EMSESP::nvs_.getString("model") + " v" + EMSESP::nvs_.getString("hwrevision") + "/" + EMSESP::nvs_.getString("batch");
|
||||||
|
*/
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint32_t no : 4;
|
||||||
|
uint32_t month : 4;
|
||||||
|
uint32_t year : 8;
|
||||||
|
uint32_t rev_minor : 4;
|
||||||
|
uint32_t rev_major : 4;
|
||||||
|
uint32_t model : 4;
|
||||||
|
uint32_t mfg : 4;
|
||||||
|
};
|
||||||
|
uint32_t reg;
|
||||||
|
} gw;
|
||||||
|
gw.reg = esp_efuse_read_reg(EFUSE_BLK3, 0);
|
||||||
|
const char * mfg[] = {"unknown", "BBQKees Electronics", "", "", "", "", "", ""};
|
||||||
|
const char * model[] = {"unknown", "S3", "E32V2", "E32V2.2", "S32", "E32", "", "", ""};
|
||||||
|
|
||||||
|
return gw.reg ? String(mfg[gw.mfg]) + " " + String(model[gw.model]) + " rev." + String(gw.rev_major) + "." + String(gw.rev_minor) + "/"
|
||||||
|
+ String(2000 + gw.year) + "-" + String(gw.month) + "-" + String(gw.no) + " (fuse 0x" + String(gw.reg, 16) + ")"
|
||||||
|
: "";
|
||||||
#else
|
#else
|
||||||
return "";
|
return "";
|
||||||
#endif
|
#endif
|
||||||
@@ -2160,7 +2190,7 @@ bool System::readCommand(const char * data) {
|
|||||||
|
|
||||||
// first check deviceID
|
// first check deviceID
|
||||||
if ((p = strtok(data_args, " ,"))) { // delimiter comma or space
|
if ((p = strtok(data_args, " ,"))) { // delimiter comma or space
|
||||||
strlcpy(value, p, 10); // get string
|
strlcpy(value, p, sizeof(value)); // get string
|
||||||
device_id = (uint8_t)Helpers::hextoint(value); // convert hex to int
|
device_id = (uint8_t)Helpers::hextoint(value); // convert hex to int
|
||||||
if (!EMSESP::valid_device(device_id)) {
|
if (!EMSESP::valid_device(device_id)) {
|
||||||
LOG_ERROR("Invalid device ID (0x%02X) in read command", device_id);
|
LOG_ERROR("Invalid device ID (0x%02X) in read command", device_id);
|
||||||
@@ -2171,8 +2201,8 @@ bool System::readCommand(const char * data) {
|
|||||||
// iterate until end
|
// iterate until end
|
||||||
uint8_t num_args = 0;
|
uint8_t num_args = 0;
|
||||||
while (p != 0) {
|
while (p != 0) {
|
||||||
if ((p = strtok(nullptr, " ,"))) { // delimiter comma or space
|
if ((p = strtok(nullptr, " ,"))) { // delimiter comma or space
|
||||||
strlcpy(value, p, 10); // get string
|
strlcpy(value, p, sizeof(value)); // get string
|
||||||
if (num_args == 0) {
|
if (num_args == 0) {
|
||||||
type_id = (uint16_t)Helpers::hextoint(value); // convert hex to int
|
type_id = (uint16_t)Helpers::hextoint(value); // convert hex to int
|
||||||
} else if (num_args == 1) {
|
} else if (num_args == 1) {
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ uuid::log::Logger TemperatureSensor::logger_{F_(temperaturesensor), uuid::log::F
|
|||||||
|
|
||||||
// start the 1-wire
|
// start the 1-wire
|
||||||
void TemperatureSensor::start(const bool factory_settings) {
|
void TemperatureSensor::start(const bool factory_settings) {
|
||||||
// set_internal_ = factory_settings && EMSESP::nvs_.getString("boot").equals("E32V3") && EMSESP::nvs_.getString("hwrevision").equals("3.0");
|
// set_internal_ = factory_settings && EMSESP::nvs_.getString("boot").equals("E32V2_2") && EMSESP::nvs_.getString("hwrevision").equals("3.0");
|
||||||
set_internal_ = factory_settings && analogReadMilliVolts(39) > 800; // core voltage > 3V
|
set_internal_ = factory_settings && analogReadMilliVolts(39) > 700; // core voltage > 2.6V
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
if (!dallas_gpio_) {
|
if (!dallas_gpio_) {
|
||||||
@@ -205,9 +205,11 @@ void TemperatureSensor::loop() {
|
|||||||
set_internal_ = false;
|
set_internal_ = false;
|
||||||
Sensor * s = &sensors_[0];
|
Sensor * s = &sensors_[0];
|
||||||
if (firstscan_ > 1) {
|
if (firstscan_ > 1) {
|
||||||
for (auto s1 : sensors_) {
|
std::string s_nvs = EMSESP::nvs_.getString("intTemp").c_str();
|
||||||
if (EMSESP::nvs_.getString("intTemp").equals(s1.id().c_str())) {
|
for (uint8_t i = 0; i < firstscan_; i++) {
|
||||||
s = &s1;
|
if (s_nvs == sensors_[i].id()) {
|
||||||
|
s = &sensors_[i];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,8 +180,8 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
|
|||||||
if (ETH.begin(ETH_PHY_LAN8720, 0, 23, 18, 15, ETH_CLOCK_GPIO0_OUT)) {
|
if (ETH.begin(ETH_PHY_LAN8720, 0, 23, 18, 15, ETH_CLOCK_GPIO0_OUT)) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (analogReadMilliVolts(39) > 800) { // core voltage > 3V
|
if (analogReadMilliVolts(39) > 700) { // core voltage > 2.6V
|
||||||
settings.board_profile = "E32V3"; // Ethernet, PSRAM, internal sensors
|
settings.board_profile = "E32V2_2"; // Ethernet, PSRAM, internal sensors
|
||||||
} else {
|
} else {
|
||||||
settings.board_profile = "E32V2"; // Ethernet and PSRAM
|
settings.board_profile = "E32V2"; // Ethernet and PSRAM
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user