You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
:param binding_secret: Binding secret to be used for binding the device
9
-
:raises AnedyaInvalidConfig: If the configuration is not provided
10
-
:raises AnedyaTxFailure: If the transaction fails
8
+
Call this function to bind a device with the Anedya platform
11
9
12
-
This function provides a way to bind a device to the Anedya platform.
10
+
Args:
11
+
binding_secret (str): A one time Binding secret obtained from the platform. This secret is usually passed to device during provisioning process through
12
+
mobile app or any other process.
13
+
timeout (float | None, optional): Time out in seconds for the request. In production setup it is advisable to use a timeout or else your program can get stuck indefinitely. Defaults to None.
14
+
15
+
Raises:
16
+
AnedyaInvalidConfig: Method can raise this method if either configuration is not provided or if the connection mode is invalid.
17
+
AnedyaTxFailure: Method can raise this method if the transaction fails.
18
+
19
+
Returns:
20
+
bool: Returns true if the device is successfully bound with the platform.
13
21
"""
14
22
ifself._configisNone:
15
23
raiseAnedyaInvalidConfig('Configuration not provided')
:param data: Data to send as a :class: DataPoints object
10
-
:param timeout: Timeout in seconds, default is None
9
+
Submit data to Anedya Platform.
11
10
12
-
:raises AnedyaTxFailure: If data could not be submitted due to an error
11
+
Args:
12
+
data (DataPoints): Datapoints object, you can submit multiple types of variable in single request.
13
+
timeout (float | None, optional): Time out in seconds for the request. In production setup it is advisable to use a timeout or else your program can get stuck indefinitely. Defaults to None.
13
14
14
-
This function sends data to the Anedya Cloud platform. It determines the connection mode from the SDK configuration and calls the appropriate submit data method (_submit_data_http or _submit_data_mqtt).
15
+
Raises:
16
+
AnedyaInvalidConfig: Method can raise this method if either configuration is not provided or if the connection mode is invalid.
17
+
AnedyaTxFailure: Method can raise this method if the transaction fails.
:param logs: Logs to be send. :class: LogCache format.
10
-
:param timeout: Timeout in seconds, default is None.
9
+
Submit logs to Anedya
10
+
11
+
Args:
12
+
logs (LogsCache): Logs
13
+
timeout (float | None, optional): Time out in seconds for the request. In production setup it is advisable to use a timeout or else your program can get stuck indefinitely. Defaults to None.
14
+
15
+
Raises:
16
+
AnedyaInvalidConfig: Method can raise this method if either configuration is not provided or if the connection mode is invalid.
17
+
AnedyaTxFailure: Method can raise this method if the transaction fails.
11
18
"""
12
19
ifself._configisNone:
13
20
raiseAnedyaInvalidConfig('Configuration not provided')
Copy file name to clipboardExpand all lines: src/anedya/client/timeSync.py
+15-8Lines changed: 15 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,19 @@
4
4
importtime
5
5
6
6
7
-
defget_time(self, timeout: float|None=None):
7
+
defget_time(self, timeout: float|None=None)->int:
8
8
"""
9
-
Get current time from Anedya Time Service using HTTP request -
10
-
Gets current time using HTTP requests.
11
-
Accuracy is generally within few tens of millisecond. For greater accuracy
12
-
consider using NTP time service from Anedya
9
+
Fetch the time information from Anedya.
10
+
11
+
Args:
12
+
timeout (float | None, optional): Time out in seconds for the request. In production setup it is advisable to use a timeout or else your program can get stuck indefinitely. Defaults to None.
13
+
14
+
Raises:
15
+
AnedyaInvalidConfig: Method can raise this method if either configuration is not provided or if the connection mode is invalid.
16
+
AnedyaTxFailure: Method can raise this method if the transaction fails.
17
+
18
+
Returns:
19
+
int: The method returns the current time in Unix millisecond epoch in UTC timezone
13
20
"""
14
21
ifself._configisNone:
15
22
raiseAnedyaInvalidConfig('Configuration not provided')
Copy file name to clipboardExpand all lines: src/anedya/config.py
+32-26Lines changed: 32 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
fromenumimportEnum
2
2
importuuid
3
3
from .errorsimportAnedyaInvalidConfig
4
+
fromtypingimportCallable
4
5
5
6
6
7
classConnectionMode(Enum):
@@ -18,6 +19,10 @@ class Encoding(Enum):
18
19
CBOR="CBOR"
19
20
20
21
22
+
classRegionCode(Enum):
23
+
AP_IN_1="ap-in-1"
24
+
25
+
21
26
classAnedyaConfig:
22
27
def__init__(self):
23
28
"""
@@ -52,57 +57,58 @@ def __init__(self):
52
57
self._security_set=False
53
58
self._testmode=False
54
59
55
-
defset_connection_key(self, key):
60
+
defset_connection_key(self, key: str):
56
61
"""
57
-
Set a connection key
62
+
This method sets the connection key for the client
63
+
64
+
Args:
65
+
key (str): Connection key for the client
58
66
"""
59
67
self.connection_key=key
60
68
61
69
defset_deviceid(self, id: str):
62
70
"""
63
-
Set DeviceID
71
+
This method sets the device ID for the client
72
+
73
+
Args:
74
+
id (str): A Unique physical device ID which should not change for the entire lifetime of the device. Requires a valid UUID
75
+
76
+
Raises:
77
+
AnedyaInvalidConfig: The provided device ID should be a valid UUID, otherwise this exception will be raised
64
78
"""
65
79
try:
66
80
self._deviceID=uuid.UUID(id)
67
81
exceptValueError:
68
82
raiseAnedyaInvalidConfig("Device ID needs to be valid UUID")
69
83
self._deviceid_set=True
70
84
71
-
defset_timeout(self, timeout):
72
-
"""
73
-
Set timeout for automatic flush of the data
74
-
"""
75
-
self.timeout=timeout
76
-
77
-
defset_maxbuffer_size(self, buffersize):
85
+
defset_region(self, region: RegionCode):
78
86
"""
79
-
Set maximum buffer size
80
-
"""
81
-
self.max_buffer_size=buffersize
87
+
This method sets the region for the client
82
88
83
-
defset_region(self, region):
84
-
"""
85
-
Set region
89
+
Args:
90
+
region (RegionCode): Set the regioncode where your Anedya project is created.
86
91
"""
87
92
self.region=region
88
93
89
-
defset_on_connect(self, callback):
94
+
defset_on_connect(self, callback: Callable[[],]):
90
95
"""
91
-
Set on connect callback
96
+
You can use this function to set a callback function that will be called when the connection is established.
97
+
98
+
Args:
99
+
callback (Callable[[],]): A function which will be called when the connection is established. Please note that callback functions should not be blocking.
You can use this function to set a callback function that will be called when the connection is disconnected. This callback will be called for both intentional
106
+
and unintentional disconnections.
100
107
101
-
defset_on_message(self, callback):
102
-
"""
103
-
Set on message callback
108
+
Args:
109
+
callback (Callable[[],]): A function which will be called when the connection is disconnected. Please note that callback functions should not be blocking.
0 commit comments