awkman / pywifi

A cross-platform module for manipulating WiFi devices.
MIT License
447 stars 154 forks source link

About remove_network_profile API #26

Closed Alrash closed 5 years ago

Alrash commented 6 years ago

I want to use remove_network_profile() API to remove one specified AP settings, but I could not find the example or its code. Could you help me?

lxjmaster commented 6 years ago

You can inherit WifiUtil class from _wifiutil_win and add the following code in your subclass.

def remove_network_profile(self, obj, name): """Remove the specified AP settings."""

profile_name_list = super().network_profile_name_list(obj)
for profile_name in profile_name_list:
    if name == profile_name:
       super()._logger.debug("delete profile: %s", profile_name)
       str_buf = create_unicode_buffer(profile_name)
       ret = super()._wlan_delete_profile(super()._handle, obj['guid'], str_buf)
       super()._logger.debug("delete result %d", ret)
   else:
       pass

And then,you can use the method remove_network_profile(iface._raw_obj,profile.ssid) to remove the profile. The iface is a interface object.

awkman commented 5 years ago

Current pywifi support remove_network_profile() API.