Skip to content

Commit 8e8f44b

Browse files
authored
Code updates & harmonization (#1201)
1 parent b6ab7aa commit 8e8f44b

File tree

101 files changed

+2114
-557
lines changed

Some content is hidden

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

101 files changed

+2114
-557
lines changed

MyASM.S

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
*
1919
*/
2020

21-
#if defined(ARDUINO_ARCH_NRF5)
21+
#if defined(ARDUINO_ARCH_SAMD)
22+
/* workaround to prevent compiler error */
23+
.thumb_func
24+
doNothing:
25+
nop
26+
.size doNothing, .-doNothing
27+
28+
#elif defined(ARDUINO_ARCH_NRF5)
2229
/* workaround to prevent compiler error */
2330
.thumb_func
2431
doNothing:

MyConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,7 @@
16411641
* | @ref MY_SIGNING_SOFT_RANDOMSEED_PIN | Change default software RNG seed pin | "#define" in the top of your sketch | Not supported
16421642
* | @ref MY_RF24_ENABLE_ENCRYPTION | Enables encryption on RF24 radios | "#define" in the top of your sketch | @verbatim --my-rf24-encryption-enabled @endverbatim
16431643
* | @ref MY_RFM69_ENABLE_ENCRYPTION | Enables encryption on %RFM69 radios | "#define" in the top of your sketch | @verbatim --my-rfm69-encryption-enabled @endverbatim
1644+
* | @ref MY_RFM95_ENABLE_ENCRYPTION | Enables encryption on %RFM95 radios | "#define" in the top of your sketch | @verbatim --my-rfm95-encryption-enabled @endverbatim
16441645
* | @ref MY_NRF5_ESB_ENABLE_ENCRYPTION | Enables encryption on nRF5 radios | "#define" in the top of your sketch | Not supported
16451646
* | @ref MY_NODE_LOCK_FEATURE | Enables the node locking feature | "#define" in the top of your sketch | Not supported
16461647
* | @ref MY_NODE_UNLOCK_PIN | Change default unlock pin | "#define" in the top of your sketch | Not supported

MySensors.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#endif
5050

5151
// HARDWARE
52-
#include "hal/architecture/MyHw.h"
52+
#include "hal/architecture/MyHwHAL.h"
5353
#include "hal/crypto/MyCryptoHAL.h"
5454
#if defined(ARDUINO_ARCH_ESP8266)
5555
#include "hal/architecture/ESP8266/MyHwESP8266.cpp"
@@ -58,7 +58,7 @@
5858
#include "hal/architecture/ESP32/MyHwESP32.cpp"
5959
#include "hal/crypto/ESP32/MyCryptoESP32.cpp"
6060
#elif defined(ARDUINO_ARCH_AVR)
61-
#include "drivers/AVR/DigitalWriteFast/digitalWriteFast.h"
61+
#include "hal/architecture/AVR/drivers/DigitalWriteFast/digitalWriteFast.h"
6262
#include "hal/architecture/AVR/MyHwAVR.cpp"
6363
#include "hal/crypto/AVR/MyCryptoAVR.cpp"
6464
#elif defined(ARDUINO_ARCH_SAMD)
@@ -338,7 +338,7 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
338338
#if defined(ARDUINO_ARCH_ESP8266)
339339
#error Soft SPI is not available on ESP8266
340340
#endif
341-
#include "drivers/AVR/DigitalIO/DigitalIO.h"
341+
#include "hal/architecture/AVR/drivers/DigitalIO/DigitalIO.h"
342342
#endif
343343

344344
// SOFTSERIAL
@@ -361,14 +361,14 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
361361

362362
// Transport drivers
363363
#if defined(MY_RADIO_RF24)
364-
#include "drivers/RF24/RF24.cpp"
364+
#include "hal/transport/RF24/driver/RF24.cpp"
365365
#include "hal/transport/RF24/MyTransportRF24.cpp"
366366
#elif defined(MY_RADIO_NRF5_ESB)
367367
#if !defined(ARDUINO_ARCH_NRF5)
368368
#error No support for nRF5 radio on this platform
369369
#endif
370-
#include "drivers/NRF5/Radio.cpp"
371-
#include "drivers/NRF5/Radio_ESB.cpp"
370+
#include "hal/transport/NRF5_ESB/driver/Radio.cpp"
371+
#include "hal/transport/NRF5_ESB/driver/Radio_ESB.cpp"
372372
#include "hal/transport/NRF5_ESB/MyTransportNRF5_ESB.cpp"
373373
#elif defined(MY_RS485)
374374
#if !defined(MY_RS485_HWSERIAL)
@@ -380,13 +380,13 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
380380
#include "hal/transport/RS485/MyTransportRS485.cpp"
381381
#elif defined(MY_RADIO_RFM69)
382382
#if defined(MY_RFM69_NEW_DRIVER)
383-
#include "drivers/RFM69/new/RFM69_new.cpp"
383+
#include "hal/transport/RFM69/driver/new/RFM69_new.cpp"
384384
#else
385-
#include "drivers/RFM69/old/RFM69_old.cpp"
385+
#include "hal/transport/RFM69/driver/old/RFM69_old.cpp"
386386
#endif
387387
#include "hal/transport/RFM69/MyTransportRFM69.cpp"
388388
#elif defined(MY_RADIO_RFM95)
389-
#include "drivers/RFM95/RFM95.cpp"
389+
#include "hal/transport/RFM95/driver/RFM95.cpp"
390390
#include "hal/transport/RFM95/MyTransportRFM95.cpp"
391391
#endif
392392

core/MyEepromAddresses.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@
8383
/** @brief Address RF AES encryption key. This is set with @ref SecurityPersonalizer.ino */
8484
#define EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS (EEPROM_SIGNING_SOFT_SERIAL_ADDRESS + SIZE_SIGNING_SOFT_SERIAL)
8585
/** @brief Address node lock counter. This is set with @ref SecurityPersonalizer.ino */
86-
#define EEPROM_NODE_LOCK_COUNTER (EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS + SIZE_RF_ENCRYPTION_AES_KEY)
86+
#define EEPROM_NODE_LOCK_COUNTER_ADDRESS (EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS + SIZE_RF_ENCRYPTION_AES_KEY)
8787
/** @brief First free address for sketch static configuration */
88-
#define EEPROM_LOCAL_CONFIG_ADDRESS (EEPROM_NODE_LOCK_COUNTER + SIZE_NODE_LOCK_COUNTER)
88+
#define EEPROM_LOCAL_CONFIG_ADDRESS (EEPROM_NODE_LOCK_COUNTER_ADDRESS + SIZE_NODE_LOCK_COUNTER)
8989

9090
#endif // MyEepromAddresses_h
9191

core/MyMessage.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,9 @@ typedef union {
479479
struct {
480480

481481
#endif
482-
uint8_t last; ///< 8 bit - Id of last node this message passed
483-
uint8_t sender; ///< 8 bit - Id of sender node (origin)
484-
uint8_t destination; ///< 8 bit - Id of destination node
482+
uint8_t last; //!< 8 bit - Id of last node this message passed
483+
uint8_t sender; //!< 8 bit - Id of sender node (origin)
484+
uint8_t destination; //!< 8 bit - Id of destination node
485485

486486
/**
487487
* 2 bit - Protocol version<br>
@@ -498,35 +498,35 @@ typedef union {
498498
*/
499499
uint8_t command_ack_payload;
500500

501-
uint8_t type; ///< 8 bit - Type varies depending on command
502-
uint8_t sensor; ///< 8 bit - Id of sensor that this message concerns.
501+
uint8_t type; //!< 8 bit - Type varies depending on command
502+
uint8_t sensor; //!< 8 bit - Id of sensor that this message concerns.
503503

504504
/*
505505
* Each message can transfer a payload. We add one extra byte for string
506506
* terminator \0 to be "printable" this is not transferred OTA
507507
* This union is used to simplify the construction of the binary data types transferred.
508508
*/
509509
union {
510-
uint8_t bValue; ///< unsigned byte value (8-bit)
511-
uint16_t uiValue; ///< unsigned integer value (16-bit)
512-
int16_t iValue; ///< signed integer value (16-bit)
513-
uint32_t ulValue; ///< unsigned long value (32-bit)
514-
int32_t lValue; ///< signed long value (32-bit)
515-
struct { //< Float messages
510+
uint8_t bValue; //!< unsigned byte value (8-bit)
511+
uint16_t uiValue; //!< unsigned integer value (16-bit)
512+
int16_t iValue; //!< signed integer value (16-bit)
513+
uint32_t ulValue; //!< unsigned long value (32-bit)
514+
int32_t lValue; //!< signed long value (32-bit)
515+
struct { //!< Float messages
516516
float fValue;
517-
uint8_t fPrecision; ///< Number of decimals when serializing
517+
uint8_t fPrecision; //!< Number of decimals when serializing
518518
};
519-
struct { //< Presentation messages
520-
uint8_t version; ///< Library version
521-
uint8_t sensorType; ///< Sensor type hint for controller, see table above
519+
struct { //!< Presentation messages
520+
uint8_t version; //!< Library version
521+
uint8_t sensorType; //!< Sensor type hint for controller, see table above
522522
};
523-
char data[MAX_PAYLOAD + 1]; ///< Buffer for raw payload data
524-
} __attribute__((packed)); ///< Doxygen will complain without this comment
523+
char data[MAX_PAYLOAD + 1]; //!< Buffer for raw payload data
524+
} __attribute__((packed)); //!< Doxygen will complain without this comment
525525
#if defined(__cplusplus) || defined(DOXYGEN)
526526
} __attribute__((packed));
527527
#else
528528
};
529-
uint8_t array[HEADER_SIZE + MAX_PAYLOAD + 1]; ///< buffer for entire message
529+
uint8_t array[HEADER_SIZE + MAX_PAYLOAD + 1]; //!< buffer for entire message
530530
} __attribute__((packed)) MyMessage;
531531
#endif
532532

core/MySensorsCore.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ void _nodeLock(const char* str)
706706
{
707707
#ifdef MY_NODE_LOCK_FEATURE
708708
// Make sure EEPROM is updated to locked status
709-
hwWriteConfig(EEPROM_NODE_LOCK_COUNTER, 0);
709+
hwWriteConfig(EEPROM_NODE_LOCK_COUNTER_ADDRESS, 0);
710710
while (1) {
711711
setIndication(INDICATION_ERR_LOCKED);
712712
CORE_DEBUG(PSTR("MCO:NLK:NODE LOCKED. TO UNLOCK, GND PIN %" PRIu8 " AND RESET\n"),
@@ -730,15 +730,15 @@ void _checkNodeLock(void)
730730
{
731731
#ifdef MY_NODE_LOCK_FEATURE
732732
// Check if node has been locked down
733-
if (hwReadConfig(EEPROM_NODE_LOCK_COUNTER) == 0) {
733+
if (hwReadConfig(EEPROM_NODE_LOCK_COUNTER_ADDRESS) == 0) {
734734
// Node is locked, check if unlock pin is asserted, else hang the node
735735
hwPinMode(MY_NODE_UNLOCK_PIN, INPUT_PULLUP);
736736
// Make a short delay so we are sure any large external nets are fully pulled
737737
uint32_t enter = hwMillis();
738738
while (hwMillis() - enter < 2) {}
739739
if (hwDigitalRead(MY_NODE_UNLOCK_PIN) == 0) {
740740
// Pin is grounded, reset lock counter
741-
hwWriteConfig(EEPROM_NODE_LOCK_COUNTER, MY_NODE_LOCK_COUNTER_MAX);
741+
hwWriteConfig(EEPROM_NODE_LOCK_COUNTER_ADDRESS, MY_NODE_LOCK_COUNTER_MAX);
742742
// Disable pullup
743743
hwPinMode(MY_NODE_UNLOCK_PIN, INPUT);
744744
setIndication(INDICATION_ERR_LOCKED);
@@ -748,9 +748,9 @@ void _checkNodeLock(void)
748748
hwPinMode(MY_NODE_UNLOCK_PIN, INPUT);
749749
_nodeLock("LDB"); //Locked during boot
750750
}
751-
} else if (hwReadConfig(EEPROM_NODE_LOCK_COUNTER) == 0xFF) {
751+
} else if (hwReadConfig(EEPROM_NODE_LOCK_COUNTER_ADDRESS) == 0xFF) {
752752
// Reset value
753-
hwWriteConfig(EEPROM_NODE_LOCK_COUNTER, MY_NODE_LOCK_COUNTER_MAX);
753+
hwWriteConfig(EEPROM_NODE_LOCK_COUNTER_ADDRESS, MY_NODE_LOCK_COUNTER_MAX);
754754
}
755755
#endif
756756
}

core/MyTransport.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void stInitTransition(void)
9090
#endif
9191

9292
// Read node settings (ID, parent ID, GW distance) from EEPROM
93-
hwReadConfigBlock((void*)&_transportConfig, (void*)EEPROM_NODE_ID_ADDRESS,
93+
hwReadConfigBlock((void *)&_transportConfig, (void *)EEPROM_NODE_ID_ADDRESS,
9494
sizeof(transportConfig_t));
9595
}
9696

@@ -360,7 +360,7 @@ void stFailureUpdate(void)
360360
}
361361
}
362362

363-
void transportSwitchSM(transportState_t& newState)
363+
void transportSwitchSM(transportState_t &newState)
364364
{
365365
if (_transportSM.currentState != &newState) {
366366
_transportSM.stateRetries = 0u; // state change, reset retry counter
@@ -411,7 +411,6 @@ void resetMessageReceived(void)
411411
_transportSM.msgReceived = false;
412412
}
413413

414-
415414
void transportInitialise(void)
416415
{
417416
_transportSM.failureCounter = 0u; // reset failure counter
@@ -431,6 +430,7 @@ void transportDisable(void)
431430
transportSleep();
432431
}
433432
}
433+
434434
void transportReInitialise(void)
435435
{
436436
if (RADIO_CAN_POWER_OFF == true) {
@@ -443,7 +443,6 @@ void transportReInitialise(void)
443443
}
444444
}
445445

446-
447446
bool transportWaitUntilReady(const uint32_t waitingMS)
448447
{
449448
// check if transport ready
@@ -467,7 +466,6 @@ void transportProcess(void)
467466
transportProcessFIFO();
468467
}
469468

470-
471469
bool transportCheckUplink(const bool force)
472470
{
473471
if (!force && (hwMillis() - _transportSM.lastUplinkCheck) < MY_TRANSPORT_CHKUPL_INTERVAL_MS) {
@@ -717,7 +715,7 @@ void transportProcessMessage(void)
717715
// Is message addressed to this node?
718716
if (destination == _transportConfig.nodeId) {
719717
// prevent buffer overflow by limiting max. possible message length (5 bits=31 bytes max) to MAX_PAYLOAD (25 bytes)
720-
mSetLength(_msg, min(mGetLength(_msg),(uint8_t)MAX_PAYLOAD));
718+
mSetLength(_msg, min(mGetLength(_msg), (uint8_t)MAX_PAYLOAD));
721719
// null terminate data
722720
_msg.data[msgLength] = 0u;
723721
// Check if sender requests an ack back.

core/MyTransport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ typedef int16_t transportRSSI_t; //!< Datatype for internal RSSI storage
253253
*/
254254
typedef struct {
255255
// SM variables
256-
transportState_t* currentState; //!< pointer to current FSM state
256+
transportState_t *currentState; //!< pointer to current FSM state
257257
uint32_t stateEnter; //!< state enter timepoint
258258
// general transport variables
259259
uint32_t lastUplinkCheck; //!< last uplink check, required to prevent GW flooding
@@ -334,7 +334,7 @@ void stFailureUpdate(void);
334334
* @brief Switch SM state
335335
* @param newState New state to switch SM to
336336
*/
337-
void transportSwitchSM(transportState_t& newState);
337+
void transportSwitchSM(transportState_t &newState);
338338
/**
339339
* @brief Update SM state
340340
*/

core/Version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
#define MYSENSORS_LIBRARY_VERSION_MAJOR 2 //!< Major release version
5050
#define MYSENSORS_LIBRARY_VERSION_MINOR 3 //!< Minor release version
5151
#define MYSENSORS_LIBRARY_VERSION_PATCH 1 //!< Patch version
52-
#define MYSENSORS_LIBRARY_VERSION_PRERELEASE "beta" //!< Pre-release suffix, i.e. alpha, beta, rc.1, etc
53-
#define MYSENSORS_LIBRARY_VERSION_PRERELEASE_NUMBER 0x01 //!< incremental counter, starting at 0x00. 0xFF for final release
52+
#define MYSENSORS_LIBRARY_VERSION_PRERELEASE "beta" //!< Pre-release suffix, i.e. alpha, beta, rc.1, etc
53+
#define MYSENSORS_LIBRARY_VERSION_PRERELEASE_NUMBER 0x02 //!< incremental counter, starting at 0x00. 0xFF for final release
5454

5555

5656
#if (MYSENSORS_LIBRARY_VERSION_PRERELEASE_NUMBER != 0xFF)

0 commit comments

Comments
 (0)