ESP8266-based WiFi serial modem emulator ROM
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move all debugging behind *_TRACE ifdefs

+61 -10
+6
SocksClient.cpp
··· 347 347 348 348 if (tls()) { 349 349 client_out_tls.setInsecure(); 350 + client_out_tls.setBufferSizes(1024, 1024); 351 + #ifdef SOCKS_TRACE 352 + syslog.logf(LOG_DEBUG, "[%d] making TLS connection to %s:%d " 353 + "with %d free mem", slot, ipaddr_ntoa(&remote_ip), 354 + remote_port, ESP.getFreeHeap()); 355 + #endif 350 356 ret = client_out_tls.connect(remote_ip, remote_port); 351 357 } else 352 358 ret = client_out.connect(remote_ip, remote_port);
-2
SocksClient.h
··· 20 20 #include <WiFiClient.h> 21 21 #include <WiFiClientSecure.h> 22 22 23 - // #define SOCKS_TRACE 24 - 25 23 class SocksClient : public WiFiClient { 26 24 public: 27 25 virtual ~SocksClient();
+29 -7
ppp.cpp
··· 51 51 ip4_addr_set_u32(&d_addr, WiFi.dnsIP()); 52 52 ppp_set_ipcp_dnsaddr(_ppp, 0, &d_addr); 53 53 54 - outputf("CONNECT %d %s:PPP\r\n", settings->baud, ipaddr_ntoa(&s_addr)); 54 + outputf("CONNECT %d %s:PPP\r\n", Serial.baudRate(), 55 + ipaddr_ntoa(&s_addr)); 55 56 serial_dcd(true); 56 57 57 58 ppp_listen(_ppp); 58 59 60 + #ifdef PPP_TRACE 59 61 syslog.log(LOG_INFO, "starting PPP negotiation"); 62 + #endif 60 63 61 64 return true; 62 65 } ··· 65 68 ppp_output_cb(__attribute__((unused)) ppp_pcb *pcb, u8_t *data, u32_t len, 66 69 __attribute__((unused)) void *ctx) 67 70 { 68 - u32_t i; 71 + #ifdef PPP_TRACE 72 + long now = millis(); 73 + #endif 69 74 70 - for (i = 0; i < len; i++) 71 - serial_write(data[i]); 75 + serial_write(data, len); 76 + 77 + #ifdef PPP_TRACE 78 + long elap = millis(); 79 + syslog.logf(LOG_DEBUG, "forwarded %ld PPP bytes in %ldms", len, 80 + elap - now); 81 + #endif 72 82 73 83 return len; 74 84 } ··· 78 88 { 79 89 unsigned long now = millis(); 80 90 81 - ppp_close(_ppp, 0); 82 - 83 91 if (wait) { 92 + ppp_close(_ppp, 0); 93 + 84 94 while (state == STATE_PPP && now - millis() < 1000) { 85 95 pppos_input(_ppp, ppp_buf, 0); 86 96 yield(); 87 97 } 88 98 } 99 + 100 + if (state == STATE_PPP) 101 + ppp_close(_ppp, 1); 89 102 } 90 103 91 104 void ··· 116 129 117 130 switch (err) { 118 131 case PPPERR_NONE: 119 - syslog.log(LOG_DEBUG, "PPP session established"); 120 132 ppp_setup_nat(nif); 133 + #ifdef PPP_TRACE 134 + syslog.logf(LOG_DEBUG, "PPP session established, free mem %d", 135 + ESP.getFreeHeap()); 136 + #endif 121 137 break; 122 138 case PPPERR_PARAM: 123 139 /* Invalid parameter. */ ··· 137 153 break; 138 154 case PPPERR_USER: 139 155 /* User interrupt. */ 156 + #ifdef PPP_TRACE 140 157 syslog.logf(LOG_ERR, "%s: PPPERR_USER", __func__); 158 + #endif 141 159 break; 142 160 case PPPERR_CONNECT: 143 161 /* Connection lost. */ ··· 176 194 return; 177 195 178 196 if (err == PPPERR_USER) { 197 + #ifdef PPP_TRACE 179 198 syslog.log(LOG_DEBUG, "ending PPP session, " 180 199 "returning to AT mode"); 200 + #endif 181 201 ppp_free(_ppp); 182 202 _ppp = NULL; 183 203 state = STATE_AT; ··· 186 206 return; 187 207 } 188 208 209 + #ifdef PPP_TRACE 189 210 syslog.log(LOG_DEBUG, "closing PPP session"); 211 + #endif 190 212 ppp_close(_ppp, 0); 191 213 } 192 214
+2
socks.cpp
··· 51 51 } 52 52 } 53 53 54 + #ifdef SOCKS_TRACE 54 55 syslog.logf(LOG_DEBUG, "new SOCKS client, slot %d", slot); 56 + #endif 55 57 56 58 if (slot > -1) { 57 59 WiFiClient client = socks_server.available();
+4
util.cpp
··· 176 176 { 177 177 size_t len = strlen(str); 178 178 179 + #ifdef OUTPUT_TRACE 180 + syslog.logf(LOG_DEBUG, "output: \"%s\"", str); 181 + #endif 182 + 179 183 for (size_t i = 0; i < len; i++) 180 184 output(str[i]); 181 185
+6
wifippp.h
··· 26 26 27 27 #define WIFIPPP_VERSION "0.1" 28 28 29 + /* enable various debugging */ 30 + // #define AT_TRACE 31 + // #define OUTPUT_TRACE 32 + // #define PPP_TRACE 33 + // #define SOCKS_TRACE 34 + 29 35 #define EEPROM_SIZE 512 30 36 struct __attribute((__packed__)) eeprom_data { 31 37 char magic[3];
+14 -1
wifippp.ino
··· 50 50 if (serial_dtr()) { 51 51 if (!last_dtr) { 52 52 /* new connection, re-autobaud */ 53 + #ifdef AT_TRACE 53 54 syslog.logf(LOG_DEBUG, "new connection with DTR, " 54 55 "doing auto-baud"); 56 + #endif 55 57 serial_autobaud(); 56 58 now = millis(); 57 59 last_autobaud = now; ··· 61 63 /* had DTR, dropped it for 1.75 secs, hangup */ 62 64 hangup = true; 63 65 last_dtr = 0; 64 - syslog.log(LOG_INFO, "dropped DTR, hanging up"); 66 + #ifdef AT_TRACE 67 + syslog.log(LOG_DEBUG, "dropped DTR, hanging up"); 68 + #endif 65 69 } 66 70 67 71 switch (state) { ··· 222 226 return; 223 227 } 224 228 229 + #ifdef AT_TRACE 230 + syslog.logf(LOG_DEBUG, "%s: parsing \"%s\"", __func__, cmd); 231 + #endif 232 + 225 233 for (size_t i = 0; i < len; i++) 226 234 lcmd[i] = tolower(cmd[i]); 227 235 lcmd[len] = '\0'; ··· 261 269 cmd++; 262 270 lcmd++; 263 271 } 272 + 273 + #ifdef AT_TRACE 274 + syslog.logf(LOG_DEBUG, "%s: parsing AT %c[%d] args \"%s\"", __func__, 275 + cmd_char, cmd_num, lcmd); 276 + #endif 264 277 265 278 switch (cmd_char) { 266 279 case 'd': {