Skip to content

Commit f87d9c0

Browse files
committed
chore: strip out memory logs
1 parent 72b5bf0 commit f87d9c0

File tree

1 file changed

+1
-70
lines changed

1 file changed

+1
-70
lines changed

src/Arduino_NotecardConnectionHandler.cpp

+1-70
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,6 @@
5252
STLINK DEBUG OUTPUT
5353
******************************************************************************/
5454

55-
// Report memory usage when enabled
56-
#if defined(LOG_MEMORY_USAGE)
57-
#include <malloc.h>
58-
59-
void logMemoryUsage (const char *ctx_, bool enter_ = false) {
60-
struct mallinfo mi = mallinfo();
61-
Debug.print(DBG_DEBUG, F("[MEMORY][%s %s] Allocated: %d bytes"), (enter_ ? ">>>>" : "<<<<"), ctx_, mi.uordblks);
62-
}
63-
#endif
64-
6555
// Provide Notehub debug output via STLINK serial port when available
6656
#if defined(ARDUINO_SWAN_R5) || defined(ARDUINO_CYGNET)
6757
#define STLINK_DEBUG
@@ -328,9 +318,6 @@ int NotecardConnectionHandler::write(const uint8_t * buf_, size_t size_)
328318
NetworkConnectionState NotecardConnectionHandler::update_handleInit()
329319
{
330320
NetworkConnectionState result = NetworkConnectionState::INIT;
331-
#if defined(LOG_MEMORY_USAGE)
332-
logMemoryUsage(__FUNCTION__, true);
333-
#endif
334321

335322
// Configure Hardware
336323
///////////////////////
@@ -527,18 +514,12 @@ NetworkConnectionState NotecardConnectionHandler::update_handleInit()
527514
}
528515
}
529516

530-
#if defined(LOG_MEMORY_USAGE)
531-
logMemoryUsage(__FUNCTION__);
532-
#endif
533517
return result;
534518
}
535519

536520
NetworkConnectionState NotecardConnectionHandler::update_handleConnecting()
537521
{
538522
NetworkConnectionState result;
539-
#if defined(LOG_MEMORY_USAGE)
540-
logMemoryUsage(__FUNCTION__, true);
541-
#endif
542523

543524
// Check the connection status
544525
const NotecardConnectionStatus conn_status = connected();
@@ -566,18 +547,12 @@ NetworkConnectionState NotecardConnectionHandler::update_handleConnecting()
566547
}
567548
}
568549

569-
#if defined(LOG_MEMORY_USAGE)
570-
logMemoryUsage(__FUNCTION__);
571-
#endif
572550
return result;
573551
}
574552

575553
NetworkConnectionState NotecardConnectionHandler::update_handleConnected()
576554
{
577555
NetworkConnectionState result;
578-
#if defined(LOG_MEMORY_USAGE)
579-
logMemoryUsage(__FUNCTION__, true);
580-
#endif
581556

582557
const NotecardConnectionStatus conn_status = connected();
583558
if (!conn_status.connected_to_notehub) {
@@ -591,34 +566,22 @@ NetworkConnectionState NotecardConnectionHandler::update_handleConnected()
591566
result = NetworkConnectionState::CONNECTED;
592567
}
593568

594-
#if defined(LOG_MEMORY_USAGE)
595-
logMemoryUsage(__FUNCTION__);
596-
#endif
597569
return result;
598570
}
599571

600572
NetworkConnectionState NotecardConnectionHandler::update_handleDisconnecting()
601573
{
602574
NetworkConnectionState result;
603-
#if defined(LOG_MEMORY_USAGE)
604-
logMemoryUsage(__FUNCTION__, true);
605-
#endif
606575

607576
Debug.print(DBG_ERROR, F("Connection to the network lost."));
608577
result = NetworkConnectionState::DISCONNECTED;
609578

610-
#if defined(LOG_MEMORY_USAGE)
611-
logMemoryUsage(__FUNCTION__);
612-
#endif
613579
return result;
614580
}
615581

616582
NetworkConnectionState NotecardConnectionHandler::update_handleDisconnected()
617583
{
618584
NetworkConnectionState result;
619-
#if defined(LOG_MEMORY_USAGE)
620-
logMemoryUsage(__FUNCTION__, true);
621-
#endif
622585

623586
if (_keep_alive)
624587
{
@@ -636,9 +599,6 @@ NetworkConnectionState NotecardConnectionHandler::update_handleDisconnected()
636599
}
637600
}
638601

639-
#if defined(LOG_MEMORY_USAGE)
640-
logMemoryUsage(__FUNCTION__);
641-
#endif
642602
return result;
643603
}
644604

@@ -649,9 +609,6 @@ NetworkConnectionState NotecardConnectionHandler::update_handleDisconnected()
649609
bool NotecardConnectionHandler::armInterrupt (void) const
650610
{
651611
bool result;
652-
#if defined(LOG_MEMORY_USAGE)
653-
logMemoryUsage(__FUNCTION__, true);
654-
#endif
655612

656613
if (J *req = _notecard.newRequest("card.attn")) {
657614
JAddStringToObject(req, "mode","rearm,files");
@@ -681,18 +638,12 @@ bool NotecardConnectionHandler::armInterrupt (void) const
681638
result = false;
682639
}
683640

684-
#if defined(LOG_MEMORY_USAGE)
685-
logMemoryUsage(__FUNCTION__);
686-
#endif
687641
return result;
688642
}
689643

690644
bool NotecardConnectionHandler::configureConnection (bool connect_) const
691645
{
692646
bool result;
693-
#if defined(LOG_MEMORY_USAGE)
694-
logMemoryUsage(__FUNCTION__, true);
695-
#endif
696647

697648
if (J *req = _notecard.newRequest("hub.set")) {
698649
// Only update the product if it is not empty or the default value
@@ -733,18 +684,12 @@ bool NotecardConnectionHandler::configureConnection (bool connect_) const
733684
result = false; // Assume the worst
734685
}
735686

736-
#if defined(LOG_MEMORY_USAGE)
737-
logMemoryUsage(__FUNCTION__);
738-
#endif
739687
return result;
740688
}
741689

742690
uint_fast8_t NotecardConnectionHandler::connected (void) const
743691
{
744692
NotecardConnectionStatus result;
745-
#if defined(LOG_MEMORY_USAGE)
746-
logMemoryUsage(__FUNCTION__, true);
747-
#endif
748693

749694
// Query the connection status from the Notecard
750695
if (J *rsp = _notecard.requestAndResponse(_notecard.newRequest("hub.status"))) {
@@ -775,18 +720,12 @@ uint_fast8_t NotecardConnectionHandler::connected (void) const
775720
result.host_error = true;
776721
}
777722

778-
#if defined(LOG_MEMORY_USAGE)
779-
logMemoryUsage(__FUNCTION__);
780-
#endif
781723
return result;
782724
}
783725

784726
J * NotecardConnectionHandler::getNote (bool pop_) const
785727
{
786728
J * result;
787-
#if defined(LOG_MEMORY_USAGE)
788-
logMemoryUsage(__FUNCTION__, true);
789-
#endif
790729

791730
// Look for a Note in the NOTEFILE_SECURE_INBOUND file
792731
if (J *req = _notecard.newRequest("note.get")) {
@@ -824,15 +763,13 @@ J * NotecardConnectionHandler::getNote (bool pop_) const
824763
result = nullptr;
825764
}
826765

827-
#if defined(LOG_MEMORY_USAGE)
828-
logMemoryUsage(__FUNCTION__);
829-
#endif
830766
return result;
831767
}
832768

833769
int NotecardConnectionHandler::initiateNotehubSync (void) const
834770
{
835771
int result;
772+
836773
Debug.print(DBG_DEBUG, F("Initiating Notehub sync..."));
837774
if (J *rsp = _notecard.requestAndResponse(_notecard.newRequest("hub.sync"))) {
838775
// Check the response for errors
@@ -856,9 +793,6 @@ int NotecardConnectionHandler::initiateNotehubSync (void) const
856793
bool NotecardConnectionHandler::updateUidCache (void)
857794
{
858795
bool result;
859-
#if defined(LOG_MEMORY_USAGE)
860-
logMemoryUsage(__FUNCTION__, true);
861-
#endif
862796

863797
// This operation is safe to perform before a sync has occurred, because the
864798
// Notecard UID is static and the cloud value of Serial Number is strictly
@@ -885,9 +819,6 @@ bool NotecardConnectionHandler::updateUidCache (void)
885819
result = false;
886820
}
887821

888-
#if defined(LOG_MEMORY_USAGE)
889-
logMemoryUsage(__FUNCTION__);
890-
#endif
891822
return result;
892823
}
893824

0 commit comments

Comments
 (0)