From c58c48eb2f9386e30ce8b1963e49353054824779 Mon Sep 17 00:00:00 2001 From: Tim Van Laer Date: Fri, 19 Jul 2024 13:10:52 +0200 Subject: [PATCH 1/2] Update dialup profile --- huawei_lte_api/api/DialUp.py | 44 ++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/huawei_lte_api/api/DialUp.py b/huawei_lte_api/api/DialUp.py index 0d85f2e..d1f590b 100644 --- a/huawei_lte_api/api/DialUp.py +++ b/huawei_lte_api/api/DialUp.py @@ -38,9 +38,9 @@ def set_mobile_dataswitch(self, dataswitch: int = 0) -> SetResponseType: 'dataswitch': dataswitch }) - def set_default_profile(self, default: int = 0) -> SetResponseType: + def set_default_profile(self, index: int = 0) -> SetResponseType: return self._session.post_set('dialup/profiles', { - 'SetDefault': default, + 'SetDefault': index, 'Delete': 0, 'Modify': 0 }, is_encrypted=True) @@ -59,11 +59,10 @@ def create_profile(self, apn: Optional[str] = None, dialup_number: Optional[str] = None, auth_mode: AuthModeEnum = AuthModeEnum.AUTO, - ip_type: IpType = IpType.IPV4_IPV6, - is_default: bool = False + ip_type: IpType = IpType.IPV4_IPV6 ) -> SetResponseType: return self._session.post_set('dialup/profiles', { - 'SetDefault': 1 if is_default else 0, + 'SetDefault': 0, 'Delete': 0, 'Modify': 1, 'Profile': { @@ -86,6 +85,41 @@ def create_profile(self, } }, is_encrypted=True) + def update_profile(self, + index: int, + name: str, + username: Optional[str] = None, + password: Optional[str] = None, + apn: Optional[str] = None, + dialup_number: Optional[str] = None, + auth_mode: AuthModeEnum = AuthModeEnum.AUTO, + ip_type: IpType = IpType.IPV4_IPV6, + is_default: bool = False + ) -> SetResponseType: + return self._session.post_set('dialup/profiles', { + 'SetDefault': index if is_default else 0, + 'Delete': 0, + 'Modify': 2, + 'Profile': { + 'Index': index, + 'IsValid': 1, + 'Name': name, + 'ApnIsStatic': 1 if apn else 0, + 'ApnName': apn, + 'DialupNum': dialup_number, + 'Username': username, + 'Password': password, + 'AuthMode': auth_mode.value, + 'IpIsStatic': '', + 'IpAddress': '', + 'DnsIsStatic': '', + 'PrimaryDns': '', + 'SecondaryDns': '', + 'ReadOnly': '0', + 'iptype': ip_type.value + } + }, is_encrypted=True) + def set_connection_settings( self, roam_auto_connect_enable: bool = True, From db4dfb2a5e34bd63376d4acd6dc37da17d62782f Mon Sep 17 00:00:00 2001 From: Tim Van Laer Date: Mon, 19 Aug 2024 11:14:53 +0200 Subject: [PATCH 2/2] Revert is_default param removal for DialUp.create_profile --- huawei_lte_api/api/DialUp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/huawei_lte_api/api/DialUp.py b/huawei_lte_api/api/DialUp.py index d1f590b..b283664 100644 --- a/huawei_lte_api/api/DialUp.py +++ b/huawei_lte_api/api/DialUp.py @@ -59,10 +59,11 @@ def create_profile(self, apn: Optional[str] = None, dialup_number: Optional[str] = None, auth_mode: AuthModeEnum = AuthModeEnum.AUTO, - ip_type: IpType = IpType.IPV4_IPV6 + ip_type: IpType = IpType.IPV4_IPV6, + is_default: bool = False ) -> SetResponseType: return self._session.post_set('dialup/profiles', { - 'SetDefault': 0, + 'SetDefault': 1 if is_default else 0, # For E5576, the new profile will always become the default (See #221) 'Delete': 0, 'Modify': 1, 'Profile': {