-
Notifications
You must be signed in to change notification settings - Fork 516
added server mode to StandardFirmataEthernet #375
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
@@ -55,7 +56,9 @@ YunClient client; | |||
|
|||
// STEP 3 [REQUIRED] | |||
// Replace with the port that your server is listening on | |||
// for client mode comment out remote_port / for server mode comment out server_port | |||
#define remote_port 3030 |
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.
This could be simplified by renaming remote_port
to network_port
and then using that for both client and server applications.
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 update the comment to:
// Replace with the port that your client or server is listening on.
@@ -3,8 +3,9 @@ | |||
* | |||
* You must configure your particular hardware. Follow the steps below. | |||
* | |||
* Currently StandardFirmataEthernet is configured as a TCP client. An | |||
* option to configure as a server may be added in the future. | |||
* Currently StandardFirmataEthernet is configured as a TCP client. |
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.
Please change this text to:
"By default, StandardFirmataEthernet is configured as a TCP client. To configure as a TCP server, see STEP 2."
Then update STEP 2 to read as follows:
// STEP 2 [REQUIRED for all boards and shields]
// TCP Client configuration:
// To configure your board as a TCP client, set the IP address of the server you want to connect to.
// TCP Server configuration:
// To configure your board as a TCP server, comment out the following line and also ensure that
// remote_host is also commented out.
stream.maintain(Ethernet.localIP()); | ||
#else | ||
stream.maintain(); |
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 don't think you need to call stream.maintain() here since it is already called on each iteration of loop when firmata.available is called. However, you may need to copy the maintain(IPAddress local) method from EthernetClientStream to EthernetServerStream and then leave this block of code as it originally was. You should test this however to ensure there are not side effects.
I think the parameter client is useless at initialization of EthernetServerStream.h => removed it. |
|
||
#if !defined remote_ip && !defined remote_host | ||
#ifdef local_ip | ||
EthernetServerStream stream(client, local_ip, network_port); |
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.
Please remove the client
parameter here and on line 125. Then make sure StandardFirmataEthernet compiles when configured for TCP server.
Tested on Arduino Ethernet and Arduino Mega/ Ethernet shield |
I finally got around to thoroughly testing this today and it's working without issue. However, one addition would be helpful. Please add the following 3 lines at the end of the DEBUG_PRINT("IP Address: ");
IPAddress ip = Ethernet.localIP();
DEBUG_PRINTLN(ip); That will print the local IP address when debugging is enabled, which is helpful for the user to know what the board's IP address is when configured as a TCP server. After that, please squash all commits to a single commit. Then this PR will be ready to merge. Thanks for all the work so far! |
server mode implemented.
server mode implemented.
For server mode remote_ip, remote_host and remote_port should not be
defined.
Instead the server_port has to be defined.