-
Notifications
You must be signed in to change notification settings - Fork 129
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
Add copy assignment operator #16
Add copy assignment operator #16
Conversation
c7da784
to
a743538
Compare
a743538
to
18413f3
Compare
I have rebased these changes on top of the newly-updated master branch, this is ready to merge. |
@turkycat thanks for submitting! A few notes:
|
Things are a little better, when I add a check to void WiFiClient::setMembersAndWiFiCache(const WiFiClient& other)
{
_socket = other._socket;
_flag = other._flag;
_head = other._head;
_tail = other._tail;
for (int sock = 0; sock < TCP_SOCK_MAX; sock++) {
if (WiFi._client[sock] == this)
WiFi._client[sock] = 0;
}
if (_socket > -1) {
WiFi._client[_socket] = this;
// Add socket buffer handler:
socketBufferRegister(_socket, &_flag, &_head, &_tail, (uint8 *)_buffer);
// Enable receive buffer:
recv(_socket, _buffer, SOCKET_BUFFER_MTU, 0);
}
m2m_wifi_handle_events(NULL);
} |
I forgot to mention this before, without the I've added a void WiFiClient::setMembersAndWiFiCache(const WiFiClient& other)
{
_socket = other._socket;
_flag = other._flag;
_head = other._head;
_tail = other._tail;
memcpy(_buffer, other._buffer, sizeof(_buffer));
for (int sock = 0; sock < TCP_SOCK_MAX; sock++) {
if (WiFi._client[sock] == this)
WiFi._client[sock] = 0;
}
if (_socket > -1) {
WiFi._client[_socket] = this;
// Add socket buffer handler:
socketBufferRegister(_socket, &_flag, &_head, &_tail, (uint8 *)_buffer);
// Enable receive buffer:
recv(_socket, _buffer, SOCKET_BUFFER_MTU, 0);
}
m2m_wifi_handle_events(NULL);
} (It's a bigger change, but maybe it's worth considering keeping the socket buffer outside of |
@turkycat I've pushed a branch based on this pull request with the changes discussed above: https://github.com/sandeepmistry/WiFi101/tree/copy-assignment-operator |
One more changed pushed to my branch, I've renamed |
Ahh, yes it definitely should have been private. I like the name change as well. I'll try out the changes with the tests I've been running as well as your sample sketch above and will report back |
I was able to take your changes and run both your sketch above as well as my full Firmata implementation that uses WiFi101 within a Stream wrapper class... all with no issues |
Great thanks for trying the changes out! I've submitted #20 which includes the changes included in this PR. |
This PR resolves issue #15
NOTE: This pull request will show "Able to merge", as my commit is added on top of the current master branch. However, this will cause one small conflict with #14I suggest pulling #14 and #13 (which I have tested), and allow me to make the necessary changes to my existing commit before pulling this request!