@@ -43,7 +43,7 @@ Tested with:
4343#define REPEAT_CONNECTION 0
4444
4545/* Edit this with your other TLS host server address to connect to: */
46- #define WOLFSSL_TLS_SERVER_HOST " 192.168.1.34 "
46+ #define WOLFSSL_TLS_SERVER_HOST " 192.168.1.39 "
4747
4848/* wolfssl TLS examples communicate on port 11111 */
4949#define WOLFSSL_PORT 11111
@@ -58,7 +58,7 @@ Tested with:
5858#define RECONNECT_ATTEMPTS 20
5959
6060/* Optional stress test. Define to consume memory until exhausted: */
61- #define MEMORY_STRESS_TEST
61+ /* #define MEMORY_STRESS_TEST */
6262
6363/* Choose client or server example, not both. */
6464#define WOLFSSL_CLIENT_EXAMPLE
@@ -68,12 +68,12 @@ Tested with:
6868 /* the /workspace directory may contain a private config
6969 * excluded from GitHub with items such as WiFi passwords */
7070 #include MY_PRIVATE_CONFIG
71- const char * ssid PROGMEM = CONFIG_ESP_WIFI_SSID ;
72- const char * password PROGMEM = CONFIG_ESP_WIFI_PASSWORD ;
71+ static const char * ssid PROGMEM = MY_ARDUINO_WIFI_SSID ;
72+ static const char * password PROGMEM = MY_ARDUINO_WIFI_PASSWORD ;
7373#else
7474 /* when using WiFi capable boards: */
75- const char * ssid PROGMEM = " your_SSID" ;
76- const char * password PROGMEM = " your_PASSWORD" ;
75+ static const char * ssid PROGMEM = " your_SSID" ;
76+ static const char * password PROGMEM = " your_PASSWORD" ;
7777#endif
7878
7979#define BROADCAST_ADDRESS " 255.255.255.255"
@@ -135,7 +135,7 @@ Tested with:
135135#elif defined(ARDUINO_SAMD_NANO_33_IOT)
136136 #define USING_WIFI
137137 #include < SPI.h>
138- #include < WiFiNINA.h>
138+ #include < WiFiNINA.h> /* Needs Arduino WiFiNINA library installed manually */
139139 WiFiClient client;
140140
141141#elif defined(ARDUINO_ARCH_RP2040)
@@ -176,21 +176,20 @@ Tested with:
176176 || defined (HAVE_SERVER_RENEGOTIATION_INFO)
177177#endif
178178
179- const char host[] PROGMEM = WOLFSSL_TLS_SERVER_HOST; /* server to connect to */
180- const int port PROGMEM = WOLFSSL_PORT; /* port on server to connect to */
181- const int serial_baud PROGMEM = SERIAL_BAUD; /* local serial port to monitor */
179+ static const char host[] PROGMEM = WOLFSSL_TLS_SERVER_HOST; /* server to connect to */
180+ static const int port PROGMEM = WOLFSSL_PORT; /* port on server to connect to */
182181
183- WOLFSSL_CTX* ctx = NULL ;
184- WOLFSSL* ssl = NULL ;
185- char * wc_error_message = (char *)malloc(80 + 1 );
186- char errBuf[80 ];
182+ static WOLFSSL_CTX* ctx = NULL ;
183+ static WOLFSSL* ssl = NULL ;
184+ static char * wc_error_message = (char *)malloc(80 + 1 );
185+ static char errBuf[80 ];
187186
188187#if defined(MEMORY_STRESS_TEST)
189188 #define MEMORY_STRESS_ITERATIONS 100
190189 #define MEMORY_STRESS_BLOCK_SIZE 1024
191190 #define MEMORY_STRESS_INITIAL (4 *1024 )
192- char * memory_stress[MEMORY_STRESS_ITERATIONS]; /* typically 1K per item */
193- int mem_ctr = 0 ;
191+ static char * memory_stress[MEMORY_STRESS_ITERATIONS]; /* typically 1K per item */
192+ static int mem_ctr = 0 ;
194193#endif
195194
196195static int EthernetSend (WOLFSSL* ssl, char * msg, int sz, void * ctx);
@@ -202,8 +201,8 @@ static int lng_index PROGMEM = 0; /* 0 = English */
202201 #include < malloc.h>
203202 extern char _end;
204203 extern " C" char *sbrk (int i);
205- char *ramstart=(char *)0x20070000 ;
206- char *ramend=(char *)0x20088000 ;
204+ static char *ramstart=(char *)0x20070000 ;
205+ static char *ramend=(char *)0x20088000 ;
207206#endif
208207
209208/* ****************************************************************************/
@@ -372,28 +371,31 @@ int setup_network(void) {
372371#if defined(USING_WIFI)
373372 int status = WL_IDLE_STATUS;
374373
375- if (WiFi.status () == WL_NO_MODULE) {
376- Serial.println (" Communication with WiFi module failed!" );
377- /* don't continue if no network */
378- while (true ) ;
379- }
380-
381- String fv = WiFi.firmwareVersion ();
382- if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
383- Serial.println (" Please upgrade the firmware" );
384- }
385-
386374 /* The ESP8266 & ESP32 support both AP and STA. We'll use STA: */
387375 #if defined(ESP8266) || defined(ESP32)
388376 WiFi.mode (WIFI_STA);
377+ #else
378+ String fv;
379+ if (WiFi.status () == WL_NO_MODULE) {
380+ Serial.println (" Communication with WiFi module failed!" );
381+ /* don't continue if no network */
382+ while (true ) ;
383+ }
384+
385+ fv = WiFi.firmwareVersion ();
386+ if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
387+ Serial.println (" Please upgrade the firmware" );
388+ }
389389 #endif
390390
391391 Serial.print (F (" Connecting to WiFi " ));
392392 Serial.print (ssid);
393+ status = WiFi.begin (ssid, password);
393394 while (status != WL_CONNECTED) {
394- status = WiFi.begin (ssid, password);
395- delay (5000 );
395+ delay (1000 );
396396 Serial.print (F (" ." ));
397+ Serial.print (status);
398+ status = WiFi.status ();
397399 }
398400
399401 Serial.println (F (" Connected!" ));
@@ -598,9 +600,12 @@ int setup_certificates(void) {
598600/* ****************************************************************************/
599601/* ****************************************************************************/
600602void setup (void ) {
601- Serial.begin (serial_baud);
602- while (!Serial) {
603+ int i = 0 ;
604+ Serial.begin (SERIAL_BAUD);
605+ while (!Serial && (i < 10 )) {
603606 /* wait for serial port to connect. Needed for native USB port only */
607+ delay (1000 );
608+ i++;
604609 }
605610 Serial.println (F (" " ));
606611 Serial.println (F (" " ));
@@ -623,10 +628,10 @@ void setup(void) {
623628
624629 setup_hardware ();
625630
626- setup_datetime ();
627-
628631 setup_network ();
629632
633+ setup_datetime ();
634+
630635 setup_wolfssl ();
631636
632637 setup_certificates ();
0 commit comments