Skip to content

Commit

Permalink
Add PJON transport layer (#1278)
Browse files Browse the repository at this point in the history
* Add PJON transport layer

* Update PJON 13.0

* PJON transport now non-blocking, fixed polling

Co-authored-by: Giovanni Blu Mitolo <[email protected]>
  • Loading branch information
tekka007 and gioblu authored Mar 20, 2021
1 parent dc562a2 commit 2e00bf6
Show file tree
Hide file tree
Showing 134 changed files with 16,414 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .ci/doxygen.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def call(config) {
Documentation/doxygen.sh"""
warnings canComputeNew: false, canResolveRelativePaths: false,
defaultEncoding: '',
excludePattern: '''.*/hal/architecture/Linux/drivers/.*,.*/hal/architecture/AVR/drivers/.*,.*/drivers/TinyGSM/.*''',
excludePattern: '''.*/hal/architecture/Linux/drivers/.*,.*/hal/transport/PJON/driver/.*,.*/hal/architecture/AVR/drivers/.*,.*/drivers/TinyGSM/.*''',
failedTotalAll: '', healthy: '', includePattern: '', messagesPattern: '',
parserConfigurations: [[parserName: 'Doxygen', pattern: config.repository_root+'doxygen.log']],
unHealthy: '', unstableTotalAll: '0'
Expand Down
1 change: 1 addition & 0 deletions .mystools/cppcheck/config/suppressions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
// 3rd party
*:hal/architecture/Linux/*
*:drivers/*
*:hal/transport/PJON/driver/*
54 changes: 53 additions & 1 deletion MyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,55 @@
* @{
*/

/**
* @defgroup PJONSettingGrpPub PJON
* @ingroup RadioSettingGrpPub
* @brief These options are specific to the PJON wired transport.
* @{
*/

/**
* @def MY_PJON
* @brief Define this to use the PJON wired transport for sensor network communication.
*/
//#define MY_PJON

/**
* @def MY_PJON_PIN
* @brief Define this to change pin for PJON communication
*/
#ifndef MY_PJON_PIN
#define MY_PJON_PIN (12u)
#endif

/**
* @def MY_DEBUG_VERBOSE_PJON
* @brief Define this for verbose debug prints related to the %PJON driver.
*/
//#define MY_DEBUG_VERBOSE_PJON

/**
* @def MY_PJON_MAX_RETRIES
* @brief Define this to change max send retry in PJON communication
*/
#ifndef MY_PJON_MAX_RETRIES
#define MY_PJON_MAX_RETRIES (5u)
#endif

#ifdef MY_PJON

#ifndef PJON_STRATEGY_ALL
#define PJON_STRATEGY_BITBANG
#endif

#define PJON_NOT_ASSIGNED (253u)
#define PJON_BROADCAST (255u)

#define SWBB_MAX_ATTEMPTS (50u)
#define PJON_INCLUDE_SWBB
#endif

/** @}*/ // End of PJONSettingGrpPub group

/**
* @defgroup RS485SettingGrpPub RS485
Expand Down Expand Up @@ -2226,7 +2275,7 @@
#endif

// Enable sensor network "feature" if one of the transport types was enabled
#if defined(MY_RADIO_RF24) || defined(MY_RADIO_NRF5_ESB) || defined(MY_RADIO_RFM69) || defined(MY_RADIO_RFM95) || defined(MY_RS485)
#if defined(MY_RADIO_RF24) || defined(MY_RADIO_NRF5_ESB) || defined(MY_RADIO_RFM69) || defined(MY_RADIO_RFM95) || defined(MY_RS485) || defined(MY_PJON)
#define MY_SENSOR_NETWORK
#endif

Expand Down Expand Up @@ -2391,6 +2440,9 @@
#define MY_RS485_DE_PIN
#define MY_RS485_DE_INVERSE
#define MY_RS485_HWSERIAL
// PJON
#define MY_PJON
#define MY_DEBUG_VERBOSE_PJON
// RF24
#define MY_RADIO_RF24
#define MY_RADIO_NRF24 //deprecated
Expand Down
16 changes: 14 additions & 2 deletions MySensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,13 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
#else
#define __RS485CNT 0 //!< __RS485CNT
#endif
#if defined(MY_PJON)
#define _PJONCNT 1 //!< _PJONCNT
#else
#define _PJONCNT 0 //!< _PJONCNT
#endif

#if (__RF24CNT + __NRF5ESBCNT + __RFM69CNT + __RFM95CNT + __RS485CNT > 1)
#if (__RF24CNT + __NRF5ESBCNT + __RFM69CNT + __RFM95CNT + __RS485CNT + _PJONCNT > 1)
#error Only one forward link driver can be activated
#endif
#endif //DOXYGEN
Expand All @@ -297,7 +302,7 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
#endif

// TRANSPORT INCLUDES
#if defined(MY_RADIO_RF24) || defined(MY_RADIO_NRF5_ESB) || defined(MY_RADIO_RFM69) || defined(MY_RADIO_RFM95) || defined(MY_RS485)
#if defined(MY_RADIO_RF24) || defined(MY_RADIO_NRF5_ESB) || defined(MY_RADIO_RFM69) || defined(MY_RADIO_RFM95) || defined(MY_RS485) || defined (MY_PJON)
#include "hal/transport/MyTransportHAL.h"
#include "core/MyTransport.h"

Expand Down Expand Up @@ -381,6 +386,13 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
#elif defined(MY_RADIO_RFM95)
#include "hal/transport/RFM95/driver/RFM95.cpp"
#include "hal/transport/RFM95/MyTransportRFM95.cpp"
#elif defined(MY_PJON)
#include "hal/transport/PJON/driver/PJON.h"
#include "hal/transport/PJON/driver/PJONSoftwareBitBang.h"
#if (PJON_BROADCAST == 0)
#error "You must change PJON_BROADCAST to BROADCAST_ADDRESS (255u) and PJON_NOT_ASSIGNED to other one."
#endif
#include "hal/transport/PJON/MyTransportPJON.cpp"
#endif

#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))
Expand Down
1 change: 1 addition & 0 deletions examples/AirQualitySensor/AirQualitySensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
1 change: 1 addition & 0 deletions examples/BatteryPoweredSensor/BatteryPoweredSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
1 change: 1 addition & 0 deletions examples/CO2Sensor/CO2Sensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
1 change: 1 addition & 0 deletions examples/DimmableLEDActuator/DimmableLEDActuator.ino
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
1 change: 1 addition & 0 deletions examples/DimmableLight/DimmableLight.ino
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
1 change: 1 addition & 0 deletions examples/DustSensor/DustSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
4 changes: 4 additions & 0 deletions examples/GatewaySerial/GatewaySerial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

// Set pin for PJON wired communication.
//#define MY_PJON_PIN 12

// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level.
Expand Down
1 change: 1 addition & 0 deletions examples/GatewayW5100/GatewayW5100.ino
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

// Enable gateway ethernet module type
#define MY_GATEWAY_W5100
Expand Down
1 change: 1 addition & 0 deletions examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#define MY_RADIO_RF24
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#define MY_GATEWAY_MQTT_CLIENT

Expand Down
1 change: 1 addition & 0 deletions examples/MockMySensors/MockMySensors.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#define MY_NODE_ID 254

Expand Down
1 change: 1 addition & 0 deletions examples/MotionSensor/MotionSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
1 change: 1 addition & 0 deletions examples/PHSensor/PHSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
1 change: 1 addition & 0 deletions examples/PassiveNode/PassiveNode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
1 change: 1 addition & 0 deletions examples/PingPongSensor/PingPongSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>
#include "MYSLog.h"
Expand Down
1 change: 1 addition & 0 deletions examples/RelayActuator/RelayActuator.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

// Enable repeater functionality for this node
#define MY_REPEATER_FEATURE
Expand Down
1 change: 1 addition & 0 deletions examples/RepeaterNode/RepeaterNode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

// Enabled repeater feature for this node
#define MY_REPEATER_FEATURE
Expand Down
1 change: 1 addition & 0 deletions examples/SecretKnockSensor/SecretKnockSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level.
Expand Down
1 change: 1 addition & 0 deletions examples/SoilMoistSensor/SoilMoistSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <math.h> // Conversion equation from resistance to %
#include <MySensors.h>
Expand Down
1 change: 1 addition & 0 deletions examples/UVSensor/UVSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
1 change: 1 addition & 0 deletions examples/VibrationSensor/VibrationSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>
#include <Wire.h>
Expand Down
1 change: 1 addition & 0 deletions examples/WaterMeterPulseSensor/WaterMeterPulseSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
//#define MY_PJON

#include <MySensors.h>

Expand Down
Loading

1 comment on commit 2e00bf6

@kofec
Copy link

@kofec kofec commented on 2e00bf6 Mar 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, why example for rs485 was not updated (#define MY_PJON) ? Does it means that it cannot be used with rs485 ?

Please sign in to comment.