Browse Source

Support for software serial on UART_MQTT module

rfm69
Xose Pérez 6 years ago
parent
commit
904cb26b5f
2 changed files with 14 additions and 3 deletions
  1. +4
    -1
      code/espurna/config/general.h
  2. +10
    -2
      code/espurna/uartmqtt.ino

+ 4
- 1
code/espurna/config/general.h View File

@ -497,7 +497,10 @@ PROGMEM const char* const custom_reset_string[] = {
#define UART_MQTT_SUPPORT 0 // No support by default
#endif
#define UART_MQTT_PORT Serial // Serial port
#define UART_MQTT_USE_SOFT 0 // Use SoftwareSerial
#define UART_MQTT_HW_PORT Serial // Hardware serial port (if UART_MQTT_USE_SOFT == 0)
#define UART_MQTT_RX_PIN 4 // RX PIN (if UART_MQTT_USE_SOFT == 1)
#define UART_MQTT_TX_PIN 5 // TX PIN (if UART_MQTT_USE_SOFT == 1)
#define UART_MQTT_BAUDRATE 115200 // Serial speed
#define UART_MQTT_BUFFER_SIZE 100 // UART buffer size


+ 10
- 2
code/espurna/uartmqtt.ino View File

@ -12,6 +12,14 @@ Adapted by Xose Pérez <xose dot perez at gmail dot com>
char _uartmqttBuffer[UART_MQTT_BUFFER_SIZE];
bool _uartmqttNewData = false;
#if UART_MQTT_USE_SOFT
#include <SoftwareSerial.h>
SoftwareSerial _uart_mqtt_serial(UART_MQTT_RX_PIN, UART_MQTT_TX_PIN, false, UART_MQTT_BUFFER_SIZE);
#define UART_MQTT_PORT _uart_mqtt_serial
#else
#define UART_MQTT_PORT UART_MQTT_HW_PORT
#endif
// -----------------------------------------------------------------------------
// Private
// -----------------------------------------------------------------------------
@ -75,8 +83,8 @@ void _uartmqttMQTTCallback(unsigned int type, const char * topic, const char * p
// -----------------------------------------------------------------------------
void _uartmqttLoop() {
_uartmqttReceiveUART();
_uartmqttSendMQTT();
_uartmqttReceiveUART();
_uartmqttSendMQTT();
}
void uartmqttSetup() {


Loading…
Cancel
Save