Skip to content

Change IP-Address (IPv4) #293

Description

@SebZar

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions