Skip to content

Commit

Permalink
Bump version to v1.4.1
Browse files Browse the repository at this point in the history
* Clear modbus retained
  • Loading branch information
hung-eoh committed Aug 7, 2024
1 parent 1318de6 commit 07e2828
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 7 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ERa",
"version": "1.4.0",
"version": "1.4.1",
"description": "E-Ra by EoH. An IoT Market Enabler! It supports WiFi, Ethernet, Zigbee, Modbus, Serial. Works with boards like Arduino, ESP8266, ESP32, STM32, Raspberry Pi...",
"keywords": "ERa, E-Ra, esp8266, esp32, stm32, raspberry-pi, http, mqtt, zigbee, modbus, sensors, control, device, smartphone, mobile, app, web, cloud, communication, protocol, iot, wifi, ethernet, serial",
"authors":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ERa
version=1.4.0
version=1.4.1
author=EoH Ltd
license=MIT
maintainer=EoH Ltd <info@eoh.io>
Expand Down
6 changes: 3 additions & 3 deletions linux/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

ERA_MAJOR = 1
ERA_MINOR = 4
ERA_PATCH = 0
ERA_VERSION = "1.4.0"
ERA_FIRMWARE_VERSION = "1.4.0"
ERA_PATCH = 1
ERA_VERSION = "1.4.1"
ERA_FIRMWARE_VERSION = "1.4.1"

BUTTON_GPIO = 16

Expand Down
8 changes: 8 additions & 0 deletions src/ERa/ERaApi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ class ERaApi
#endif
}

void configIdRemove(ERaInt_t configId) {
this->thisProto().removeRetainedConfigIdData(configId);
}

#if defined(ERA_MODBUS)
void modbusDataWrite(ERaDataBuff* value) {
#if ERA_MAX_EVENTS
Expand All @@ -468,6 +472,10 @@ class ERaApi
this->thisProto().sendCommand(rsp, value);
#endif
}

void modbusDataRemove() {
this->thisProto().removeRetainedModbusData();
}
#endif

#if defined(ERA_ZIGBEE)
Expand Down
21 changes: 21 additions & 0 deletions src/ERa/ERaProtocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class ERaProto
bool sendChangeResultWiFi(const char* payload);
bool publishData(const char* prefixTopic, const char* payload,
bool retained, bool extended = false);
bool removeRetainedData(const char* prefixTopic);
bool isConfigMode();
void onConnected();
void onDisconnected();
Expand Down Expand Up @@ -322,7 +323,9 @@ class ERaProto
void sendCommandVirtual(ERaRsp_t& rsp, ERaDataJson* data);
#if defined(ERA_MODBUS)
void sendCommandModbus(ERaRsp_t& rsp, ERaDataBuff* data);
void removeRetainedModbusData();
#endif
void removeRetainedConfigIdData(ERaInt_t configId);

void processRequest(const char* topic, const char* payload);
#if !defined(ERA_HAS_FUNCTIONAL_H)
Expand Down Expand Up @@ -1020,6 +1023,11 @@ bool ERaProto<Transp, Flash>::publishData(const char* prefixTopic, const char* p
return this->transp.publishData(topic, payload, retained);
}

template <class Transp, class Flash>
bool ERaProto<Transp, Flash>::removeRetainedData(const char* prefixTopic) {
return this->publishData(prefixTopic, "", true);
}

template <class Transp, class Flash>
bool ERaProto<Transp, Flash>::sendListWiFi(const char* payload) {
return this->publishData(ERA_PUB_PREFIX_LIST_WIFI_TOPIC,
Expand Down Expand Up @@ -1640,8 +1648,21 @@ void ERaProto<Transp, Flash>::sendCommandVirtual(ERaRsp_t& rsp, ERaDataJson* dat
cJSON_Delete(root);
root = nullptr;
}

template <class Transp, class Flash>
void ERaProto<Transp, Flash>::removeRetainedModbusData() {
this->removeRetainedData(ERA_PUB_PREFIX_MODBUS_DATA_TOPIC);
}
#endif

template <class Transp, class Flash>
void ERaProto<Transp, Flash>::removeRetainedConfigIdData(ERaInt_t configId) {
char topicName[MAX_TOPIC_LENGTH] {0};
FormatString(topicName, this->ERA_TOPIC);
FormatString(topicName, ERA_PUB_PREFIX_CONFIG_DATA_TOPIC, configId);
this->transp.publishData(topicName, "", true);
}

template <class Transp, class Flash>
size_t ERaProto<Transp, Flash>::splitString(char* strInput, const char* delims) {
if ((strInput == nullptr) ||
Expand Down
4 changes: 2 additions & 2 deletions src/ERa/ERaVersion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define ERA_MAJOR 1
#define ERA_MINOR 4
#define ERA_PATCH 0
#define ERA_PATCH 1

#define ERA_VERSION_TO_STR_2(val) # val
#define ERA_VERSION_TO_STR(val) ERA_VERSION_TO_STR_2(val)
Expand All @@ -17,7 +17,7 @@
#define ERA_VERSION ERA_VERSION_TO_STR(ERA_MAJOR) "." \
ERA_VERSION_TO_STR(ERA_MINOR) "." \
ERA_VERSION_TO_STR(ERA_PATCH)
#define ERA_VERSION_1_4_0
#define ERA_VERSION_1_4_1

#if !defined(ERA_FIRMWARE_VERSION)
#define ERA_FIRMWARE_VERSION ERA_VERSION
Expand Down
11 changes: 11 additions & 0 deletions src/Modbus/ERaModbus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ class ERaModbus
this->thisApi().configIdWrite(configId, value);
}

void configIdModbusRemove(ERaInt_t configId) override {
this->thisApi().configIdRemove(configId);
}

void clearDataBuff() {
this->dataBuff.clearBuffer();
}
Expand Down Expand Up @@ -413,6 +417,13 @@ class ERaModbus
this->modbusConfig->resize();
this->modbusControl->resize();
this->initModbus(true);
ERaDelay(500);
if (ModbusTransp::isNewReport()) {
this->thisApi().modbusDataRemove();
}
else {
ModbusTransp::removeConfigId();
}
}
ModbusState::set(ModbusStateT::STATE_MB_RUNNING);
}
Expand Down
22 changes: 22 additions & 0 deletions src/Modbus/ERaModbusData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ class ERaModbusData
return this->enableReport;
}

void removeConfigId();
void updateRegister();
void parseConfig(const void* ptr, bool json);
void processParseParamConvertAi(const cJSON* const root, iterator& it);
Expand All @@ -288,6 +289,11 @@ class ERaModbusData
ERA_LOG_WARNING(TAG, ERA_PSTR("configIdModbusWrite default."));
}

virtual void configIdModbusRemove(ERaInt_t configId) {
ERA_FORCE_UNUSED(configId);
ERA_LOG_WARNING(TAG, ERA_PSTR("configIdModbusRemove default."));
}

private:
iterator addInternalRegister(ERaInt_t configId, uint8_t addr, uint8_t func, uint16_t reg) {
return this->addInternalRegister(configId, addr, func, HI_WORD(reg), LO_WORD(reg));
Expand Down Expand Up @@ -328,6 +334,7 @@ class ERaModbusData
}

ERaList<Register_t*> ERaReg;
ERaList<ERaInt_t> ERaRegId;
ERaReport ERaRegRp;
unsigned int numRegister;

Expand Down Expand Up @@ -387,6 +394,7 @@ ERaModbusData::Register_t* ERaModbusData::setupRegister(WrapperBase* value, uint

inline
void ERaModbusData::updateRegister() {
this->ERaRegId.clear();
Register_t* pReg = nullptr;
ModbusDataIterator* next = nullptr;
const ModbusDataIterator* e = this->ERaReg.end();
Expand All @@ -399,6 +407,7 @@ void ERaModbusData::updateRegister() {
if (!pReg->configId) {
continue;
}
this->ERaRegId.put(pReg->configId);
if (pReg->value != nullptr) {
delete pReg->value;
pReg->value = nullptr;
Expand Down Expand Up @@ -616,6 +625,19 @@ bool ERaModbusData::handler(ERaModbusRequest* request, ERaModbusResponse* respon
return found;
}

inline
void ERaModbusData::removeConfigId() {
const ERaList<ERaInt_t>::iterator* e = this->ERaRegId.end();
for (ERaList<ERaInt_t>::iterator* it = this->ERaRegId.begin(); it != e; it = it->getNext()) {
ERaInt_t configId = it->get();
if (!configId) {
continue;
}
this->configIdModbusRemove(configId);
}
this->ERaRegId.clear();
}

inline
bool ERaModbusData::handlerBits(ERaModbusRequest* request, ERaModbusResponse* response, bool success) {
bool found {false};
Expand Down

0 comments on commit 07e2828

Please sign in to comment.