Je regarde le GitHub README de AWS IoT Device SDK for Python, en pensant que la fonction d'approvisionnement de flotte d'AWS IoT semble intéressante. Quand ## New Version Available Le personnage est !!!
Le kit SDK AWS IoT pour Python v2 est sorti.
https://github.com/aws/aws-iot-device-sdk-python-v2
(Je ne sais pas s'il s'appelle ʻAWS IoT SDK for Python v2 ou ʻaws-iot-device-sdk-python-v2
ou ʻAWS IoT Client SDK for Python`)
Selon README
This SDK is built on the AWS Common Runtime, a collection of libraries written in C to be cross-platform, high-performance, secure, and reliable.
C'est vrai.
De plus, la v2 prend déjà en charge l'API de provisioning de flotte et inclut des exemples. La v2 sera-t-elle le courant dominant à l'avenir?
J'ai essayé le même contenu dans la v2 que l'exemple présenté sur le blog AWS.
[Comment utiliser le provisionnement de flotte pour automatiser la configuration initiale des appareils IoT et AWS IoT Core](https://aws.amazon.com/jp/blogs/news/how-to-automate-onboarding-of-iot- devices-to-aws-iot-core-at-scale-with-flotte-provisioning /)
Mac Python 3.8.2
git clone https://github.com/aws/aws-iot-device-sdk-python-v2.git
pip install ./aws-iot-device-sdk-python-v2
J'ai placé le certificat à l'emplacement suivant.
console
.
├── aws-iot-device-sdk-python-v2
└── certs
├── bootstrap-certificate.pem.crt
├── bootstrap-private.pem.key
└── root.ca.pem
Veuillez bien modifier templateName
et templateParameters
.
cd aws-iot-device-sdk-python-v2/samples/
python fleetprovisioning.py \
--endpoint xxxxxxxxxx.iot.ap-northeast-1.amazonaws.com \
--root-ca ../../certs/root.ca.pem \
--cert ../../certs/bootstrap-certificate.pem.crt \
--key ../../certs/bootstrap-private.pem.key \
--templateName production_template \
--templateParameters '{"SerialNumber": 9999, "hasValidAccount": false}'
Résultat de l'exécution (je suis allongé ou cassé par endroits)
Connecting to xxxxxxxxxx.iot.ap-northeast-1.amazonaws.com with client ID 'samples-client-id'...
Connected!
Subscribing to CreateKeysAndCertificate Accepted topic...
Subscribing to CreateKeysAndCertificate Rejected topic...
Subscribing to RegisterThing Accepted topic...
Subscribing to RegisterThing Rejected topic...
Publishing to CreateKeysAndCertificate...
Waiting... CreateKeysAndCertificateResponse: null
Published CreateKeysAndCertificate request..
Received a new message awsiot.iotidentity.CreateKeysAndCertificateResponse(certificate_id='xxxxxxxxxx', certificate_ownership_token='xxxxxxxxxx', certificate_pem='-----BEGIN CERTIFICATE-----\nxxxxxxxxxx\n-----END CERTIFICATE-----\n', private_key='-----BEGIN RSA PRIVATE KEY-----\nxxxxxxxxxx\n-----END RSA PRIVATE KEY-----\n')
Publishing to RegisterThing topic...
Waiting... RegisterThingResponse: null
Published RegisterThing request..
Received a new message awsiot.iotidentity.RegisterThingResponse(device_configuration={}, thing_name='born_9999')
Exiting Sample: success
Disconnecting...
Disconnected.
https://docs.aws.amazon.com/ja_jp/iot/latest/developerguide/provision-wo-cert.html https://aws.amazon.com/jp/about-aws/whats-new/2020/04/announcing-general-availability-of-aws-iot-core-fleet-provisioning/ https://aws.amazon.com/jp/blogs/news/how-to-automate-onboarding-of-iot-devices-to-aws-iot-core-at-scale-with-fleet-provisioning/ https://qiita.com/tatsuhiroiida/items/46ef5035f99b304d3d6f
Recommended Posts