Skip to content

Commit 40edbcc

Browse files
committed
Make Portenta a LoRa device if Arduino_LoRaConnectionHandler.h is included in sketch file
1 parent 8257328 commit 40edbcc

3 files changed

+23
-14
lines changed

src/Arduino_ConnectionHandler.h

+16-11
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,22 @@
4444
#endif
4545

4646
#if defined(ARDUINO_PORTENTA_H7_M7)
47-
#include <WiFi.h>
48-
#include <WiFiUdp.h>
49-
#include <Ethernet.h>
50-
#include <PortentaEthernet.h>
51-
52-
#define BOARD_HAS_WIFI
53-
#define BOARD_HAS_ETHERNET
54-
#define BOARD_HAS_PORTENTA_VISION_SHIELD_ETHERNET
55-
#define NETWORK_HARDWARE_ERROR WL_NO_SHIELD
56-
#define NETWORK_IDLE_STATUS WL_IDLE_STATUS
57-
#define NETWORK_CONNECTED WL_CONNECTED
47+
#if __has_include("Arduino_LoRaConnectionHandler.h")
48+
#include <MKRWAN.h>
49+
#define BOARD_HAS_LORA
50+
#else
51+
#include <WiFi.h>
52+
#include <WiFiUdp.h>
53+
#include <Ethernet.h>
54+
#include <PortentaEthernet.h>
55+
56+
#define BOARD_HAS_WIFI
57+
#define BOARD_HAS_ETHERNET
58+
#define BOARD_HAS_PORTENTA_VISION_SHIELD_ETHERNET
59+
#define NETWORK_HARDWARE_ERROR WL_NO_SHIELD
60+
#define NETWORK_IDLE_STATUS WL_IDLE_STATUS
61+
#define NETWORK_CONNECTED WL_CONNECTED
62+
#endif
5863
#endif
5964

6065
#if defined(ARDUINO_NICLA_VISION)

src/Arduino_LoRaConnectionHandler.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
INCLUDE
2020
******************************************************************************/
2121

22-
#if defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) /* Only compile if the board has LoRa */
23-
2422
#include "Arduino_LoRaConnectionHandler.h"
2523

24+
#ifdef BOARD_HAS_LORA
25+
2626
/******************************************************************************
2727
TYPEDEF
2828
******************************************************************************/
@@ -171,4 +171,4 @@ NetworkConnectionState LoRaConnectionHandler::update_handleDisconnected()
171171
}
172172
}
173173

174-
#endif
174+
#endif /* #ifdef BOARD_HAS_LORA */

src/Arduino_LoRaConnectionHandler.h

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include "Arduino_ConnectionHandler.h"
2626

27+
#ifdef BOARD_HAS_LORA /* Only compile if this is a board with LoRa */
28+
2729
/******************************************************************************
2830
CLASS DECLARATION
2931
******************************************************************************/
@@ -72,4 +74,6 @@ class LoRaConnectionHandler : public ConnectionHandler
7274
LoRaModem _modem;
7375
};
7476

77+
#endif /* #ifdef BOARD_HAS_LORA */
78+
7579
#endif /* ARDUINO_LORA_CONNECTION_HANDLER_H_ */

0 commit comments

Comments
 (0)