-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reolink api v7 #65
base: master
Are you sure you want to change the base?
Reolink api v7 #65
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,14 +41,14 @@ def set_osd(self, bg_color: bool = 0, channel: float = 0, osd_channel_enabled: b | |
body = [{"cmd": "SetOsd", "action": 1, | ||
"param": { | ||
"Osd": { | ||
"bgcolor": bg_color, | ||
"bgcolor": int(bg_color), | ||
"channel": channel, | ||
"osdChannel": { | ||
"enable": osd_channel_enabled, "name": osd_channel_name, | ||
"enable": int(osd_channel_enabled), "name": osd_channel_name, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
"pos": osd_channel_pos | ||
}, | ||
"osdTime": {"enable": osd_time_enabled, "pos": osd_time_pos}, | ||
"watermark": osd_watermark_enabled, | ||
"osdTime": {"enable": int(osd_time_enabled), "pos": osd_time_pos}, | ||
"watermark": int(osd_watermark_enabled), | ||
Comment on lines
+50
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and same here |
||
}}}] | ||
r_data = self._execute_command('SetOsd', body)[0] | ||
if 'value' in r_data and r_data["value"]["rspCode"] == 200: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,10 @@ | |
|
||
class NetworkAPIMixin: | ||
"""API calls for network settings.""" | ||
def set_net_port(self, http_port: float = 80, https_port: float = 443, media_port: float = 9000, | ||
onvif_port: float = 8000, rtmp_port: float = 1935, rtsp_port: float = 554) -> bool: | ||
def set_net_port(self, http_enable: bool = False, http_port: float = 80, | ||
https_enable: bool = True, https_port: float = 443, media_port: float = 9000, | ||
onvif_enable: bool = True, onvif_port: float = 8000, | ||
rtmp_enable: bool = False, rtmp_port: float = 1935, rtsp_enable: bool = True, rtsp_port: float = 554) -> bool: | ||
""" | ||
Set network ports | ||
If nothing is specified, the default values will be used | ||
|
@@ -16,17 +18,46 @@ def set_net_port(self, http_port: float = 80, https_port: float = 443, media_por | |
:type http_port: int | ||
:return: bool | ||
""" | ||
if http_enable: | ||
http_enable = 1 | ||
else: | ||
http_enable = 0 | ||
if https_enable: | ||
https_enable = 1 | ||
else: | ||
https_enable = 0 | ||
if onvif_enable: | ||
onvif_enable = 1 | ||
else: | ||
onvif_enable = 0 | ||
if rtmp_enable: | ||
rtmp_enable = 1 | ||
else: | ||
rtmp_enable = 0 | ||
if rtsp_enable: | ||
rtsp_enable = 1 | ||
else: | ||
rtsp_enable = 0 | ||
|
||
body = [{"cmd": "SetNetPort", "action": 0, "param": {"NetPort": { | ||
"httpEnable": http_enable, | ||
"httpPort": http_port, | ||
"httpsEnable": https_enable, | ||
"httpsPort": https_port, | ||
"mediaPort": media_port, | ||
"onvifEnable": onvif_enable, | ||
"onvifPort": onvif_port, | ||
"rtmpEnable": rtmp_enable, | ||
"rtmpPort": rtmp_port, | ||
"rtspEnable": rtsp_enable, | ||
"rtspPort": rtsp_port | ||
Comment on lines
+21
to
53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could rather use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably don't even need to convert from |
||
}}}] | ||
self._execute_command('SetNetPort', body, multi=True) | ||
print("Successfully Set Network Ports") | ||
return True | ||
response = self._execute_command('SetNetPort', body, multi=True) | ||
if response[0]["code"] == 0: | ||
print("Successfully Set Network Ports") | ||
return True | ||
else: | ||
raise Exception(f"Failure to set network ports: {response}") | ||
|
||
def set_wifi(self, ssid: str, password: str) -> Dict: | ||
body = [{"cmd": "SetWifi", "action": 0, "param": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ def get_recording_advanced(self) -> Dict: | |
return self._execute_command('GetRec', body) | ||
|
||
def set_recording_encoding(self, | ||
audio: float = 0, | ||
audio: bool = 0, | ||
main_bit_rate: float = 8192, | ||
main_frame_rate: float = 8, | ||
main_profile: str = 'High', | ||
|
@@ -34,7 +34,7 @@ def set_recording_encoding(self, | |
sub_size: str = '640*480') -> Dict: | ||
""" | ||
Sets the current camera encoding settings for "Clear" and "Fluent" profiles. | ||
:param audio: int Audio on or off | ||
:param audio: bool Audio on or off | ||
:param main_bit_rate: int Clear Bit Rate | ||
:param main_frame_rate: int Clear Frame Rate | ||
:param main_profile: string Clear Profile | ||
|
@@ -51,7 +51,7 @@ def set_recording_encoding(self, | |
"action": 0, | ||
"param": { | ||
"Enc": { | ||
"audio": audio, | ||
"audio": int(audio), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
"channel": 0, | ||
"mainStream": { | ||
"bitRate": main_bit_rate, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if one needs to convert
bool
explicitly here toint
sincerequests
will convert this for us when sending the request.