Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed extra TELNET_SERVER_VERBOSE_LOGGING define #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions components/telnet_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# ToDo: Max number of clients
CONF_CLIENT_COUNT = "client_count"
CONF_CLIENT_IPS = "client_ips"
CONF_VERBOSE = "verbose"
CONF_DISCONNECT_DELAY = "disconnect_delay"

DEPENDENCIES = ["network"]
Expand All @@ -27,7 +26,6 @@
accuracy_decimals=0,
),
cv.Optional(CONF_CLIENT_IPS): text_sensor.text_sensor_schema(),
cv.Optional(CONF_VERBOSE, default=False): cv.boolean,
cv.Optional(
CONF_DISCONNECT_DELAY, default="2500ms"
): cv.positive_time_period_milliseconds,
Expand All @@ -48,6 +46,3 @@ async def to_code(config):
cg.add(var.set_client_ip_text_sensor(sens))

cg.add(var.set_disconnect_delay(config[CONF_DISCONNECT_DELAY].total_milliseconds))

if config.get(CONF_VERBOSE):
cg.add_define("TELNET_SERVER_VERBOSE_LOGGING")
11 changes: 1 addition & 10 deletions components/telnet_server/telnet_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,14 @@ void TelnetServer::readSerial() {
uint16_t lineStartIdx = char_idx;
int len = Serial.readBytesUntil('\n', &buffer[char_idx], (MAXLINELENGTH - char_idx));

// Add terminator for Verbose logging:
buffer[char_idx + len] = '\0';
#ifdef TELNET_SERVER_VERBOSE_LOGGING
ESP_LOGV(TAG, " %s", &buffer[lineStartIdx]);
#endif

// Add the newline for TelNet
char_idx += len;
buffer[char_idx] = '\n';
buffer[char_idx + 1] = '\0';
char_idx++;
len++;

// push UART data to all connected telnet clients
ESP_LOGV(TAG, "Pushing to telnet clients: %s", &buffer[lineStartIdx]);
for (auto const &client : this->clients_) {
client->tcp_client->write(&buffer[lineStartIdx], len);
}
Expand All @@ -97,9 +91,6 @@ void TelnetServer::readSerial() {
// Dump buffer contents
char_idx = MIN(char_idx, MAXLINELENGTH - 1);
buffer[char_idx] = '\0';
#ifdef TELNET_SERVER_VERBOSE_LOGGING
ESP_LOGV(TAG, "\n%s", buffer);
#endif
// Clear buffer
memset(buffer, 0, sizeof(buffer));
char_idx = 0;
Expand Down