Skip to content

Make Arduino_DebugUtils optional #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Arduino_Portenta_OTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
******************************************************************************/

#include "Arduino_Portenta_OTA.h"

#include "Arduino_Portenta_OTA_Debug.h"
#include <stm32h7xx_hal_rtc_ex.h>

/******************************************************************************
Expand Down Expand Up @@ -143,15 +143,15 @@ bool Arduino_Portenta_OTA::caStorageInit()
_bd_raw_qspi = mbed::BlockDevice::get_default_instance();

if (_bd_raw_qspi->init() != QSPIF_BD_ERROR_OK) {
Debug.print(DBG_ERROR, F("Error: QSPI init failure."));
DEBUG_ERROR(F("Error: QSPI init failure."));
return false;
}

mbed::MBRBlockDevice * cert_bd_qspi = new mbed::MBRBlockDevice(_bd_raw_qspi, 1);
mbed::FATFileSystem * cert_fs_qspi = new mbed::FATFileSystem("wlan");
int const err_mount = cert_fs_qspi->mount(cert_bd_qspi);
if (err_mount) {
Debug.print(DBG_ERROR, F("Error while mounting the certificate filesystem. Err = %d"), err_mount);
DEBUG_ERROR(F("Error while mounting the certificate filesystem. Err = %d"), err_mount);
return false;
}
return true;
Expand All @@ -161,7 +161,7 @@ bool Arduino_Portenta_OTA::caStorageOpen()
{
FILE* fp = fopen("/wlan/cacert.pem", "r");
if (!fp) {
Debug.print(DBG_ERROR, F("Error while opening the certificate file."));
DEBUG_ERROR(F("Error while opening the certificate file."));
return false;
}
fclose(fp);
Expand Down
1 change: 0 additions & 1 deletion src/Arduino_Portenta_OTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <MBRBlockDevice.h>
#include <FATFileSystem.h>
#include <LittleFileSystem.h>
#include <Arduino_DebugUtils.h>

#include "WiFi.h" /* WiFi from ArduinoCore-mbed */
#include <SocketHelpers.h>
Expand Down
44 changes: 44 additions & 0 deletions src/Arduino_Portenta_OTA_Debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
This file is part of Arduino_Portenta_OTA.

Copyright 2024 ARDUINO SA (http://www.arduino.cc/)

This software is released under the GNU General Public License version 3,
which covers the main part of arduino-cli.
The terms of this license can be found at:
https://www.gnu.org/licenses/gpl-3.0.en.html

You can be released from the requirements of the above licenses by purchasing
a commercial license. Buying such a license is mandatory if you want to modify or
otherwise use the software for commercial activities involving the Arduino
software without disclosing the source code of your own applications. To purchase
a commercial license, send an email to [email protected].
*/

#ifndef ARDUINO_PORTENTA_OTA_DEBUG_H_
#define ARDUINO_PORTENTA_OTA_DEBUG_H_

/******************************************************************************
* INCLUDE
******************************************************************************/

#if defined __has_include
#if __has_include (<Arduino_DebugUtils.h>)
#include <Arduino_DebugUtils.h>
#else
#define ARDUINO_PORTENTA_OTA_NO_DEBUG
#endif
#else
#define ARDUINO_PORTENTA_OTA_NO_DEBUG
#endif

#ifdef ARDUINO_PORTENTA_OTA_NO_DEBUG
#define DEBUG_ERROR(fmt, ...) ((void)0)
#define DEBUG_WARNING(fmt, ...) ((void)0)
#define DEBUG_INFO(fmt, ...) ((void)0)
#define DEBUG_DEBUG(fmt, ...) ((void)0)
#define DEBUG_VERBOSE(fmt, ...) ((void)0)
#endif
#undef ARDUINO_PORTENTA_OTA_NO_DEBUG

#endif /* ARDUINO_PORTENTA_OTA_DEBUG_H_ */
6 changes: 3 additions & 3 deletions src/Arduino_Portenta_OTA_QSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#if defined(ARDUINO_PORTENTA_OTA_QSPI_SUPPORT)

#include "Arduino_Portenta_OTA_QSPI.h"

#include "Arduino_Portenta_OTA_Debug.h"
#include <assert.h>

using namespace arduino;
Expand Down Expand Up @@ -52,7 +52,7 @@ bool Arduino_Portenta_OTA_QSPI::init()
int const err_mount = _fs_qspi->mount(_bd_raw_qspi);
if (err_mount)
{
Debug.print(DBG_ERROR, F("Error while mounting the filesystem. Err = %d"), err_mount);
DEBUG_ERROR(F("Error while mounting the filesystem. Err = %d"), err_mount);
return false;
}
return true;
Expand All @@ -64,7 +64,7 @@ bool Arduino_Portenta_OTA_QSPI::init()
_fs_qspi = new mbed::FATFileSystem("fs");
int const err_mount = _fs_qspi->mount(_bd_qspi);
if (err_mount) {
Debug.print(DBG_ERROR, F("Error while mounting the filesystem. Err = %d"), err_mount);
DEBUG_ERROR(F("Error while mounting the filesystem. Err = %d"), err_mount);
return false;
}
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/Arduino_Portenta_OTA_SD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#if defined(ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT)

#include "Arduino_Portenta_OTA_SD.h"

#include "Arduino_Portenta_OTA_Debug.h"
#include "BSP.h"
#include "stm32h7xx_hal_sd.h"

Expand Down Expand Up @@ -61,7 +61,7 @@ bool Arduino_Portenta_OTA_SD::init()
_fs_sd = new mbed::FATFileSystem("fs");
int const err = _fs_sd->mount(&_block_device);
if (err) {
Debug.print(DBG_ERROR, F("Error while mounting the filesystem. Err = %d"), err);
DEBUG_ERROR(F("Error while mounting the filesystem. Err = %d"), err);
return false;
}
return true;
Expand All @@ -74,7 +74,7 @@ bool Arduino_Portenta_OTA_SD::init()
int const err = _fs_sd->mount(_bd);
if (err)
{
Debug.print(DBG_ERROR, F("Error while mounting the filesystem. Err = %d"), err);
DEBUG_ERROR(F("Error while mounting the filesystem. Err = %d"), err);
return false;
}
return true;
Expand Down