mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
Merge branch 'feature/build-split-testing-sets-in-4-pieces' of https://github.com/tonhuisman/ESPEasy-1 into feature/build-split-testing-sets-in-4-pieces
This commit is contained in:
@@ -172,6 +172,12 @@ The conversion always outputs a string, but not all of these can be converted ba
|
||||
* - Dew point(T,H): ``%c_dew_th%(18.6,67)``
|
||||
- Dew point(T,H): ``12.31``
|
||||
- Compute dew point given 2 values, temperature and relative humidity
|
||||
* - Altitude(air,sea): ``%c_alt_pres_sea%(850,1000)``
|
||||
- Altitude(air,sea): ``1350.03``
|
||||
- Compute Altitude (m) given 2 values, atmospheric pressure and pressure at sea level (hPa). (Added: 2021/04/27)
|
||||
* - PressureElevation(air,alt): ``%c_sea_pres_alt%(850,1350.03)``
|
||||
- PressureElevation(air,alt): ``1000.00``
|
||||
- Compensate air pressure for measured atmospheric pressure (hPa) and given altitude (m). (Added: 2021/04/27)
|
||||
* - cm to imperial: ``%c_cm2imp%(190)``
|
||||
- cm to imperial: ``6'2.8"``
|
||||
- Centimeter to imperial units
|
||||
|
||||
@@ -237,6 +237,11 @@ bool rn2xx3::setFrequencyPlan(RN2xx3_datatypes::Freq_plan fp)
|
||||
return _rn2xx3_handler.setFrequencyPlan(fp);
|
||||
}
|
||||
|
||||
bool rn2xx3::setTTNstack(RN2xx3_datatypes::TTN_stack_version version)
|
||||
{
|
||||
return _rn2xx3_handler.setTTNstack(version);
|
||||
}
|
||||
|
||||
String rn2xx3::peekLastError() const
|
||||
{
|
||||
return _rn2xx3_handler.peekLastError();
|
||||
|
||||
@@ -285,6 +285,11 @@ public:
|
||||
*/
|
||||
bool setFrequencyPlan(RN2xx3_datatypes::Freq_plan);
|
||||
|
||||
/*
|
||||
* Set version of TTN stack to use.
|
||||
*/
|
||||
bool setTTNstack(RN2xx3_datatypes::TTN_stack_version version);
|
||||
|
||||
/*
|
||||
* Returns the last downlink message HEX string.
|
||||
*/
|
||||
|
||||
@@ -29,6 +29,13 @@ public:
|
||||
DEFAULT_EU
|
||||
};
|
||||
|
||||
enum TTN_stack_version {
|
||||
TTN_v2 = 0,
|
||||
TTN_v3 = 1,
|
||||
|
||||
TTN_NOT_SET
|
||||
};
|
||||
|
||||
enum TX_return_type {
|
||||
TX_FAIL = 0, // The transmission failed.
|
||||
// If you sent a confirmed message and it is not acked,
|
||||
|
||||
@@ -599,6 +599,24 @@ bool rn2xx3_handler::setFrequencyPlan(RN2xx3_datatypes::Freq_plan fp)
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
bool rn2xx3_handler::setTTNstack(RN2xx3_datatypes::TTN_stack_version version)
|
||||
{
|
||||
switch(version) {
|
||||
case RN2xx3_datatypes::TTN_stack_version::TTN_v2:
|
||||
_rxdelay1 = 1000;
|
||||
_rxdelay2 = 2000;
|
||||
break;
|
||||
case RN2xx3_datatypes::TTN_stack_version::TTN_v3:
|
||||
_rxdelay1 = 5000;
|
||||
_rxdelay2 = 6000;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
sendMacSet(F("rxdelay1"), String(_rxdelay1));
|
||||
return true;
|
||||
}
|
||||
|
||||
RN2xx3_datatypes::Model rn2xx3_handler::configureModuleType()
|
||||
{
|
||||
RN2xx3_datatypes::Firmware firmware;
|
||||
|
||||
@@ -155,6 +155,8 @@ public:
|
||||
|
||||
bool setFrequencyPlan(RN2xx3_datatypes::Freq_plan fp);
|
||||
|
||||
bool setTTNstack(RN2xx3_datatypes::TTN_stack_version version);
|
||||
|
||||
private:
|
||||
|
||||
// Return the data to send
|
||||
@@ -251,8 +253,8 @@ private:
|
||||
unsigned long _start_prep = 0; // timestamp of preparing command
|
||||
unsigned long _start = 0; // timestamp of last set timeout
|
||||
unsigned long _timeout = 100; // timeout duration
|
||||
uint32_t _rxdelay1 = 1000; // delay from last moment of sending to receive RX1 window
|
||||
uint32_t _rxdelay2 = 2000; // delay from last moment of sending to receive RX2 window
|
||||
uint32_t _rxdelay1 = 5000; // delay from last moment of sending to receive RX1 window
|
||||
uint32_t _rxdelay2 = 6000; // delay from last moment of sending to receive RX2 window
|
||||
uint8_t _busy_count = 0; // Number of times the module replied with "busy"
|
||||
uint8_t _retry_count = 0; // Number of retries of current TX command
|
||||
RN_state _state = RN_state::idle;
|
||||
|
||||
@@ -655,7 +655,62 @@ function Converter(decoded, port) {
|
||||
// TODO TD-er: This is probably the worst possible value to send over a LoRa network, as packets may get lost.
|
||||
converted.countdelta = converted.val_1;
|
||||
break;
|
||||
|
||||
|
||||
case 102:
|
||||
converted.name = "PZEM004T v30";
|
||||
break;
|
||||
|
||||
case 106:
|
||||
converted.name = "BME680";
|
||||
converted.temp = converted.val_1;
|
||||
converted.hum = converted.val_2;
|
||||
converted.pressure = converted.val_3;
|
||||
converted.gas = converted.val_4;
|
||||
break;
|
||||
|
||||
case 107:
|
||||
converted.name = "SI1145";
|
||||
converted.visible = converted.val_1;
|
||||
converted.infra = converted.val_2;
|
||||
converted.uv = converted.val_3;
|
||||
break;
|
||||
|
||||
case 108:
|
||||
converted.name = "DDS238-x ZN";
|
||||
// This plugin can output any value, so show string representation
|
||||
// of the unit of measure
|
||||
converted.unit1 = getDDS238_xUnit(converted.unit1);
|
||||
converted.unit2 = getDDS238_xUnit(converted.unit2);
|
||||
converted.unit3 = getDDS238_xUnit(converted.unit3);
|
||||
converted.unit4 = getDDS238_xUnit(converted.unit4);
|
||||
converted.v1 = converted.val_1;
|
||||
converted.v2 = converted.val_2;
|
||||
converted.v3 = converted.val_3;
|
||||
converted.v4 = converted.val_4;
|
||||
break;
|
||||
|
||||
case 110:
|
||||
converted.name = "VL53L0X";
|
||||
converted.distance = converted.val_1;
|
||||
break;
|
||||
|
||||
|
||||
case 111:
|
||||
converted.name = "RC522 RFID";
|
||||
{
|
||||
// Not sure if it is present, since the sensor only has a single output value in ESPeasy.
|
||||
var ulongvalue = converted.val_2 * 65536 + converted.val_1;
|
||||
converted.tag = ulongvalue.toFixed(0);
|
||||
}
|
||||
break;
|
||||
|
||||
case 113:
|
||||
converted.name = "VL53L1X";
|
||||
converted.distance = converted.val_1;
|
||||
converted.ambient = converted.val_2;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
default:
|
||||
converted.v1 = converted.val_1;
|
||||
@@ -697,4 +752,30 @@ function getAcuDC243Unit(unit_id) {
|
||||
return "hours load";
|
||||
}
|
||||
return "unknown" + unit_id;
|
||||
}
|
||||
};
|
||||
|
||||
function getDDS238_xUnit(unit_id) {
|
||||
switch (unit_id) {
|
||||
case 0: // P108_QUERY_V 0
|
||||
return "V";
|
||||
case 1: // P108_QUERY_A 1
|
||||
return "A";
|
||||
case 2: // P108_QUERY_W 2
|
||||
return "W";
|
||||
case 3: // P108_QUERY_VA 3
|
||||
return "VA";
|
||||
case 4: // P108_QUERY_PF 4
|
||||
return "cosphi";
|
||||
case 5: // P108_QUERY_F 5
|
||||
return "Hz";
|
||||
case 6: // P108_QUERY_Wh_imp 6
|
||||
return "Wh imp";
|
||||
case 7: // P108_QUERY_Wh_exp 7
|
||||
return "Wh exp";
|
||||
case 8: // P108_QUERY_Wh_tot 8
|
||||
return "Wh total";
|
||||
}
|
||||
return "unknown" + unit_id;
|
||||
};
|
||||
|
||||
|
||||
@@ -34,10 +34,23 @@ function Decoder(bytes, port) {
|
||||
|
||||
case 85:
|
||||
// AcuDC243
|
||||
// FIXME TD-er: Same code as in P108, Make new type for this with 4 selectable variables
|
||||
return decode(bytes, [header, uint8, int32_1e4, uint8, int32_1e4, uint8, int32_1e4, uint8, int32_1e4],
|
||||
['header', 'unit1', 'val_1', 'unit2', 'val_2', 'unit3', 'val_3', 'unit4', 'val_4']);
|
||||
|
||||
case 102:
|
||||
// PZEM004T v30
|
||||
data = decode(bytes, [header, int16_1e1, int32_1e3, int32_1e1, int32_1e1, uint16_1e2, uint8_1e1],
|
||||
['header', 'voltage', 'current', 'power', 'energy', 'powerfactor', 'frequency']);
|
||||
data.frequency += 40;
|
||||
return data;
|
||||
|
||||
case 108:
|
||||
// DDS238-x ZN
|
||||
// FIXME TD-er: Same code as in P085, Make new type for this with 4 selectable variables
|
||||
return decode_plugin(input.fPort, input.bytes, [header, uint8, int32_1e4, uint8, int32_1e4, uint8, int32_1e4, uint8, int32_1e4],
|
||||
['header', 'unit1', 'val_1', 'unit2', 'val_2', 'unit3', 'val_3', 'unit4', 'val_4']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -139,6 +139,9 @@ platform_packages =
|
||||
[core_esp32_1_12_2]
|
||||
platform = espressif32@1.12.4
|
||||
|
||||
[core_esp32_2_1_0]
|
||||
platform = espressif32@2.1.0
|
||||
|
||||
[core_esp32_3_2_0]
|
||||
platform = espressif32@3.2.0
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
[esp32_common]
|
||||
extends = common, core_esp32_3_2_0
|
||||
extends = common, core_esp32_2_1_0
|
||||
lib_ignore = ESP8266WiFi, ESP8266Ping, ESP8266WebServer, ESP8266HTTPUpdateServer, ESP8266mDNS, IRremoteESP8266, ESPEasy_ESP8266Ping, ESP32_ping, HeatpumpIR
|
||||
lib_deps = https://github.com/TD-er/ESPEasySerial.git#v2.0.5, adafruit/Adafruit ILI9341 @ ^1.5.6, Adafruit GFX Library, LOLIN_EPD, Adafruit BusIO, VL53L0X @ 1.3.0, SparkFun VL53L1X 4m Laser Distance Sensor @ 1.2.9
|
||||
board_build.f_flash = 80000000L
|
||||
|
||||
@@ -135,6 +135,14 @@ struct C018_data_struct {
|
||||
return res;
|
||||
}
|
||||
|
||||
bool setTTNstack(RN2xx3_datatypes::TTN_stack_version version) {
|
||||
if (!isInitialized()) { return false; }
|
||||
bool res = myLora->setTTNstack(version);
|
||||
|
||||
C018_logError(F("setTTNstack"));
|
||||
return res;
|
||||
}
|
||||
|
||||
bool setFrequencyPlan(RN2xx3_datatypes::Freq_plan plan) {
|
||||
if (!isInitialized()) { return false; }
|
||||
bool res = myLora->setFrequencyPlan(plan);
|
||||
@@ -419,6 +427,9 @@ struct C018_ConfigStruct
|
||||
if ((baudrate < 2400) || (baudrate > 115200)) {
|
||||
reset();
|
||||
}
|
||||
if (stackVersion >= RN2xx3_datatypes::TTN_stack_version::TTN_NOT_SET) {
|
||||
stackVersion = RN2xx3_datatypes::TTN_stack_version::TTN_v2;
|
||||
}
|
||||
}
|
||||
|
||||
void reset() {
|
||||
@@ -432,6 +443,7 @@ struct C018_ConfigStruct
|
||||
resetpin = -1;
|
||||
sf = 7;
|
||||
frequencyplan = RN2xx3_datatypes::Freq_plan::TTN_EU;
|
||||
stackVersion = RN2xx3_datatypes::TTN_stack_version::TTN_v2;
|
||||
joinmethod = C018_USE_OTAA;
|
||||
}
|
||||
|
||||
@@ -447,6 +459,7 @@ struct C018_ConfigStruct
|
||||
uint8_t frequencyplan = RN2xx3_datatypes::Freq_plan::TTN_EU;
|
||||
uint8_t joinmethod = C018_USE_OTAA;
|
||||
uint8_t serialPort = 0;
|
||||
uint8_t stackVersion = RN2xx3_datatypes::TTN_stack_version::TTN_v2;
|
||||
};
|
||||
|
||||
|
||||
@@ -537,6 +550,7 @@ bool CPlugin_018(CPlugin::Function function, struct EventStruct *event, String&
|
||||
uint8_t sf;
|
||||
uint8_t frequencyplan;
|
||||
uint8_t joinmethod;
|
||||
uint8_t stackVersion;
|
||||
|
||||
{
|
||||
// Keep this object in a small scope so we can destruct it as soon as possible again.
|
||||
@@ -554,6 +568,7 @@ bool CPlugin_018(CPlugin::Function function, struct EventStruct *event, String&
|
||||
sf = customConfig->sf;
|
||||
frequencyplan = customConfig->frequencyplan;
|
||||
joinmethod = customConfig->joinmethod;
|
||||
stackVersion = customConfig->stackVersion;
|
||||
|
||||
{
|
||||
addFormTextBox(F("Device EUI"), F("deveui"), customConfig->DeviceEUI, C018_DEVICE_EUI_LEN - 1);
|
||||
@@ -592,6 +607,16 @@ bool CPlugin_018(CPlugin::Function function, struct EventStruct *event, String&
|
||||
|
||||
addFormSelector(F("Frequency Plan"), F("frequencyplan"), 4, options, values, NULL, frequencyplan, false);
|
||||
}
|
||||
{
|
||||
String options[2] = { F("TTN v2"), F("TTN v3") };
|
||||
int values[2] = {
|
||||
RN2xx3_datatypes::TTN_stack_version::TTN_v2,
|
||||
RN2xx3_datatypes::TTN_stack_version::TTN_v3
|
||||
};
|
||||
|
||||
addFormSelector(F("TTN Stack"), F("ttnstack"), 2, options, values, NULL, stackVersion, false);
|
||||
}
|
||||
|
||||
addFormNumericBox(F("Spread Factor"), F("sf"), sf, 7, 12);
|
||||
|
||||
|
||||
@@ -681,6 +706,7 @@ bool CPlugin_018(CPlugin::Function function, struct EventStruct *event, String&
|
||||
customConfig->sf = getFormItemInt(F("sf"), customConfig->sf);
|
||||
customConfig->frequencyplan = getFormItemInt(F("frequencyplan"), customConfig->frequencyplan);
|
||||
customConfig->joinmethod = getFormItemInt(F("joinmethod"), customConfig->joinmethod);
|
||||
customConfig->stackVersion = getFormItemInt(F("ttnstack"), customConfig->stackVersion);
|
||||
serialHelper_webformSave(customConfig->serialPort, customConfig->rxpin, customConfig->txpin);
|
||||
SaveCustomControllerSettings(event->ControllerIndex, (byte *)customConfig.get(), sizeof(C018_ConfigStruct));
|
||||
}
|
||||
@@ -834,6 +860,10 @@ bool C018_init(struct EventStruct *event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!C018_data->setTTNstack(static_cast<RN2xx3_datatypes::TTN_stack_version>(customConfig->stackVersion))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!C018_data->txUncnf("ESPeasy (TTN)", Port)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -90,9 +90,7 @@ boolean Plugin_006(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
if (elev != 0)
|
||||
{
|
||||
pressure = P006_data->pressureElevation(
|
||||
pressure,
|
||||
elev);
|
||||
pressure = pressureElevation(pressure, elev);
|
||||
}
|
||||
UserVar[event->BaseVarIndex + 1] = pressure;
|
||||
|
||||
|
||||
@@ -242,17 +242,18 @@ boolean Plugin_020(byte function, struct EventStruct *event, String& string)
|
||||
if (nullptr == task) {
|
||||
break;
|
||||
}
|
||||
success = true;
|
||||
|
||||
|
||||
if (command == F("serialsend")) {
|
||||
const char *tmpBuf = string.substring(11).c_str();
|
||||
task->ser2netSerial->write(tmpBuf);
|
||||
task->ser2netSerial->flush();
|
||||
success = true;
|
||||
}
|
||||
|
||||
if ((command == F("ser2netclientsend")) && (task->hasClientConnected())) {
|
||||
task->ser2netClient.print(string.substring(18));
|
||||
task->ser2netClient.flush();
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ boolean Plugin_028(byte function, struct EventStruct *event, String& string)
|
||||
const int elev = PCONFIG(1);
|
||||
|
||||
if (elev != 0) {
|
||||
UserVar[event->BaseVarIndex + 2] = P028_data->pressureElevation(elev);
|
||||
UserVar[event->BaseVarIndex + 2] = pressureElevation(P028_data->last_press_val, elev);
|
||||
} else {
|
||||
UserVar[event->BaseVarIndex + 2] = P028_data->last_press_val;
|
||||
}
|
||||
|
||||
@@ -101,11 +101,11 @@ boolean Plugin_032(byte function, struct EventStruct *event, String& string)
|
||||
P032_data->readout();
|
||||
|
||||
UserVar[event->BaseVarIndex] = P032_data->ms5611_temperature / 100;
|
||||
int elev = PCONFIG(1);
|
||||
|
||||
if (elev)
|
||||
|
||||
const int elev = PCONFIG(1);
|
||||
if (elev != 0)
|
||||
{
|
||||
UserVar[event->BaseVarIndex + 1] = P032_data->pressureElevation(P032_data->ms5611_pressure, elev);
|
||||
UserVar[event->BaseVarIndex + 1] = pressureElevation(P032_data->ms5611_pressure, elev);
|
||||
} else {
|
||||
UserVar[event->BaseVarIndex + 1] = P032_data->ms5611_pressure;
|
||||
}
|
||||
|
||||
@@ -363,6 +363,7 @@ boolean Plugin_085(byte function, struct EventStruct *event, String& string) {
|
||||
#ifdef USES_PACKED_RAW_DATA
|
||||
case PLUGIN_GET_PACKED_RAW_DATA:
|
||||
{
|
||||
// FIXME TD-er: Same code as in P102, share in LoRa code.
|
||||
P085_data_struct *P085_data =
|
||||
static_cast<P085_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
|
||||
@@ -295,6 +295,38 @@ boolean Plugin_102(byte function, struct EventStruct *event, String& string)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef USES_PACKED_RAW_DATA
|
||||
case PLUGIN_GET_PACKED_RAW_DATA:
|
||||
{
|
||||
// Matching JS code:
|
||||
// return decode(bytes, [header, int16_1e1, int32_1e3, int32_1e1, int32_1e1, uint16_1e2, uint8_1e1],
|
||||
// ['header', 'voltage', 'current', 'power', 'energy', 'powerfactor', 'frequency']);
|
||||
//
|
||||
// Resolutions:
|
||||
// Voltage: 0.1V => int16_1e1 (range 80-260V)
|
||||
// Current: 0.001A => int32_1e3
|
||||
// Power: 0.1W => int32_1e1
|
||||
// Energy: 1Wh => int32_1e1
|
||||
// PowerFactor: 0.01 => uint16_1e2
|
||||
// Frequency: 0.1Hz => uint8_1e1 (range 45Hz - 65Hz), offset 40Hz
|
||||
|
||||
// FIXME TD-er: Calling these functions is probably done within the 200 msec timeout used in the library.
|
||||
// If not, this should be cached in a task data struct.
|
||||
string += LoRa_addFloat(P102_PZEM_sensor->voltage(), PackedData_int16_1e1);
|
||||
string += LoRa_addFloat(P102_PZEM_sensor->current(), PackedData_int32_1e3);
|
||||
string += LoRa_addFloat(P102_PZEM_sensor->power(), PackedData_int32_1e1);
|
||||
string += LoRa_addFloat(P102_PZEM_sensor->energy(), PackedData_int32_1e1);
|
||||
string += LoRa_addFloat(P102_PZEM_sensor->pf(), PackedData_uint16_1e2);
|
||||
string += LoRa_addFloat(P102_PZEM_sensor->frequency() - 40, PackedData_uint8_1e1);
|
||||
event->Par1 = 6; // valuecount
|
||||
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
#endif // USES_PACKED_RAW_DATA
|
||||
|
||||
|
||||
|
||||
case PLUGIN_WRITE:
|
||||
{
|
||||
if (Plugin_102_init)
|
||||
|
||||
@@ -132,8 +132,15 @@ boolean Plugin_106(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
UserVar[event->BaseVarIndex + 0] = P106_data->bme.temperature;
|
||||
UserVar[event->BaseVarIndex + 1] = P106_data->bme.humidity;
|
||||
UserVar[event->BaseVarIndex + 2] = P106_data->bme.pressure / 100.0f;
|
||||
UserVar[event->BaseVarIndex + 3] = P106_data->bme.gas_resistance / 1000.0f;
|
||||
|
||||
const int elev = PCONFIG(1);
|
||||
if (elev != 0)
|
||||
{
|
||||
UserVar[event->BaseVarIndex + 2] = pressureElevation(P106_data->bme.pressure / 100.0f, elev);
|
||||
} else {
|
||||
UserVar[event->BaseVarIndex + 2] = P106_data->bme.pressure / 100.0f;
|
||||
}
|
||||
}
|
||||
|
||||
success = true;
|
||||
|
||||
@@ -317,6 +317,32 @@ boolean Plugin_108(byte function, struct EventStruct *event, String& string) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef USES_PACKED_RAW_DATA
|
||||
case PLUGIN_GET_PACKED_RAW_DATA:
|
||||
{
|
||||
// FIXME TD-er: Same code as in P102, share in LoRa code.
|
||||
P108_data_struct *P108_data =
|
||||
static_cast<P108_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if ((nullptr != P108_data) && P108_data->isInitialized()) {
|
||||
// Matching JS code:
|
||||
// return decode(bytes, [header, uint8, int32_1e4, uint8, int32_1e4, uint8, int32_1e4, uint8, int32_1e4],
|
||||
// ['header', 'unit1', 'val_1', 'unit2', 'val_2', 'unit3', 'val_3', 'unit4', 'val_4']);
|
||||
for (byte i = 0; i < VARS_PER_TASK; ++i) {
|
||||
const byte pconfigIndex = i + P108_QUERY1_CONFIG_POS;
|
||||
const byte choice = PCONFIG(pconfigIndex);
|
||||
string += LoRa_addInt(choice, PackedData_uint8);
|
||||
string += LoRa_addFloat(UserVar[event->BaseVarIndex + i], PackedData_int32_1e4);
|
||||
}
|
||||
event->Par1 = 8; // valuecount
|
||||
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif // USES_PACKED_RAW_DATA
|
||||
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "_Plugin_Helper.h"
|
||||
#ifdef USES_P111
|
||||
//#######################################################################################################
|
||||
//################################ Plugin-214: RC522 SPI RFID reader ####################################
|
||||
//################################ Plugin-111: RC522 SPI RFID reader ####################################
|
||||
//#######################################################################################################
|
||||
|
||||
// Changelog:
|
||||
|
||||
@@ -103,7 +103,7 @@ bool ControllerSettingsStruct::checkHostReachable(bool quick) {
|
||||
if (!NetworkConnected(10)) {
|
||||
return false; // Not connected, so no use in wasting time to connect to a host.
|
||||
}
|
||||
delay(1); // Make sure the Watchdog will not trigger a reset.
|
||||
delay(0); // Make sure the Watchdog will not trigger a reset.
|
||||
|
||||
if (quick && ipSet()) { return true; }
|
||||
|
||||
|
||||
@@ -46,6 +46,16 @@ WiFi_AP_Candidate::WiFi_AP_Candidate(uint8_t networkItem) : index(0) {
|
||||
last_seen = millis();
|
||||
}
|
||||
|
||||
WiFi_AP_Candidate::WiFi_AP_Candidate(const WiFi_AP_Candidate& other)
|
||||
: ssid(other.ssid), key(other.key), last_seen(other.last_seen),
|
||||
rssi(other.rssi), channel(other.channel), index(other.index),
|
||||
enc_type(other.enc_type), isHidden(other.isHidden),
|
||||
lowPriority(other.lowPriority),
|
||||
isEmergencyFallback(other.isEmergencyFallback)
|
||||
{
|
||||
setBSSID(other.bssid);
|
||||
}
|
||||
|
||||
WiFi_AP_Candidate::WiFi_AP_Candidate() {}
|
||||
|
||||
bool WiFi_AP_Candidate::operator<(const WiFi_AP_Candidate& other) const {
|
||||
|
||||
@@ -16,6 +16,8 @@ struct WiFi_AP_Candidate {
|
||||
// Construct using index from WiFi scan result
|
||||
WiFi_AP_Candidate(uint8_t networkItem);
|
||||
|
||||
WiFi_AP_Candidate(const WiFi_AP_Candidate& other);
|
||||
|
||||
// Default constructor
|
||||
WiFi_AP_Candidate();
|
||||
|
||||
|
||||
@@ -1460,6 +1460,7 @@ void createRuleEvents(struct EventStruct *event) {
|
||||
eventString += F("#");
|
||||
eventString += ExtraTaskSettings.TaskDeviceValueNames[0];
|
||||
eventString += F("=");
|
||||
eventString += '`';
|
||||
if (appendCompleteStringvalue) {
|
||||
eventString += event->String2;
|
||||
} else {
|
||||
@@ -1467,6 +1468,7 @@ void createRuleEvents(struct EventStruct *event) {
|
||||
eventString += F("...");
|
||||
eventString += event->String2.substring(event->String2.length() - 10);
|
||||
}
|
||||
eventString += '`';
|
||||
eventQueue.addMove(std::move(eventString));
|
||||
} else if (Settings.CombineTaskValues_SingleEvent(event->TaskIndex)) {
|
||||
String eventString;
|
||||
|
||||
@@ -88,7 +88,7 @@ void handle_unprocessedNetworkEvents()
|
||||
|
||||
// WiFi connection is not yet available, so introduce some extra delays to
|
||||
// help the background tasks managing wifi connections
|
||||
delay(1);
|
||||
delay(0);
|
||||
|
||||
NetworkConnectRelaxed();
|
||||
|
||||
@@ -222,7 +222,16 @@ void processDisconnect() {
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
|
||||
if (Settings.WiFiRestart_connection_lost()) {
|
||||
|
||||
bool mustRestartWiFi = Settings.WiFiRestart_connection_lost();
|
||||
if (WiFiEventData.lastConnectedDuration_us > 0 && (WiFiEventData.lastConnectedDuration_us / 1000) < 5000) {
|
||||
mustRestartWiFi = true;
|
||||
}
|
||||
|
||||
if (mustRestartWiFi) {
|
||||
WifiDisconnect(); // Needed or else node may not reconnect reliably.
|
||||
delay(100);
|
||||
setWifiMode(WIFI_OFF);
|
||||
initWiFi();
|
||||
delay(100);
|
||||
if (WiFiEventData.unprocessedWifiEvents()) {
|
||||
|
||||
@@ -181,6 +181,34 @@ float compute_humidity_from_dewpoint(float temperature, float dew_temperature) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
Compensate air pressure for given altitude (in meters)
|
||||
\*********************************************************************************************/
|
||||
float pressureElevation(float atmospheric, float altitude) {
|
||||
// Equation taken from BMP180 datasheet (page 16):
|
||||
// http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf
|
||||
|
||||
// Note that using the equation from wikipedia can give bad results
|
||||
// at high altitude. See this thread for more information:
|
||||
// http://forums.adafruit.com/viewtopic.php?f=22&t=58064
|
||||
return atmospheric / pow(1.0f - (altitude / 44330.0f), 5.255f);
|
||||
}
|
||||
|
||||
float altitudeFromPressure(float atmospheric, float seaLevel)
|
||||
{
|
||||
// Equation taken from BMP180 datasheet (page 16):
|
||||
// http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf
|
||||
|
||||
// Note that using the equation from wikipedia can give bad results
|
||||
// at high altitude. See this thread for more information:
|
||||
// http://forums.adafruit.com/viewtopic.php?f=22&t=58064
|
||||
return 44330.0f * (1.0f - pow(atmospheric / seaLevel, 0.1903f));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
In memory convert float to long
|
||||
\*********************************************************************************************/
|
||||
|
||||
@@ -38,6 +38,19 @@ float compute_dew_point_temp(float temperature, float humidity_percentage);
|
||||
// f = 100 * ((112 - 0.1*T + Td) / (112 + 0.9 * T))^8
|
||||
float compute_humidity_from_dewpoint(float temperature, float dew_temperature);
|
||||
|
||||
/********************************************************************************************\
|
||||
Compensate air pressure for measured atmospheric
|
||||
pressure (in hPa) and given altitude (in meters)
|
||||
\*********************************************************************************************/
|
||||
float pressureElevation(float atmospheric, float altitude);
|
||||
|
||||
/********************************************************************************************\
|
||||
Calculates the altitude (in meters) from the specified atmospheric
|
||||
pressure (in hPa), and sea-level pressure (in hPa).
|
||||
@param seaLevel Sea-level pressure in hPa
|
||||
@param atmospheric Atmospheric pressure in hPa
|
||||
\*********************************************************************************************/
|
||||
float altitudeFromPressure(float atmospheric, float seaLevel);
|
||||
|
||||
/********************************************************************************************\
|
||||
In memory convert float to long
|
||||
|
||||
@@ -1184,7 +1184,7 @@ String LoadFromFile(const char *fname, int offset, byte *memAddress, int datasiz
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
return log;
|
||||
}
|
||||
delay(1);
|
||||
delay(0);
|
||||
START_TIMER;
|
||||
#ifndef BUILD_NO_RAM_TRACKER
|
||||
checkRAM(F("LoadFromFile"));
|
||||
@@ -1196,7 +1196,7 @@ String LoadFromFile(const char *fname, int offset, byte *memAddress, int datasiz
|
||||
f.close();
|
||||
|
||||
STOP_TIMER(LOADFILE_STATS);
|
||||
delay(1);
|
||||
delay(0);
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
@@ -904,6 +904,8 @@ void parseStandardConversions(String& s, bool useURLencode) {
|
||||
float arg2 = 0.0f;
|
||||
SMART_CONV(F("%c_dew_th%"), toString(compute_dew_point_temp(arg1, arg2), 2))
|
||||
SMART_CONV(F("%c_u2ip%"), formatUnitToIPAddress(arg1, arg2))
|
||||
SMART_CONV(F("%c_alt_pres_sea%"), toString(altitudeFromPressure(arg1, arg2), 2))
|
||||
SMART_CONV(F("%c_sea_pres_alt%"), toString(pressureElevation(arg1, arg2), 2))
|
||||
#undef SMART_CONV
|
||||
}
|
||||
|
||||
|
||||
@@ -130,8 +130,4 @@ float P006_data_struct::readTemperature(void)
|
||||
return temp;
|
||||
}
|
||||
|
||||
float P006_data_struct::pressureElevation(float atmospheric, int altitude) {
|
||||
return atmospheric / pow(1.0f - (altitude / 44330.0f), 5.255f);
|
||||
}
|
||||
|
||||
#endif // ifdef USES_P006
|
||||
|
||||
@@ -18,9 +18,6 @@ struct P006_data_struct : public PluginTaskData_base {
|
||||
|
||||
float readTemperature(void);
|
||||
|
||||
float pressureElevation(float atmospheric,
|
||||
int altitude);
|
||||
|
||||
uint8_t oversampling = BMP085_ULTRAHIGHRES;
|
||||
int16_t ac1, ac2, ac3, b1, b2, mb, mc, md = 0;
|
||||
uint16_t ac4, ac5, ac6 = 0;
|
||||
|
||||
@@ -78,7 +78,7 @@ bool P020_Task::hasClientConnected() {
|
||||
if (ser2netClient) { ser2netClient.stop(); }
|
||||
ser2netClient = ser2netServer->available();
|
||||
ser2netClient.setTimeout(CONTROLLER_CLIENTTIMEOUT_DFLT);
|
||||
sendConnectedEvent(false);
|
||||
sendConnectedEvent(true);
|
||||
addLog(LOG_LEVEL_INFO, F("Ser2Net : Client connected!"));
|
||||
}
|
||||
|
||||
|
||||
@@ -397,22 +397,4 @@ float P028_data_struct::readHumidity()
|
||||
return h / 1024.0f;
|
||||
}
|
||||
|
||||
float P028_data_struct::Plugin_028_readAltitude(float seaLevel)
|
||||
{
|
||||
// Equation taken from BMP180 datasheet (page 16):
|
||||
// http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf
|
||||
|
||||
// Note that using the equation from wikipedia can give bad results
|
||||
// at high altitude. See this thread for more information:
|
||||
// http://forums.adafruit.com/viewtopic.php?f=22&t=58064
|
||||
|
||||
float atmospheric = readPressure() / 100.0f;
|
||||
|
||||
return 44330.0f * (1.0f - pow(atmospheric / seaLevel, 0.1903f));
|
||||
}
|
||||
|
||||
float P028_data_struct::pressureElevation(int altitude) {
|
||||
return last_press_val / pow(1.0f - (altitude / 44330.0f), 5.255f);
|
||||
}
|
||||
|
||||
#endif // ifdef USES_P028
|
||||
|
||||
@@ -156,19 +156,6 @@ struct P028_data_struct : public PluginTaskData_base {
|
||||
// **************************************************************************/
|
||||
float readHumidity();
|
||||
|
||||
// **************************************************************************/
|
||||
// Calculates the altitude (in meters) from the specified atmospheric
|
||||
// pressure (in hPa), and sea-level pressure (in hPa).
|
||||
// @param seaLevel Sea-level pressure in hPa
|
||||
// @param atmospheric Atmospheric pressure in hPa
|
||||
// **************************************************************************/
|
||||
float Plugin_028_readAltitude(float seaLevel);
|
||||
|
||||
// **************************************************************************/
|
||||
// MSL pressure formula
|
||||
// **************************************************************************/
|
||||
float pressureElevation(int altitude);
|
||||
|
||||
bme280_uncomp_data uncompensated;
|
||||
bme280_calib_data calib;
|
||||
float last_hum_val = 0.0f;
|
||||
|
||||
@@ -117,11 +117,5 @@ void P032_data_struct::readout() {
|
||||
ms5611_pressure = (((D1 * SENS) / (1 << 21) - Offset) / (1 << 15)); // FIXME TD-er: This is computed twice, is that correct?
|
||||
}
|
||||
|
||||
// **************************************************************************/
|
||||
// MSL pressure formula
|
||||
// **************************************************************************/
|
||||
double P032_data_struct::pressureElevation(double atmospheric, int altitude) {
|
||||
return atmospheric / pow(1.0f - (altitude / 44330.0f), 5.255f);
|
||||
}
|
||||
|
||||
#endif // ifdef USES_P032
|
||||
|
||||
@@ -35,12 +35,6 @@ public:
|
||||
// **************************************************************************/
|
||||
void readout();
|
||||
|
||||
// **************************************************************************/
|
||||
// MSL pressure formula
|
||||
// **************************************************************************/
|
||||
double pressureElevation(double atmospheric,
|
||||
int altitude);
|
||||
|
||||
uint8_t i2cAddress;
|
||||
unsigned int ms5611_prom[8] = { 0 };
|
||||
double ms5611_pressure = 0;
|
||||
|
||||
@@ -151,17 +151,16 @@ const String& P094_data_struct::peekSentence() const {
|
||||
}
|
||||
|
||||
void P094_data_struct::getSentence(String& string, bool appendSysTime) {
|
||||
string = std::move(sentence_part);
|
||||
sentence_part = ""; // FIXME TD-er: Should not be needed as move already cleared it.
|
||||
if (appendSysTime) {
|
||||
// Unix timestamp = 10 decimals + separator
|
||||
if (string.reserve(sentence_part.length() + 11)) {
|
||||
string = sentence_part;
|
||||
string += ';';
|
||||
string += node_time.getUnixTime();
|
||||
}
|
||||
sentence_part = "";
|
||||
} else {
|
||||
string = std::move(sentence_part);
|
||||
}
|
||||
sentence_part.reserve(string.length());
|
||||
}
|
||||
|
||||
void P094_data_struct::getSentencesReceived(uint32_t& succes, uint32_t& error, uint32_t& length_last) const {
|
||||
|
||||
@@ -203,6 +203,8 @@ void handle_sysvars() {
|
||||
addSysVar_html(F("{D}C to {D}F: %c_c2f%(20.4)"));
|
||||
addSysVar_html(F("m/s to Bft: %c_ms2Bft%(5.1)"));
|
||||
addSysVar_html(F("Dew point(T,H): %c_dew_th%(18.6,67)"));
|
||||
addSysVar_html(F("Altitude(air,sea): %c_alt_pres_sea%(850,1000)"));
|
||||
addSysVar_html(F("PressureElevation(air,alt): %c_sea_pres_alt%(850,1350.03)"));
|
||||
addFormSeparator(3);
|
||||
addSysVar_html(F("cm to imperial: %c_cm2imp%(190)"));
|
||||
addSysVar_html(F("mm to imperial: %c_mm2imp%(1900)"));
|
||||
|
||||
Reference in New Issue
Block a user