awkman/pywifi

About remove_network_profile API

Alrash opened this issue · 2 comments

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?

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.

Current pywifi support remove_network_profile() API.