Skip to content

Commit 1123d21

Browse files
committed
Extend hardware for target WIN32 with VC++ for Visual Studio
Align Win32 HAL for VirtualBoard Support VM_USE_HARDWARE to access IOWarrior hardware Support VB_FIRMATA_PORT to access Firmata hardware
1 parent 6fdb52e commit 1123d21

19 files changed

+1202
-26
lines changed

MyConfig.h

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,52 @@
305305
//#define MY_RS485_DE_INVERSE
306306

307307
/**
308-
* @def MY_RS485_HWSERIAL
309-
* @brief Define this if RS485 is connected to a hardware serial port.
310-
*
311-
* Example: @code #define MY_RS485_HWSERIAL Serial1 @endcode
312-
*/
308+
* @def MY_RS485_HWSERIAL
309+
* @brief Define this if RS485 is connected to a hardware serial port.
310+
*
311+
* Example: @code #define MY_RS485_HWSERIAL Serial1 @endcode
312+
*/
313313
//#define MY_RS485_HWSERIAL (Serial1)
314314
/** @}*/ // End of RS485SettingGrpPub group
315315

316+
/**
317+
* @defgroup EtherTcpSettingGrpPub ETHER_TCP
318+
* @ingroup RadioSettingGrpPub
319+
* @brief These options are specific to the Ethernet via TCP transport.
320+
* @{
321+
*/
322+
323+
/**
324+
* @def MY_ETHER_TCP
325+
* @brief Define this to use the Ethernet via TCP transport or WiFi with ESP8266 for sensor network communication.
326+
*/
327+
//#define MY_ETHER_TCP
328+
329+
/**
330+
* @def MY_ETHER_TCP_SERVER
331+
* @brief The ETHER_TCP server name or server IP.
332+
*/
333+
#ifndef MY_ETHER_TCP_SERVER
334+
#define MY_ETHER_TCP_SERVER "localhost"
335+
#endif
336+
337+
/**
338+
* @def MY_ETHER_TCP_PORT
339+
* @brief The ETHER_TCP server IP port.
340+
*/
341+
#ifndef MY_ETHER_TCP_PORT
342+
#define MY_ETHER_TCP_PORT (5445)
343+
#endif
344+
345+
/**
346+
* @def MY_ETHER_TCP_MAX_MESSAGE_LENGTH
347+
* @brief The maximum message length used for Ethernet TCP transport.
348+
*/
349+
#ifndef MY_ETHER_TCP_MAX_MESSAGE_LENGTH
350+
#define MY_ETHER_TCP_MAX_MESSAGE_LENGTH (40)
351+
#endif
352+
/** @}*/ // End of EtherTcpSettingGrpPub group
353+
316354
/**
317355
* @defgroup RF24SettingGrpPub RF24
318356
* @ingroup TransportSettingGrpPub
@@ -1250,6 +1288,17 @@
12501288
* Incompatible libraries are unable to send sensor data.
12511289
*/
12521290
#define MY_CORE_COMPATIBILITY_CHECK
1291+
1292+
/**
1293+
* @def MY_PROCESS_SYNCHRONIZATION
1294+
* @brief This applies only to MyVirtualSensor WIN32 applications.
1295+
* If defined, _coreprocess() will acquire a named mutex and stop
1296+
* all other running virtual MySensors applications until _process ends.
1297+
* This is useful for debug of this application in Visual Studio
1298+
* while other MyVirtualSensor WIN32 applications are running at the same time.
1299+
* When you reach a breakpoint in this app then all ather applications also will stop.
1300+
*/
1301+
//#define MY_PROCESS_SYNCHRONIZATION
12531302
/** @}*/ // End of CoreSettingGrpPub group
12541303

12551304
/**
@@ -1445,6 +1494,8 @@
14451494
* @brief Define this for Ethernet GW based on the ESP32.
14461495
* @def MY_GATEWAY_LINUX
14471496
* @brief Define this for Ethernet GW based on Linux.
1497+
* @def MY_GATEWAY_WIN32
1498+
* @brief Define this for Ethernet GW based on Windows.
14481499
* @def MY_GATEWAY_TINYGSM
14491500
* @brief Define this for Ethernet GW based on GSM modems supported by TinyGSM library.
14501501
* @def MY_GATEWAY_MQTT_CLIENT
@@ -1459,6 +1510,7 @@
14591510
//#define MY_GATEWAY_ESP8266_SECURE
14601511
//#define MY_GATEWAY_ESP32
14611512
//#define MY_GATEWAY_LINUX
1513+
//#define MY_GATEWAY_WIN32
14621514
//#define MY_GATEWAY_TINYGSM
14631515
//#define MY_GATEWAY_MQTT_CLIENT
14641516
//#define MY_GATEWAY_SERIAL
@@ -2271,6 +2323,24 @@
22712323
#define MY_LINUX_CONFIG_FILE "/etc/mysensors.conf"
22722324
#endif
22732325
/** @}*/ // End of LinuxSettingGrpPub group
2326+
2327+
/**
2328+
* @defgroup Win32SettingGrpPub Win32
2329+
* @ingroup PlatformSettingGrpPub
2330+
* @brief These options control Win32 specific configurations.
2331+
* @{
2332+
*/
2333+
2334+
/**
2335+
* @def MY_WIN32_CONFIG_FILE
2336+
* @brief Sets the filepath for the gateway config file.
2337+
*
2338+
* @note For now the configuration file is only used to store the emulated eeprom state.
2339+
*/
2340+
#ifndef MY_WIN32_CONFIG_FILE
2341+
#define MY_WIN32_CONFIG_FILE "mysensors-eeprom.dat"
2342+
#endif
2343+
/** @}*/ // End of Win32SettingGrpPub group
22742344
/** @}*/ // End of PlatformSettingGrpPub group
22752345

22762346
/*
@@ -2283,7 +2353,7 @@
22832353
* MY_IS_GATEWAY is true when @ref MY_GATEWAY_FEATURE is set.
22842354
* MY_NODE_TYPE contain a string describing the class of sketch/node (gateway/repeater/node).
22852355
*/
2286-
#if defined(MY_GATEWAY_SERIAL) || defined(MY_GATEWAY_W5100) || defined(MY_GATEWAY_ENC28J60) || defined(MY_GATEWAY_ESP8266) || defined(MY_GATEWAY_ESP32)|| defined(MY_GATEWAY_LINUX) || defined(MY_GATEWAY_MQTT_CLIENT) || defined(MY_GATEWAY_TINYGSM)
2356+
#if defined(MY_GATEWAY_SERIAL) || defined(MY_GATEWAY_W5100) || defined(MY_GATEWAY_ENC28J60) || defined(MY_GATEWAY_ESP8266) || defined(MY_GATEWAY_ESP32)|| defined(MY_GATEWAY_LINUX) || defined(MY_GATEWAY_MQTT_CLIENT) || defined(MY_GATEWAY_TINYGSM) || defined(MY_GATEWAY_WIN32)
22872357
#define MY_GATEWAY_FEATURE
22882358
#define MY_IS_GATEWAY (true)
22892359
#define MY_NODE_TYPE "GW"
@@ -2313,16 +2383,28 @@
23132383
#if defined(MY_DEBUG) || defined(MY_DEBUG_VERBOSE_CORE) || defined(MY_DEBUG_VERBOSE_TRANSPORT) || defined(MY_DEBUG_VERBOSE_GATEWAY) || defined(MY_DEBUG_VERBOSE_SIGNING) || defined(MY_DEBUG_VERBOSE_OTA_UPDATE) || defined(MY_DEBUG_VERBOSE_RF24) || defined(MY_DEBUG_VERBOSE_NRF5_ESB) || defined(MY_DEBUG_VERBOSE_RFM69) || defined(MY_DEBUG_VERBOSE_RFM95) || defined(MY_DEBUG_VERBOSE_TRANSPORT_HAL)
23142384
#define DEBUG_OUTPUT_ENABLED //!< DEBUG_OUTPUT_ENABLED
23152385
#ifndef MY_DEBUG_OTA
2386+
#if defined(WIN32)
2387+
#define DEBUG_OUTPUT(x,...) hwDebugPrint(x, __VA_ARGS__) //!< debug
2388+
#else
23162389
#define DEBUG_OUTPUT(x,...) hwDebugPrint(x, ##__VA_ARGS__) //!< debug
2390+
#endif
23172391
#else
23182392
#ifndef MY_OTA_LOG_SENDER_FEATURE
23192393
#define MY_OTA_LOG_SENDER_FEATURE
23202394
#endif
23212395
#ifndef MY_DEBUG_OTA_DISABLE_ECHO
2396+
#if defined(WIN32)
2397+
#define DEBUG_OUTPUT(x,...) OTALog((MY_DEBUG_OTA), true, x, __VA_ARGS__) //!< debug
2398+
#else
23222399
#define DEBUG_OUTPUT(x,...) OTALog((MY_DEBUG_OTA), true, x, ##__VA_ARGS__) //!< debug
2400+
#endif
2401+
#else
2402+
#if defined(WIN32)
2403+
#define DEBUG_OUTPUT(x,...) OTALog((MY_DEBUG_OTA), false, x, __VA_ARGS__) //!< debug
23232404
#else
23242405
#define DEBUG_OUTPUT(x,...) OTALog((MY_DEBUG_OTA), false, x, ##__VA_ARGS__) //!< debug
23252406
#endif
2407+
#endif
23262408
// disable radio related debugging messages
23272409
#undef MY_DEBUG_VERBOSE_RF24
23282410
#undef MY_DEBUG_VERBOSE_NRF5_ESB
@@ -2469,6 +2551,7 @@
24692551
#define MY_WIFI_BSSID
24702552
#define MY_WIFI_PASSWORD
24712553
#define MY_GATEWAY_LINUX
2554+
#define MY_GATEWAY_WIN32
24722555
#define MY_GATEWAY_TINYGSM
24732556
#define MY_GATEWAY_MQTT_CLIENT
24742557
#define MY_GATEWAY_SERIAL

MySensors.h

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@
5454
// HARDWARE
5555
#include "hal/architecture/MyHwHAL.h"
5656
#include "hal/crypto/MyCryptoHAL.h"
57-
#if defined(ARDUINO_ARCH_ESP8266)
57+
#if defined(WIN32)
58+
#include "hal/architecture/Win32/MyHwWin32Generic.cpp"
59+
#include "hal/crypto/generic/MyCryptoGeneric.cpp"
60+
#elif defined(ARDUINO_ARCH_ESP8266)
5861
#if defined(MY_EXT_EEPROM)
5962
#include "drivers/extEEPROM/extEEPROM.cpp"
6063
#endif
@@ -142,7 +145,7 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
142145
#if defined(MY_SIGNING_ATSHA204) && defined(MY_SIGNING_SOFT)
143146
#error Only one signing engine can be activated
144147
#endif
145-
#if defined(MY_SIGNING_ATSHA204) && defined(__linux__)
148+
#if defined(MY_SIGNING_ATSHA204) && (defined(__linux__) || defined(WIN32))
146149
#error No support for ATSHA204 on this platform
147150
#endif
148151

@@ -245,6 +248,12 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
245248
#include "hal/architecture/Linux/drivers/core/EthernetServer.h"
246249
#include "hal/architecture/Linux/drivers/core/IPAddress.h"
247250
#include "core/MyGatewayTransportEthernet.cpp"
251+
#elif defined(MY_GATEWAY_WIN32)
252+
// GATEWAY - Generic Windows
253+
#if defined(MY_USE_UDP)
254+
#error UDP mode is not available for Windows
255+
#endif
256+
#include "core/MyGatewayTransportEthernetWin32.cpp"
248257
#elif defined(MY_GATEWAY_W5100)
249258
// GATEWAY - W5100
250259
#include "core/MyGatewayTransportEthernet.cpp"
@@ -306,6 +315,13 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
306315

307316
// TRANSPORT INCLUDES
308317
#if defined(MY_RADIO_RF24) || defined(MY_RADIO_NRF5_ESB) || defined(MY_RADIO_RFM69) || defined(MY_RADIO_RFM95) || defined(MY_RS485) || defined (MY_PJON)
318+
319+
// BRIDGE TRANSPORT INCLUDES
320+
#if defined(MY_REPEATER_FEATURE) && (defined(MY_BRIDGE_XY_TRANSPORT) || defined(MY_BRIDGE_ZZ_TRANSPORT))
321+
#define MY_BRIDGE_FEATURE
322+
#include "hal/bridgeTransport/MyBridgeTransportHAL.h"
323+
#endif
324+
309325
#include "hal/transport/MyTransportHAL.h"
310326
#include "core/MyTransport.h"
311327

@@ -329,7 +345,7 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
329345
#define MY_RAM_ROUTING_TABLE_ENABLED
330346
#elif defined(MY_RAM_ROUTING_TABLE_FEATURE) && defined(MY_REPEATER_FEATURE)
331347
// activate feature based on architecture
332-
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_NRF5) || defined(ARDUINO_ARCH_STM32F1) || defined(TEENSYDUINO) || defined(__linux__)
348+
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_NRF5) || defined(ARDUINO_ARCH_STM32F1) || defined(TEENSYDUINO) || defined(__linux__) || defined(WIN32)
333349
#define MY_RAM_ROUTING_TABLE_ENABLED
334350
#elif defined(ARDUINO_ARCH_AVR)
335351
#if defined(__avr_atmega1280__) || defined(__avr_atmega1284__) || defined(__avr_atmega2560__)
@@ -373,7 +389,7 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
373389
#include "hal/transport/NRF5_ESB/MyTransportNRF5_ESB.cpp"
374390
#elif defined(MY_RS485)
375391
#if !defined(MY_RS485_HWSERIAL)
376-
#if defined(__linux__)
392+
#if defined(__linux__) || defined(WIN32)
377393
#error You must specify MY_RS485_HWSERIAL for RS485 transport
378394
#endif
379395
#include "drivers/AltSoftSerial/AltSoftSerial.cpp"
@@ -398,11 +414,18 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
398414
#include "hal/transport/PJON/MyTransportPJON.cpp"
399415
#endif
400416

417+
#if defined(MY_BRIDGE_FEATURE)
418+
// Include bridge transport libraries
419+
#endif
420+
401421
#if (defined(MY_RF24_ENABLE_ENCRYPTION) && defined(MY_RADIO_RF24)) || (defined(MY_NRF5_ESB_ENABLE_ENCRYPTION) && defined(MY_RADIO_NRF5_ESB)) || (defined(MY_RFM69_ENABLE_ENCRYPTION) && defined(MY_RADIO_RFM69)) || (defined(MY_RFM95_ENABLE_ENCRYPTION) && defined(MY_RADIO_RFM95))
402422
#define MY_TRANSPORT_ENCRYPTION //!< ïnternal flag
403423
#endif
404424

405425
#include "hal/transport/MyTransportHAL.cpp"
426+
#if defined(MY_BRIDGE_FEATURE)
427+
#include "hal/bridgeTransport/MyBridgeTransportHAL.cpp"
428+
#endif
406429

407430
// PASSIVE MODE
408431
#if defined(MY_PASSIVE_NODE) && !defined(DOXYGEN)
@@ -448,7 +471,9 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
448471
#include "core/MySensorsCore.cpp"
449472

450473
// HW mains
451-
#if defined(ARDUINO_ARCH_AVR)
474+
#if defined(WIN32)
475+
#include "hal/architecture/Win32/MyMainWin32Generic.cpp"
476+
#elif defined(ARDUINO_ARCH_AVR)
452477
#include "hal/architecture/AVR/MyMainAVR.cpp"
453478
#elif defined(ARDUINO_ARCH_SAMD)
454479
#include "hal/architecture/SAMD/MyMainSAMD.cpp"

core/MyCapabilities.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
* | STM32F1 | M
154154
* | TEENSY | T
155155
* | Linux | L
156+
* | Win32 | W
156157
* | Unknown | -
157158
*/
158159
#if defined(ARDUINO_ARCH_SAMD)
@@ -171,6 +172,8 @@
171172
#define MY_CAP_ARCH "T"
172173
#elif defined(__linux__)
173174
#define MY_CAP_ARCH "L"
175+
#elif defined(WIN32)
176+
#define MY_CAP_ARCH "W"
174177
#else
175178
#define MY_CAP_ARCH "-"
176179
#endif

core/MyGatewayTransport.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ inline void gatewayTransportProcess(void)
5656
}
5757
} else {
5858
// Call incoming message callback if available
59+
#if defined(WIN32)
60+
// Visual C++ has no weak function support
61+
receive(_msg);
62+
#else
5963
if (receive) {
6064
receive(_msg);
6165
}
66+
#endif
6267
}
6368
} else {
6469
#if defined(MY_SENSOR_NETWORK)

core/MyGatewayTransport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@
8080
#define MSG_GW_STARTUP_COMPLETE "Gateway startup complete." //!< Gateway startup message
8181

8282
#if defined(MY_DEBUG_VERBOSE_GATEWAY)
83+
#if defined(WIN32)
84+
#define GATEWAY_DEBUG(x,...) DEBUG_OUTPUT(x, __VA_ARGS__) //!< debug output
85+
#else
8386
#define GATEWAY_DEBUG(x,...) DEBUG_OUTPUT(x, ##__VA_ARGS__) //!< debug output
87+
#endif
8488
#else
8589
#define GATEWAY_DEBUG(x,...) //!< debug NULL
8690
#endif

0 commit comments

Comments
 (0)