tutk.py
Attributes
AV_ER_DATA_NOREADY
An error raised when the client asks for data not yet available on the camera.
AV_ER_INCOMPLETE_FRAME
An error sent during video streaming if the camera wasn't able to send a complete frame.
AV_ER_LOSED_THIS_FRAME
An error sent during video streaming if the frame was lost in transmission.
AV_ER_SESSION_CLOSE_BY_REMOTE
An error raised when the camera closes the connection.
AV_ER_TIMEOUT
An error raised when the AV library times out.
BITRATE_360P
The bitrate used by the "360P" setting in the app. Approx 30 KB/s.
BITRATE_HD
The bitrate used by the "HD" setting in the app. Approx 120 KB/s.
BITRATE_SD
The bitrate used by the "SD" setting in the app. Approx 60 KB/s.
BITRATE_SUPER_HD
A bitrate higher than the "HD" setting in the app. Approx 150 KB/s.
BITRATE_SUPER_SUPER_HD
A bitrate higher than the "HD" setting in the app. Approx 240 KB/s.
FRAME_SIZE_1080P
Represents the size of the video stream sent back from the server; 1080P or 1920x1080 pixels.
FRAME_SIZE_360P
Represents the size of the video stream sent back from the server; 360P or 640x360 pixels.
FRAME_SIZE_DOORBELL_HD
Represents the size of the video stream sent back from the server; portrait 1296 x 1728.
FRAME_SIZE_DOORBELL_SD
Represents the size of the video stream sent back from the server; portrait 480 x 640.
Classes
FrameInfoStruct
A struct recieved on every video frame, with lots of useful information about the frame sent by the camera.
Attributes:
Name | Type | Description |
---|---|---|
codec_id |
int |
78: h264 80: h265 |
is_keyframe |
int |
True if the frame being described is a keyframe |
cam_index |
int |
The index of the camera |
online_num |
int |
Not clear |
framerate |
int |
framerate of the video frame, in frames / second |
frame_size |
int |
frame size of the video frame, either |
bitrate |
int |
bitrate of the video frame, as configured. |
timestamp_ms |
int |
the millisecond component of the timestamp. |
timestamp |
int |
the seconds component of the timestamp. |
frame_len |
int |
the size of the data sent by the camera, in bytes. |
frame_no |
int |
the current frame number as recorded by the camera |
ac_mac_addr |
str |
unknown |
n_play_token |
int |
unknown |
SInfoStruct
Result of iotc_session_check(), this struct holds a bunch of diagnostic data about the state of the connection to the camera.
Attributes:
Name | Type | Description |
---|---|---|
mode |
int |
0: P2P mode, 1: Relay mode, 2: LAN mode |
c_or_d |
int |
0: As a Client, 1: As a Device |
uid |
str |
The UID of the device. |
remote_ip |
str |
The IP address of remote site used during this IOTC session. |
remote_port |
int |
The port number of remote site used during this IOTC session. |
tx_packet_count |
int |
The total packets sent from the device and the client during this IOTC session. |
rx_packet_count |
int |
The total packets received in the device and the client during this IOTC session |
iotc_version |
int |
version number of the IOTC device. |
vendor_id |
int |
id of the vendor of the device |
product_id |
int |
id of the product of the device |
group_id |
int |
id of the group of the device |
nat_type |
int |
The remote NAT type. |
is_secure |
int |
0: The IOTC session is in non-secure mode, 1: The IOTC session is in secure mode |
Functions
av_client_set_max_buf_size(tutk_platform_lib, size)
Set the maximum video frame buffer used in AV client.
AV client sets the maximum video frame buffer by this function. The size of video frame buffer will affect the streaming fluency. The default size of video frame buffer is 1MB.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
the c library loaded from the 'load_library' call. |
required |
size |
int |
The maximum video frame buffer, in unit of kilo-byte |
required |
Source code in wyzecam/tutk/tutk.py
def av_client_set_max_buf_size(tutk_platform_lib: CDLL, size: int) -> None:
"""Set the maximum video frame buffer used in AV client.
AV client sets the maximum video frame buffer by this function. The size of
video frame buffer will affect the streaming fluency. The default size of
video frame buffer is 1MB.
:param tutk_platform_lib: the c library loaded from the 'load_library' call.
:param size: The maximum video frame buffer, in unit of kilo-byte
"""
tutk_platform_lib.avClientSetMaxBufSize(c_int(size))
av_client_start(tutk_platform_lib, session_id, username, password, timeout_secs, channel_id)
Start an AV client.
Start an AV client by providing view account and password. It shall pass the authentication of the AV server before receiving AV data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
the c library loaded from the 'load_library' call. |
required |
session_id |
Union[int, ctypes.c_int] |
The session ID of the IOTC session to start AV client |
required |
username |
bytes |
The view account for authentication |
required |
password |
bytes |
The view password for authentication |
required |
timeout_secs |
int |
The timeout for this function in unit of second Specify it as 0 will make this AV client try connection once and this process will exit immediately if not connection is unsuccessful. |
required |
channel_id |
int |
The channel ID of the channel to start AV client |
required |
Returns:
Type | Description |
---|---|
Tuple[ctypes.c_int, ctypes.c_uint] |
returns a tuple of two values: - av_chan_id: AV channel ID if return value >= 0; error code if return value < 0 - pn_serv_type: The user-defined service type set when an AV server starts. Can be NULL. |
Source code in wyzecam/tutk/tutk.py
def av_client_start(
tutk_platform_lib: CDLL,
session_id: Union[int, c_int],
username: bytes,
password: bytes,
timeout_secs: int,
channel_id: int,
) -> typing.Tuple[c_int, c_uint]:
"""Start an AV client.
Start an AV client by providing view account and password. It shall pass
the authentication of the AV server before receiving AV data.
:param tutk_platform_lib: the c library loaded from the 'load_library' call.
:param session_id: The session ID of the IOTC session to start AV client
:param username: The view account for authentication
:param password: The view password for authentication
:param timeout_secs: The timeout for this function in unit of second
Specify it as 0 will make this AV client try connection once
and this process will exit immediately if not connection
is unsuccessful.
:param channel_id: The channel ID of the channel to start AV client
:return: returns a tuple of two values:
- av_chan_id: AV channel ID if return value >= 0; error code if return value < 0
- pn_serv_type: The user-defined service type set when an AV server starts. Can be NULL.
"""
n_timeout = c_uint(timeout_secs)
user_defined_service_type = c_uint()
chan_id = c_uint8(channel_id)
av_chan_id = tutk_platform_lib.avClientStart(
session_id,
c_char_p(username),
c_char_p(password),
n_timeout,
pointer(user_defined_service_type),
chan_id,
)
return av_chan_id, user_defined_service_type
av_client_stop(tutk_platform_lib, av_chan_id)
Stop an AV client.
An AV client stop AV channel by this function if this channel is no longer required.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
the c library loaded from the 'load_library' call. |
required |
av_chan_id |
c_int |
The channel ID of the AV channel to be stopped |
required |
Source code in wyzecam/tutk/tutk.py
def av_client_stop(tutk_platform_lib: CDLL, av_chan_id: c_int) -> None:
"""Stop an AV client.
An AV client stop AV channel by this function if this channel is no longer
required.
:param tutk_platform_lib: the c library loaded from the 'load_library' call.
:param av_chan_id: The channel ID of the AV channel to be stopped
"""
tutk_platform_lib.avClientStop(av_chan_id)
av_deinitialize(tutk_platform_lib)
Deinitialize AV module.
This function will deinitialize AV module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
The underlying c library (from tutk.load_library()) |
required |
Returns:
Type | Description |
---|---|
int |
Error code if return value < 0 |
Source code in wyzecam/tutk/tutk.py
def av_deinitialize(tutk_platform_lib: CDLL) -> int:
"""Deinitialize AV module.
This function will deinitialize AV module.
:param tutk_platform_lib: The underlying c library (from tutk.load_library())
:return: Error code if return value < 0
"""
errno: int = tutk_platform_lib.avDeInitialize()
return errno
av_initialize(tutk_platform_lib, max_num_channels=1)
Initialize AV module.
This function is used by AV servers or AV clients to initialize AV module and shall be called before any AV module related function is invoked.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
the c library loaded from the 'load_library' call. |
required |
max_num_channels |
Optional[int] |
The max number of AV channels. If it is specified less than 1, AV will set max number of AV channels as 1. |
1 |
Returns:
Type | Description |
---|---|
int |
The actual maximum number of AV channels to be set. Error code if return value < 0. |
Source code in wyzecam/tutk/tutk.py
def av_initialize(
tutk_platform_lib: CDLL, max_num_channels: Optional[int] = 1
) -> int:
"""Initialize AV module.
This function is used by AV servers or AV clients to initialize AV module
and shall be called before any AV module related function is invoked.
:param tutk_platform_lib: the c library loaded from the 'load_library' call.
:param max_num_channels: The max number of AV channels. If it is specified
less than 1, AV will set max number of AV channels as 1.
:return:The actual maximum number of AV channels to be set. Error code if return value < 0.
"""
max_chans: int = tutk_platform_lib.avInitialize(max_num_channels)
return max_chans
av_recv_frame_data(tutk_platform_lib, av_chan_id)
A new version AV client receives frame data from an AV server.
An AV client uses this function to receive frame data from AV server
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
the c library loaded from the 'load_library' call. |
required |
av_chan_id |
c_int |
The channel ID of the AV channel to recv data on. |
required |
Returns:
Type | Description |
---|---|
Tuple[int, Optional[bytes], Union[wyzecam.tutk.tutk.FrameInfoStruct, wyzecam.tutk.tutk.FrameInfo3Struct], Optional[int]] |
a 4-tuple of errno, frame_data, frame_info, and frame_index |
Source code in wyzecam/tutk/tutk.py
def av_recv_frame_data(
tutk_platform_lib: CDLL, av_chan_id: c_int
) -> typing.Tuple[
int,
Optional[bytes],
Optional[Union[FrameInfoStruct, FrameInfo3Struct]],
Optional[int],
]:
"""A new version AV client receives frame data from an AV server.
An AV client uses this function to receive frame data from AV server
:param tutk_platform_lib: the c library loaded from the 'load_library' call.
:param av_chan_id: The channel ID of the AV channel to recv data on.
:return: a 4-tuple of errno, frame_data, frame_info, and frame_index
"""
frame_data_max_len = 5 * 1024 * 1024
frame_data_actual_len = c_int()
frame_data_expected_len = c_int()
frame_data = (c_char * frame_data_max_len)()
frame_info_actual_len = c_int()
frame_index = c_uint()
frame_info_max_len = max(sizeof(FrameInfo3Struct), sizeof(FrameInfoStruct))
frame_info = (c_char * frame_info_max_len)()
errno = tutk_platform_lib.avRecvFrameData2(
av_chan_id,
pointer(frame_data),
c_int(frame_data_max_len),
pointer(frame_data_actual_len),
pointer(frame_data_expected_len),
pointer(frame_info),
c_int(frame_info_max_len),
pointer(frame_info_actual_len),
pointer(frame_index),
)
if errno < 0:
return errno, None, None, None
else:
frame_data_actual: bytes = frame_data[: frame_data_actual_len.value] # type: ignore
frame_info_actual: Union[FrameInfoStruct, FrameInfo3Struct]
if frame_info_actual_len.value == sizeof(FrameInfo3Struct):
frame_info_actual = FrameInfo3Struct.from_buffer(frame_info)
elif frame_info_actual_len.value == sizeof(FrameInfoStruct):
frame_info_actual = FrameInfoStruct.from_buffer(frame_info)
else:
from wyzecam.tutk.tutk_protocol import TutkWyzeProtocolError
raise TutkWyzeProtocolError(
f"Unknown frame info structure format! len={frame_info_actual_len}"
)
return (
0,
frame_data_actual,
frame_info_actual,
frame_index.value,
)
av_recv_io_ctrl(tutk_platform_lib, av_chan_id, timeout_ms)
Receive AV IO control.
This function is used by AV servers or AV clients to receive a AV IO control.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
the c library loaded from the 'load_library' call. |
required |
av_chan_id |
c_int |
The channel ID of the AV channel to be stopped |
required |
timeout_ms |
int |
the number of milliseconds to wait before timing out |
required |
Returns:
Type | Description |
---|---|
Tuple[int, int, Optional[List[bytes]]] |
a tuple of (the length of the io_ctrl received (or error number), the io_ctrl_type, and the data in bytes) |
Source code in wyzecam/tutk/tutk.py
def av_recv_io_ctrl(
tutk_platform_lib: CDLL, av_chan_id: c_int, timeout_ms: int
) -> typing.Tuple[int, int, Optional[typing.List[bytes]]]:
"""Receive AV IO control.
This function is used by AV servers or AV clients to receive a AV IO control.
:param tutk_platform_lib: the c library loaded from the 'load_library' call.
:param av_chan_id: The channel ID of the AV channel to be stopped
:param timeout_ms: the number of milliseconds to wait before timing out
:returns: a tuple of (the length of the io_ctrl received (or error number),
the io_ctrl_type, and the data in bytes)
"""
pn_io_ctrl_type = c_uint()
ctl_data_len = 1024 * 1024
ctl_data = (c_char * ctl_data_len)()
actual_len = tutk_platform_lib.avRecvIOCtrl(
av_chan_id,
pointer(pn_io_ctrl_type),
ctl_data,
c_int(ctl_data_len),
c_int(timeout_ms),
)
return (
actual_len,
pn_io_ctrl_type.value,
ctl_data[0:actual_len] if actual_len > 0 else None,
)
iotc_connect_by_uid(tutk_platform_lib, p2p_id)
Used by a client to connect a device.
This function is for a client to connect a device by specifying the UID of that device. If connection is established with the help of IOTC servers, the IOTC session ID will be returned in this function and then device and client can communicate for the other later by using this IOTC session ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
The underlying c library (from tutk.load_library()) |
required |
p2p_id |
str |
The UID of a device that client wants to connect |
required |
Returns:
Type | Description |
---|---|
c_int |
IOTC session ID if return value >= 0, error code if return value < 0 |
Source code in wyzecam/tutk/tutk.py
def iotc_connect_by_uid(tutk_platform_lib: CDLL, p2p_id: str) -> c_int:
"""Used by a client to connect a device.
This function is for a client to connect a device by specifying the UID of
that device. If connection is established with the help of IOTC servers,
the IOTC session ID will be returned in this function and then device and
client can communicate for the other later by using this IOTC session ID.
:param tutk_platform_lib: The underlying c library (from tutk.load_library())
:param p2p_id: The UID of a device that client wants to connect
:return: IOTC session ID if return value >= 0, error code if return value < 0
"""
session_id: c_int = tutk_platform_lib.IOTC_Connect_ByUID(
c_char_p(p2p_id.encode("ascii"))
)
return session_id
iotc_connect_by_uid_parallel(tutk_platform_lib, p2p_id, session_id)
Used by a client to connect a device and bind to a specified session ID.
This function is for a client to connect a device by specifying the UID of that device, and bind to a tutk_platform_free session ID from IOTC_Get_SessionID(). If connection is established with the help of IOTC servers, the IOTC_ER_NoERROR will be returned in this function and then device and client can communicate for the other later by using this IOTC session ID. If this function is called by multiple threads, the connections will be processed concurrently.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
The underlying c library (from tutk.load_library()) |
required |
p2p_id |
str |
The UID of a device that client wants to connect |
required |
session_id |
c_int |
The Session ID got from IOTC_Get_SessionID() the connection should bind to. |
required |
Returns:
Type | Description |
---|---|
c_int |
IOTC session ID if return value >= 0, error code if return value < 0 |
Source code in wyzecam/tutk/tutk.py
def iotc_connect_by_uid_parallel(
tutk_platform_lib: CDLL, p2p_id: str, session_id: c_int
) -> c_int:
"""Used by a client to connect a device and bind to a specified session ID.
This function is for a client to connect a device by specifying the UID of that device,
and bind to a tutk_platform_free session ID from IOTC_Get_SessionID(). If connection is
established with the help of IOTC servers, the IOTC_ER_NoERROR will be returned in this
function and then device and client can communicate for the other later by using this
IOTC session ID. If this function is called by multiple threads, the connections will
be processed concurrently.
:param tutk_platform_lib: The underlying c library (from tutk.load_library())
:param p2p_id: The UID of a device that client wants to connect
:param session_id: The Session ID got from IOTC_Get_SessionID() the connection should bind to.
:return: IOTC session ID if return value >= 0, error code if return value < 0
"""
resultant_session_id: c_int = tutk_platform_lib.IOTC_Connect_ByUID_Parallel(
c_char_p(p2p_id.encode("ascii")), session_id
)
return resultant_session_id
iotc_connect_stop_by_session_id(tutk_platform_lib, session_id)
Used by a client to stop a specific session connecting a device.
This function is for a client to stop connecting a device. Since IOTC_Connect_ByUID_Parallel() is a block processes, that means the client will have to wait for the return of these functions before executing sequential instructions. In some cases, users may want the client to stop connecting immediately by this function in another thread before the return of connection process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
The underlying c library (from tutk.load_library()) |
required |
session_id |
c_int |
The Session ID got from IOTC_Get_SessionID() the connection should bind to. |
required |
Returns:
Type | Description |
---|---|
c_int |
Error code if return value < 0, otherwise 0 if successful |
Source code in wyzecam/tutk/tutk.py
def iotc_connect_stop_by_session_id(
tutk_platform_lib: CDLL, session_id: c_int
) -> c_int:
"""
Used by a client to stop a specific session connecting a device.
This function is for a client to stop connecting a device. Since IOTC_Connect_ByUID_Parallel()
is a block processes, that means the client will have to wait for the return of these functions
before executing sequential instructions. In some cases, users may want the client to stop
connecting immediately by this function in another thread before the return of connection process.
:param tutk_platform_lib: The underlying c library (from tutk.load_library())
:param session_id: The Session ID got from IOTC_Get_SessionID() the connection should bind to.
:return: Error code if return value < 0, otherwise 0 if successful
"""
errno: c_int = tutk_platform_lib.IOTC_Connect_Stop_BySID(session_id)
return errno
iotc_deinitialize(tutk_platform_lib)
Deinitialize IOTC module.
This function will deinitialize IOTC module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
The underlying c library (from tutk.load_library()) |
required |
Returns:
Type | Description |
---|---|
c_int |
Error code if return value < 0 |
Source code in wyzecam/tutk/tutk.py
def iotc_deinitialize(tutk_platform_lib: CDLL) -> c_int:
"""Deinitialize IOTC module.
This function will deinitialize IOTC module.
:param tutk_platform_lib: The underlying c library (from tutk.load_library())
:return: Error code if return value < 0
"""
errno: c_int = tutk_platform_lib.IOTC_DeInitialize()
return errno
iotc_get_session_id(tutk_platform_lib)
Used by a client to get a tutk_platform_free session ID.
This function is for a client to get a tutk_platform_free session ID used for a parameter of iotc_connect_by_uid_parallel()
Source code in wyzecam/tutk/tutk.py
def iotc_get_session_id(tutk_platform_lib: CDLL) -> c_int:
"""Used by a client to get a tutk_platform_free session ID.
This function is for a client to get a tutk_platform_free
session ID used for a parameter of iotc_connect_by_uid_parallel()
"""
session_id: c_int = tutk_platform_lib.IOTC_Get_SessionID()
return session_id
iotc_get_version(tutk_platform_lib)
Get the version of IOTC module.
This function returns the version of IOTC module.
Source code in wyzecam/tutk/tutk.py
def iotc_get_version(tutk_platform_lib: CDLL) -> int:
"""Get the version of IOTC module.
This function returns the version of IOTC module.
"""
version = c_uint32()
tutk_platform_lib.IOTC_Get_Version(pointer(version))
return version.value
iotc_initialize(tutk_platform_lib, udp_port=0)
Initialize IOTC module.
This function is used by devices or clients to initialize IOTC module and shall be called before any IOTC module related function is invoked except for IOTC_Set_Max_Session_Number().
The different between this function and IOTC_Initialize() is this function uses following steps to connect masters (1) IP addresses of master (2) if fails to connect in step 1, resolve predefined domain name of masters (3) try to connect again with the resolved IP address of step 2 if IP is resolved successfully.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
The underlying c library (from tutk.load_library()) |
required |
udp_port |
int |
Specify a UDP port. Random UDP port is used if it is specified as 0. |
0 |
Returns:
Type | Description |
---|---|
int |
0 if successful, Error code if return value < 0 |
Source code in wyzecam/tutk/tutk.py
def iotc_initialize(tutk_platform_lib: CDLL, udp_port: int = 0) -> int:
"""Initialize IOTC module.
This function is used by devices or clients to initialize IOTC module and
shall be called before any IOTC module related function is invoked except
for IOTC_Set_Max_Session_Number().
The different between this function and IOTC_Initialize() is this function
uses following steps to connect masters (1) IP addresses of master (2) if
fails to connect in step 1, resolve predefined domain name of masters (3)
try to connect again with the resolved IP address of step 2 if IP is
resolved successfully.
:param tutk_platform_lib: The underlying c library (from tutk.load_library())
:param udp_port: Specify a UDP port. Random UDP port is used if it is specified as 0.
:return: 0 if successful, Error code if return value < 0
"""
errno: int = tutk_platform_lib.IOTC_Initialize2(udp_port)
return errno
iotc_session_check(tutk_platform_lib, session_id)
Used by a device or a client to check the IOTC session info.
A device or a client may use this function to check if the IOTC session is still alive as well as getting the IOTC session info.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
The underlying c library (from tutk.load_library()) |
required |
session_id |
c_int |
The session ID of the IOTC session to be checked |
required |
Returns:
Type | Description |
---|---|
Tuple[int, wyzecam.tutk.tutk.SInfoStruct] |
The session info of specified IOTC session |
Source code in wyzecam/tutk/tutk.py
def iotc_session_check(
tutk_platform_lib: CDLL, session_id: c_int
) -> typing.Tuple[int, SInfoStruct]:
"""Used by a device or a client to check the IOTC session info.
A device or a client may use this function to check if the IOTC session is
still alive as well as getting the IOTC session info.
:param tutk_platform_lib: The underlying c library (from tutk.load_library())
:param session_id: The session ID of the IOTC session to be checked
:return: The session info of specified IOTC session
"""
sess_info = SInfoStruct()
err_code = tutk_platform_lib.IOTC_Session_Check(
session_id, pointer(sess_info)
)
return err_code, sess_info
iotc_session_close(tutk_platform_lib, session_id)
Used by a device or a client to close a IOTC session.
A device or a client uses this function to close a IOTC session specified by its session ID if this IOTC session is no longer required.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tutk_platform_lib |
CDLL |
the c library loaded from the 'load_library' call. |
required |
session_id |
c_int |
The session ID of the IOTC session to start AV client |
required |
Source code in wyzecam/tutk/tutk.py
def iotc_session_close(tutk_platform_lib: CDLL, session_id: c_int) -> None:
"""Used by a device or a client to close a IOTC session.
A device or a client uses this function to close a IOTC session specified
by its session ID if this IOTC session is no longer required.
:param tutk_platform_lib: the c library loaded from the 'load_library' call.
:param session_id: The session ID of the IOTC session to start AV client
"""
tutk_platform_lib.IOTC_Session_Close(session_id)
iotc_set_log_path(tutk_platform_lib, path)
Set path of log file.
Set the absolute path of log file
Source code in wyzecam/tutk/tutk.py
def iotc_set_log_path(tutk_platform_lib: CDLL, path: str) -> None:
"""Set path of log file.
Set the absolute path of log file
"""
tutk_platform_lib.IOTC_Set_Log_Path(
c_char_p(path.encode("ascii")), c_int(0)
)
load_library(shared_lib_path=None)
Load the underlying iotc library
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shared_lib_path |
Optional[str] |
the path to the shared library libIOTCAPIs_ALL |
None |
Returns:
Type | Description |
---|---|
CDLL |
the tutk_platform_lib, suitable for passing to other functions in this module |
Source code in wyzecam/tutk/tutk.py
def load_library(
shared_lib_path: Optional[str] = None,
) -> CDLL:
"""Load the underlying iotc library
:param shared_lib_path: the path to the shared library libIOTCAPIs_ALL
:return: the tutk_platform_lib, suitable for passing to other functions in this module
"""
if shared_lib_path is None:
if pathlib.Path("/usr/local/lib/libIOTCAPIs_ALL.dylib").exists():
shared_lib_path = "/usr/local/lib/libIOTCAPIs_ALL.dylib"
if pathlib.Path("/usr/local/lib/libIOTCAPIs_ALL.so").exists():
shared_lib_path = "/usr/local/lib/libIOTCAPIs_ALL.so"
if shared_lib_path is None:
raise RuntimeError(
"Could not find libIOTCAPIs_ALL shared library. See documentation, "
"or specify the full path as an argument to load_library()."
)
return cdll.LoadLibrary(shared_lib_path)