WiFi Networking

Now that I am back behind the wheel of a working Meadow, I am also back to trying to connect to my WiFi router.

Does anyone have any sort of sample code for connecting? And how does one go about connecting to a network that is secured by a password?

I have been through some of the samples on Hackster.io, but found nothing.

Thanks in advance,
Woody

There is a Networking Section on the Developer site.

Regards,
Mark

Mark,
Thank you for the quick response. I found the page, but InitWiFiAdapter() doesn’t appear in the list of options in VS after I type ‘Device.’, and my code won’t compile with Error

‘F7Micro’ does not contain a definition for ‘InitWiFiAdapter’…

Looking at my list of packages, I am running Meadow.Foundation(0.15.2) and Meadow(0.13.0).

I am obviously missing a dependency.

Thanks again,
Woody

some additional information.
I decided to un-install the meadow extension, download and install the latest meadow package, version 0.11.0

I then erased the flash on the meadow and tried to re-flash, which produces this output.

[9/24/2020 11:10:17 AM] Begin ‘Flash Device’
[9/24/2020 11:10:17 AM] Upload Meadow.OS.bin (~2 mins)
[9/24/2020 11:11:26 AM] Initialize device
[9/24/2020 11:11:26 AM] An unexpected error occurred. Please try again.

I received this particular Meadow on Monday, September 21, and had successfully flashed the OS, and was able to run a variant on the LED Dice that I had been using to try to connect to my WiFi network.

I have tried re-flashing without erasing the flash and with erasing the flash multiple times, getting the same error each time. And my Dice application does not load with errors

1>------ Build started: Project: leddice, Configuration: Debug Any CPU ------
1>leddice -> C:\Users\wlath\source\repos\leddice\leddice\bin\Debug\net472\App.exe
2>------ Deploy started: Project: leddice, Configuration: Debug Any CPU ------
2>[9/24/2020 11:28:09 AM] Deploying to Meadow on COM4…
2>[9/24/2020 11:28:09 AM] Initializing Meadow 2>[9/24/2020 11:28:09 AM] Couldn’t initialize serial port 2>Failed to initialize Meadow. Try resetting or reconnecting the device.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

which is actually what I expected.
I seem to be marching backward

Woody

The problem seems to have been that I did not correctly manage the nuget packages within my application, so originally I was just running an earlier version of the Meadow.Foundation, even though I had downloaded the latest package in the package manager.

The fix was to remove all of the nuget packages and re-add them. I assume that the problem that I was having with flashing the Meadow OS had to do with having something out of sync, although sadly I don’t know what that would have been.

I am now able to initialize my WiFi Adapter. I haven’t been able to connect yet.

Woody

Still trying to connect. The adapter initialization is a waitable process. Seems as though the connection process should also be waitable, but it is not.

The connection code from the web page only ever produces an “UnspecifiedFailure”, immediately, so I put a loop after the connect statement to see if the connection would eventually be made, but at the end of 120 seconds, nothing.

I tried to connect using both my SSID /passcode, and a WiFiNetwork object / passcode.
I tried it with several different networks, both secure and open, both with passcodes and without. Always the same result.

I guess that I need more than what is in the documents to get my Meadow connected.

thanks,
Woody

I’ve got the same, exact problem. Followed the documentation available in the Networking section of the developer site, with the following code:

public MeadowApp()
{
  Console.WriteLine("Initializing WiFi adapter.");
  Device.InitWiFiAdapter().Wait();
  Console.WriteLine("WiFi adapter initialized.");

  // Temporary limitation, fixed later?  I hope?
  ConnectionStatus connStatus = Device.WiFiAdapter.Connect("ibl", "**********").ConnectionStatus;
  if (connStatus != ConnectionStatus.Success)
  {
    Console.WriteLine($"Could not connect to ibl (connStatus = {connStatus}).  Skipping scan.");
  }
  else
  {
    ScanForAccessPoints();
  } 

  Initialize();
  CycleColors(1000);
}

And I get this error message:

Could not connect to ibl (connStatus = UnspecifiedFailure).  Skipping scan.

I even tested it with an external antenna, and I still get the error.

Hey, sorry for the delay, @wlathbury and @nychold, sorry for the delay. We’ve released Beta 4.0.1 and an updated Visual Studio Extension. Please try upgrading your extension and flashing b4.0.1 to your Meadow. Let me know if you still have issues.

Just downloaded visual studio changes and Meadow.OS, and flashed my device.

When I tried to deploy my app, I got the following

Could not load file or assembly ‘Mono.Cecil, Version=0.11.3.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e’ or one of its dependencies

How do I go about updating my version of Mono?

thanks for all of your work on this project. I’m sure that it seems thankless from time to time.

follow up, downloading the Meadow.OS looks like this

[10/27/2020 12:25:35 PM] Downloading firmware version: 0.4.0.
[10/27/2020 12:25:37 PM] Download complete.

I don’t know if this is the latest, or if I should be seeing 0.4.1

Ditto on the Mono.Cecil error and firmware version 0.4.0. Additionally, the check I check the version number on the device, it says the release date was Sep 19, 2020 14:37:21

So I don’t think the extension is actually downloading the right Meadow OS version.

I uninstalled the Meadow VS extensions and reinstalled them, thinking maybe that might help the issue. I downloaded the newest version of the OS (which still says 0.4.0), but when I try to flash it, I get this:

[10/27/2020 9:39:58 PM] Begin ‘Flash Device’
[10/27/2020 9:39:58 PM] Upload Meadow.OS.bin (~2 mins)
[10/27/2020 9:41:07 PM] Initialize device (~30s)
[10/27/2020 9:41:33 PM] Trace logs no longer sent to CLI
[10/27/2020 9:41:34 PM] Mono disabled. Restarting Meadow
[10/27/2020 9:41:35 PM] MONO won’t start, it’s not enabled
[10/27/2020 9:41:35 PM] Mono disabled, will not run app.exe
[10/27/2020 9:41:45 PM] Meadow file download of ‘Meadow.OS.Runtime.bin’ has begun
[10/27/2020 9:41:48 PM] File 10% downloaded
[10/27/2020 9:41:51 PM] File 20% downloaded
[10/27/2020 9:41:54 PM] File 30% downloaded
[10/27/2020 9:43:40 PM] File 40% downloaded
[10/27/2020 9:46:49 PM] File 50% downloaded
[10/27/2020 9:49:58 PM] File 60% downloaded
[10/27/2020 9:53:07 PM] File 70% downloaded
[10/27/2020 9:56:16 PM] File 80% downloaded
[10/27/2020 9:59:25 PM] File 90% downloaded
[10/27/2020 10:02:34 PM] Download success (checksums calc:0x2E3049D9, expected:0x2E3049D9)
[10/27/2020 10:05:54 PM] An unexpected error occurred. Please try again.

This was my second attempt. Nearly 30 minutes, and an error.

Hi @nychold,

Too bad this is happening on your board. Out of curiosity, have you tried flashing the board via CLI? I have flashed about 5 boards and I haven’t got this issue (yet). I’ll try again, see if I can repro so we can investigate.

Okay, I’ve managed to (somehow) resolve my problem. I uninstalled the Meadow Visual Studio extension (as mentioned above), then rebooted. When that caused Visual Studio to report errors on the VS extension, I assumed there had been an error in installation, so I uninstalled and reinstalled again. After a second reboot, the VS extension errors were still there, so I posted a comment on the board, and tried again. This time, however, I uninstalled the extension, rebooted the machine, and reinstalled the extension. That worked, and after correcting my code, I’m now able to get networking.

The joys of beta testing. :slight_smile:

inspired by @nychold, I tried removing, re-adding and rebooting a couple of times, re-fetched and re-flashed my Meadow a couple of times. When I tried to publish the app, the error that I got was that it could not find file System.Configuration.Dll, I added a configuration file and some code to read from the config file to force the dll to be a dependency. No change.

This morning, I found a copy of System.Configuration.Dll on my laptop and copied it into the debug directory (On a good day, not a smart thing to do.) and now my error is "file not found ‘System.Xml.dll’ " which I have not been able to find on my laptop and also leads me to believe that I am chasing my wrong tail.

[11/15/2020 9:50:45 AM] Device MeadowOS Version: 0.4.0 (Sep 19 2020 14:37:21) downloaded and flashed this morning, 11/15/20.

我找到一个手册你可以试试看这个手册有没有你需要的内容。可以找平台人解答
ESP32 HC05

Shortly after Christmas, I watched the Jorge’s demonstration of the clima project, so I wired up my meadow accordingly, and copied the code. There were a couple of hiccups along the way but the whole thing works. I am able to connect to my home WiFi network and communicate with the web service. Bonus, I now know the macaddress of my meadow. Awesome! thanks.
I look forward to the implementation of TLS.

Hello,
I updated all libraries and flashed device, at the end of the post.

Below is my code and I am getting error.

Mono enabled, will run app.exe Unhandled Exception: System.InvalidOperationException: Coprocessor is not ready or is sleeping.

protected void ScanForAccessPoints()
{
Device.InitWiFiAdapter().Wait();
Device.WiFiAdapter.SetAntenna(Meadow.Gateways.AntennaType.OnBoard);
Console.WriteLine(“Getting list of access points.”);
ObservableCollection networks = Device.WiFiAdapter.Scan();
if (networks.Count > 0)
{
Console.WriteLine("|-------------------------------------------------------------|---------|");
Console.WriteLine("| Network Name | RSSI | BSSID | Channel |");
Console.WriteLine("|-------------------------------------------------------------|---------|");
foreach (WifiNetwork accessPoint in networks)
{
Console.WriteLine($"| {accessPoint.Ssid,-32} | {accessPoint.SignalDbStrength,4} | {accessPoint.Bssid,17} | {accessPoint.ChannelCenterFrequency,3} |");
}
}
else
{
Console.WriteLine($“No access points detected.”);
}
}


‘App.exe’ (CLR v4.0.30319: DefaultDomain): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘App.exe’ (CLR v4.0.30319: DefaultDomain): Loaded ‘D:\Source\repos\meadow\MeadowApplication1\bin\Debug\net472\App.exe’. Symbols loaded.
‘App.exe’ (CLR v4.0.30319: App.exe): Loaded ‘D:\Source\repos\meadow\MeadowApplication1\bin\Debug\net472\Meadow.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
The program ‘[16628] App.exe’ has exited with code 0 (0x0).
Meadow successfully started MONO Initialize hardware…
Mono enabled, will run app.exe Unhandled Exception: System.InvalidOperationException: Coprocessor is not ready or is sleeping.
at Meadow.Devices.Esp32Coprocessor.CheckStatus () <0xc0d94bb8 + 0x00018> in <1d12d24bb4cb45e5b8da959c3c36c73b>:0
at Meadow.Devices.Esp32Coprocessor.SetAntenna (Meadow.Gateways.AntennaType antenna, System.Boolean persist) <0xc0d94a98 + 0x0001a> in <1d12d24bb4cb45e5b8da959c3c36c73b>:
at MeadowApplication1.MeadowApp.ScanForAccessPoints () <0xc0d93c60 + 0x00032> in :0
at MeadowApplication1.MeadowApp…ctor () <0xc0833898 + 0x00012> in :0
at MeadowApplication1.Program.Main (System.String[] args) <0xc08336b8 + 0x00034> in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationExcept ion: Coprocessor is not ready or is sleeping.
at Meadow.Devices.Esp32Coprocessor.CheckStatus () <0xc0d94bb8 + 0x00018> in <1d12d24bb4cb45e5b8da959c3c36c73b>:0
at Meadow.Devices.Esp32Coprocessor.SetAntenna (Meadow.Gateways.AntennaType antenna, System.Boolean persist) <0xc0d94a98 + 0x0001a> in <1d12d24bb4cb45e5b8da959c3c36c73b>:0
at MeadowApplication1.MeadowApp.ScanForAccess oints () <0xc0d93c60 + 0x00032> in :0
at MeadowApplication1.MeadowApp…ctor () <0xc0833898 + 0x00012> in :0
at MeadowApplication1.Program.Main (System.String[] args) <0xc08336b8 + 0x00034> in :0

UPDATE STEPS

D:\Source\repos\meadow>meadow --InstallDfuUtil
Installing dfu-util…
dfu-util 0.10 installed

D:\Source\repos\meadow>meadow --FlashOS
Flashing OS with C:\Users…\AppData\Local\WildernessLabs\Firmware\Meadow.OS.bin
dfu-util 0.10

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2020 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Warning: Invalid DFU suffix signature
A valid DFU suffix will be required in a future dfu-util release!!!
Match vendor ID from file: 0000
Match product ID from file: 0000
Opening DFU capable USB device…
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface…
Setting Alternate Setting #0
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash "
Downloading element to address = 0x08000000, size = 2097152
Erase [=========================] 100% 2097152 bytes
Erase done.
Download [=========================] 100% 2097152 bytes
Download done.
File downloaded successfully
Transitioning to dfuMANIFEST state

D:\Source\repos\meadow> meadow --MonoDisable -s COM9
Opening port ‘COM9’
Data: Mono enabled, will run app.exe
Data: Mono has been disabled. Restarting Meadow
Device successfully reconnected
Data: Mono enabled, will run app.exe

D:\Source\repos\meadow>meadow --MonoUpdateRt -s COM9
Opening port ‘COM9’
FileName not specified, using latest download.
Updating runtime…
[==================================================]
Data: Download of ‘Meadow.OS.Runtime.bin’ success (checksums calc:0xECE2E753, expected:0xECE2E753)
Data: Erasing mono flash memory
Data: Mono memory erase success
Data: Flashing 10% complete
Data: Flashing 20% complete
Data: Flashing 30% complete
Data: Flashing 40% complete
Data: Flashing 50% complete
Data: Flashing 60% complete
Data: Flashing 70% complete
Data: Flashing 80% complete
Data: Flashing 90% complete
Data: Mono runtime successfully flashed.

D:\Source\repos\meadow>meadow --FlashEsp -s COM9
Opening port ‘COM9’
Transferring MeadowComms.bin
Erasing ESP32 Flash…Data: Mono must be disabled for ESP32 file download
done.
[==================================================]
Transferring bootloader.bin
Erasing ESP32 Flash…done.
[==================================================]
Transferring partition-table.bin
Erasing ESP32 Flash…done.
[==================================================]

D:\Source\repos\meadow> meadow --MonoEnable -s COM9
Opening port ‘COM9’
Data: Mono has been enabled. Restarting F7 Micro
Device successfully reconnected
Data: Mono enabled, will run app.exe

D:\Source\repos\meadow>meadow --Download
Download and extracted OS version 0.4.6.2 to:
C:\Users…\AppData\Local\WildernessLabs\Firmware

ok, I performed same steps again. now It doesn’t throw that error. But it doesn’t list access points.

D:\Source\repos\meadow> meadow --MonoDisable -s COM9
Opening port ‘COM9’
Data: Mono enabled, will run app.exe
Data: Mono has been disabled. Restarting Meadow
Device successfully reconnected
Data: Mono enabled, will run app.exe

D:\Source\repos\meadow>meadow --MonoUpdateRt -s COM9
Opening port ‘COM9’
FileName not specified, using latest download.
Updating runtime…
[==================================================]
Data: Download of ‘Meadow.OS.Runtime.bin’ success (checksums calc:0xECE2E753, expected:0xECE2E753)
Data: Erasing mono flash memory
Data: Mono memory erase success
Data: Flashing 10% complete
Data: Flashing 20% complete
Data: Flashing 30% complete
Data: Flashing 40% complete
Data: Flashing 50% complete
Data: Flashing 60% complete
Data: Flashing 70% complete
Data: Flashing 80% complete
Data: Flashing 90% complete
Data: Mono runtime successfully flashed.

D:\Source\repos\meadow>meadow --FlashEsp -s COM9
Opening port ‘COM9’
Transferring MeadowComms.bin
Erasing ESP32 Flash…Data: Mono must be disabled for ESP32 file download
done.
[==================================================]
Transferring bootloader.bin
Erasing ESP32 Flash…done.
[==================================================]
Transferring partition-table.bin
Erasing ESP32 Flash…done.
[==================================================]

D:\Source\repos\meadow> meadow --MonoEnable -s COM9
Opening port ‘COM9’
Data: Mono has been enabled. Restarting F7 Micro
Device successfully reconnected
Data: Mono enabled, will run app.exe

D:\Source\repos\meadow>meadow --Download
Download and extracted OS version 0.4.6.2 to:
C:\Users\karay\AppData\Local\WildernessLabs\Firmware

D:\Source\repos\meadow> meadow --MonoDisable -s COM9
Opening port ‘COM9’
Error connecting to device: Access to the path ‘COM9’ is denied.

D:\Source\repos\meadow> meadow --MonoDisable -s COM9
Opening port ‘COM9’
Data: Meadow successfully started MONO
Data: Mono enabled, will run app.exe
Data: Mono has been disabled. Restarting Meadow
Device successfully reconnected
Data: Mono disabled, will not run app.exe

D:\Source\repos\meadow>meadow --MonoUpdateRt
Opening port ‘COM9’
FileName not specified, using latest download.
Updating runtime…
[==================================================]
Data: Download of ‘Meadow.OS.Runtime.bin’ success (checksums calc:0xECE2E753, expected:0xECE2E753)
Data: Erasing mono flash memory
Data: Mono memory erase success
Data: Flashing 10% complete
Data: Flashing 20% complete
Data: Flashing 30% complete
Data: Flashing 40% complete
Data: Flashing 50% complete
Data: Flashing 60% complete
Data: Flashing 70% complete
Data: Flashing 80% complete
Data: Flashing 90% complete
Data: Mono runtime successfully flashed.

D:\Source\repos\meadow>meadow --FlashEsp
Opening port ‘COM9’
Transferring MeadowComms.bin
Erasing ESP32 Flash…Data: Initiating ESP32 download.
Data: File download to ESP32 flash at ‘0x00010000’ has begun
done.
[==================================================]
Transferring bootloader.bin
Erasing ESP32 Flash…done.
[==================================================]
Data: File Sent Success MD5 ESP32 Calulated:‘781348d224c0fadac2d3a21ec88d24c0’, received from CLI:‘781348d224c0fadac2d3a21ec88d24c0’)
Transferring partition-table.bin
Erasing ESP32 Flash…done.
[==================================================]
Data: File Sent Success MD5 ESP32 Calulated:‘d845cbc34f76d600bd979245058ddbe5’, received from CLI:‘d845cbc34f76d600bd979245058ddbe5’)

D:\Source\repos\meadow> meadow --MonoEnable -s COM9
Opening port ‘COM9’
Data: Mono has been enabled. Restarting F7 Micro
Device successfully reconnected

D:\Source\repos\meadow>

FYI, it doesn’t work while you debug/deploy from VS. it looks like scanning network but there is no visible sign. I tested with onboard led colors… :frowning:

Before doing development this boards needs a lot of improvement. Progress is very slow. putting back to shelve until another release.