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

Change IP-Address (IPv4) #293

Open
SebZar opened this issue Aug 13, 2018 · 0 comments
Open

Change IP-Address (IPv4) #293

SebZar opened this issue Aug 13, 2018 · 0 comments

Comments

@SebZar
Copy link

SebZar commented Aug 13, 2018

Hi,
can you add the support to change the network settings of a device?

At the moment I use this snipped to set a IPv4 configuration, but it would be nice to have this feature in the wrapper.

`HttpClient client = new HttpClient();
//
client.BaseAddress = new System.Uri(DevicePortalAddress, UriKind.RelativeOrAbsolute);
//
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
"Basic", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", .DevicePortalUsername, DevicePortalPassword)))
);
var newConfig = new NetworkConfiguration() {
AdapterName = AdapterName,
IPAddress = IPAddress,
SubnetMask = SubnetMask,
DefaultGateway = DefaultGateway,
PrimaryDNS = PrimaryDNS,
SecondryDNS = SecondryDNS
};
//
string json = JsonConvert.SerializeObject(newConfig);
//
HttpContent content = new StringContent(json);
//
await client.PutAsync("api/networking/ipv4config", content);

internal class NetworkConfiguration {

    public string AdapterName { get; set; }

    public string IPAddress { get; set; }

    public string SubnetMask { get; set; }

    public string DefaultGateway { get; set; }

    public string PrimaryDNS { get; set; }

    public string SecondryDNS { get; set; }

}

`

Thanks

lg

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

No branches or pull requests

1 participant