Skip to content

Commit ea35d73

Browse files
committed
Correct ws_pb_helpers includes + CompareVersion for Airlift FW + RSSI label
1 parent 8c338be commit ea35d73

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

src/Wippersnapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void Wippersnapper::getMacAddr() {
185185
/****************************************************************************/
186186
/*!
187187
@brief Gets the network's RSSI.
188-
@return int32_t RSSI value
188+
@return int32_t RSSI value, 0 to 255, in dB
189189
*/
190190
/****************************************************************************/
191191
int32_t Wippersnapper::getRSSI() {

src/nanopb/ws_pb_helpers.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* @file ws_pb_helpers.h
2+
* @file ws_pb_helpers.cpp
33
*
44
* Protobuf encode/decode helpers with error logging for Wippersnapper.
55
*
@@ -12,12 +12,9 @@
1212
* BSD license, all text here must be included in any redistribution.
1313
*
1414
*/
15-
#include "pb.h"
16-
#include "pb_decode.h"
17-
#include "pb_encode.h"
18-
#include "ws_pb_helpers.h"
19-
#include <Wippersnapper.h>
2015

16+
#include "ws_pb_helpers.h"
17+
#include "../Wippersnapper.h"
2118

2219
// *****************************************************************************
2320
/*!
@@ -32,7 +29,7 @@
3229
!*/
3330
// *****************************************************************************
3431
bool ws_pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields,
35-
void *dest_struct) {
32+
void *dest_struct) {
3633
bool status = pb_decode(stream, fields, dest_struct);
3734
if (!status) {
3835
WS_DEBUG_PRINT("Protobuf decode error: ");
@@ -54,7 +51,7 @@ bool ws_pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields,
5451
!*/
5552
// *****************************************************************************
5653
bool ws_pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields,
57-
const void *src_struct) {
54+
const void *src_struct) {
5855
bool status = pb_encode(stream, fields, src_struct);
5956
if (!status) {
6057
WS_DEBUG_PRINT("Protobuf encode error: ");

src/nanopb/ws_pb_helpers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#define WS_PB_ENCODE_H
1717

1818
#include "pb.h"
19+
#include "pb_decode.h"
20+
#include "pb_encode.h"
1921

2022
bool ws_pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields,
2123
void *dest_struct);

src/network_interfaces/Wippersnapper_AIRLIFT.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,23 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
193193
equal to the required version, False otherwise.
194194
*/
195195
/********************************************************/
196-
bool compareVersions(const String &currentVersion,
197-
const String &requiredVersion) {
198-
int curMajor, curMinor, curPatch;
199-
int reqMajor, reqMinor, reqPatch;
200-
201-
sscanf(currentVersion.c_str(), "%d.%d.%d", &curMajor, &curMinor, &curPatch);
202-
sscanf(requiredVersion.c_str(), "%d.%d.%d", &reqMajor, &reqMinor,
203-
&reqPatch);
196+
bool compareVersions(const char *currentVersion,
197+
const char *requiredVersion) {
198+
int curMajor, curMinor, curPatch = 0;
199+
int reqMajor, reqMinor, reqPatch = 0;
200+
201+
if (!sscanf(currentVersion, "%d.%d.%d", &curMajor, &curMinor, &curPatch) ||
202+
!sscanf(requiredVersion, "%d.%d.%d", &reqMajor, &reqMinor, &reqPatch)) {
203+
WS_DEBUG_PRINTLN("Error parsing firmware version strings");
204+
WS_PRINTER.flush();
205+
WS_DEBUG_PRINT("Required version: ");
206+
WS_DEBUG_PRINTLN(requiredVersion);
207+
WS_PRINTER.flush();
208+
WS_DEBUG_PRINT("Current version: ");
209+
WS_DEBUG_PRINTLN(currentVersion);
210+
WS_PRINTER.flush();
211+
return false;
212+
}
204213

205214
if (curMajor != reqMajor)
206215
return curMajor > reqMajor;
@@ -272,7 +281,7 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
272281
protected:
273282
const char *_ssid; /*!< Network SSID. */
274283
const char *_pass; /*!< Network password. */
275-
String _fv; /*!< nina-fw firmware version. */
284+
const char *_fv; /*!< nina-fw firmware version. */
276285
int _ssPin = -1; /*!< SPI S.S. pin. */
277286
int _ackPin = -1; /*!< SPI ACK pin. */
278287
int _rstPin = -1; /*!< SPI RST pin. */
@@ -326,7 +335,7 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
326335
RETRY_FUNCTION_UNTIL_TIMEOUT(
327336
[]() -> int { return WiFi.status(); }, // Function call each cycle
328337
int, // return type
329-
lastResult, // return variable (unused here)
338+
lastResult, // return variable
330339
[](int status) { return status == WL_CONNECTED; }, // check
331340
20000, // timeout interval (ms)
332341
200); // interval between retries

0 commit comments

Comments
 (0)