Skip to content

Commit

Permalink
0.8.63
Browse files Browse the repository at this point in the history
* made code review
* fixed endless loop #1387
  • Loading branch information
lumapu committed Jan 22, 2024
1 parent e039820 commit 77b1f96
Show file tree
Hide file tree
Showing 21 changed files with 290 additions and 273 deletions.
4 changes: 2 additions & 2 deletions src/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@
},
"cmake.configureOnOpen": false,
"editor.formatOnSave": false,
"cmake.sourceDirectory": "C:/lpusch/github/ahoy/src/.pio/libdeps/esp32-wroom32-release-prometheus/Adafruit BusIO",
}
"cmake.sourceDirectory": "C:/lpusch/github/ahoy/src/.pio/libdeps/esp32-wroom32-release-prometheus/Adafruit BusIO"
}
4 changes: 4 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Development Changes

## 0.8.63 - 2024-01-22
* made code review
* fixed endless loop #1387

## 0.8.62 - 2024-01-21
* updated version in footer #1381
* repaired radio statistics #1382
Expand Down
24 changes: 11 additions & 13 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,20 @@ void app::loop(void) {
esp_task_wdt_reset();

if(mConfig->nrf.enabled)
mNrfActive = mNrfRadio.loop();
mNrfRadio.loop();

if(!mNrfActive) {
#if defined(ESP32)
if(mConfig->cmt.enabled)
mNrfActive = mCmtRadio.loop();
#endif
#if defined(ESP32)
if(mConfig->cmt.enabled)
mCmtRadio.loop();
#endif

ah::Scheduler::loop();
mCommunication.loop();
ah::Scheduler::loop();
mCommunication.loop();

#if defined(ENABLE_MQTT)
if (mMqttEnabled && mNetworkConnected)
mMqtt.loop();
#endif
}
#if defined(ENABLE_MQTT)
if (mMqttEnabled && mNetworkConnected)
mMqtt.loop();
#endif
yield();
}

Expand Down
3 changes: 1 addition & 2 deletions src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class app : public IApp, public ah::Scheduler {
~app() {}

void setup(void);
void loop(void);
void loop(void) override;
void onNetwork(bool gotIp);
void regularTickers(void);

Expand Down Expand Up @@ -405,7 +405,6 @@ class app : public IApp, public ah::Scheduler {
uint8_t mSendLastIvId;
bool mSendFirst;
bool mAllIvNotAvail;
bool mNrfActive = false;

bool mNetworkConnected;

Expand Down
8 changes: 6 additions & 2 deletions src/config/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,10 @@ class settings {

#if defined(ESP32)
void getChar(JsonObject obj, const char *key, char *dst, int maxLen) {
if(obj.containsKey(key))
if(obj.containsKey(key)) {
snprintf(dst, maxLen, "%s", obj[key].as<const char*>());
dst[maxLen-1] = '\0';
}
}

template<typename T=uint8_t>
Expand All @@ -835,8 +837,10 @@ class settings {
}
#else
void getChar(JsonObject obj, const __FlashStringHelper *key, char *dst, int maxLen) {
if(obj.containsKey(key))
if(obj.containsKey(key)) {
snprintf(dst, maxLen, "%s", obj[key].as<const char*>());
dst[maxLen-1] = '\0';
}
}

template<typename T=uint8_t>
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 62
#define VERSION_PATCH 63

//-------------------------------------
typedef struct {
Expand Down
6 changes: 3 additions & 3 deletions src/eth/ahoyeth.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//-----------------------------------------------------------------------------
// 2023 Ahoy, https://www.mikrocontroller.net/topic/525778
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// 2024 Ahoy, https://github.com/lumpapu/ahoy
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/4.0/deed
//-----------------------------------------------------------------------------

#if defined(ETHERNET)
Expand Down Expand Up @@ -49,7 +49,7 @@ class ahoyeth {
#if defined(CONFIG_IDF_TARGET_ESP32S3)
EthSpi mEthSpi;
#endif
settings_t *mConfig;
settings_t *mConfig = NULL;

uint32_t *mUtcTimestamp;
AsyncUDP mUdp; // for time server
Expand Down
15 changes: 10 additions & 5 deletions src/hm/nrfHal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//-----------------------------------------------------------------------------
// 2023 Ahoy, https://www.mikrocontroller.net/topic/525778
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// 2024 Ahoy, https://github.com/lumpapu/ahoy
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/4.0/deed
//-----------------------------------------------------------------------------

#ifndef __NRF_HAL_H__
Expand Down Expand Up @@ -144,6 +144,8 @@ class nrfHal: public RF24_hal, public SpiPatcherHandle {
uint8_t read(uint8_t cmd, uint8_t* buf, uint8_t len) override {
uint8_t data[NRF_MAX_TRANSFER_SZ];
data[0] = cmd;
if(len > NRF_MAX_TRANSFER_SZ)
len = NRF_MAX_TRANSFER_SZ;
memset(&data[1], 0xff, len);

request_spi();
Expand All @@ -168,13 +170,16 @@ class nrfHal: public RF24_hal, public SpiPatcherHandle {
}

uint8_t read(uint8_t cmd, uint8_t* buf, uint8_t data_len, uint8_t blank_len) override {
uint8_t data[NRF_MAX_TRANSFER_SZ];
uint8_t data[NRF_MAX_TRANSFER_SZ + 1];
uint8_t len = data_len + blank_len;
data[0] = cmd;
memset(&data[1], 0xff, (data_len + blank_len));
if(len > (NRF_MAX_TRANSFER_SZ + 1))
len = (NRF_MAX_TRANSFER_SZ + 1);
memset(&data[1], 0xff, len);

request_spi();

size_t spiLen = (static_cast<size_t>(data_len) + static_cast<size_t>(blank_len) + 1u) << 3;
size_t spiLen = (static_cast<size_t>(len) + 1u) << 3;
spi_transaction_t t = {
.flags = 0,
.cmd = 0,
Expand Down
Loading

0 comments on commit 77b1f96

Please sign in to comment.