@@ -316,50 +316,59 @@ unsigned long arduino::WiFiClass::getTime() {
316
316
317
317
#if defined(COMPONENT_4343W)
318
318
319
- #include " QSPIFBlockDevice.h"
320
- #include " MBRBlockDevice.h"
321
- #include " FATFileSystem.h"
322
-
323
- #define WIFI_FIRMWARE_PATH " /wlan/4343WA1.BIN"
324
-
325
- QSPIFBlockDevice root (PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000 );
326
- mbed::MBRBlockDevice wifi_data (&root, 1 );
327
- mbed::FATFileSystem wifi_data_fs (" wlan" );
319
+ #define WIFI_FIRMWARE_NAME " 4343WA1.BIN"
328
320
329
321
bool firmware_available = false ;
322
+ static std::string fullname;
323
+
324
+ #include " wiced_filesystem.h"
325
+ #include " resources.h"
330
326
331
- extern " C" bool wiced_filesystem_mount () {
332
- mbed::MBRBlockDevice::partition (&root, 1 , 0x0B , 0 , 1024 * 1024 );
333
- int err = wifi_data_fs.mount (&wifi_data);
334
- if (err) {
327
+ void wiced_filesystem_mount_error (void ) {
335
328
Serial.println (" Failed to mount the filesystem containing the WiFi firmware." );
336
329
Serial.println (" Usually that means that the WiFi firmware has not been installed yet"
337
330
" or was overwritten with another firmware." );
338
- goto error;
339
- }
340
-
341
- DIR *dir;
342
- struct dirent *ent;
343
- if ((dir = opendir (" /wlan" )) != NULL ) {
344
- /* print all the files and directories within directory */
345
- while ((ent = readdir (dir)) != NULL ) {
346
- String fullname = " /wlan/" + String (ent->d_name );
347
- if (fullname == WIFI_FIRMWARE_PATH) {
348
- closedir (dir);
349
- firmware_available = true ;
350
- return true ;
351
- }
331
+ whd_print_logbuffer ();
332
+ while (1 ) {}
333
+ }
334
+
335
+ void wiced_filesystem_firmware_error (void ) {
336
+ Serial.println (" Please run the \" PortentaWiFiFirmwareUpdater\" sketch once to install the WiFi firmware." );
337
+ whd_print_logbuffer ();
338
+ while (1 ) {}
339
+ }
340
+
341
+ wiced_result_t whd_firmware_check_hook (const char *mounted_name, int mount_err)
342
+ {
343
+ DIR *dir;
344
+ struct dirent *ent;
345
+ std::string dir_name (mounted_name);
346
+ if (mount_err) {
347
+ wiced_filesystem_mount_error ();
348
+ } else {
349
+ if ((dir = opendir (mounted_name)) != NULL ) {
350
+ // print all the files and directories within directory
351
+ while ((ent = readdir (dir)) != NULL ) {
352
+ fullname = " /" + dir_name + " /" + std::string (ent->d_name );
353
+ if (std::string (ent->d_name ) == WIFI_FIRMWARE_NAME) {
354
+ closedir (dir);
355
+ firmware_available = true ;
356
+ // Update Mbed resource default mount point /wlan
357
+ wifi_firmware_image.val .fs .filename = (const char *)fullname.c_str ();
358
+ // Serial.println(fullname.c_str());
359
+ // Serial.println((char*)(wifi_firmware_image.val.fs.filename));
360
+ return WICED_SUCCESS;
361
+ }
362
+ }
363
+ Serial.println (" File not found" );
364
+ closedir (dir);
365
+ }
366
+ wiced_filesystem_firmware_error ();
352
367
}
353
- Serial.println (" File not found" );
354
- closedir (dir);
355
- }
356
- error:
357
- Serial.println (" Please run the \" PortentaWiFiFirmwareUpdater\" sketch once to install the WiFi firmware." );
358
- whd_print_logbuffer ();
359
- while (1 ) {}
360
- return false ;
368
+ return WICED_ERROR;
361
369
}
362
370
371
+
363
372
#include " whd_version.h"
364
373
char * arduino::WiFiClass::firmwareVersion () {
365
374
if (firmware_available) {
0 commit comments