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

Long commands in telnet #477

Closed
mcspr opened this issue Jan 27, 2018 · 6 comments
Closed

Long commands in telnet #477

mcspr opened this issue Jan 27, 2018 · 6 comments
Assignees
Labels
enhancement New feature or request telnet
Milestone

Comments

@mcspr
Copy link
Collaborator

mcspr commented Jan 27, 2018

I was having problem setting long WiFi and MQTT passwords using telnet module. Serial connection works fine typing same things.
Turns out, it is somehow dependant on length and stops working around 32. I inserted small debug message inside telnet/onData to display value of data and len:

client->onData([i](void *s, AsyncClient *c, void *data, size_t len) {
    DEBUG_MSG_P(PSTR("[TELNET] Data len: %u\n"), len);
    DEBUG_MSG_P(PSTR("[TELNET] Data msg: %s\n"), (char *) data);
    _telnetData(i, data, len);
}, 0);

default

I am a bit fuzzy where exactly this breaks.

@xoseperez
Copy link
Owner

The limit is 32 and is defined by the STREAM_INJECTOR_BUFFER_SIZE constant in 'code/espurna/libs/StreamInjector.h'. Basically, it defines a ring buffer so when your string is longer than 32 it overwrites the begining of the command and the settings interpreter complains.

@mcspr
Copy link
Collaborator Author

mcspr commented Jan 27, 2018

Oops, I've missed the wrapper.

Any reason it is 32 and not 128 as EmbedisWrap buffer?

EmbedisWrap(Stream& stream, size_t buflen = 128, size_t argvlen = 8): Embedis(stream, buflen, argvlen) {}

Serial at least shows errors:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-ERROR unknown command
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-ERROR buffer overflow

@xoseperez
Copy link
Owner

No reason except for memory usage. The EmbedisWrap value is the default value for Embedis too. I don't remember but I guess I just copied the signature. Do you have any good reason to have such long commands?

@mcspr
Copy link
Collaborator Author

mcspr commented Jan 27, 2018

For me this breaks relatively long set XXX commands:
set pass0 ... with psk length 27 chars. (I guess this may be uncommon preference :)
set mqttGroup0 hallway/group/lights is 37 chars. This was set earlier using serial, but cannot be done again using telnet.

@xoseperez
Copy link
Owner

Good points indeed. I'm changing it to 128.

@xoseperez
Copy link
Owner

Pushed fix to dev branch. Will be released soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request telnet
Projects
None yet
Development

No branches or pull requests

2 participants