-
Notifications
You must be signed in to change notification settings - Fork 135
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
[modem]: Add support for guessing mode #612
[modem]: Add support for guessing mode #612
Conversation
85abac4
to
6f4231b
Compare
return false; | ||
} | ||
mode = modem_mode::UNDEF; | ||
ESP_LOGI("DCE mode", "Detected mode: %d", static_cast<int>(guessed)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to log it in INFO mode? Could we move to DEBUG or VERBOSE?
// Check whether the response resembles the "golden" reply (for these 3 protocols) | ||
if (reply_pos >= sizeof(probe::ppp::lcp_echo_reply_head)) { | ||
// check for initial 2 bytes | ||
uint8_t *ptr = static_cast<uint8_t *>(memmem(reply, reply_pos, probe::ppp::lcp_echo_reply_head, 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build a string_view
from the received buffer and use provided algorithms might lead to simpler code here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any idea how to do it without reinterpret cast?
std::string_view reply_view(reinterpret_cast<const char*>(reply), reply_size);
// Create a string_view for the bytes to compare against
std::string_view head_view(reinterpret_cast<const char*>(ppp::lcp_echo_reply_head.data()), 2);
// Check if the reply starts with the first 2 bytes of lcp_echo_reply_head
return reply_view.starts_with(head_view);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is that I'm actually testing if the current protocol is binary or ascii, so I think the best option is to just use the old good memmem()...
6f4231b
to
de23a00
Compare
de23a00
to
52598e5
Compare
Supports only DATA and PPP mode
Add CMUX modes