Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 3f656f2

Browse files
authored
v1.8.14-7 to remove analogRead() from example
### Releases v1.8.14-7 1. Modify [WiFiWebServer](https://github.com/khoih-prog/WiFiNINA_Generic/tree/master/examples/WiFiWebServer) example to avoid `analogRead()` crash in `arduino-pico` core. Check [WiFi.localIP() hangs in Nano RP2040 Connect with Arduino-Pico core (EarlePhilhower) #24](#24) 2. Use `allman astyle` and add `utils` 3. Update `Packages' Patches`
1 parent 1a3896e commit 3f656f2

34 files changed

+1356
-1158
lines changed

CONTRIBUTING.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1515
Please ensure to specify the following:
1616

1717
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18-
* Core Version (e.g. Arduino SAMD core v1.8.13, Adafruit SAMD core v1.7.10, Arduino-mbed RP2040 v3.1.1)
18+
* Core Version (e.g. Arduino SAMD core v1.8.13, Adafruit SAMD core v1.7.11, Arduino-mbed RP2040 v3.4.1)
1919
* Board type (e.g. NANO_RP2040_CONNECT, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc.)
2020
* Contextual information (e.g. what you were trying to achieve)
2121
* Simplest possible steps to reproduce
@@ -28,29 +28,50 @@ Please ensure to specify the following:
2828

2929
```
3030
Arduino IDE version: 1.8.19
31-
Arduino-mbed RP2040 v3.1.1
31+
Arduino-mbed RP2040 v3.4.1
3232
NANO_RP2040_CONNECT Module
3333
OS: Ubuntu 20.04 LTS
34-
Linux xy-Inspiron-3593 5.15.0-41-generic #44~20.04.1-Ubuntu SMP Fri Jun 24 13:27:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
34+
Linux xy-Inspiron-3593 5.15.0-52-generic #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3535
3636
Context:
37-
I encountered an endless loop while trying to connect to Local WiFi.
38-
37+
I encountered a crash while using this library
3938
Steps to reproduce:
4039
1. ...
4140
2. ...
4241
3. ...
4342
4. ...
4443
```
4544

45+
### Additional context
46+
47+
Add any other context about the problem here.
48+
49+
---
4650

4751
### Sending Feature Requests
4852

4953
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
5054

5155
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/WiFiNINA_Generic/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
5256

57+
---
58+
5359
### Sending Pull Requests
5460

5561
Pull Requests with changes and fixes are also welcome!
5662

63+
Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)
64+
65+
1. Change directory to the library GitHub
66+
67+
```
68+
xy@xy-Inspiron-3593:~$ cd Arduino/xy/WiFiNINA_Generic_GitHub/
69+
xy@xy-Inspiron-3593:~/Arduino/xy/WiFiNINA_Generic_GitHub$
70+
```
71+
72+
2. Issue astyle command
73+
74+
```
75+
xy@xy-Inspiron-3593:~/Arduino/xy/WiFiNINA_Generic_GitHub$ bash utils/restyle.sh
76+
```
77+

README.md

Lines changed: 47 additions & 37 deletions
Large diffs are not rendered by default.

changelog.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
77
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/WiFiNINA_Generic.svg)](http://github.com/khoih-prog/WiFiNINA_Generic/issues)
88

9+
10+
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
11+
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
12+
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
13+
<a href="https://profile-counter.glitch.me/khoih-prog-WiFiNINA_Generic/count.svg" title="WiFiNINA_Generic Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-WiFiNINA_Generic/count.svg" style="height: 30px;width: 200px;"></a>
14+
915
---
1016
---
1117

1218
## Table of Contents
1319

1420
* [Changelog](#changelog)
21+
* [Releases v1.8.14-7](#releases-v1814-7)
1522
* [Releases v1.8.14-6](#releases-v1814-6)
1623
* [Releases v1.8.14-5](#releases-v1814-5)
1724
* [Releases v1.8.14-4](#releases-v1814-4)
@@ -42,6 +49,12 @@
4249

4350
## Changelog
4451

52+
### Releases v1.8.14-7
53+
54+
1. Modify [WiFiWebServer](https://github.com/khoih-prog/WiFiNINA_Generic/tree/master/examples/WiFiWebServer) example to avoid `analogRead()` crash in `arduino-pico` core. Check [WiFi.localIP() hangs in Nano RP2040 Connect with Arduino-Pico core (EarlePhilhower) #24](https://github.com/khoih-prog/WiFiNINA_Generic/discussions/24)
55+
2. Use `allman astyle` and add `utils`
56+
3. Update `Packages' Patches`
57+
4558
### Releases v1.8.14-6
4659

4760
1. Add support to `Teensy 4.x` using `Adafruit Airlift Featherwing Co-Processor`

library.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "WiFiNINA_Generic",
3-
"version": "1.8.14-6",
3+
"version": "1.8.14-7",
44
"keywords": "wifi, wi-fi, WiFiNINA, NINA-B302-ublox, W101, W102, shield, Teensy, SAM DUE, SAMD, STM32, nRF52, rpi-pico, rp2040, Credentials, Manager, nano-rp2040-connect, raspberry-pi-pico, mega, 32u4",
55
"description": "Enables network connection (local and Internet) and WiFiStorage for SAM DUE, SAMD21, SAMD51, Teensy, AVR (328P, 32u4, 16u4, etc.), Mega, STM32F/L/H/G/WB/MP1, nRF52, NINA_B302_ublox, NINA_B112_ublox, RP2040-based boards, etc. in addition to Arduino MKR WiFi 1010, Arduino MKR VIDOR 4000, Arduino UNO WiFi Rev.2, Nano 33 IoT, Nano RP2040 Connect",
66
"authors": [
@@ -34,12 +34,12 @@
3434
{
3535
"owner": "khoih-prog",
3636
"name": "WiFiMulti_Generic",
37-
"version": ">=1.1.1",
37+
"version": ">=1.2.2",
3838
"platforms": ["*"]
3939
}
4040
],
4141
"frameworks": "*",
4242
"platforms": "*",
4343
"examples": "examples/*/*/*.ino",
44-
"headers": "WiFiNINA_Generic.h"
44+
"headers": ["WiFiNINA_Generic.h"]
4545
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=WiFiNINA_Generic
2-
version=1.8.14-6
2+
version=1.8.14-7
33
author=Arduino, Khoi Hoang <[email protected]>
44
maintainer=Khoi Hoang <[email protected]>
55
sentence=Enables network connection (local and Internet) and WiFiStorage for SAM DUE, SAMD21, SAMD51, Teensy, AVR (328P, 32u4, 16u4, etc.), Mega, STM32F/L/H/G/WB/MP1, nRF52, NINA_B302_ublox, NINA_B112_ublox, RP2040-based boards, etc. in addition to Arduino MKR WiFi 1010, Arduino MKR VIDOR 4000, Arduino UNO WiFi Rev.2, Nano 33 IoT, Nano RP2040 Connect

src/WiFiClient_Generic.cpp

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA
55
to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc.
6-
6+
77
Built by Khoi Hoang https://github.com/khoih-prog/WiFiNINA_Generic
88
Licensed under MIT license
99
@@ -23,8 +23,8 @@
2323
You should have received a copy of the GNU Lesser General Public
2424
License along with this library; if not, write to the Free Software
2525
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26-
27-
Version: 1.8.14-6
26+
27+
Version: 1.8.14-7
2828
2929
Version Modified By Date Comments
3030
------- ----------- ---------- -----------
@@ -38,16 +38,17 @@
3838
1.8.14-4 K Hoang 01/05/2022 Fix bugs by using some PRs from original WiFiNINA. Add WiFiMulti-related examples
3939
1.8.14-5 K Hoang 23/05/2022 Fix bug causing data lost when sending large files
4040
1.8.14-6 K Hoang 17/08/2022 Add support to Teensy 4.x using WiFiNINA AirLift. Fix minor bug
41+
1.8.14-7 K Hoang 11/11/2022 Modify WiFiWebServer example to avoid crash in arduino-pico core
4142
***********************************************************************************************************************************/
4243

4344
#define _WIFININA_LOGLEVEL_ 1
4445

45-
extern "C"
46+
extern "C"
4647
{
47-
#include "utility/wl_definitions.h"
48-
#include "utility/wl_types.h"
49-
#include "string.h"
50-
#include "utility/debug.h"
48+
#include "utility/wl_definitions.h"
49+
#include "utility/wl_types.h"
50+
#include "string.h"
51+
#include "utility/debug.h"
5152
}
5253

5354

@@ -111,7 +112,7 @@ int WiFiClient::connect(IPAddress ip, uint16_t port)
111112
{
112113
// KH
113114
NN_LOGDEBUG(F("No Socket available"));
114-
115+
115116
return 0;
116117
}
117118

@@ -152,6 +153,7 @@ int WiFiClient::connectSSL(IPAddress ip, uint16_t port)
152153

153154
return 0;
154155
}
156+
155157
return 1;
156158
}
157159

@@ -163,7 +165,7 @@ int WiFiClient::connectSSL(const char *host, uint16_t port)
163165
}
164166

165167
_sock = ServerDrv::getSocket();
166-
168+
167169
if (_sock != NO_SOCKET_AVAIL)
168170
{
169171
ServerDrv::startClient(host, strlen(host), uint32_t(0), port, _sock, TLS_MODE);
@@ -220,15 +222,15 @@ int WiFiClient::connectBearSSL(IPAddress ip, uint16_t port)
220222
{
221223
return 0;
222224
}
223-
}
224-
else
225+
}
226+
else
225227
{
226228
// KH
227229
NN_LOGDEBUG(F("No Socket available"));
228-
230+
229231
return 0;
230232
}
231-
233+
232234
return 1;
233235
}
234236

@@ -240,7 +242,7 @@ int WiFiClient::connectBearSSL(const char *host, uint16_t port)
240242
}
241243

242244
_sock = ServerDrv::getSocket();
243-
245+
244246
if (_sock != NO_SOCKET_AVAIL)
245247
{
246248
ServerDrv::startClient(host, strlen(host), uint32_t(0), port, _sock, TLS_BEARSSL_MODE);
@@ -258,15 +260,15 @@ int WiFiClient::connectBearSSL(const char *host, uint16_t port)
258260
{
259261
return 0;
260262
}
261-
}
262-
else
263+
}
264+
else
263265
{
264266
// KH
265267
NN_LOGDEBUG(F("No Socket available"));
266-
268+
267269
return 0;
268270
}
269-
271+
270272
return 1;
271273
}
272274
//////
@@ -281,68 +283,68 @@ size_t WiFiClient::write(uint8_t b)
281283
size_t WiFiClient::write(const uint8_t *buf, size_t size)
282284
{
283285
NN_LOGDEBUG1("WiFiClient::write: To write, size = ", size);
284-
286+
285287
if (_sock == NO_SOCKET_AVAIL)
286288
{
287289
setWriteError();
288-
290+
289291
NN_LOGDEBUG("WiFiClient::write: NO_SOCKET_AVAIL");
290-
292+
291293
return 0;
292294
}
293295

294296
if (size == 0)
295297
{
296298
setWriteError();
297-
299+
298300
NN_LOGDEBUG("WiFiClient::write: size = 0");
299-
301+
300302
return 0;
301303
}
302304

303305
size_t written = ServerDrv::sendData(_sock, buf, size);
304-
306+
305307
uint8_t timesResent = 0;
306-
308+
307309
while ( (written != size) && (timesResent++ < 100) )
308310
{
309311
// Don't use too short delay so that NINA has some time to recover
310312
// The fix is considered as kludge, and the correct place to fix is in ServerDrv::sendData()
311313
delay(100);
312-
314+
313315
written += ServerDrv::sendData(_sock, buf + written, size - written);
314316
}
315-
317+
316318
NN_LOGDEBUG1("WiFiClient::write: loopSend => written = ", written);
317319
NN_LOGDEBUG1("WiFiClient::write: loopSend => timesResent = ", timesResent);
318-
319-
if (!written && _retrySend)
320+
321+
if (!written && _retrySend)
320322
{
321323
written = retry(buf, size, true);
322-
324+
323325
NN_LOGDEBUG1("WiFiClient::write: _retrySend => written = ", written);
324326
}
325-
327+
326328
if (!written)
327329
{
328330
// close socket
329331
ServerDrv::stopClient(_sock);
330332
setWriteError();
331-
333+
332334
NN_LOGDEBUG("WiFiClient::write: !written error");
333-
335+
334336
return 0;
335337
}
336338

337339
if (!ServerDrv::checkDataSent(_sock))
338340
{
339341
setWriteError();
340-
342+
341343
NN_LOGDEBUG("WiFiClient::write: error !checkDataSent");
342-
344+
343345
return 0;
344346
}
345-
347+
346348
if (written == size)
347349
{
348350
NN_LOGINFO1("WiFiClient::write: OK, written = ", written);
@@ -357,26 +359,26 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size)
357359

358360
///////////////////////////////////////////////////////////////////////////
359361

360-
size_t WiFiClient::retry(const uint8_t *buf, size_t size, bool write)
362+
size_t WiFiClient::retry(const uint8_t *buf, size_t size, bool write)
361363
{
362364
size_t rec_bytes = 0;
363365

364-
if (write)
366+
if (write)
365367
{
366368
//RETRY WRITE
367-
for (int i = 0; i < 5; i++)
369+
for (int i = 0; i < 5; i++)
368370
{
369371
rec_bytes = ServerDrv::sendData(_sock, buf, size);
370-
371-
if (rec_bytes)
372+
373+
if (rec_bytes)
372374
{
373375
break;
374376
}
375377
}
376-
378+
377379
return rec_bytes;
378380
}
379-
else
381+
else
380382
{
381383
//RETRY READ
382384
// To be implemented, if needed
@@ -418,7 +420,7 @@ int WiFiClient::peek()
418420
return WiFiSocketBuffer.peek(_sock);
419421
}
420422

421-
void WiFiClient::setRetry(bool retry)
423+
void WiFiClient::setRetry(bool retry)
422424
{
423425
_retrySend = retry;
424426
}

0 commit comments

Comments
 (0)