Moved to debug macro for SLIP_DBG and fixed an error when SLIP_DBG was defined

Removed unnecessary stuff
Switched VS project to use sdk 1.4.0 sources for intellisense
pull/72/head
Benjamin Runnels 9 years ago
parent 8a93a5eebe
commit b7ae39ae8d
  1. 4
      esp-link.vcxproj
  2. 31
      esp-link/mqtt_client.c
  3. 24
      serial/slip.c

@ -129,8 +129,8 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<NMakeOutput />
<NMakePreprocessorDefinitions>__ets__;_STDINT_H;ICACHE_FLASH;__MINGW32__;__WIN32__</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>.\rest;.\esp-link;.\mqtt;.\cmd;.\serial;.\user;.\espfs;.\httpd;.\include;..\esp_iot_sdk_v1.3.0\include;..\xtensa-lx106-elf\xtensa-lx106-elf\include;c:\tools\mingw64\x86_64-w64-mingw32\include;c:\tools\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.3\include</NMakeIncludeSearchPath>
<NMakePreprocessorDefinitions>__ets__;_STDINT_H;ICACHE_FLASH;__MINGW32__;__WIN32__;MQTT</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>.\rest;.\esp-link;.\mqtt;.\cmd;.\serial;.\user;.\espfs;.\httpd;.\include;..\esp_iot_sdk_v1.4.0\include;..\xtensa-lx106-elf\xtensa-lx106-elf\include;c:\tools\mingw64\x86_64-w64-mingw32\include;c:\tools\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.3\include</NMakeIncludeSearchPath>
<ExecutablePath />
<ReferencePath />
<LibraryPath />

@ -12,11 +12,6 @@
MQTT_Client mqttClient; // main mqtt client used by esp-link
#ifdef BRUNNELS
char* statusTopicStr;
static char* onlineMsgStr;
#endif
static MqttCallback connected_cb;
static MqttCallback disconnected_cb;
static MqttCallback published_cb;
@ -27,9 +22,6 @@ mqttConnectedCb(uint32_t *args) {
DBG_MQTTCLIENT("MQTT Client: Connected\n");
//MQTT_Client* client = (MQTT_Client*)args;
//MQTT_Subscribe(client, "system/time", 0); // handy for testing
#ifdef BRUNNELS
MQTT_Publish(client, "announce/all", onlineMsgStr, 0, 0);
#endif
if (connected_cb)
connected_cb(args);
}
@ -93,29 +85,6 @@ mqtt_client_init()
flashConfig.mqtt_clientid, flashConfig.mqtt_username, flashConfig.mqtt_password,
flashConfig.mqtt_keepalive);
// removed client_id concat for now until a better solution is devised
// statusTopicStr = (char*)os_zalloc(strlen(flashConfig.mqtt_clientid) + strlen(flashConfig.mqtt_status_topic) + 2);
// os_strcpy(statusTopicStr, flashConfig.mqtt_clientid);
// os_strcat(statusTopicStr, "/");
#ifdef BRUNNELS
char* onlineMsg = " is online";
onlineMsgStr = (char*)os_zalloc(strlen(flashConfig.mqtt_clientid) + strlen(onlineMsg) + 1);
os_strcpy(onlineMsgStr, flashConfig.mqtt_clientid);
os_strcat(onlineMsgStr, onlineMsg);
char* offlineMsg = " is offline";
char* offlineMsgStr = (char*)os_zalloc(strlen(flashConfig.mqtt_clientid) + strlen(offlineMsg) + 1);
os_strcpy(offlineMsgStr, flashConfig.mqtt_clientid);
os_strcat(offlineMsgStr, offlineMsg);
char* lwt = "/lwt";
char *lwtMsgStr = (char*)os_zalloc(strlen(flashConfig.mqtt_clientid) + strlen(lwt) + 1);
os_strcpy(lwtMsgStr, flashConfig.mqtt_clientid);
os_strcat(lwtMsgStr, lwt);
MQTT_InitLWT(&mqttClient, lwtMsgStr, offlineMsg, 0, 0);
#endif
MQTT_OnConnected(&mqttClient, mqttConnectedCb);
MQTT_OnDisconnected(&mqttClient, mqttDisconnectedCb);
MQTT_OnPublished(&mqttClient, mqttPublishedCb);

@ -7,6 +7,12 @@
#include "console.h"
#include "cmd.h"
#ifdef SLIP_DBG
#define DBG(format, ...) os_printf(format, ## __VA_ARGS__)
#else
#define DBG(format, ...) do { } while(0)
#endif
uint8_t slip_disabled; // temporarily disable slip to allow flashing of attached MCU
extern void ICACHE_FLASH_ATTR console_process(char *buf, short len);
@ -48,15 +54,15 @@ slip_process() {
} else {
os_printf("SLIP: bad CRC, crc=%x rcv=%x\n", crc, rcv);
#ifdef SLIP_DBG
for (short i=0; i<slip_len; i++) {
if (slip_buf[i] >= ' ' && slip_buf[i] <= '~')
os_printf("%c", slip_buf[i]);
else
os_printf("\\%02X", slip_buf[i]);
if (slip_buf[i] >= ' ' && slip_buf[i] <= '~') {
DBG("%c", slip_buf[i]);
}
else {
DBG("\\%02X", slip_buf[i]);
}
}
os_printf("\n");
#endif
DBG("\n");
}
}
}
@ -86,9 +92,7 @@ slip_parse_char(char c) {
if (slip_len > 0) console_process(slip_buf, slip_len);
slip_reset();
slip_inpkt = true;
#ifdef SLIP_DBG
os_printf("SLIP: start\n");
#endif
DBG("SLIP: start\n");
return;
}
} else if (slip_escaped) {

Loading…
Cancel
Save