Skip to content

Commit

Permalink
add rssi info, reset stored enhanced infos when device was reset
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Dec 26, 2023
1 parent 6630a81 commit 442ff4e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/enhanced_proto.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 20 additions & 0 deletions src/lib/ebus/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -548,6 +559,7 @@ void EnhancedCharDevice::notifyInfoRetrieved() {
stream << "firmware " << m_enhInfoVersion;
if (len >= 5) {
stream << ", jumpers 0x" << setw(2) << static_cast<unsigned>(data[4]);
m_enhInfoIsWifi = (data[4]&0x08)!=0;
}
stream << setfill(' '); // reset
break;
Expand Down Expand Up @@ -610,6 +622,14 @@ void EnhancedCharDevice::notifyInfoRetrieved() {
stream << "unknown";
}
break;
case 0x0107:
stream << "rssi ";
if (data[0]) {
stream << static_cast<signed>(((int8_t*)data)[0]) << " dBm";
} else {
stream << "unknown";
}
break;
default:
stream << "unknown 0x" << hex << setfill('0') << setw(2)
<< static_cast<unsigned>(id) << ", len " << dec << setw(0)
Expand Down
5 changes: 4 additions & 1 deletion src/lib/ebus/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 442ff4e

Please sign in to comment.