14
14
from iotc import IOTCConnectType , IOTCLogLevel , IOTCEvents
15
15
from iotc .aio import IoTCClient
16
16
17
- device_id = config ['DEVICE_A ' ]['DeviceId' ]
18
- scope_id = config ['DEVICE_A ' ]['ScopeId' ]
19
- key = config ['DEVICE_A ' ]['DeviceKey' ]
17
+ device_id = config ['DEVICE_M3 ' ]['DeviceId' ]
18
+ scope_id = config ['DEVICE_M3 ' ]['ScopeId' ]
19
+ key = config ['DEVICE_M3 ' ]['DeviceKey' ]
20
20
21
21
# optional model Id for auto-provisioning
22
22
try :
23
- model_id = config ['DEVICE_A ' ]['ModelId' ]
23
+ model_id = config ['DEVICE_M3 ' ]['ModelId' ]
24
24
except :
25
25
model_id = None
26
26
@@ -40,7 +40,7 @@ async def on_enqueued_commands(command_name,command_data):
40
40
41
41
# change connect type to reflect the used key (device or group)
42
42
client = IoTCClient (device_id , scope_id ,
43
- IOTCConnectType .IOTC_CONNECT_DEVICE_KEY , key )
43
+ IOTCConnectType .IOTC_CONNECT_SYMM_KEY , key )
44
44
if model_id != None :
45
45
client .set_model_id (model_id )
46
46
@@ -51,15 +51,6 @@ async def on_enqueued_commands(command_name,command_data):
51
51
52
52
# iotc.setQosLevel(IOTQosLevel.IOTC_QOS_AT_MOST_ONCE)
53
53
54
- async def command_loop (device_client ):
55
- while True :
56
- # Wait for unknown method calls
57
- method_request = (await device_client .receive_method_request ())
58
- print ('Received command {}' .format (method_request .name ))
59
- await device_client .send_method_response (MethodResponse .create_from_method_request (
60
- method_request , 200 , {
61
- 'result' : True , 'data' : 'Command received' }
62
- ))
63
54
64
55
async def main ():
65
56
await client .connect ()
0 commit comments