-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsa.py
55 lines (39 loc) · 1.59 KB
/
sa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import random
from iottalkpy.dan import NoData
### The registeration api url, you can use IP or Domain.
api_url = 'http://localhost:9992' # default
# api_url = 'http://localhost/csm' # with URL prefix
# api_url = 'http://localhost:9992/csm' # with URL prefix + port
### [OPTIONAL] If not given or None, server will auto-generate.
# device_name = 'Dummy_Test'
### [OPTIONAL] If not given or None, DAN will register using a random UUID.
### Or you can use following code to use MAC address for device_addr.
# from uuid import getnode
# device_addr = "{:012X}".format(getnode())
# device_addr = "..."
### [OPTIONAL] If the device_addr is set as a fixed value, user can enable
### this option and make the DA register/deregister without rebinding on GUI
# persistent_binding = True
### [OPTIONAL] If not given or None, this device will be used by anyone.
# username = 'myname'
### The Device Model in IoTtalk, please check IoTtalk document.
device_model = 'Dummy_Device'
### The input/output device features, please check IoTtalk document.
idf_list = ['DummySensor-I']
odf_list = ['DummyControl-O']
### Set the push interval, default = 1 (sec)
### Or you can set to 0, and control in your feature input function.
push_interval = 10 # global interval
interval = {
'Dummy_Sensor': 3, # assign feature interval
}
def on_register(dan):
print('register successfully')
def DummySensor_I():
return random.randint(0, 100)
# Or you want to return nothing.
# Note that the object `None` is treated as normal data in IoTtalk
#
# return NoData
def DummyControl_O(data: list):
print(str(data[0]))