Skip to content

Commit

Permalink
Merge pull request #81 from iabdalkader/ninafw_bug_fixes
Browse files Browse the repository at this point in the history
Ninafw bug fixes
  • Loading branch information
facchinm authored May 17, 2022
2 parents 63823f9 + e8c3163 commit bdb8b39
Show file tree
Hide file tree
Showing 4 changed files with 497 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This firmware uses [Espressif's IDF](https://github.com/espressif/esp-idf)
1. Use `esptool` to flash the compiled firmware

## Notes
If updating **Arduino UNO WiFi Rev. 2** NINA firmware via [SerialNINAPassthrough](https://github.com/arduino-libraries/WiFiNINA/blob/master/examples/Tools/SerialNINAPassthrough/SerialNINAPassthrough.ino) sketch then the `esptool` invocation needs to be changed slightly:
If updating the NINA firmware for an **Arduino UNO WiFi Rev. 2** or **Arduino Nano RP2040** board via [SerialNINAPassthrough](https://github.com/arduino-libraries/WiFiNINA/blob/master/examples/Tools/SerialNINAPassthrough/SerialNINAPassthrough.ino) sketch, then the `esptool` invocation needs to be changed slightly:
```diff
- --baud 115200 --before default_reset
+ --baud 115200 --before no_reset
Expand Down
22 changes: 10 additions & 12 deletions arduino/libraries/WiFi/src/WiFiServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,48 @@
#include "WiFiServer.h"

WiFiServer::WiFiServer() :
WiFiServer(0)
{
}

WiFiServer::WiFiServer(uint16_t port) :
_port(port),
_port(0),
_socket(-1)
{
for (int i = 0; i < CONFIG_LWIP_MAX_SOCKETS; i++) {
_spawnedSockets[i] = -1;
}
}

void WiFiServer::begin()
uint8_t WiFiServer::begin(uint16_t port)
{
_socket = lwip_socket(AF_INET, SOCK_STREAM, 0);

if (_socket < 0) {
return;
return 0;
}

struct sockaddr_in addr;
memset(&addr, 0x00, sizeof(addr));

addr.sin_family = AF_INET;
addr.sin_addr.s_addr = (uint32_t)0;
addr.sin_port = htons(_port);
addr.sin_port = htons(port);

if (lwip_bind(_socket, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
lwip_close_r(_socket);
_socket = -1;
return;
return 0;
}

if (lwip_listen(_socket, 1) < 0) {
lwip_close_r(_socket);
_socket = -1;
return;
return 0;
}

int nonBlocking = 1;
lwip_ioctl_r(_socket, FIONBIO, &nonBlocking);

return;
// Set port.
_port = port;

return 1;
}

WiFiClient WiFiServer::available(uint8_t* status)
Expand Down
3 changes: 1 addition & 2 deletions arduino/libraries/WiFi/src/WiFiServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ class WiFiClient;
class WiFiServer /*: public Server*/ {
public:
WiFiServer();
WiFiServer(uint16_t);
WiFiClient available(uint8_t* status = NULL);
void begin();
uint8_t begin(uint16_t port);
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t *buf, size_t size);
uint8_t status();
Expand Down
Loading

0 comments on commit bdb8b39

Please sign in to comment.