user_dbg.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef __USER_DEBUG_H__
  2. #define __USER_DEBUG_H__
  3. #include "ets_sys.h"
  4. #include "osapi.h"
  5. #include "user_interface.h"
  6. #include "espconn.h"
  7. enum {
  8. EPIT_DEBUGMSG_LEVEL_ERROR = 0,
  9. EPIT_DEBUGMSG_LEVEL_WARNING,
  10. EPIT_DEBUGMSG_LEVEL_INFO,
  11. EPIT_DEBUGMSG_LEVEL_DEBUG
  12. };
  13. extern uint8 EpitDebugLevel;
  14. #define espl_print_dbgmsg(lv, ...) do{ \
  15. if(lv <= EpitDebugLevel) \
  16. { \
  17. os_printf(__VA_ARGS__); \
  18. } \
  19. }while(0)
  20. #define EPIT_DBG(...) espl_print_dbgmsg(EPIT_DEBUGMSG_LEVEL_DEBUG, __VA_ARGS__)
  21. #define EPIT_INFO(...) espl_print_dbgmsg(EPIT_DEBUGMSG_LEVEL_INFO, __VA_ARGS__)
  22. #define EPIT_WARN(...) espl_print_dbgmsg(EPIT_DEBUGMSG_LEVEL_WARNING, __VA_ARGS__)
  23. #define EPIT_ERR(...) espl_print_dbgmsg(EPIT_DEBUGMSG_LEVEL_ERROR, __VA_ARGS__)
  24. #define USER_DEBUG_PRINTBUF
  25. #ifdef USER_DEBUG_PRINTBUF
  26. #if defined(DEFINE_USER_PRINT_BUF) /* added macro DEFINE_USER_PRINT_BUF */
  27. #define user_printbuf(data, len, str) do { \
  28. uint8 *pDBGBuf = (uint8 *)(data); \
  29. uint8 DBGIndex=0; \
  30. int DBGLength=((len)<220)?(len):220; \
  31. os_printf("%s len %d\n", (str), (len)); \
  32. for(DBGIndex=0; DBGIndex< (DBGLength); DBGIndex++) \
  33. os_printf("%02x ", *(pDBGBuf + DBGIndex)); \
  34. os_printf("\n"); \
  35. } while (0)
  36. #endif /* DEFINE_USER_PRINT_BUF */
  37. static __inline void user_printbuf(uint8 *data, int len, const char *str)
  38. {
  39. uint8 *pDBGBuf = (uint8 *)(data);
  40. uint8 DBGIndex=0;
  41. int DBGLength=((len)<220)?(len):220;
  42. os_printf("%s len %d\n", (str), (len));
  43. for(DBGIndex=0; DBGIndex< (DBGLength); DBGIndex++)
  44. os_printf("%02x ", *(pDBGBuf + DBGIndex));
  45. os_printf("\n");
  46. }
  47. #else
  48. #define user_printbuf
  49. #endif
  50. void printEspconnItem(struct espconn *pespconn);
  51. #endif