You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The WiFiServer object only contains a constructor that accepts a uint16_t for the port number. It would be nice to allow the user to use an empty constructor and then define the port later.
Additionally, the begin() function's return value is void, meaning that the user has no way of knowing whether it succeeded or not, unless they use the other form of the begin() function which takes a uint8_t as a parameter, but users may not know what to pass in for that parameter, especially when all they want to do is get the result from the begin() function.
Creating an empty constructor would be dirt simple:
We can then provide 2 new forms of the begin() function. For the sake of this post, I will call this new function beginWithResult because it returns the result.
One form of the function takes a uint16_t port as a parameter, allowing the user to specify the port when they call begin() rather than when they construct the object. The other form of the function assumes a port has already been defined. Here are the two new functions:
I've already made these code changes in my own fork of the repository, and I would be happy to submit a pull request. I think these changes would really improve the usage of the WiFiServer class.
The text was updated successfully, but these errors were encountered:
The WiFiServer object only contains a constructor that accepts a uint16_t for the port number. It would be nice to allow the user to use an empty constructor and then define the port later.
Additionally, the begin() function's return value is void, meaning that the user has no way of knowing whether it succeeded or not, unless they use the other form of the begin() function which takes a uint8_t as a parameter, but users may not know what to pass in for that parameter, especially when all they want to do is get the result from the begin() function.
Creating an empty constructor would be dirt simple:
We can then provide 2 new forms of the begin() function. For the sake of this post, I will call this new function beginWithResult because it returns the result.
One form of the function takes a uint16_t port as a parameter, allowing the user to specify the port when they call begin() rather than when they construct the object. The other form of the function assumes a port has already been defined. Here are the two new functions:
I've already made these code changes in my own fork of the repository, and I would be happy to submit a pull request. I think these changes would really improve the usage of the WiFiServer class.
The text was updated successfully, but these errors were encountered: