Skip to content

Commit

Permalink
Moved to debug macro for SLIP_DBG and fixed an error when SLIP_DBG wa…
Browse files Browse the repository at this point in the history
…s defined

Removed unnecessary stuff
Switched VS project to use sdk 1.4.0 sources for intellisense
  • Loading branch information
brunnels committed Nov 23, 2015
1 parent 8a93a5e commit b7ae39a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 43 deletions.
4 changes: 2 additions & 2 deletions esp-link.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 />
Expand Down
31 changes: 0 additions & 31 deletions esp-link/mqtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
24 changes: 14 additions & 10 deletions serial/slip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
}
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b7ae39a

Please sign in to comment.