diff --git a/docs/enhanced_proto.md b/docs/enhanced_proto.md index ea157a73f..2869bbcbf 100644 --- a/docs/enhanced_proto.md +++ b/docs/enhanced_proto.md @@ -139,3 +139,6 @@ The first byte transferred in response is always the number of data bytes to be * `length`: =2 * `reset_cause`: reset cause (1=power-on, 2=brown-out, 3=watchdog, 4=clear, 5=reset, 6=stack, 7=memory) * `restart_count`: restart count (within same power cycle) + * 0x07: WIFI status (since 20231226) + * `length`: =2 + * `rssi`: signal strength in dBm (rssi, usually negative), 0 if unknown diff --git a/src/lib/ebus/device.cpp b/src/lib/ebus/device.cpp index 0fd83b0bf..55494bd15 100755 --- a/src/lib/ebus/device.cpp +++ b/src/lib/ebus/device.cpp @@ -266,6 +266,12 @@ string EnhancedCharDevice::getEnhancedInfos() { if (res != RESULT_OK) { fails += ", cannot request bus voltage"; } + if (m_enhInfoIsWifi) { + res = requestEnhancedInfo(7); + if (res != RESULT_OK) { + fails += ", cannot request rssi"; + } + } res = requestEnhancedInfo(0xff); // wait for completion if (res != RESULT_OK) { m_enhInfoBusVoltage = "bus voltage unknown"; @@ -360,6 +366,11 @@ result_t EnhancedCharDevice::notifyTransportStatus(bool opened) { // reset state m_extraFatures = 0; m_infoLen = 0; + m_enhInfoVersion = ""; + m_enhInfoIsWifi = false; + m_enhInfoTemperature = ""; + m_enhInfoSupplyVoltage = ""; + m_enhInfoBusVoltage = ""; m_arbitrationMaster = SYN; m_arbitrationCheck = 0; } @@ -548,6 +559,7 @@ void EnhancedCharDevice::notifyInfoRetrieved() { stream << "firmware " << m_enhInfoVersion; if (len >= 5) { stream << ", jumpers 0x" << setw(2) << static_cast(data[4]); + m_enhInfoIsWifi = (data[4]&0x08)!=0; } stream << setfill(' '); // reset break; @@ -610,6 +622,14 @@ void EnhancedCharDevice::notifyInfoRetrieved() { stream << "unknown"; } break; + case 0x0107: + stream << "rssi "; + if (data[0]) { + stream << static_cast(((int8_t*)data)[0]) << " dBm"; + } else { + stream << "unknown"; + } + break; default: stream << "unknown 0x" << hex << setfill('0') << setw(2) << static_cast(id) << ", len " << dec << setw(0) diff --git a/src/lib/ebus/device.h b/src/lib/ebus/device.h index 9e67ca908..d4224017e 100755 --- a/src/lib/ebus/device.h +++ b/src/lib/ebus/device.h @@ -252,7 +252,7 @@ class EnhancedCharDevice : public CharDevice { */ explicit EnhancedCharDevice(Transport* transport) : CharDevice(transport), m_resetRequested(false), - m_extraFatures(0), m_infoReqTime(0), m_infoLen(0), m_infoPos(0) { + m_extraFatures(0), m_infoReqTime(0), m_infoLen(0), m_infoPos(0), m_enhInfoIsWifi(false) { } // @copydoc @@ -340,6 +340,9 @@ class EnhancedCharDevice : public CharDevice { /** a string describing the enhanced device version. */ string m_enhInfoVersion; + /** whether the device is known to be connected via WIFI. */ + bool m_enhInfoIsWifi; + /** a string describing the enhanced device temperature. */ string m_enhInfoTemperature;