Skip to content

Commit

Permalink
PlatformIO package 6.4.0 (Arduino Version remains 2.0.11)
Browse files Browse the repository at this point in the history
LPCD, RFID_IRQ on port-expander: fix compiler warning
portTICK_RATE_MS is deprecated, use portTICK_PERIOD_MS instead (espressif/esp-idf#51)
Cppcheck: Fix some warnings/hints
  • Loading branch information
tueddy committed Oct 26, 2023
1 parent b6deb34 commit cc8a33d
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 43 deletions.
6 changes: 5 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## DEV-branch

* 22.10.2023: bugfix PortExpander: beginTransmission()/endTransmission() must be balanced
* 26.10.2023: PlatformIO package 6.4.0 (Arduino Version remains 2.0.11)
* 26.10.2023: LPCD, RFID_IRQ on port-expander: fix compiler warning
* 26.10.2023: portTICK_RATE_MS is deprecated, use portTICK_PERIOD_MS instead (https://github.com/espressif/esp-idf/issues/51)
* 26.10.2023: Cppcheck: Fix some warnings/hints
* 22.10.2023: Bugfix PortExpander: beginTransmission()/endTransmission() must be balanced
* 21.10.2023: Enhanced logging: Show Loglevel
* 14.10.2023: New define NO_SDCARD, enable to start without any SD card, e.g. for a webplayer only.
* 05.10.2023: Enable "Arduino as component" by default
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ default_envs = lolin_d32_pro_sdmmc_pe
board_build.flash_mode = qio
board_build.bootloader = dio
board_build.partitions = custom_4mb_noota.csv
platform = espressif32@^6.3.2
platform = espressif32@^6.4.0
;platform = espressif32
;platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
;framework = arduino
Expand Down
10 changes: 5 additions & 5 deletions src/AudioPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void AudioPlayer_Exit(void) {
if (!gPlayProperties.pausePlay && (gPlayProperties.playMode == AUDIOBOOK || gPlayProperties.playMode == AUDIOBOOK_LOOP)) {
AudioPlayer_TrackControlToQueueSender(PAUSEPLAY);
while (!gPlayProperties.pausePlay) { // Make sure to wait until playback is paused in order to be sure that playposition saved in NVS
vTaskDelay(portTICK_RATE_MS * 100u);
vTaskDelay(portTICK_PERIOD_MS * 100u);
}
}
#endif
Expand Down Expand Up @@ -898,7 +898,7 @@ void AudioPlayer_TrackQueueDispatcher(const char *_itemToPlay, const uint32_t _l
if (!gPlayProperties.pausePlay && (gPlayProperties.playMode == AUDIOBOOK || gPlayProperties.playMode == AUDIOBOOK_LOOP)) {
AudioPlayer_TrackControlToQueueSender(PAUSEPLAY);
while (!gPlayProperties.pausePlay) { // Make sure to wait until playback is paused in order to be sure that playposition saved in NVS
vTaskDelay(portTICK_RATE_MS * 100u);
vTaskDelay(portTICK_PERIOD_MS * 100u);
}
}
#endif
Expand All @@ -914,7 +914,7 @@ void AudioPlayer_TrackQueueDispatcher(const char *_itemToPlay, const uint32_t _l

if (_playMode != WEBSTREAM) {
if (_playMode == RANDOM_SUBDIRECTORY_OF_DIRECTORY || _playMode == RANDOM_SUBDIRECTORY_OF_DIRECTORY_ALL_TRACKS_OF_DIR_RANDOM) {
char *tmp = SdCard_pickRandomSubdirectory(filename); // *filename (input): target-directory // *filename (output): random subdirectory
const char *tmp = SdCard_pickRandomSubdirectory(filename); // *filename (input): target-directory // *filename (output): random subdirectory
if (tmp == NULL) { // If error occured while extracting random subdirectory
musicFiles = NULL;
} else {
Expand Down Expand Up @@ -944,7 +944,7 @@ void AudioPlayer_TrackQueueDispatcher(const char *_itemToPlay, const uint32_t _l
if (!gPlayProperties.pausePlay) {
AudioPlayer_TrackControlToQueueSender(STOP);
while (!gPlayProperties.pausePlay) {
vTaskDelay(portTICK_RATE_MS * 10u);
vTaskDelay(portTICK_PERIOD_MS * 10u);
}
}

Expand Down Expand Up @@ -1083,7 +1083,7 @@ size_t AudioPlayer_NvsRfidWriteWrapper(const char *_rfidCardId, const char *_tra
// If it's a directory we just want to play/save basename(path)
if (_numberOfTracks > 1) {
const char s = '/';
char *last = strrchr(_track, s);
const char *last = strrchr(_track, s);
char *first = strchr(_track, s);
unsigned long substr = last - first + 1;
if (substr <= sizeof(trackBuf) / sizeof(trackBuf[0])) {
Expand Down
4 changes: 2 additions & 2 deletions src/Bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
};
size_t sampleSize = 0;
uint8_t* sampleBuff;
sampleBuff = (uint8_t *)xRingbufferReceiveUpTo(audioSourceRingBuffer, &sampleSize, (portTickType)portMAX_DELAY, channel_len * 4);
sampleBuff = (uint8_t *)xRingbufferReceiveUpTo(audioSourceRingBuffer, &sampleSize, (TickType_t)portMAX_DELAY, channel_len * 4);
if (sampleBuff != NULL) {
// fill the channel data
for (int sample = 0; sample < (channel_len); ++sample) {
Expand Down Expand Up @@ -307,7 +307,7 @@ bool Bluetooth_Source_SendAudioData(uint32_t* sample) {
#ifdef BLUETOOTH_ENABLE
// send audio data to ringbuffer
if ((System_GetOperationMode() == OPMODE_BLUETOOTH_SOURCE) && (a2dp_source) && a2dp_source->is_connected()) {
return (pdTRUE == xRingbufferSend(audioSourceRingBuffer, sample, sizeof(uint32_t), (portTickType)portMAX_DELAY));
return (pdTRUE == xRingbufferSend(audioSourceRingBuffer, sample, sizeof(uint32_t), (TickType_t)portMAX_DELAY));
} else {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void Led_SetButtonLedsEnabled(boolean value) {
for (;;) {
// special handling
if (Led_Pause) { // Workaround to prevent exceptions while NVS-writes take place
vTaskDelay(portTICK_RATE_MS * 10);
vTaskDelay(portTICK_PERIOD_MS * 10);
continue;
}

Expand Down Expand Up @@ -417,7 +417,7 @@ void Led_SetButtonLedsEnabled(boolean value) {
taskDelay = animationTimer;
}
animationTimer -= taskDelay;
vTaskDelay(portTICK_RATE_MS * taskDelay);
vTaskDelay(portTICK_PERIOD_MS * taskDelay);
}
vTaskDelete(NULL);
}
Expand Down
8 changes: 4 additions & 4 deletions src/RfidMfrc522.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@

for (;;) {
if (RFID_SCAN_INTERVAL/2 >= 20) {
vTaskDelay(portTICK_RATE_MS * (RFID_SCAN_INTERVAL/2));
vTaskDelay(portTICK_PERIOD_MS * (RFID_SCAN_INTERVAL/2));
} else {
vTaskDelay(portTICK_RATE_MS * 20);
vTaskDelay(portTICK_PERIOD_MS * 20);
}
byte cardId[cardIdSize];
String cardIdString;
Expand Down Expand Up @@ -146,9 +146,9 @@
// https://github.com/miguelbalboa/rfid/issues/188; voodoo! :-)
while (true) {
if (RFID_SCAN_INTERVAL/2 >= 20) {
vTaskDelay(portTICK_RATE_MS * (RFID_SCAN_INTERVAL/2));
vTaskDelay(portTICK_PERIOD_MS * (RFID_SCAN_INTERVAL/2));
} else {
vTaskDelay(portTICK_RATE_MS * 20);
vTaskDelay(portTICK_PERIOD_MS * 20);
}
control=0;
for (uint8_t i=0u; i<3; i++) {
Expand Down
22 changes: 13 additions & 9 deletions src/RfidPn5180.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include <Arduino.h>
#include <freertos/task.h>
#include <esp_task_wdt.h>
#include <driver/gpio.h>
#include "settings.h"
#include "Rfid.h"
#include "Log.h"
#include "MemX.h"
#include "Queues.h"
#include "System.h"
#include "Port.h"
#include <esp_task_wdt.h>
#include "AudioPlayer.h"
#include "HallEffectSensor.h"

Expand Down Expand Up @@ -104,13 +104,13 @@ extern unsigned long Rfid_LastRfidCheckTimestamp;
}

for (;;) {
vTaskDelay(portTICK_RATE_MS * 10u);
vTaskDelay(portTICK_PERIOD_MS * 10u);
#ifdef PN5180_ENABLE_LPCD
if (Rfid_GetLpcdShutdownStatus()) {
Rfid_EnableLpcd();
Rfid_SetLpcdShutdownStatus(false); // give feedback that execution is complete
while (true) {
vTaskDelay(portTICK_RATE_MS * 100u); // there's no way back if shutdown was initiated
vTaskDelay(portTICK_PERIOD_MS * 100u); // there's no way back if shutdown was initiated
}
}
#endif
Expand Down Expand Up @@ -300,7 +300,7 @@ extern unsigned long Rfid_LastRfidCheckTimestamp;
#ifdef PN5180_ENABLE_LPCD
Rfid_SetLpcdShutdownStatus(true);
while (Rfid_GetLpcdShutdownStatus()) { // Make sure init of LPCD is complete!
vTaskDelay(portTICK_RATE_MS * 10u);
vTaskDelay(portTICK_PERIOD_MS * 10u);
}
#endif
vTaskDelete(rfidTaskHandle);
Expand Down Expand Up @@ -332,15 +332,16 @@ extern unsigned long Rfid_LastRfidCheckTimestamp;
Log_Printf("IRQ_PIN_CONFIG=0x%02X", irqConfig)
*/
nfc.prepareLPCD();
Log_Println("PN5180 IRQ PIN: ", LOGLEVEL_NOTICE);
Serial.println(Port_Read(RFID_IRQ));
Log_Printf(LOGLEVEL_DEBUG, "PN5180 IRQ PIN (%d) state: %d", RFID_IRQ, Port_Read(RFID_IRQ));
// turn on LPCD
uint16_t wakeupCounterInMs = 0x3FF; // must be in the range of 0x0 - 0xA82. max wake-up time is 2960 ms.
if (nfc.switchToLPCD(wakeupCounterInMs)) {
Log_Println("switch to low power card detection: success", LOGLEVEL_NOTICE);
// configure wakeup pin for deep-sleep wake-up, use ext1
// configure wakeup pin for deep-sleep wake-up, use ext1. For a real GPIO only, not PE
#if (RFID_IRQ >= 0 && RFID_IRQ <= MAX_GPIO)
esp_sleep_enable_ext1_wakeup((1ULL << (RFID_IRQ)), ESP_EXT1_WAKEUP_ALL_LOW);
if (ESP_ERR_INVALID_ARG == esp_sleep_enable_ext1_wakeup((1ULL << (RFID_IRQ)), ESP_EXT1_WAKEUP_ALL_LOW)) {
Log_Printf(LOGLEVEL_ERROR, wrongWakeUpGpio, RFID_IRQ);
}
#endif
// freeze pin states in deep sleep
gpio_hold_en(gpio_num_t(RFID_CS)); // CS/NSS
Expand Down Expand Up @@ -373,7 +374,10 @@ extern unsigned long Rfid_LastRfidCheckTimestamp;
if (nfc14443.switchToLPCD(wakeupCounterInMs)) {
Log_Println(lowPowerCardSuccess, LOGLEVEL_INFO);
// configure wakeup pin for deep-sleep wake-up, use ext1
esp_sleep_enable_ext1_wakeup((1ULL << (RFID_IRQ)), ESP_EXT1_WAKEUP_ALL_LOW);
#if (RFID_IRQ >= 0 && RFID_IRQ <= MAX_GPIO)
// configure wakeup pin for deep-sleep wake-up, use ext1. For a real GPIO only, not PE
esp_sleep_enable_ext1_wakeup((1ULL << (RFID_IRQ)), ESP_EXT1_WAKEUP_ALL_LOW);
#endif
// freeze pin states in deep sleep
gpio_hold_en(gpio_num_t(RFID_CS)); // CS/NSS
gpio_hold_en(gpio_num_t(RFID_RST)); // RST
Expand Down
2 changes: 1 addition & 1 deletion src/SdCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ char *SdCard_pickRandomSubdirectory(char *_directory) {
char **SdCard_ReturnPlaylist(const char *fileName, const uint32_t _playMode) {
static char **files;
char *serializedPlaylist = NULL;
char fileNameBuf[255];
bool enablePlaylistFromM3u = false;
//uint32_t listStartTimestamp = millis();

Expand Down Expand Up @@ -321,6 +320,7 @@ char **SdCard_ReturnPlaylist(const char *fileName, const uint32_t _playMode) {
// Don't read from m3u-file. Means: read filenames from SD and make playlist of it
if (!enablePlaylistFromM3u) {
Log_Println(playlistGen, LOGLEVEL_NOTICE);
char fileNameBuf[255];
// File-mode
if (!fileOrDirectory.isDirectory()) {
files = (char **) x_malloc(sizeof(char *) * 2);
Expand Down
31 changes: 15 additions & 16 deletions src/Web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,10 @@ bool JSONToSettings(JsonObject doc) {
} else if (doc.containsKey("rfidMod")) {
const char *_rfidIdModId = doc["rfidMod"]["rfidIdMod"];
uint8_t _modId = doc["rfidMod"]["modId"];
char rfidString[12];
if (_modId <= 0) {
gPrefsRfid.remove(_rfidIdModId);
} else {
char rfidString[12];
snprintf(rfidString, sizeof(rfidString) / sizeof(rfidString[0]), "%s0%s0%s%u%s0", stringDelimiter, stringDelimiter, stringDelimiter, _modId, stringDelimiter);
gPrefsRfid.putString(_rfidIdModId, rfidString);

Expand Down Expand Up @@ -1031,7 +1031,7 @@ void onWebsocketEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsE
Log_Printf(LOGLEVEL_DEBUG, "ws[%s][%u] pong[%u]: %s", server->url(), client->id(), len, (len) ? (char *)data : "");
} else if (type == WS_EVT_DATA) {
//data packet
AwsFrameInfo *info = (AwsFrameInfo *)arg;
const AwsFrameInfo *info = (AwsFrameInfo *)arg;
if (info && info->final && info->index == 0 && info->len == len && client && len > 0) {
//the whole message is in a single frame and we got all of it's data
//Serial.printf("ws[%s][%u] %s-message[%llu]: ", server->url(), client->id(), (info->opcode == WS_TEXT) ? "text" : "binary", info->len);
Expand Down Expand Up @@ -1083,7 +1083,7 @@ void explorerHandleFileUpload(AsyncWebServerRequest *request, String filename, s
String utf8FilePath;
static char filePath[MAX_FILEPATH_LENTGH];
if (request->hasParam("path")) {
AsyncWebParameter *param = request->getParam("path");
const AsyncWebParameter *param = request->getParam("path");
utf8Folder = param->value() + "/";
}
utf8FilePath = utf8Folder + filename;
Expand Down Expand Up @@ -1269,11 +1269,11 @@ void explorerHandleListRequest(AsyncWebServerRequest *request) {
#endif

String serializedJsonString;
AsyncWebParameter *param;
char filePath[MAX_FILEPATH_LENTGH];
JsonArray obj = jsonBuffer.createNestedArray();
File root;
if (request->hasParam("path")) {
AsyncWebParameter *param;
param = request->getParam("path");
convertFilenameToAscii(param->value(), filePath);
root = gFSystem.open(filePath);
Expand Down Expand Up @@ -1389,9 +1389,9 @@ void explorerHandleDownloadRequest(AsyncWebServerRequest *request) {
// requires a GET parameter path to the file or directory
void explorerHandleDeleteRequest(AsyncWebServerRequest *request) {
File file;
AsyncWebParameter *param;
char filePath[MAX_FILEPATH_LENTGH];
if (request->hasParam("path")) {
AsyncWebParameter *param;
param = request->getParam("path");
convertFilenameToAscii(param->value(), filePath);
if (gFSystem.exists(filePath)) {
Expand Down Expand Up @@ -1425,9 +1425,9 @@ void explorerHandleDeleteRequest(AsyncWebServerRequest *request) {
// Handles create request of a directory
// requires a GET parameter path to the new directory
void explorerHandleCreateRequest(AsyncWebServerRequest *request) {
AsyncWebParameter *param;
char filePath[MAX_FILEPATH_LENTGH];
if (request->hasParam("path")) {
AsyncWebParameter *param;
char filePath[MAX_FILEPATH_LENTGH];
param = request->getParam("path");
convertFilenameToAscii(param->value(), filePath);
if (gFSystem.mkdir(filePath)) {
Expand All @@ -1445,11 +1445,11 @@ void explorerHandleCreateRequest(AsyncWebServerRequest *request) {
// requires a GET parameter srcpath to the old file or directory name
// requires a GET parameter dstpath to the new file or directory name
void explorerHandleRenameRequest(AsyncWebServerRequest *request) {
AsyncWebParameter *srcPath;
AsyncWebParameter *dstPath;
char srcFullFilePath[MAX_FILEPATH_LENTGH];
char dstFullFilePath[MAX_FILEPATH_LENTGH];
if (request->hasParam("srcpath") && request->hasParam("dstpath")) {
AsyncWebParameter *srcPath;
AsyncWebParameter *dstPath;
char srcFullFilePath[MAX_FILEPATH_LENTGH];
char dstFullFilePath[MAX_FILEPATH_LENTGH];
srcPath = request->getParam("srcpath");
dstPath = request->getParam("dstpath");
convertFilenameToAscii(srcPath->value(), srcFullFilePath);
Expand Down Expand Up @@ -1477,9 +1477,9 @@ void explorerHandleAudioRequest(AsyncWebServerRequest *request) {
AsyncWebParameter *param;
String playModeString;
uint32_t playMode;
char filePath[MAX_FILEPATH_LENTGH];
if (request->hasParam("path") && request->hasParam("playmode")) {
param = request->getParam("path");
char filePath[MAX_FILEPATH_LENTGH];
convertFilenameToAscii(param->value(), filePath);
param = request->getParam("playmode");
playModeString = param->value();
Expand Down Expand Up @@ -1546,8 +1546,8 @@ void handlePostSavedSSIDs(AsyncWebServerRequest *request, JsonVariant &json) {
}

void handleDeleteSavedSSIDs(AsyncWebServerRequest *request) {
AsyncWebParameter* p = request->getParam("ssid");
String ssid = p->value();
const AsyncWebParameter* p = request->getParam("ssid");
const String ssid = p->value();

bool succ = Wlan_DeleteNetwork(ssid);

Expand Down Expand Up @@ -1796,7 +1796,6 @@ void Web_DumpSdToNvs(const char *_filename) {
uint16_t importCount = 0;
uint16_t invalidCount = 0;
nvs_t nvsEntry[1];
char buf;
File tmpFile = gFSystem.open(_filename);

if (!tmpFile || (tmpFile.available() < 3)) {
Expand All @@ -1817,7 +1816,7 @@ void Web_DumpSdToNvs(const char *_filename) {
Log_Println(errorReadingTmpfile, LOGLEVEL_ERROR);
return;
}
buf = tmpFile.read();
char buf = tmpFile.read();
if (buf != '\n') {
ebuf[j++] = buf;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void loop() {
#endif

IrReceiver_Cyclic();
vTaskDelay(portTICK_RATE_MS * 5u);
vTaskDelay(portTICK_PERIOD_MS * 5u);

#ifdef HALLEFFECT_SENSOR_ENABLE
gHallEffectSensor.cyclic();
Expand Down
2 changes: 1 addition & 1 deletion src/revision.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

#include "gitrevision.h"
constexpr const char softwareRevision[] = "Software-revision: 20231022-2";
constexpr const char softwareRevision[] = "Software-revision: 20231026-2";

0 comments on commit cc8a33d

Please sign in to comment.