add rssi info, reset stored enhanced infos when device was reset

This commit is contained in:
John
2023-12-26 15:18:16 +01:00
parent 6630a81f33
commit 442ff4ece8
3 changed files with 27 additions and 1 deletions
+3
View File
@@ -139,3 +139,6 @@ The first byte transferred in response is always the number of data bytes to be
* `length`: =2 * `length`: =2
* `reset_cause`: reset cause (1=power-on, 2=brown-out, 3=watchdog, 4=clear, 5=reset, 6=stack, 7=memory) * `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) * `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
+20
View File
@@ -266,6 +266,12 @@ string EnhancedCharDevice::getEnhancedInfos() {
if (res != RESULT_OK) { if (res != RESULT_OK) {
fails += ", cannot request bus voltage"; 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 res = requestEnhancedInfo(0xff); // wait for completion
if (res != RESULT_OK) { if (res != RESULT_OK) {
m_enhInfoBusVoltage = "bus voltage unknown"; m_enhInfoBusVoltage = "bus voltage unknown";
@@ -360,6 +366,11 @@ result_t EnhancedCharDevice::notifyTransportStatus(bool opened) {
// reset state // reset state
m_extraFatures = 0; m_extraFatures = 0;
m_infoLen = 0; m_infoLen = 0;
m_enhInfoVersion = "";
m_enhInfoIsWifi = false;
m_enhInfoTemperature = "";
m_enhInfoSupplyVoltage = "";
m_enhInfoBusVoltage = "";
m_arbitrationMaster = SYN; m_arbitrationMaster = SYN;
m_arbitrationCheck = 0; m_arbitrationCheck = 0;
} }
@@ -548,6 +559,7 @@ void EnhancedCharDevice::notifyInfoRetrieved() {
stream << "firmware " << m_enhInfoVersion; stream << "firmware " << m_enhInfoVersion;
if (len >= 5) { if (len >= 5) {
stream << ", jumpers 0x" << setw(2) << static_cast<unsigned>(data[4]); stream << ", jumpers 0x" << setw(2) << static_cast<unsigned>(data[4]);
m_enhInfoIsWifi = (data[4]&0x08)!=0;
} }
stream << setfill(' '); // reset stream << setfill(' '); // reset
break; break;
@@ -610,6 +622,14 @@ void EnhancedCharDevice::notifyInfoRetrieved() {
stream << "unknown"; stream << "unknown";
} }
break; break;
case 0x0107:
stream << "rssi ";
if (data[0]) {
stream << static_cast<signed>(((int8_t*)data)[0]) << " dBm";
} else {
stream << "unknown";
}
break;
default: default:
stream << "unknown 0x" << hex << setfill('0') << setw(2) stream << "unknown 0x" << hex << setfill('0') << setw(2)
<< static_cast<unsigned>(id) << ", len " << dec << setw(0) << static_cast<unsigned>(id) << ", len " << dec << setw(0)
+4 -1
View File
@@ -252,7 +252,7 @@ class EnhancedCharDevice : public CharDevice {
*/ */
explicit EnhancedCharDevice(Transport* transport) explicit EnhancedCharDevice(Transport* transport)
: CharDevice(transport), m_resetRequested(false), : 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 // @copydoc
@@ -340,6 +340,9 @@ class EnhancedCharDevice : public CharDevice {
/** a string describing the enhanced device version. */ /** a string describing the enhanced device version. */
string m_enhInfoVersion; string m_enhInfoVersion;
/** whether the device is known to be connected via WIFI. */
bool m_enhInfoIsWifi;
/** a string describing the enhanced device temperature. */ /** a string describing the enhanced device temperature. */
string m_enhInfoTemperature; string m_enhInfoTemperature;