def add_network_profile(self, obj, params):
        """Add an AP profile for connecting to afterward."""

        reason_code = DWORD()

        params.process_akm()
        profile_data = {}
        profile_data['ssid'] = params.ssid

        if AKM_TYPE_NONE in params.akm:
            profile_data['auth'] = auth_value_to_str_dict[params.auth]
            profile_data['encrypt'] = "none"
        else:
            profile_data['auth'] = akm_value_to_str_dict[params.akm[-1]]
            profile_data['encrypt'] = cipher_value_to_str_dict[params.cipher]

        profile_data['key'] = params.key

        profile_data['protected'] = 'false'
        profile_data['profile_name'] = params.ssid

        xml = """<?xml version="1.0"?>
        <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
            <name>{profile_name}</name>
            <SSIDConfig>
                <SSID>
                    <name>{ssid}</name>
                </SSID>
            </SSIDConfig>
            <connectionType>ESS</connectionType>
            <connectionMode>manual</connectionMode>
            <MSM>
                <security>
                    <authEncryption>
                        <authentication>{auth}</authentication>
                        <encryption>{encrypt}</encryption>
                        <useOneX>false</useOneX>
                    </authEncryption>
        """

        if AKM_TYPE_NONE not in params.akm:
            xml += """<sharedKey>
                        <keyType>passPhrase</keyType>
                        <protected>{protected}</protected>
                        <keyMaterial>{key}</keyMaterial>
                    </sharedKey>"""

        xml += """
                </security>
            </MSM>"""

        xml += """<MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
                <enableRandomization>false</enableRandomization>
            </MacRandomization>
        </WLANProfile>
        """

        xml = xml.format(**profile_data)

        status = self._wlan_set_profile(self._handle, obj['guid'], xml,
                                        True, byref(reason_code))
        if status != ERROR_SUCCESS:
            self._logger.debug("Status %d: Add profile failed", status)

        buf_size = DWORD(64)
        buf = create_unicode_buffer(64)
        self._wlan_reason_code_to_str(reason_code, buf_size, buf)
        
        return params
Add an AP profile for connecting to afterward.