Skip to content

Commit 8bb3cfb

Browse files
tekka007henrikekblad
authored andcommitted
MySensors 2.1.1 release (#752)
* Bump version to 2.2.0-beta (#713) * OTA: Add incoming FW block check (#718) * Linux: Add support for SPIDEV (#734) RPi and Linux refactor. Add GPIO Sysfs for GPIO operations. Update configure script. Fix some cppcheck warnings. Add serial emulation that prints to stdout. Fix some file headers. * Fix getControllerConfig() (#737) * Rename MyHwATmega328 to MyHwAVR (#738) * AVR: Restrict fast pin function use (#739) * Fix signing presentation bug (#740) * Consolidate open PRs for bugfix release (#741) * Revert "Bump version to 2.2.0-beta" (#744) * Merge Master into Dev (#745) * Fix spi flash error when compiling in Arduino IDE 1.6.6 * Bump minor version * Fixed "invalid suffix on literal" warning * Fix addressing bug in _doSign bitfield * Make sure nodes not supporting signing informs GW A node that does not support signing, still needs to inform the gateway about this to make sure the gateway carries a valid signing requirement table when a node Id that was requiering signing stops doing this. This fixes #286. * Prevent SecureActuator from accepting ACKs as commands As ACKs are not currently signed, allowing ACKs as commands is a considerable security hole for this sketch. This is now resolved. * Backport of bugfix (#259) in repeaters when forwarding signed messages * Bumped version to 1.5.2 * Corrected doSign variable name (was _doSign) * Bumped version to 1.5.3 * Add NULL termination to payloads Messages addressed to "this" node, will have a null char appended to the payload after message verification is done, because some "getters" assume the message being a string. * MySensors 2.1.1 release
1 parent 808f9d8 commit 8bb3cfb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1665
-719
lines changed

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ GATEWAY_OBJECTS+=$(patsubst %.c,$(BUILDDIR)/%.o,$(RPI_C_SOURCES)) $(patsubst %.c
3434
INCLUDES+=-I./drivers/RPi
3535
endif
3636

37+
ifeq ($(SPI_DRIVER), BCM)
38+
SPI_DRIVER_C_SOURCES=$(wildcard drivers/BCM/*.c)
39+
SPI_DRIVER_CPP_SOURCES=$(wildcard drivers/BCM/*.cpp)
40+
GATEWAY_OBJECTS+=$(patsubst %.c,$(BUILDDIR)/%.o,$(SPI_DRIVER_C_SOURCES)) $(patsubst %.cpp,$(BUILDDIR)/%.o,$(SPI_DRIVER_CPP_SOURCES))
41+
42+
INCLUDES+=-I./drivers/BCM
43+
endif
44+
45+
ifeq ($(SPI_DRIVER), SPIDEV)
46+
SPI_DRIVER_C_SOURCES=$(wildcard drivers/SPIDEV/*.c)
47+
SPI_DRIVER_CPP_SOURCES=$(wildcard drivers/SPIDEV/*.cpp)
48+
GATEWAY_OBJECTS+=$(patsubst %.c,$(BUILDDIR)/%.o,$(SPI_DRIVER_C_SOURCES)) $(patsubst %.cpp,$(BUILDDIR)/%.o,$(SPI_DRIVER_CPP_SOURCES))
49+
50+
INCLUDES+=-I./drivers/SPIDEV
51+
endif
52+
3753
# Gets include flags for library
3854
get_library_includes = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.properties)), \
3955
-I$(1)/src, \

MyConfig.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,12 +903,12 @@
903903
#endif
904904

905905
/**
906-
* @def MY_IS_SERIAL_PTY
906+
* @def MY_LINUX_IS_SERIAL_PTY
907907
* @brief Set serial as a pseudo terminal.
908908
*
909909
* Enable this if you need to connect to a controller running on the same device.
910910
*/
911-
//#define MY_IS_SERIAL_PTY
911+
//#define MY_LINUX_IS_SERIAL_PTY
912912

913913
/**
914914
* @def MY_LINUX_SERIAL_PTY
@@ -956,7 +956,7 @@
956956
#define MY_NODE_LOCK_FEATURE
957957
#define MY_REPEATER_FEATURE
958958
#define MY_LINUX_SERIAL_GROUPNAME
959-
#define MY_IS_SERIAL_PTY
959+
#define MY_LINUX_IS_SERIAL_PTY
960960
#define MY_RFM95_ATC_MODE_DISABLED
961961
#define MY_RFM95_RST_PIN
962962
#endif

MySensors.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,12 @@
6262
#include "core/MyHwESP8266.cpp"
6363
#elif defined(ARDUINO_ARCH_AVR)
6464
#include "drivers/AVR/DigitalWriteFast/digitalWriteFast.h"
65-
#include "core/MyHwATMega328.cpp"
65+
#include "core/MyHwAVR.cpp"
6666
#elif defined(ARDUINO_ARCH_SAMD)
6767
#include "core/MyHwSAMD.cpp"
6868
#elif defined(__linux__)
69-
#ifdef LINUX_ARCH_RASPBERRYPI
70-
#include "core/MyHwRPi.cpp"
71-
#else
7269
#include "core/MyHwLinuxGeneric.cpp"
7370
#endif
74-
#endif
7571

7672
// LEDS
7773
#if !defined(MY_DEFAULT_ERR_LED_PIN) && defined(MY_HW_ERR_LED_PIN)
@@ -254,7 +250,7 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
254250
#include "drivers/AVR/DigitalIO/DigitalIO.h"
255251
#endif
256252

257-
#if defined(MY_RADIO_NRF24) && defined(__linux__) && !defined(LINUX_ARCH_RASPBERRYPI)
253+
#if defined(MY_RADIO_NRF24) && defined(__linux__) && !(defined(LINUX_SPI_BCM) || defined(LINUX_SPI_SPIDEV))
258254
#error No support for nRF24 radio on this platform
259255
#endif
260256

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MySensors Library v2.1.0
1+
MySensors Library v2.1.1
22

33
Please visit www.mysensors.org for more information
44

configure

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ Options:
1111
Help:
1212
-h, --help print this message
1313
14+
SPI driver options:
15+
--spi-driver=[BCM|SPIDEV]
16+
--spi-spidev-device=<DEVICE>
17+
Device path. [/dev/spidev0.0]
18+
1419
Building options:
1520
--soc=[BCM2835|BCM2836|AM33XX|A10|A13|A20|H3]
1621
SoC type to be used. [configure autodetected]
@@ -58,6 +63,8 @@ MySensors options:
5863
--my-rf24-channel=<0-125> RF channel for the sensor net, 0-125. [76]
5964
--my-rf24-pa-level=[RF24_PA_MAX|RF24_PA_LOW]
6065
RF24 PA level. [RF24_PA_MAX]
66+
--my-rf24-ce-pin=<PIN> Pin number to use for rf24 Chip-Enable.
67+
--my-rf24-cs-pin=<PIN> Pin number to use for rf24 Chip-Select.
6168
--my-rf24-irq-pin=<PIN> Pin number connected to nRF24L01 IRQ pin.
6269
--my-rf24-encryption-enabled
6370
Enables RF24 encryption.
@@ -209,7 +216,7 @@ function gcc_cpu_flags {
209216
flags="-march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard"
210217
;;
211218
H3)
212-
flags="-march=armv8-a -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard"
219+
flags="-march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard"
213220
;;
214221
*)
215222
flags=""
@@ -224,7 +231,7 @@ transport_type=nrf24
224231
signing=none
225232
signing_request_signatures=false
226233

227-
params="SOC CFLAGS CXXFLAGS CPPFLAGS LDFLAGS PREFIX CC CXX ARDUINO_LIB_DIR BUILDDIR BINDIR GATEWAY_DIR INIT_SYSTEM"
234+
params="SOC CFLAGS CXXFLAGS CPPFLAGS LDFLAGS PREFIX CC CXX ARDUINO_LIB_DIR BUILDDIR BINDIR GATEWAY_DIR INIT_SYSTEM SPI_DRIVER"
228235

229236
for opt do
230237
if [ "$opt" = "-h" ] || [ "$opt" = "--help" ]; then
@@ -233,6 +240,12 @@ for opt do
233240
fi
234241
optarg="${opt#*=}"
235242
case "$opt" in
243+
--spi-driver=*)
244+
SPI_DRIVER="$optarg"
245+
;;
246+
--spi-spidev-device=*)
247+
CPPFLAGS="-DSPI_SPIDEV_DEVICE=\\\"${optarg}\\\" $CPPFLAGS"
248+
;;
236249
--soc=*)
237250
SOC="$optarg"
238251
;;
@@ -308,7 +321,7 @@ for opt do
308321
CPPFLAGS="-DMY_BAUD_RATE=${optarg} $CPPFLAGS"
309322
;;
310323
--my-serial-is-pty*)
311-
CPPFLAGS="-DMY_IS_SERIAL_PTY $CPPFLAGS"
324+
CPPFLAGS="-DMY_LINUX_IS_SERIAL_PTY $CPPFLAGS"
312325
;;
313326
--my-serial-pty=*)
314327
CPPFLAGS="-DMY_LINUX_SERIAL_PTY=\\\"${optarg}\\\" $CPPFLAGS"
@@ -322,6 +335,12 @@ for opt do
322335
--my-rf24-pa-level=*)
323336
CPPFLAGS="-DMY_RF24_PA_LEVEL=${optarg} $CPPFLAGS"
324337
;;
338+
--my-rf24-ce-pin=*)
339+
CPPFLAGS="-DMY_RF24_CE_PIN=${optarg} $CPPFLAGS"
340+
;;
341+
--my-rf24-cs-pin=*)
342+
CPPFLAGS="-DMY_RF24_CS_PIN=${optarg} $CPPFLAGS"
343+
;;
325344
--my-controller-url-address=*)
326345
CPPFLAGS="-DMY_CONTROLLER_URL_ADDRESS=\\\"${optarg}\\\" $CPPFLAGS"
327346
;;
@@ -406,7 +425,7 @@ if [ -z "${SOC}" ]; then
406425
SOC=${info[0]}
407426
TYPE=${info[1]}
408427
CPU=${info[2]}
409-
echo "[OK] machine detected: SoC=${SOC}, Type=${TYPE}, CPU=${CPU}."
428+
echo " [OK] machine detected: SoC=${SOC}, Type=${TYPE}, CPU=${CPU}."
410429
fi
411430

412431
if [ -z "${CPUFLAGS}" ]; then
@@ -415,6 +434,40 @@ fi
415434

416435
if [[ $SOC == "BCM2835" || $SOC == "BCM2836" ]]; then
417436
CPPFLAGS="-DLINUX_ARCH_RASPBERRYPI $CPPFLAGS"
437+
else
438+
echo "[SECTION] Checking GPIO Sysfs."
439+
if [[ $(eval 'ls /sys/class/gpio/export 2>/dev/null') ]]; then
440+
echo " [OK] /sys/class/gpio/export found"
441+
else
442+
echo " [WARNING] /sys/class/gpio/export not found."
443+
fi
444+
fi
445+
446+
if [ -z "${SPI_DRIVER}" ]; then
447+
echo "[SECTION] Detecting SPI driver."
448+
if [[ $SOC == "BCM2835" || $SOC == "BCM2836" ]]; then
449+
SPI_DRIVER=BCM
450+
elif [[ $(eval 'ls /dev/spidev* 2>/dev/null') ]]; then
451+
SPI_DRIVER=SPIDEV
452+
fi
453+
if [ -n "${SPI_DRIVER}" ]; then
454+
echo " [OK] SPI driver detected:${SPI_DRIVER}."
455+
else
456+
echo " [WARNING] No supported SPI driver detected."
457+
fi
458+
fi
459+
if [ -n "${SPI_DRIVER}" ]; then
460+
case ${SPI_DRIVER} in
461+
BCM)
462+
CPPFLAGS="-DLINUX_SPI_BCM $CPPFLAGS"
463+
;;
464+
SPIDEV)
465+
CPPFLAGS="-DLINUX_SPI_SPIDEV $CPPFLAGS"
466+
;;
467+
*)
468+
die "Unsupported SPI driver: ${SPI_DRIVER}." 1
469+
;;
470+
esac
418471
fi
419472

420473
if [[ ${debug} == "enable" ]]; then
@@ -431,9 +484,7 @@ elif [[ ${gateway_type} == "serial" ]]; then
431484
elif [[ ${gateway_type} == "mqtt" ]]; then
432485
CPPFLAGS="-DMY_GATEWAY_LINUX -DMY_GATEWAY_MQTT_CLIENT $CPPFLAGS"
433486
else
434-
echo "Invalid gateway type."
435-
echo "Aborting."
436-
exit 1
487+
die "Invalid gateway type." 2
437488
fi
438489

439490
if [[ ${transport_type} == "none" ]]; then
@@ -446,9 +497,7 @@ elif [[ ${transport_type} == "rs485" ]]; then
446497
elif [[ ${transport_type} == "rfm95" ]]; then
447498
CPPFLAGS="-DMY_RADIO_RFM95 $CPPFLAGS"
448499
else
449-
echo "Invalid transport type."
450-
echo "Aborting."
451-
exit 1
500+
die "Invalid transport type." 3
452501
fi
453502

454503
if [[ ${signing} == "none" ]]; then
@@ -460,24 +509,23 @@ elif [[ ${signing} == "software" ]]; then
460509
CPPFLAGS="-DMY_SIGNING_REQUEST_SIGNATURES $CPPFLAGS"
461510
fi
462511
else
463-
echo "Invalid message signing option."
464-
echo "Aborting."
465-
exit 1
512+
die "Invalid message signing option." 4
466513
fi
467514

468515
LDFLAGS="-pthread $LDFLAGS"
469516
CPPFLAGS="$CPUFLAGS $CPPFLAGS"
470517

518+
echo "[SECTION] Detecting init system."
471519
if [ "${NO_INIT}" ]; then
472-
echo "[OK] no init system chosen."
520+
echo " [OK] no init system chosen."
473521
elif [ -x /usr/bin/systemctl ] || [ -x /bin/systemctl ]; then
474522
INIT_SYSTEM=systemd
475-
echo "[OK] init system detected: systemd"
523+
echo " [OK] init system detected: systemd."
476524
elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then
477525
INIT_SYSTEM=sysvinit
478-
echo "[OK] init system detected: sysvinit"
526+
echo " [OK] init system detected: sysvinit."
479527
else
480-
echo "[FAILED] unknown init system"
528+
echo " [FAILED] unknown init system."
481529
fi
482530

483531
echo "[SECTION] Saving configuration."

core/MyHwATMega328.cpp renamed to core/MyHwAVR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#ifdef ARDUINO_ARCH_AVR
2121

22-
#include "MyHwATMega328.h"
22+
#include "MyHwAVR.h"
2323

2424
#define INVALID_INTERRUPT_NUM (0xFFu)
2525

core/MyHwATMega328.h renamed to core/MyHwAVR.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* version 2 as published by the Free Software Foundation.
1818
*/
1919

20-
#ifndef MyHwATMega328_h
21-
#define MyHwATMega328_h
20+
#ifndef MyHwAVR_h
21+
#define MyHwAVR_h
2222

2323
#include "MyHw.h"
2424
#include <avr/eeprom.h>
@@ -58,12 +58,10 @@
5858

5959

6060
// Define these as macros to save valuable space
61-
6261
#define hwDigitalWrite(__pin, __value) digitalWriteFast(__pin, __value)
6362
#define hwDigitalRead(__pin) digitalReadFast(__pin)
6463
#define hwPinMode(__pin, __value) pinModeFast(__pin, __value)
6564

66-
6765
#if defined(MY_DISABLED_SERIAL)
6866
#define hwInit()
6967
#else

core/MyHwLinuxGeneric.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ static SoftEeprom eeprom = SoftEeprom(MY_LINUX_CONFIG_FILE, 1024); // ATMega328
2828

2929
void hwInit()
3030
{
31-
#ifdef MY_GATEWAY_SERIAL
3231
MY_SERIALDEVICE.begin(MY_BAUD_RATE);
32+
#ifdef MY_GATEWAY_SERIAL
3333
#ifdef MY_LINUX_SERIAL_GROUPNAME
3434
if (!MY_SERIALDEVICE.setGroupPerm(MY_LINUX_SERIAL_GROUPNAME)) {
3535
logError("Unable to change permission for serial port device.\n");
@@ -120,6 +120,21 @@ uint16_t hwFreeMem()
120120
}
121121
#endif
122122

123+
void hwDigitalWrite(uint8_t pin, uint8_t value)
124+
{
125+
digitalWrite(pin, value);
126+
}
127+
128+
int hwDigitalRead(uint8_t pin)
129+
{
130+
return digitalRead(pin);
131+
}
132+
133+
void hwPinMode(uint8_t pin, uint8_t mode)
134+
{
135+
pinMode(pin, mode);
136+
}
137+
123138
#ifdef MY_DEBUG
124139
void hwDebugPrint(const char *fmt, ...)
125140
{

core/MyHwLinuxGeneric.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@
2424
#include <pthread.h>
2525
#include "MyHw.h"
2626
#include "SerialPort.h"
27+
#include "SerialSimulator.h"
2728

28-
#ifdef MY_IS_SERIAL_PTY
29+
#ifdef MY_GATEWAY_SERIAL
30+
#ifdef MY_LINUX_IS_SERIAL_PTY
2931
SerialPort Serial = SerialPort(MY_LINUX_SERIAL_PTY, true);
3032
#else
3133
SerialPort Serial = SerialPort(MY_LINUX_SERIAL_PORT);
3234
#endif
35+
#else
36+
SerialSimulator Serial = SerialSimulator();
37+
#endif
3338

3439
#ifndef MY_SERIALDEVICE
3540
#define MY_SERIALDEVICE Serial
@@ -39,9 +44,9 @@ SerialPort Serial = SerialPort(MY_LINUX_SERIAL_PORT);
3944
#define hwWatchdogReset()
4045
#define hwReboot()
4146

42-
#define hwDigitalWrite(__pin, __value) _Pragma("GCC error \"Not supported on linux-generic\"")
43-
#define hwDigitalRead(__pin) _Pragma("GCC error \"Not supported on linux-generic\"")
44-
#define hwPinMode(__pin, __value) _Pragma("GCC error \"Not supported on linux-generic\"")
47+
inline void hwDigitalWrite(uint8_t, uint8_t);
48+
inline int hwDigitalRead(uint8_t);
49+
inline void hwPinMode(uint8_t, uint8_t);
4550

4651
void hwInit();
4752
inline void hwReadConfigBlock(void* buf, void* addr, size_t length);

0 commit comments

Comments
 (0)