Merge branch 'master' of https://github.com/iot-for-all/iotc-python-client into master
This commit is contained in:
Коммит
e6d8b8c87d
|
@ -1,3 +1,7 @@
|
|||
1.0.4 (2020-10-07)
|
||||
------------------
|
||||
- fix property report with value wrapped
|
||||
|
||||
1.0.3 (2020-06-17)
|
||||
------------------
|
||||
- remove wrong dependency
|
||||
|
|
12
README.md
12
README.md
|
@ -87,11 +87,11 @@ from iotc.aio import IoTCClient
|
|||
|
||||
#### X509
|
||||
```py
|
||||
scopeId = 'scopeID';
|
||||
scope_id = 'scope_id';
|
||||
device_id = 'device_id';
|
||||
key = {'certFile':'<CERT_CHAIN_FILE_PATH>','keyFile':'<CERT_KEY_FILE_PATH>','certPhrase':'<CERT_PASSWORD>'}
|
||||
|
||||
iotc = IoTCClient(device_id, scopeId,
|
||||
iotc = IoTCClient(device_id, scope_id,
|
||||
IOTCConnectType.IOTC_CONNECT_X509_CERT, key)
|
||||
```
|
||||
IOTCConnectType enum can be imported from the same module of IoTCClient
|
||||
|
@ -108,7 +108,7 @@ device_id = 'device_id'
|
|||
sasKey = 'masterKey' # or use device key directly
|
||||
|
||||
iotc = IoTCClient(device_id, scopeId,
|
||||
IOTCConnectType.IOTC_CONNECT_SYMM_KEY, sasKey)
|
||||
IOTCConnectType.IOTC_CONNECT_SYMM_KEY, sas_key)
|
||||
```
|
||||
IOTCConnectType enum can be imported from the same module of IoTCClient
|
||||
|
||||
|
@ -216,7 +216,7 @@ A device can send custom data during provision process: if a device is aware of
|
|||
|
||||
### How to set IoTC template ID in your device
|
||||
Template Id can be found in the device explorer page of IoTCentral
|
||||
![Img](assets/modelId.jpg)
|
||||
![Img](https://github.com/iot-for-all/iotc-python-client/raw/master/assets/modelId.jpg)
|
||||
|
||||
Then call this method before connect():
|
||||
|
||||
|
@ -227,14 +227,14 @@ iotc.set_model_id('<modelId>')
|
|||
### Manual approval (default)
|
||||
By default device auto-approval in IoT Central is disabled, which means that administrator needs to approve the device registration to complete the provisioning process.
|
||||
This can be done from explorer page after selecting the device
|
||||
![Img](assets/manual_approval.jpg)
|
||||
![Img](https://github.com/iot-for-all/iotc-python-client/raw/master/assets/manual_approval.jpg)
|
||||
|
||||
|
||||
### Automatic approval
|
||||
To change default behavior, administrator can enable device auto-approval from Device Connection page under the Administration section.
|
||||
With automatic approval a device can be provisioned without any manual action and can start sending/receiving data after status changes to "Provisioned"
|
||||
|
||||
![Img](assets/auto_approval.jpg)
|
||||
![Img](https://github.com/iot-for-all/iotc-python-client/raw/master/assets/auto_approval.jpg)
|
||||
|
||||
## License
|
||||
This samples is licensed with the MIT license. For more information, see [LICENSE](./LICENSE)
|
||||
|
|
|
@ -56,9 +56,9 @@ async def main():
|
|||
await client.connect()
|
||||
while client.is_connected():
|
||||
await client.send_telemetry({
|
||||
't777b192a': str(randint(20, 45)),
|
||||
'h6941c57b': str(randint(20, 45)),
|
||||
"b2fba1eb1": str(randint(20, 45))
|
||||
'accelerometerX': str(randint(20, 45)),
|
||||
'accelerometerY': str(randint(20, 45)),
|
||||
"accelerometerZ": str(randint(20, 45))
|
||||
})
|
||||
await asyncio.sleep(3)
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -5,7 +5,7 @@ import sys
|
|||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
version = "1.0.3"
|
||||
version = "1.0.4"
|
||||
|
||||
setuptools.setup(
|
||||
name='iotc',
|
||||
|
|
|
@ -209,10 +209,11 @@ class IoTCClient(AbstractClient):
|
|||
self._logger.debug('Acknowledging {}'.format(prop))
|
||||
self.send_property({
|
||||
'{}'.format(prop): {
|
||||
"value": patch[prop]["value"],
|
||||
'status': 'completed',
|
||||
'desiredVersion': patch['$version'],
|
||||
'message': 'Property received'}
|
||||
"ac": 200,
|
||||
"ad": 'Property received',
|
||||
"av": patch['$version'],
|
||||
"value": patch[prop]["value"]
|
||||
}
|
||||
})
|
||||
else:
|
||||
self._logger.debug(
|
||||
|
|
|
@ -92,10 +92,10 @@ class IoTCClient(AbstractClient):
|
|||
await self._logger.debug('Acknowledging {}'.format(prop))
|
||||
await self.send_property({
|
||||
'{}'.format(prop): {
|
||||
"value": patch[prop]["value"],
|
||||
'status': 'completed',
|
||||
'desiredVersion': patch['$version'],
|
||||
'message': 'Property received'}
|
||||
"ac": 200,
|
||||
"ad": 'Property received',
|
||||
"av": patch['$version'],
|
||||
"value": patch[prop]["value"]}
|
||||
})
|
||||
else:
|
||||
await self._logger.debug(
|
||||
|
|
Загрузка…
Ссылка в новой задаче