Browse Source

Changed from hardware to feature

rfm69
AlbertWeterings 6 years ago
committed by GitHub
parent
commit
41286c545f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 12 deletions
  1. +12
    -12
      code/espurna/uart_mqtt

+ 12
- 12
code/espurna/uart_mqtt View File

@ -1,4 +1,4 @@
#ifdef UARTtoMQTT
#ifdef UART_MQTT_SUPPORT
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// GLOBALS TO THE MODULE // GLOBALS TO THE MODULE
@ -30,22 +30,22 @@ void _recvWithEndMarker() {
} }
} }
void _uartSendUARTtoMQTT() {
void _uartSendUART_MQTT() {
if (newData == true && MQTT_SUPPORT) { if (newData == true && MQTT_SUPPORT) {
DEBUG_MSG_P(PSTR("[UARTtoMQTT] Send data over MQTT: %s\n"), receivedChars);
DEBUG_MSG_P(PSTR("[UART_MQTT] Send data over MQTT: %s\n"), receivedChars);
mqttSend(MQTT_TOPIC_UARTIN, receivedChars); // publish: UART -> mqtt bus mqttSend(MQTT_TOPIC_UARTIN, receivedChars); // publish: UART -> mqtt bus
newData = false; newData = false;
} }
} }
void _uartSendMQTTtoUART(const char * message) {
DEBUG_MSG_P(PSTR("[UARTtoMQTT] Send data over UART: %s\n"), message);
void _uartSendMQTT_UART(const char * message) {
DEBUG_MSG_P(PSTR("[UART_MQTT] Send data over UART: %s\n"), message);
Serial.print(message); Serial.print(message);
Serial.println(); Serial.println();
} }
#if MQTT_SUPPORT #if MQTT_SUPPORT
void _UARTtoMQTTMqttCallback(unsigned int type, const char * topic, const char * payload) {
void _UART_MQTTMqttCallback(unsigned int type, const char * topic, const char * payload) {
if (type == MQTT_CONNECT_EVENT) { if (type == MQTT_CONNECT_EVENT) {
mqttSubscribe(MQTT_TOPIC_UARTOUT); mqttSubscribe(MQTT_TOPIC_UARTOUT);
} }
@ -57,7 +57,7 @@ void _UARTtoMQTTMqttCallback(unsigned int type, const char * topic, const char *
bool isUARTOut = t.equals(MQTT_TOPIC_UARTOUT); bool isUARTOut = t.equals(MQTT_TOPIC_UARTOUT);
if (isUARTOut) { if (isUARTOut) {
_uartSendMQTTtoUART(payload);
_uartSendMQTT_UART(payload);
} }
} }
} }
@ -67,20 +67,20 @@ void _UARTtoMQTTMqttCallback(unsigned int type, const char * topic, const char *
// SETUP & LOOP // SETUP & LOOP
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UARTtoMQTTSetup() {
void uart_mqttSetup() {
#if MQTT_SUPPORT #if MQTT_SUPPORT
mqttRegister(_UARTtoMQTTMqttCallback);
mqttRegister(_UART_MQTTMqttCallback);
#endif #endif
// Register oop // Register oop
espurnaRegisterLoop(UARTtoMQTTLoop);
espurnaRegisterLoop(UART_MQTTLoop);
} }
void UARTtoMQTTLoop() {
void UART_MQTTLoop() {
_recvWithEndMarker(); _recvWithEndMarker();
_uartSendUARTtoMQTT();
_uartSendUART_MQTT();
} }
#endif #endif

Loading…
Cancel
Save