Skip to content

Commit ee9a1b0

Browse files
authored
Merge pull request #778 from pennam/__has_include_fix
GSM: do not check for __has_include in library main include
2 parents 98b9ea5 + 714bbab commit ee9a1b0

File tree

4 files changed

+47
-23
lines changed

4 files changed

+47
-23
lines changed

libraries/GSM/src/GSM.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#include "GSM.h"
21+
#include "GSMDebug.h"
2122

2223
#include "mbed.h"
2324
#include "CellularLog.h"

libraries/GSM/src/GSM.h

+1-23
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,6 @@
6363
#endif
6464
#endif
6565

66-
#if defined __has_include
67-
#if __has_include ("Arduino_DebugUtils.h")
68-
#include "Arduino_DebugUtils.h"
69-
#define GSM_DEBUG_ENABLE 1
70-
#else
71-
#define DEBUG_ERROR(fmt, ...)
72-
#define DEBUG_WARNING(fmt, ...)
73-
#define DEBUG_INFO(fmt, ...)
74-
#define DEBUG_DEBUG(fmt, ...)
75-
#define DEBUG_VERBOSE(fmt, ...)
76-
#define GSM_DEBUG_ENABLE 0
77-
#endif
78-
#else
79-
#define DEBUG_ERROR(fmt, ...)
80-
#define DEBUG_WARNING(fmt, ...)
81-
#define DEBUG_INFO(fmt, ...)
82-
#define DEBUG_DEBUG(fmt, ...)
83-
#define DEBUG_VERBOSE(fmt, ...)
84-
#define GSM_DEBUG_ENABLE 0
85-
#endif
86-
8766
namespace arduino {
8867

8968
typedef void* (*voidPrtFuncPtr)(void);
@@ -159,7 +138,6 @@ class GSMClass : public MbedSocketClass {
159138
*/
160139
const uint16_t _retry_timeout[6] = {1, 2, 4, 8, 16, 32};
161140

162-
#if GSM_DEBUG_ENABLE
163141
static constexpr int RSSI_UNKNOWN = 99;
164142
static const char * const sim_state_str[];
165143
static const char * const reg_type_str[];
@@ -172,7 +150,7 @@ class GSMClass : public MbedSocketClass {
172150
static const char * getSIMStateString(const mbed::CellularDevice::SimState state);
173151
static const char * getRegistrationStateString(const mbed::CellularNetwork::RegistrationStatus state);
174152
void onStatusChange(nsapi_event_t ev, intptr_t in);
175-
#endif
153+
176154
void reset();
177155
bool isReady(const int timeout = 5000);
178156
};

libraries/GSM/src/GSMDebug.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#include <GSM.h>
21+
#include <GSMDebug.h>
2122

2223
#if GSM_DEBUG_ENABLE
2324

libraries/GSM/src/GSMDebug.h

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
GSMDebug.h
3+
Copyright (c) 2021 Arduino SA. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifndef GSMDEBUG_H
21+
#define GSMDEBUG_H
22+
23+
#if defined __has_include
24+
#if __has_include ("Arduino_DebugUtils.h")
25+
#include "Arduino_DebugUtils.h"
26+
#define GSM_DEBUG_ENABLE 1
27+
#else
28+
#define DEBUG_ERROR(fmt, ...)
29+
#define DEBUG_WARNING(fmt, ...)
30+
#define DEBUG_INFO(fmt, ...)
31+
#define DEBUG_DEBUG(fmt, ...)
32+
#define DEBUG_VERBOSE(fmt, ...)
33+
#define GSM_DEBUG_ENABLE 0
34+
#endif
35+
#else
36+
#define DEBUG_ERROR(fmt, ...)
37+
#define DEBUG_WARNING(fmt, ...)
38+
#define DEBUG_INFO(fmt, ...)
39+
#define DEBUG_DEBUG(fmt, ...)
40+
#define DEBUG_VERBOSE(fmt, ...)
41+
#define GSM_DEBUG_ENABLE 0
42+
#endif
43+
44+
#endif /* GSMDEBUG_H*/

0 commit comments

Comments
 (0)