Tag Archives: MQTT code issues ESP8266

ESP8266 MQTT and the UART

I wonder… those of you who have used the excellent MQTT software (stand-alone – not the LUA version)… I need to do two things – one of them is giving me problems but is no doubt trivial – the other I’m hoping someone has already solved.

Ok, so I’m using the MQTT software and I’ve added my own drivers… and that’s fine.

There is a function call INFO which prints stuff to the serial – I want to optionally turn that off. Here’s the DEBUG.H file.

#ifndef USER_DEBUG_H_
#define USER_DEBUG_H_

#ifndef INFO
    #define INFO os_printf
#endif

#endif /* USER_DEBUG_H_ */

That’s simple enough – INFO function simply is the os_printf function. So I figured I’d put my own function in which I could control.

#ifndef USER_DEBUG_H_
#define USER_DEBUG_H_

#ifndef INFO
    #include <stdarg.h>
    void ICACHE_FLASH_ATTR petes_debug_print(char *fmt, ... ){
     // if (debug==0) return;
      va_list args;
      va_start (args, fmt );
      os_printf(fmt, args);
      va_end (args);
    }

    #define INFO petes_debug_print
#endif

#endif /* USER_DEBUG_H_ */

Looks simple enough but this will NOT compile – stating that the function is being redefined… ie (petes_debug_print) -  this occurs NO-where else – I have of course tried a different name just in case I’m living in an alternative reality – no matter what I do it says it’s being redefined – and yet the IFNDEF should be stopping that.

Anyone know what I’m doing wrong?

Secondly – in the MQTT code – only UART out is used…. uart IN is not – and what I’d like to do is have an Arduino send a suggested MQTT subscription… for the life of me I can’t get my head around how to simple check for incoming characters…’

Facebooktwittergoogle_pluspinterestlinkedin