6.5.0.3 Add command Sensor20

6.5.0.3 20190328
 * Add command Sensor20 1..255 to change Nova Fitness SDS01 working period in minutes (#5452)
This commit is contained in:
Theo Arends 2019-03-28 12:06:48 +01:00
parent e631d49d0f
commit e8e5d1c03c
6 changed files with 51 additions and 25 deletions

View File

@ -1,4 +1,7 @@
/* 6.5.0.2 20190325 /* 6.5.0.3 20190328
* Add command Sensor20 1..255 to change Nova Fitness SDS01 working period in minutes (#5452)
*
* 6.5.0.2 20190325
* Change UDP initial message handling from string to char using static memory and add debug info (#5505) * Change UDP initial message handling from string to char using static memory and add debug info (#5505)
* Add optional support for Badger HR-E Water Meter (#5539) * Add optional support for Badger HR-E Water Meter (#5539)
* *

View File

@ -330,8 +330,9 @@ struct SYSCFG {
uint8_t rgbwwTable[5]; // 71A uint8_t rgbwwTable[5]; // 71A
uint8_t user_template_base; // 71F uint8_t user_template_base; // 71F
mytmplt user_template; // 720 29 bytes mytmplt user_template; // 720 29 bytes
uint8_t novasds_period; // 73D
uint8_t free_73D[87]; // 73D uint8_t free_73D[86]; // 73E
uint32_t drivers[3]; // 794 uint32_t drivers[3]; // 794
uint32_t monitors; // 7A0 uint32_t monitors; // 7A0

View File

@ -815,6 +815,8 @@ void SettingsDefaultSet2(void)
Settings.rgbwwTable[j] = 255; Settings.rgbwwTable[j] = 255;
} }
Settings.novasds_period = WORKING_PERIOD;
memset(&Settings.drivers, 0xFF, 32); // Enable all possible monitors, displays, drivers and sensors memset(&Settings.drivers, 0xFF, 32); // Enable all possible monitors, displays, drivers and sensors
} }
@ -1055,6 +1057,9 @@ void SettingsDelta(void)
if (Settings.version < 0x06040113) { if (Settings.version < 0x06040113) {
Settings.param[P_RGB_REMAP] = RGB_REMAP_RGBW; Settings.param[P_RGB_REMAP] = RGB_REMAP_RGBW;
} }
if (Settings.version < 0x06050003) {
Settings.novasds_period = WORKING_PERIOD;
}
Settings.version = VERSION; Settings.version = VERSION;
SettingsSave(1); SettingsSave(1);

View File

@ -20,7 +20,7 @@
#ifndef _SONOFF_VERSION_H_ #ifndef _SONOFF_VERSION_H_
#define _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_
#define VERSION 0x06050002 #define VERSION 0x06050003
#define D_PROGRAMNAME "Sonoff-Tasmota" #define D_PROGRAMNAME "Sonoff-Tasmota"
#define D_AUTHOR "Theo Arends" #define D_AUTHOR "Theo Arends"

View File

@ -47,13 +47,11 @@
#define NOVA_SDS_DEVICE_ID 0xFFFF // NodaSDS all sensor response #define NOVA_SDS_DEVICE_ID 0xFFFF // NodaSDS all sensor response
#endif #endif
TasmotaSerial *NovaSdsSerial; TasmotaSerial *NovaSdsSerial;
uint8_t novasds_type = 1; uint8_t novasds_type = 1;
uint8_t novasds_valid = 0; uint8_t novasds_valid = 0;
struct sds011data { struct sds011data {
uint16_t pm100; uint16_t pm100;
uint16_t pm25; uint16_t pm25;
@ -126,9 +124,9 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor
void NovaSdsSetWorkPeriod(void) void NovaSdsSetWorkPeriod(void)
{ {
// set sensor working period // set sensor working period
NovaSdsCommand(NOVA_SDS_WORKING_PERIOD, NOVA_SDS_SET_MODE, WORKING_PERIOD, NOVA_SDS_DEVICE_ID, nullptr); NovaSdsCommand(NOVA_SDS_WORKING_PERIOD, NOVA_SDS_SET_MODE, Settings.novasds_period, NOVA_SDS_DEVICE_ID, nullptr);
// set sensor report only on query // set sensor report only on query
NovaSdsCommand(NOVA_SDS_REPORTING_MODE, NOVA_SDS_SET_MODE, NOVA_SDS_REPORT_QUERY, NOVA_SDS_DEVICE_ID, nullptr); NovaSdsCommand(NOVA_SDS_REPORTING_MODE, NOVA_SDS_SET_MODE, NOVA_SDS_REPORT_QUERY, NOVA_SDS_DEVICE_ID, nullptr);
} }
bool NovaSdsReadData(void) bool NovaSdsReadData(void)
@ -162,7 +160,22 @@ void NovaSdsSecond(void) // Every second
} }
} }
/*********************************************************************************************/ /*********************************************************************************************\
* Command Sensor20
*
* 1 .. 255 - Set working period in minutes
\*********************************************************************************************/
bool NovaSdsCommandSensor(void)
{
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload < 256)) {
Settings.novasds_period = XdrvMailbox.payload;
NovaSdsSetWorkPeriod();
}
Response_P(S_JSON_SENSOR_INDEX_NVALUE, XSNS_20, Settings.novasds_period);
return true;
}
void NovaSdsInit(void) void NovaSdsInit(void)
{ {
@ -226,6 +239,11 @@ bool Xsns20(uint8_t function)
case FUNC_EVERY_SECOND: case FUNC_EVERY_SECOND:
NovaSdsSecond(); NovaSdsSecond();
break; break;
case FUNC_COMMAND_SENSOR:
if (XSNS_20 == XdrvMailbox.index) {
result = NovaSdsCommandSensor();
}
break;
case FUNC_JSON_APPEND: case FUNC_JSON_APPEND:
NovaSdsShow(1); NovaSdsShow(1);
break; break;

View File

@ -17,6 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifdef USE_HRE
/*********************************************************************************************\ /*********************************************************************************************\
* HR-E LCD Water meter register interface * HR-E LCD Water meter register interface
* *
@ -45,8 +46,6 @@
* *
\*********************************************************************************************/ \*********************************************************************************************/
#ifdef USE_HRE
#define XSNS_43 43 #define XSNS_43 43
enum hre_states { enum hre_states {