Initial RAK One-Wire implementation for WisMesh Solar Repeater#1847
Initial RAK One-Wire implementation for WisMesh Solar Repeater#1847hb9fxq wants to merge 1 commit intomeshcore-dev:mainfrom
Conversation
…e (RAK9154 Solar Battery + RAK2560_HZB + RAK4630 Module) to report battery pack telemetry in channel 2
|
|
||
| case SNHUBAPI_EVT_SDATA_REQ: { | ||
| uint8_t ipso_type = msg[0]; | ||
| uint16_t val_len = len - 1; |
There was a problem hiding this comment.
can len be passed in as 0? would the resulting value for val_len (65536) for the subsequent loop be a problem?
| uint16_t val_len = len - 1; | ||
|
|
||
| uint8_t ordered[256]; | ||
| for (uint16_t i = 0; i < val_len; i += 2) { |
There was a problem hiding this comment.
if val_len is >= 256, the writes to ordered would be beyond the end of its allocated size. can val_len be that value?
| bool OneWireSensorHub::hasVoltage() const { return _has_voltage; } | ||
| float OneWireSensorHub::getVoltage() const { return _cached_voltage; } | ||
| bool OneWireSensorHub::hasCurrent() const { return _has_current; } | ||
| float OneWireSensorHub::getCurrent() const { return (float)_cached_current_ma / 100.0f; } |
There was a problem hiding this comment.
should this be dividing by 1000 to go from mA to A?
There was a problem hiding this comment.
if the value is 1/100 of an amp, then the variable should not be named "ma" (milli means 1/1000). I would suggest keeping the variable representing ma and divide by 10 when fetching from the hardware, and fix this line to divide by 1000. I prefer consistency, and most other variants use ma, ma is a more common unit, etc
| uint8_t* msg, uint16_t len) { | ||
| switch (eid) { | ||
| case SNHUBAPI_EVT_QSEND: | ||
| oneWireSerial.write(msg, len); |
There was a problem hiding this comment.
should the return value of write() be checked to handle failed or partial writes?
|
Thx @robekl for the inputs, will update probably tonight or on the weekend! Do you also have the HW to verify? |
WisMesh Solar Repeater boundle (RAK9154 Solar Battery + RAK2560_HZB + RAK4630 Module) to report battery pack telemetry in channel 2