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
This commit is contained in:
Olivier
2017-01-18 21:57:07 +01:00
committed by Henrik Ekblad
parent 808f9d8de6
commit 8bb3cfb2e1
59 changed files with 1665 additions and 719 deletions
+1 -1
View File
@@ -19,7 +19,7 @@
#ifdef ARDUINO_ARCH_AVR
#include "MyHwATMega328.h"
#include "MyHwAVR.h"
#define INVALID_INTERRUPT_NUM (0xFFu)
+2 -4
View File
@@ -17,8 +17,8 @@
* version 2 as published by the Free Software Foundation.
*/
#ifndef MyHwATMega328_h
#define MyHwATMega328_h
#ifndef MyHwAVR_h
#define MyHwAVR_h
#include "MyHw.h"
#include <avr/eeprom.h>
@@ -58,12 +58,10 @@
// Define these as macros to save valuable space
#define hwDigitalWrite(__pin, __value) digitalWriteFast(__pin, __value)
#define hwDigitalRead(__pin) digitalReadFast(__pin)
#define hwPinMode(__pin, __value) pinModeFast(__pin, __value)
#if defined(MY_DISABLED_SERIAL)
#define hwInit()
#else
+16 -1
View File
@@ -28,8 +28,8 @@ static SoftEeprom eeprom = SoftEeprom(MY_LINUX_CONFIG_FILE, 1024); // ATMega328
void hwInit()
{
#ifdef MY_GATEWAY_SERIAL
MY_SERIALDEVICE.begin(MY_BAUD_RATE);
#ifdef MY_GATEWAY_SERIAL
#ifdef MY_LINUX_SERIAL_GROUPNAME
if (!MY_SERIALDEVICE.setGroupPerm(MY_LINUX_SERIAL_GROUPNAME)) {
logError("Unable to change permission for serial port device.\n");
@@ -120,6 +120,21 @@ uint16_t hwFreeMem()
}
#endif
void hwDigitalWrite(uint8_t pin, uint8_t value)
{
digitalWrite(pin, value);
}
int hwDigitalRead(uint8_t pin)
{
return digitalRead(pin);
}
void hwPinMode(uint8_t pin, uint8_t mode)
{
pinMode(pin, mode);
}
#ifdef MY_DEBUG
void hwDebugPrint(const char *fmt, ...)
{
+9 -4
View File
@@ -24,12 +24,17 @@
#include <pthread.h>
#include "MyHw.h"
#include "SerialPort.h"
#include "SerialSimulator.h"
#ifdef MY_IS_SERIAL_PTY
#ifdef MY_GATEWAY_SERIAL
#ifdef MY_LINUX_IS_SERIAL_PTY
SerialPort Serial = SerialPort(MY_LINUX_SERIAL_PTY, true);
#else
SerialPort Serial = SerialPort(MY_LINUX_SERIAL_PORT);
#endif
#else
SerialSimulator Serial = SerialSimulator();
#endif
#ifndef MY_SERIALDEVICE
#define MY_SERIALDEVICE Serial
@@ -39,9 +44,9 @@ SerialPort Serial = SerialPort(MY_LINUX_SERIAL_PORT);
#define hwWatchdogReset()
#define hwReboot()
#define hwDigitalWrite(__pin, __value) _Pragma("GCC error \"Not supported on linux-generic\"")
#define hwDigitalRead(__pin) _Pragma("GCC error \"Not supported on linux-generic\"")
#define hwPinMode(__pin, __value) _Pragma("GCC error \"Not supported on linux-generic\"")
inline void hwDigitalWrite(uint8_t, uint8_t);
inline int hwDigitalRead(uint8_t);
inline void hwPinMode(uint8_t, uint8_t);
void hwInit();
inline void hwReadConfigBlock(void* buf, void* addr, size_t length);
-146
View File
@@ -1,146 +0,0 @@
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2016 Sensnology AB
* Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*/
#include "MyHwRPi.h"
#include <stdarg.h>
#include <time.h>
#include "SoftEeprom.h"
static SoftEeprom eeprom = SoftEeprom(MY_LINUX_CONFIG_FILE, 1024); // ATMega328 has 1024 bytes
void hwInit()
{
#ifdef MY_GATEWAY_SERIAL
MY_SERIALDEVICE.begin(MY_BAUD_RATE);
#ifdef MY_LINUX_SERIAL_GROUPNAME
if (!MY_SERIALDEVICE.setGroupPerm(MY_LINUX_SERIAL_GROUPNAME)) {
logError("Unable to change permission for serial port device.\n");
exit(1);
}
#endif
#endif
}
void hwReadConfigBlock(void* buf, void* adr, size_t length)
{
eeprom.readBlock(buf, adr, length);
}
void hwWriteConfigBlock(void* buf, void* adr, size_t length)
{
eeprom.writeBlock(buf, adr, length);
}
uint8_t hwReadConfig(int adr)
{
return eeprom.readByte(adr);
}
void hwWriteConfig(int adr, uint8_t value)
{
eeprom.writeByte(adr, value);
}
void hwRandomNumberInit()
{
randomSeed(time(NULL));
}
unsigned long hwMillis()
{
return millis();
}
// Not supported!
int8_t hwSleep(unsigned long ms)
{
(void)ms;
return MY_SLEEP_NOT_POSSIBLE;
}
// Not supported!
int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms)
{
(void)interrupt;
(void)mode;
(void)ms;
return MY_SLEEP_NOT_POSSIBLE;
}
// Not supported!
int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2,
unsigned long ms)
{
(void)interrupt1;
(void)mode1;
(void)interrupt2;
(void)mode2;
(void)ms;
return MY_SLEEP_NOT_POSSIBLE;
}
#if defined(MY_DEBUG) || defined(MY_SPECIAL_DEBUG)
uint16_t hwCPUVoltage()
{
// TODO: Not supported!
return 0;
}
uint16_t hwCPUFrequency()
{
// TODO: Not supported!
return 0;
}
uint16_t hwFreeMem()
{
// TODO: Not supported!
return 0;
}
#endif
#ifdef MY_DEBUG
void hwDebugPrint(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vlogDebug(fmt, args);
va_end(args);
}
#endif
void hwDigitalWrite(uint8_t pin, uint8_t value)
{
digitalWrite(pin, value);
}
int hwDigitalRead(uint8_t pin)
{
return digitalRead(pin);
}
void hwPinMode(uint8_t pin, uint8_t mode)
{
pinMode(pin, mode);
}
-55
View File
@@ -1,55 +0,0 @@
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2016 Sensnology AB
* Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*/
#ifndef MyHwRPi_h
#define MyHwRPi_h
#include <stdint.h>
#include <stdlib.h>
#include "MyHwLinuxGeneric.h"
#include "log.h"
#include "bcm2835.h"
class Bcm2835Init
{
public:
Bcm2835Init()
{
if (!bcm2835_init()) {
logError("Failed to initialized bcm2835.\n");
exit(1);
}
}
~Bcm2835Init()
{
bcm2835_close();
}
};
Bcm2835Init bcm2835Init;
#undef hwDigitalWrite
inline void hwDigitalWrite(uint8_t, uint8_t);
#undef hwDigitalRead
inline int hwDigitalRead(uint8_t);
#undef hwPinMode
inline void hwPinMode(uint8_t, uint8_t);
#endif
+1
View File
@@ -44,6 +44,7 @@ typedef enum {
INDICATION_WAKEUP, //!< Node just woke from sleep.
INDICATION_FW_UPDATE_START, //!< Start of OTA firmware update process.
INDICATION_FW_UPDATE_RX, //!< Received a piece of firmware data.
INDICATION_FW_UPDATE_RX_ERR, //!< Received wrong piece of firmware data.
INDICATION_ERR_START = 100,
INDICATION_ERR_TX, //!< Failed to transmit message.
+15 -15
View File
@@ -50,7 +50,7 @@ void handle_sigint(int sig)
closelog();
exit(0);
exit(EXIT_SUCCESS);
}
static int daemonize(void)
@@ -167,12 +167,12 @@ void generate_soft_sign_hmac_key()
void set_soft_sign_hmac_key(char *key_str)
{
uint8_t key[32];
int n;
if (strlen(key_str) != 64) {
printf("invalid key!\n");
} else {
for (int i = 0; i < 64; ++i) {
int n;
char c = key_str[i];
if (c <= '9') {
n = c - '0';
@@ -242,12 +242,12 @@ void generate_soft_sign_serial_key()
void set_soft_sign_serial_key(char *key_str)
{
uint8_t key[9];
int n;
if (strlen(key_str) != 18) {
printf("invalid key!\n");
} else {
for (int i = 0; i < 18; ++i) {
int n;
char c = key_str[i];
if (c <= '9') {
n = c - '0';
@@ -317,12 +317,12 @@ void generate_aes_key()
void set_aes_key(char *key_str)
{
uint8_t key[16];
int n;
if (strlen(key_str) != 32) {
printf("invalid key!\n");
} else {
for (int i = 0; i < 32; ++i) {
int n;
char c = key_str[i];
if (c <= '9') {
n = c - '0';
@@ -375,7 +375,7 @@ int main(int argc, char *argv[])
switch (opt) {
case 'h':
print_usage();
exit(0);
exit(EXIT_SUCCESS);
case 'd':
debug = 1;
break;
@@ -384,37 +384,37 @@ int main(int argc, char *argv[])
break;
case 'A':
generate_soft_sign_hmac_key();
exit(0);
exit(EXIT_SUCCESS);
case 'B':
generate_soft_sign_serial_key();
exit(0);
exit(EXIT_SUCCESS);
case 'C':
generate_aes_key();
exit(0);
exit(EXIT_SUCCESS);
case 'D':
print_soft_sign_hmac_key();
exit(0);
exit(EXIT_SUCCESS);
case 'E':
print_soft_sign_serial_key();
exit(0);
exit(EXIT_SUCCESS);
case 'F':
print_aes_key();
exit(0);
exit(EXIT_SUCCESS);
case 'G':
key = strdup(optarg);
set_soft_sign_hmac_key(key);
exit(0);
exit(EXIT_SUCCESS);
case 'H':
key = strdup(optarg);
set_soft_sign_serial_key(key);
exit(0);
exit(EXIT_SUCCESS);
case 'I':
key = strdup(optarg);
set_aes_key(key);
exit(0);
exit(EXIT_SUCCESS);
default:
print_usage();
exit(0);
exit(EXIT_SUCCESS);
}
}
+12 -5
View File
@@ -93,19 +93,26 @@ bool firmwareOTAUpdateProcess(void)
OTA_DEBUG(PSTR("OTA:FWP:UPDATE SKIPPED\n")); // FW update skipped, no newer version available
} else if (_msg.type == ST_FIRMWARE_RESPONSE) {
if (_firmwareUpdateOngoing) {
// Save block to flash
setIndication(INDICATION_FW_UPDATE_RX);
OTA_DEBUG(PSTR("OTA:FWP:RECV B=%04X\n"), _firmwareBlock); // received FW block
// extract FW block
replyFirmwareBlock_t *firmwareResponse = (replyFirmwareBlock_t *)_msg.data;
// write to flash
OTA_DEBUG(PSTR("OTA:FWP:RECV B=%04X\n"), firmwareResponse->block); // received FW block
if (firmwareResponse->block != _firmwareBlock - 1) {
OTA_DEBUG(PSTR("!OTA:FWP:WRONG FWB\n")); // received FW block
// wrong firmware block received
setIndication(INDICATION_FW_UPDATE_RX_ERR);
// no further processing required
return true;
}
setIndication(INDICATION_FW_UPDATE_RX);
// Save block to flash
_flash.writeBytes( ((_firmwareBlock - 1) * FIRMWARE_BLOCK_SIZE) + FIRMWARE_START_OFFSET,
firmwareResponse->data, FIRMWARE_BLOCK_SIZE);
// wait until flash written
while (_flash.busy()) {}
_firmwareBlock--;
if (!_firmwareBlock) {
// We're finished! Do a checksum and reboot.
// We're done! Do a checksum and reboot.
OTA_DEBUG(PSTR("OTA:FWP:FW END\n")); // received FW block
_firmwareUpdateOngoing = false;
if (transportIsValidFirmware()) {
+1
View File
@@ -40,6 +40,7 @@
* |!| OTA | FWP | FLASH INIT FAIL | Failed to initialise flash
* | | OTA | FWP | UPDATE SKIPPED | FW update skipped, no newer version available
* | | OTA | FWP | RECV B=%04X | Received FW block (B)
* |!| OTA | FWP | WRONG FWB | Wrong FW block received
* | | OTA | FWP | FW END | FW received, proceed to CRC verification
* | | OTA | FWP | CRC OK | FW CRC verification OK
* |!| OTA | FWP | CRC FAIL | FW CRC verification failed
+1 -1
View File
@@ -262,7 +262,7 @@ uint8_t getDistanceGW(void)
return result;
}
controllerConfig_t getConfig(void)
controllerConfig_t getControllerConfig(void)
{
return _coreConfig.controllerConfig;
}
+21 -18
View File
@@ -337,7 +337,8 @@ static bool skipSign(MyMessage &msg)
msg.type == I_FIND_PARENT_REQUEST || msg.type == I_FIND_PARENT_RESPONSE ||
msg.type == I_HEARTBEAT_REQUEST || msg.type == I_HEARTBEAT_RESPONSE ||
msg.type == I_PING || msg.type == I_PONG ||
msg.type == I_REGISTRATION_REQUEST )) {
msg.type == I_REGISTRATION_REQUEST || msg.type == I_DISCOVER_REQUEST ||
msg.type == I_DISCOVER_RESPONSE )) {
SIGN_DEBUG(PSTR("Skipping security for command %d type %d\n"), mGetCommand(msg), msg.type);
ret = true;
} else if (mGetCommand(msg) == C_STREAM &&
@@ -366,6 +367,7 @@ static void prepareSigningPresentation(MyMessage &msg, uint8_t destination)
// Helper to process presentation mesages
static bool signerInternalProcessPresentation(MyMessage &msg)
{
const uint8_t sender = msg.sender;
#if defined(MY_SIGNING_FEATURE)
if (msg.data[0] != SIGNING_PRESENTATION_VERSION_1) {
SIGN_DEBUG(PSTR("Unsupported signing presentation version (%d)!\n"), msg.data[0]);
@@ -374,21 +376,21 @@ static bool signerInternalProcessPresentation(MyMessage &msg)
// We only handle version 1 here...
if (msg.data[1] & SIGNING_PRESENTATION_REQUIRE_SIGNATURES) {
// We received an indicator that the sender require us to sign all messages we send to it
SIGN_DEBUG(PSTR("Mark node %d as one that require signed messages\n"), msg.sender);
SET_SIGN(msg.sender);
SIGN_DEBUG(PSTR("Mark node %d as one that require signed messages\n"), sender);
SET_SIGN(sender);
} else {
// We received an indicator that the sender does not require us to sign all messages we send to it
SIGN_DEBUG(PSTR("Mark node %d as one that do not require signed messages\n"), msg.sender);
CLEAR_SIGN(msg.sender);
SIGN_DEBUG(PSTR("Mark node %d as one that do not require signed messages\n"), sender);
CLEAR_SIGN(sender);
}
if (msg.data[1] & SIGNING_PRESENTATION_REQUIRE_WHITELISTING) {
// We received an indicator that the sender require us to salt signatures with serial
SIGN_DEBUG(PSTR("Mark node %d as one that require whitelisting\n"), msg.sender);
SET_WHITELIST(msg.sender);
SIGN_DEBUG(PSTR("Mark node %d as one that require whitelisting\n"), sender);
SET_WHITELIST(sender);
} else {
// We received an indicator that the sender does not require us to sign all messages we send to it
SIGN_DEBUG(PSTR("Mark node %d as one that do not require whitelisting\n"), msg.sender);
CLEAR_WHITELIST(msg.sender);
SIGN_DEBUG(PSTR("Mark node %d as one that do not require whitelisting\n"), sender);
CLEAR_WHITELIST(sender);
}
// Save updated tables
@@ -400,12 +402,12 @@ static bool signerInternalProcessPresentation(MyMessage &msg)
// Inform sender about our preference if we are a gateway, but only require signing if the sender
// required signing unless we explicitly configure it to
#if defined(MY_GATEWAY_FEATURE)
prepareSigningPresentation(msg, msg.sender);
prepareSigningPresentation(msg, sender);
#if defined(MY_SIGNING_REQUEST_SIGNATURES)
#if defined(MY_SIGNING_GW_REQUEST_SIGNATURES_FROM_ALL)
msg.data[1] |= SIGNING_PRESENTATION_REQUIRE_SIGNATURES;
#else
if (DO_SIGN(msg.sender)) {
if (DO_SIGN(sender)) {
msg.data[1] |= SIGNING_PRESENTATION_REQUIRE_SIGNATURES;
}
#endif
@@ -414,20 +416,20 @@ static bool signerInternalProcessPresentation(MyMessage &msg)
#if defined(MY_SIGNING_GW_REQUEST_SIGNATURES_FROM_ALL)
msg.data[1] |= SIGNING_PRESENTATION_REQUIRE_WHITELISTING;
#else
if (DO_WHITELIST(msg.sender)) {
if (DO_WHITELIST(sender)) {
msg.data[1] |= SIGNING_PRESENTATION_REQUIRE_WHITELISTING;
}
#endif
#endif // MY_SIGNING_NODE_WHITELISTING
if (msg.data[1] & SIGNING_PRESENTATION_REQUIRE_SIGNATURES) {
SIGN_DEBUG(PSTR("Informing node %d that we require signatures\n"), msg.sender);
SIGN_DEBUG(PSTR("Informing node %d that we require signatures\n"), sender);
} else {
SIGN_DEBUG(PSTR("Informing node %d that we do not require signatures\n"), msg.sender);
SIGN_DEBUG(PSTR("Informing node %d that we do not require signatures\n"), sender);
}
if (msg.data[1] & SIGNING_PRESENTATION_REQUIRE_WHITELISTING) {
SIGN_DEBUG(PSTR("Informing node %d that we require whitelisting\n"), msg.sender);
SIGN_DEBUG(PSTR("Informing node %d that we require whitelisting\n"), sender);
} else {
SIGN_DEBUG(PSTR("Informing node %d that we do not require whitelisting\n"), msg.sender);
SIGN_DEBUG(PSTR("Informing node %d that we do not require whitelisting\n"), sender);
}
if (!_sendRoute(msg)) {
SIGN_DEBUG(PSTR("Failed to transmit signing presentation!\n"));
@@ -437,10 +439,10 @@ static bool signerInternalProcessPresentation(MyMessage &msg)
#if defined(MY_GATEWAY_FEATURE)
// If we act as gateway and do not have the signing feature and receive a signing request we still
// need to do make sure the requester does not believe the gateway still require signatures
prepareSigningPresentation(msg, msg.sender);
prepareSigningPresentation(msg, sender);
SIGN_DEBUG(
PSTR("Informing node %d that we do not require signatures because we do not support it\n"),
msg.sender);
sender);
if (!_sendRoute(msg)) {
SIGN_DEBUG(PSTR("Failed to transmit signing presentation!\n"));
}
@@ -448,6 +450,7 @@ static bool signerInternalProcessPresentation(MyMessage &msg)
// If we act as a node and do not have the signing feature then we just silently drop any signing
// presentation messages received
(void)msg;
(void)sender;
SIGN_DEBUG(PSTR("Received signing presentation, but signing is not supported (message ignored)\n"));
#endif // not MY_GATEWAY_FEATURE
#endif // not MY_SIGNING_FEATURE
+2 -2
View File
@@ -6,7 +6,7 @@
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Copyright (C) 2013-2017 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
@@ -24,6 +24,6 @@
#ifndef Version_h
#define Version_h
#define MYSENSORS_LIBRARY_VERSION "2.1.0"
#define MYSENSORS_LIBRARY_VERSION "2.1.1"
#endif