Skip to content

Commit 2af93cf

Browse files
author
Mickael Hubert
committed
Merge branch 'development' of https://github.com/mysensors/Arduino into development
2 parents 15136c0 + ebf183c commit 2af93cf

File tree

13 files changed

+56
-41
lines changed

13 files changed

+56
-41
lines changed

hardware/MySensors/samd/variants/mysensors_gw/variant.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ static const uint8_t SCK = PIN_SPI_SCK ;
189189
#define MYSX_A1
190190
#define MYSX_A2
191191

192+
193+
#define MY_SIGNING_ATSHA204_PIN 17
194+
#define MY_DEFAULT_ERR_LED_PIN LED_RED
195+
#define MY_DEFAULT_RX_LED_PIN LED_YELLOW
196+
#define MY_DEFAULT_TX_LED_PIN LED_GREEN
197+
192198
/*----------------------------------------------------------------------------
193199
* Arduino objects - C++ only
194200
*----------------------------------------------------------------------------*/
@@ -226,11 +232,12 @@ extern Uart Serial1;
226232
//
227233
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
228234
// pins are NOT connected to anything by default.
229-
#define SERIAL_PORT_USBVIRTUAL SerialUSB
230-
#define SERIAL_PORT_MONITOR Serial
235+
//#define SERIAL_PORT_USBVIRTUAL SerialUSB
236+
//#define SERIAL_PORT_MONITOR Serial
231237
// Serial has no physical pins broken out, so it's not listed as HARDWARE port
232-
#define SERIAL_PORT_HARDWARE Serial1
233-
#define SERIAL_PORT_HARDWARE_OPEN Serial1
238+
//#define SERIAL_PORT_HARDWARE Serial1
239+
//#define SERIAL_PORT_HARDWARE_OPEN Serial1
234240

241+
#define Serial SerialUSB
235242
#endif /* _VARIANT_ARDUINO_ZERO_ */
236243

libraries/MySensors/core/MyGatewayTransportEthernet.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,22 @@ bool gatewayTransportInit() {
107107
while (WiFi.status() != WL_CONNECTED)
108108
{
109109
delay(500);
110-
SERIALDEVICE.print(".");
110+
MY_SERIALDEVICE.print(".");
111111
yield();
112112
}
113-
SERIALDEVICE.print(F("IP: "));
114-
SERIALDEVICE.println(WiFi.localIP());
113+
MY_SERIALDEVICE.print(F("IP: "));
114+
MY_SERIALDEVICE.println(WiFi.localIP());
115115

116116
#else
117117
#ifdef MY_IP_ADDRESS
118118
Ethernet.begin(_ethernetGatewayMAC, _ethernetGatewayIP);
119-
SERIALDEVICE.print(F("IP: "));
120-
SERIALDEVICE.println(Ethernet.localIP());
119+
MY_SERIALDEVICE.print(F("IP: "));
120+
MY_SERIALDEVICE.println(Ethernet.localIP());
121121
#else
122122
// Get IP address from DHCP
123123
Ethernet.begin(_ethernetGatewayMAC);
124-
SERIALDEVICE.print(F("IP: "));
125-
SERIALDEVICE.println(Ethernet.localIP());
124+
MY_SERIALDEVICE.print(F("IP: "));
125+
MY_SERIALDEVICE.println(Ethernet.localIP());
126126
#endif /* IP_ADDRESS_DHCP */
127127
// give the Ethernet interface a second to initialize
128128
// TODO: use HW delay

libraries/MySensors/core/MyGatewayTransportMQTTClient.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,21 @@ bool gatewayTransportInit() {
161161
while (WiFi.status() != WL_CONNECTED)
162162
{
163163
delay(500);
164-
SERIALDEVICE.print(".");
164+
MY_SERIALDEVICE.print(".");
165165
yield();
166166
}
167-
SERIALDEVICE.print(F("IP: "));
168-
SERIALDEVICE.println(WiFi.localIP());
167+
MY_SERIALDEVICE.print(F("IP: "));
168+
MY_SERIALDEVICE.println(WiFi.localIP());
169169
#else
170170
#ifdef MY_IP_ADDRESS
171171
Ethernet.begin(_clientMAC, _clientIp);
172-
SERIALDEVICE.print(F("IP: "));
173-
SERIALDEVICE.println(Ethernet.localIP());
172+
MY_SERIALDEVICE.print(F("IP: "));
173+
MY_SERIALDEVICE.println(Ethernet.localIP());
174174
#else
175175
// Get IP address from DHCP
176176
Ethernet.begin(_clientMAC);
177-
SERIALDEVICE.print(F("IP: "));
178-
SERIALDEVICE.println(Ethernet.localIP());
177+
MY_SERIALDEVICE.print(F("IP: "));
178+
MY_SERIALDEVICE.println(Ethernet.localIP());
179179
#endif /* IP_ADDRESS_DHCP */
180180
// give the Ethernet interface a second to initialize
181181
// TODO: use HW delay

libraries/MySensors/core/MyGatewayTransportSerial.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ MyMessage _serialMsg;
3131

3232

3333
bool gatewayTransportSend(MyMessage &message) {
34-
SERIALDEVICE.print(protocolFormat(message));
34+
MY_SERIALDEVICE.print(protocolFormat(message));
3535
// Serial print is always successful
3636
return true;
3737
}
@@ -45,9 +45,9 @@ bool gatewayTransportInit() {
4545
bool gatewayTransportAvailable() {
4646
bool available = false;
4747

48-
while (SERIALDEVICE.available()) {
48+
while (MY_SERIALDEVICE.available()) {
4949
// get the new byte:
50-
char inChar = (char) SERIALDEVICE.read();
50+
char inChar = (char) MY_SERIALDEVICE.read();
5151
// if the incoming character is a newline, set a flag
5252
// so the main loop can do something about it:
5353
if (_serialInputPos < MY_GATEWAY_MAX_RECEIVE_LENGTH - 1 && !available) {

libraries/MySensors/core/MyHwATMega328.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include <Arduino.h>
3737
#endif
3838

39-
#define SERIALDEVICE Serial
39+
#define MY_SERIALDEVICE Serial
4040
#if defined __AVR_ATmega328P__
4141
#ifndef sleep_bod_disable
4242
#define sleep_bod_disable() \

libraries/MySensors/core/MyHwESP8266.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//#include <SPI.h>
3131
#endif
3232

33-
#define SERIALDEVICE Serial
33+
#define MY_SERIALDEVICE Serial
3434
#define min(a,b) ((a)<(b)?(a):(b))
3535
#define max(a,b) ((a)>(b)?(a):(b))
3636

libraries/MySensors/core/MyHwSAMD.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ void hwWriteConfig(int adr, uint8_t value)
9999
}
100100

101101
void hwInit() {
102-
SERIALDEVICE.begin(MY_BAUD_RATE);
103-
while (!SERIALDEVICE) {}
102+
MY_SERIALDEVICE.begin(MY_BAUD_RATE);
103+
#ifndef MY_GATEWAY_W5100
104+
while (!MY_SERIALDEVICE) {}
105+
#endif
106+
Wire.begin();
104107
}
105108

106109
void hwWatchdogReset() {
@@ -137,11 +140,12 @@ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mo
137140

138141
#ifdef MY_DEBUG
139142
void hwDebugPrint(const char *fmt, ... ) {
143+
if (MY_SERIALDEVICE) {
140144
char fmtBuffer[300];
141145
#ifdef MY_GATEWAY_FEATURE
142146
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
143147
snprintf(fmtBuffer, 299, PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
144-
SERIALDEVICE.print(fmtBuffer);
148+
MY_SERIALDEVICE.print(fmtBuffer);
145149
#endif
146150
va_list args;
147151
va_start (args, fmt );
@@ -155,9 +159,10 @@ void hwDebugPrint(const char *fmt, ... ) {
155159
vsnprintf(fmtBuffer, 299, fmt, args);
156160
#endif
157161
va_end (args);
158-
SERIALDEVICE.print(fmtBuffer);
159-
// SERIALDEVICE.flush();
162+
MY_SERIALDEVICE.print(fmtBuffer);
163+
// MY_SERIALDEVICE.flush();
160164

161165
//Serial.write(freeRam());
166+
}
162167
}
163168
#endif

libraries/MySensors/core/MyHwSAMD.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#endif
3232

3333
#include <avr/dtostrf.h>
34-
#define I2C_EEP_ADDRESS 55
34+
#define I2C_EEP_ADDRESS 0x50
3535

3636
#define min(a,b) ((a)<(b)?(a):(b))
3737
#define max(a,b) ((a)>(b)?(a):(b))
@@ -52,7 +52,7 @@ void hwWriteConfigBlock(void* buf, void* adr, size_t length);
5252
void hwWriteConfig(int adr, uint8_t value);
5353
uint8_t hwReadConfig(int adr);
5454

55-
#define SERIALDEVICE SerialUSB
55+
#define MY_SERIALDEVICE SerialUSB
5656

5757

5858
/*

libraries/MySensors/core/MySigningAtsha204.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf,
6363
#ifdef MY_GATEWAY_FEATURE
6464
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
6565
snprintf_P(printBuffer, 299, PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
66-
SERIALDEVICE.print(printBuffer);
66+
MY_SERIALDEVICE.print(printBuffer);
6767
#endif
6868
for (int i=0; i<sz; i++)
6969
{
@@ -75,12 +75,12 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf,
7575
// Truncate message if this is gateway node
7676
printBuffer[MY_GATEWAY_MAX_SEND_LENGTH-1-strlen_P((const char*)str)] = '\0';
7777
#endif
78-
SERIALDEVICE.print(str);
78+
MY_SERIALDEVICE.print(str);
7979
if (sz > 0)
8080
{
81-
SERIALDEVICE.print(printBuffer);
81+
MY_SERIALDEVICE.print(printBuffer);
8282
}
83-
SERIALDEVICE.println("");
83+
MY_SERIALDEVICE.println("");
8484
}
8585
#else
8686
#define DEBUG_SIGNING_PRINTBUF(str, buf, sz)

libraries/MySensors/core/MySigningAtsha204Soft.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf,
6666
#ifdef MY_GATEWAY_FEATURE
6767
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
6868
snprintf_P(printBuffer, 299, PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
69-
SERIALDEVICE.print(printBuffer);
69+
MY_SERIALDEVICE.print(printBuffer);
7070
#endif
7171
for (int i=0; i<sz; i++)
7272
{
@@ -78,12 +78,12 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf,
7878
// Truncate message if this is gateway node
7979
printBuffer[MY_GATEWAY_MAX_SEND_LENGTH-1-strlen_P((const char*)str)] = '\0';
8080
#endif
81-
SERIALDEVICE.print(str);
81+
MY_SERIALDEVICE.print(str);
8282
if (sz > 0)
8383
{
84-
SERIALDEVICE.print(printBuffer);
84+
MY_SERIALDEVICE.print(printBuffer);
8585
}
86-
SERIALDEVICE.println("");
86+
MY_SERIALDEVICE.println("");
8787
}
8888
#else
8989
#define DEBUG_SIGNING_PRINTBUF(str, buf, sz)

libraries/MySensors/examples/GatewaySerial/GatewaySerial.ino

+2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@
7272
// Digital pin used for inclusion mode button
7373
#define MY_INCLUSION_MODE_BUTTON_PIN 3
7474

75+
#ifndef MY_DEFAULT_ERR_LED_PIN
7576
#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin
7677
#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
7778
#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
79+
#endif
7880

7981
#include <SPI.h>
8082
#include <MySensor.h>

libraries/MySensors/examples/GatewayW5100/GatewayW5100.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
// Enable Soft SPI for NRF radio (note different radio wiring is required)
5858
// The W5100 ethernet module seems to have a hard time co-operate with
5959
// radio on the same spi bus.
60-
#if !defined(MY_W5100_SPI_EN)
60+
#if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
6161
#define MY_SOFTSPI
6262
#define MY_SOFT_SPI_SCK_PIN 14
6363
#define MY_SOFT_SPI_MISO_PIN 16
@@ -100,9 +100,11 @@
100100
// Digital pin used for inclusion mode button
101101
#define MY_INCLUSION_MODE_BUTTON_PIN 3
102102

103+
#ifndef MY_DEFAULT_ERR_LED_PIN
103104
#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin
104105
#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin
105106
#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED
107+
#endif
106108

107109
#include <SPI.h>
108110

libraries/MySensors/examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
5858
*/
5959

60-
#include <EEPROM.h>
6160
#include <SPI.h>
6261

6362
// Enable debug prints to serial monitor
@@ -82,7 +81,7 @@
8281
// Enable Soft SPI for NRF radio (note different radio wiring is required)
8382
// The W5100 ethernet module seems to have a hard time co-operate with
8483
// radio on the same spi bus.
85-
#if !defined(MY_W5100_SPI_EN)
84+
#if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
8685
#define MY_SOFTSPI
8786
#define MY_SOFT_SPI_SCK_PIN 14
8887
#define MY_SOFT_SPI_MISO_PIN 16

0 commit comments

Comments
 (0)