-
Notifications
You must be signed in to change notification settings - Fork 3k
ONME-3433 ESP8266 driver support for UDP get - modified ESP8266 drive… #12320
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
Conversation
Looks OK. |
9cb9866
to
9692cfe
Compare
Pull request has been modified.
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.
Functionally this looks good to me.
I just have a few small improvement suggestions.
int id; | ||
nsapi_protocol_t proto; | ||
bool connected; | ||
bool binded; |
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.
Should it rather be "bound"? See here for example.
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.
Done
@@ -167,6 +177,14 @@ class ESP8266 { | |||
*/ | |||
bool disconnect(void); | |||
|
|||
/** | |||
* Enable or disconnect Remote IP and Port with +IPD |
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.
I guess this only enabled or disatble remote IP and port printing ? We can still connect to remote IPs if we set this to false, but they address and port will not be printed?
I also think that the name of this function is misleading. Could we make it ip_info_print
or something similar?
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.
Done
@@ -236,9 +254,10 @@ class ESP8266 { | |||
* @param addr the IP address of the destination | |||
* @param port the port on the destination | |||
* @param local_port UDP socket's local port, zero means any | |||
* @param udp_mode UDP socket's mode, zero means can't change remote, 1 can change ones, 2 can change |
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.
"ones" -> "once"
"2 can change" -> "2 can change multiple times"
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.
Done
if (!_parser.scanf("%d:", &amount)) { | ||
return; | ||
} | ||
} |
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.
Seems that _parser.scanf("%d,", &amount)
is done whether cip_info
is 1
or 0
, so let's just do it before the check?
What comes next could be merged so it takes less space and matches the style of how we normally do it in this file. So something like this:
} else {
if (!_parser.scanf("%d,", &amount)) {
return;
}
if (cip_info == 1) {
if (!(_parser.scanf("%15[^,],", _ip_buffer)
&& _parser.scanf("%d:", &port)) {
return;
}
}
It takes less space, is equally readable and matches the way we normally do this in this file.
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.
Unfortunately you're wrong.
Delimiter for "amount" is different in version with showing ip, port against to version without showing ip, port. In first case it is "," in second case is ":"
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.
True, I missed that.
so let's just merge the scanfs together:
if (!(_parser.scanf("%d,", &amount)
&& _parser.scanf("%15[^,],", _ip_buffer)
&& _parser.scanf("%d:", &port)) {
return;
}
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.
Done
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 current structure if (!sth && !sthelse && !sthelse2)
will return if ALL conditions fail, so it will have to check all of them, which makes no sense if the first one failed.
I think it is better to do if (!(sth && sthelse && sthelse2))
, because then if one condition fails (for example the %d,
match fails), the other conditions will not be checked (short-circuit evaluation).
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.
Done. Yes you're right. I've broken logic operation.
af07b42
to
243f412
Compare
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
@@ -572,6 +588,8 @@ nsapi_error_t ESP8266::open_tcp(int id, const char *addr, int port, int keepaliv | |||
static const char *type = "TCP"; | |||
bool done = false; | |||
|
|||
ip_info_print(0); |
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.
Isn't this changing a global modem setting?
Doesn't this mean opening a TCP socket will turn it off, breaking UDP?
Isn't it easier to just leave the setting permanently on?
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.
I think a bit about that and you are right. We cannot have difrent ESP main configuration for difference socket. Fix added.
2513863
to
19b41d9
Compare
c1f5e90
to
715a28c
Compare
…r to support UDP connection in server mode (get)
715a28c
to
46718d0
Compare
CI started |
Test run: FAILEDSummary: 1 of 11 test jobs failed Failed test jobs:
|
Failures looks not related to my changes. Failed: @0xc0170 Please rerun CI job. |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
…r to support UDP connection in server mode (get).
Summary of changes
Now we can use boards with ESP8266 in UDP server mode by binding port for listening.
No connecting needed in this mode.
example of useage:
#include "mbed.h"
#include "UDPSocket.h"
int main() {
static const int BUFF_SIZE = 1500;
char buffer[BUFF_SIZE] = {0};
int ret = 0;
SocketAddress udp_addr;
UDPSocket sock;
}
Impact of changes
Migration actions required
Documentation
Not needed.
Pull request type
Test results
Reviewers