Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetworkHelper.SetupNetwork cannot run more than once #1374

Closed
networkfusion opened this issue Sep 29, 2023 · 4 comments
Closed

NetworkHelper.SetupNetwork cannot run more than once #1374

networkfusion opened this issue Sep 29, 2023 · 4 comments

Comments

@networkfusion
Copy link
Member

Library/API/IoT binding

System.Net

Visual Studio version

No response

.NET nanoFramework extension version

No response

Target name(s)

STM32 targets

Firmware version

latest

Device capabilities

No response

Description

The following will cause an exception

var success = false;

while (!success)
{
    CancellationTokenSource cs = new CancellationTokenSource(1000);
    success = NetworkHelper.SetupAndConnectNetwork(requiresDateTime: true, token: cs.Token);
    Thread.Sleep(1000);
}

If the network takes more than one loop.

How to reproduce

No response

Expected behaviour

You should be able to call NetworkHelper.SetupAndConnectNetwork() more than once, or add an option to retry.

Screenshots

No response

Sample project or code

No response

Aditional information

No response

@josesimoes
Copy link
Member

This is by design and on purpose.
Going through the network setup sequence once it's connected causes unpredictable behavior.
Plus, there are steps in the network setup that need to occur sequentially.
Therefore this check to prevent it from happening.

It's easier to reboot the damm thing than to try reconnecting and/or restoring the connection. 😉

@networkfusion
Copy link
Member Author

We are pretty screwed on an STM32 in that instance as there is no way of rebooting though the current managed interfaces... (e.g. nanoFramework.Hardware.Stm32.Power.RebootDevice(); does not exist).

@josesimoes
Copy link
Member

I beg to differ.!
Fortunately someone thought about such requirement and there is:
https://docs.nanoframework.net/api/nanoFramework.Runtime.Native.Power.html#nanoFramework_Runtime_Native_Power_RebootDevice 😉

@networkfusion
Copy link
Member Author

Fair enough (I was looking for that, but nothing in samples et. al.) I will close this for the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants