Package: cloud-toolkit
Cloud Device Management ToolkitSupportazure iotedgelist/get device/module infolist/get/edit device/module twinsubscribe device D2C messageinvoke device/module direct commandazure iot devicelist/get device infolist/get/edit device twinsubscribe device D2C messageinvoke device direct commandaws iot devicelist/get thing infolist/get/edit thing shadowsubscribe device D2C messageinvoke thing jobaws greengrass (TODO)aliyun (TODO)Setupgit clone this repocd to this folderedit auth configuration(setting.ini):#--------------------------------------------------------------------------------# aws credentials help# - access_key_id, secret_access_key#   * https://aws.amazon.com/tw/premiumsupport/knowledge-center/create-access-key/# - root_ca_path#   * https://www.amazontrust.com/repository/AmazonRootCA1.pem#--------------------------------------------------------------------------------[aws]region_name=ap-northeast-1host=test.iot.ap-northeast-1.amazonaws.comaccess_key_id=testsecret_access_key=testfleet_indexing=trueroot_ca_path=./aws/awsRootCA.crt#--------------------------------------------------------------------------------------------------------------------------# azure credentials help  (using the Azure CLI from cloud shell, https://docs.microsoft.com/zh-tw/azure/cloud-shell/quickstart)# - connection_string#   * az iot hub show-connection-string --name MyIotHub# - eventhub_connection_string#   * Endpoint#      - az iot hub show --query properties.eventHubEndpoints.events.endpoint --name {your IoT Hub name}#   * EntityPath#      - az iot hub show --query properties.eventHubEndpoints.events.path --name {your IoT Hub name}#   * SharedAccessKey for the SharedAccessKeyName="service"#      - az iot hub policy show --name service --query primaryKey --hub-name {your IoT Hub name}#--------------------------------------------------------------------------------------------------------------------------[azure]connection_string=HostName=${HostName};SharedAccessKeyName=${SharedAccessKeyName};SharedAccessKey=${SharedAccessKey}eventhub_connection_string=Endpoint=${Endpoint};SharedAccessKeyName=${SharedAccessKeyName};SharedAccessKey=${SharedAccessKey};EntityPath=${EntityPath}consumer_group=$defaultenter envdockerrun-it--rm--namesample-cli\-v$(pwd):/data--nethost\bibbylong/device-mgmt:1.0.9-amd64bashpython3./sample.py-hor run by docker-composedocker-composerun--rmsample-hSamplesourcehelp~python3./sample.py-h
usage:sample.py[-h][-tTARGET][-mMODE][-TTOPIC][-DDEVICE][-CCOMMAND_NAME][-PCOMMAND_PAYLOAD][-SDESIRED_PAYLOAD][--pretty]optionalarguments:-h,--helpshowthishelpmessageandexit-tTARGET,--targetTARGETconnectiontarget-mMODE,--modeMODEOperationmodes:['subscribe','list','command','device','desired']-TTOPIC,--topicTOPICTargetedtopic-DDEVICE,--deviceDEVICEcontroldevice-CCOMMAND_NAME,--commandCOMMAND_NAMEcontrolcommandname-PCOMMAND_PAYLOAD,--payloadCOMMAND_PAYLOADcontrolcommandpayload-SDESIRED_PAYLOAD,--desired_payloadDESIRED_PAYLOADdesiredpayload--prettyprettyjsonoutputlist devices~python3./sample.py--pretty\-tazure\-mlist[{"name":"mydev1","desired":{},"reported":{},"timestamp":"0001-01-01T00:00:00Z","connected":false}]get device~python3./sample.py--pretty\-tazure\-mdevice\-Dmydev1{"name":"mydev1","desired":{},"reported":{},"timestamp":"0001-01-01T00:00:00Z","connected":false}get module under device (azure)~python3./sample.py--pretty\-tazure\-mdevice\-Dmydev1?module=myModule{"name":"mydev1?module=myModule","desired":{},"reported":{},"timestamp":"0001-01-01T00:00:00Z","connected":false}update device twin~python3./sample.py\-tazure\-mdesired\-Dmydev1\--desired_payload'{"enable":true}'200update module twin (azure)python3./sample.py\-tazure\-mdesired\-Dmydev1?module=myModule\--desired_payload'{"enable":true}'subscribe D2C messageall message~python3./sample.py-tazure-msubscribe-T'#'specify topic~python3./sample.py-tazure-msubscribe-T'test'specify device (azure)~python3./sample.py-tazure-msubscribe-T'mydev'invoke method~python3./sample.py--pretty\-tazure\-mcommand\-Dmydev1\-Capi-v1\-P'{"path":"/device/ethernets","method":"GET"}'code:200response:{"data":[{"id":1,"enable":true,"ip":"192.168.3.3"},{"id":2,"enable":true,"ip":"192.168.3.4"}]}module under device (azure)~python3./sample.py--pretty\-tazure\-mcommand\-Dmydev1?module=myModule\-Capi-v1\-P'{"path":"/device/ethernets","method":"GET"}'Cloud Device Management Consoledocker-composerun--rmdevice-mgmt-taws