Skip to content

Commit 8f13fa8

Browse files
author
ludruda
committed
fix group key
1 parent b381d64 commit 8f13fa8

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ _'certPhrase'_ is optional and represents the password for the certificate if an
103103

104104
#### SAS
105105
```py
106-
scopeId = 'scopeID';
107-
device_id = 'device_id';
108-
sasKey = 'masterKey'; # or use device key directly
106+
scopeId = 'scopeID'
107+
device_id = 'device_id'
108+
sasKey = 'masterKey' # or use device key directly
109109

110110
iotc = IoTCClient(device_id, scopeId,
111111
IOTCConnectType.IOTC_CONNECT_SYMM_KEY, sasKey)
@@ -221,7 +221,7 @@ Template Id can be found in the device explorer page of IoTCentral
221221
Then call this method before connect():
222222

223223
```py
224-
iotc.setModelId('<modelId>');
224+
iotc.set_model_id('<modelId>')
225225
```
226226

227227
### Manual approval (default)

samples/py3.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
from iotc import IOTCConnectType, IOTCLogLevel, IOTCEvents
1515
from iotc.aio import IoTCClient
1616

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']
2020

2121
# optional model Id for auto-provisioning
2222
try:
23-
model_id = config['DEVICE_A']['ModelId']
23+
model_id = config['DEVICE_M3']['ModelId']
2424
except:
2525
model_id = None
2626

@@ -40,7 +40,7 @@ async def on_enqueued_commands(command_name,command_data):
4040

4141
# change connect type to reflect the used key (device or group)
4242
client = IoTCClient(device_id, scope_id,
43-
IOTCConnectType.IOTC_CONNECT_DEVICE_KEY, key)
43+
IOTCConnectType.IOTC_CONNECT_SYMM_KEY, key)
4444
if model_id != None:
4545
client.set_model_id(model_id)
4646

@@ -51,15 +51,6 @@ async def on_enqueued_commands(command_name,command_data):
5151

5252
# iotc.setQosLevel(IOTQosLevel.IOTC_QOS_AT_MOST_ONCE)
5353

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-
))
6354

6455
async def main():
6556
await client.connect()

src/iotc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def connect(self):
311311

312312
if self._model_id:
313313
self._provisioning_client.provisioning_payload = {
314-
'iotcmodel_id': self._model_id}
314+
'iotcModelId': self._model_id}
315315
try:
316316
registration_result = self._provisioning_client.register()
317317
assigned_hub = registration_result.registration_state.assigned_hub

src/iotc/aio/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ async def connect(self):
198198
provisioning_host=self._global_endpoint, registration_id=self._device_id, id_scope=self._scope_id, x509=x509)
199199

200200
if self._model_id:
201+
print("Provision model Id")
201202
self._provisioning_client.provisioning_payload = {
202-
'iotcmodel_id': self._model_id}
203+
'iotcModelId': self._model_id}
203204
try:
204205
registration_result = await self._provisioning_client.register()
205206
assigned_hub = registration_result.registration_state.assigned_hub

0 commit comments

Comments
 (0)