diff --git a/examples/network_config.py b/examples/network_config.py index fa5eaf4..51b1956 100644 --- a/examples/network_config.py +++ b/examples/network_config.py @@ -30,6 +30,9 @@ def read_config(props_path: str) -> dict: # Connect to camera cam = Camera(ip, un, pw) +# Set NTP +cam.set_ntp(enable=True, interval=1440, port=123, server="time-b.nist.gov") + # Get current network settings current_settings = cam.get_network_general() print("Current settings:", current_settings) diff --git a/reolinkapi/mixins/network.py b/reolinkapi/mixins/network.py index fc4bd7a..ae44ba4 100644 --- a/reolinkapi/mixins/network.py +++ b/reolinkapi/mixins/network.py @@ -72,6 +72,27 @@ def set_wifi(self, ssid: str, password: str) -> Dict: }}}] return self._execute_command('SetWifi', body) + def set_ntp(self, enable: bool = True, interval: int = 1440, port: int = 123, server: str = "pool.ntp.org") -> Dict: + """ + Set NTP settings. + + :param enable: bool + :param interval: int + :param port: int + :param server: str + :return: Dict + """ + body = [{"cmd": "SetNtp", "action": 0, "param": { + "Ntp": { + "enable": int(enable), + "interval": interval, + "port": port, + "server": server + }}}] + response = self._execute_command('SetNtp', body) + print("Successfully Set NTP Settings") + return response + def get_net_ports(self) -> Dict: """ Get network ports