Cycle of articles "Cross-platform IoT"
1. Cross-platform IoT: Using Azure CLI and Azure IoT Hub
2. Cross-platform IoT: Device Operations
3. Cross-platform IoT: Troubleshooting
3. Loading ...
npm install -g iothub-explorer
iothub-explorer login "HostName=yourhub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=yourkey"
az iot hub show-connection-string -g youresourcegroup
command, and get the connection string of your IoT Hub. The authorization team should open a temporary session with a fixed policy of access rights to the IoT center. By default, the life of this session is 1 hour. Session started, expires on Wed Mar 15 2017 19:59:05 GMT-0500 (CDT) Session file: /Users/niksac/Library/Application Support/iothub-explorer/config
iothub-explorer create -a
deviceId: youdeviceId generationId: 63624558311459675 connectionState: Disconnected status: enabled statusReason: null connectionStateUpdatedTime: 0001-01-01T00:00:00 statusUpdatedTime: 0001-01-01T00:00:00 lastActivityTime: 0001-01-01T00:00:00 cloudToDeviceMessageCount: 0 authentication: symmetricKey: primaryKey: symmetrickey1= secondaryKey: symmetrickey2= x509Thumprint: primaryThumbprint: null secondaryThumbprint: null connectionString: HostName=youriothub.azure-devices.net;DeviceId=youdeviceId;SharedAccessKey=symmetrickey=
connectionString
. It provides a unique device connection string and allows you to communicate with it. The privileges for the device connection string are based on the policy defined for the device in the IoT Center, the rights are limited only by the DeviceConnect
function. Policy based access protects our endpoints and limits the scope of use to a particular device. Learn more about the security of the IoT Hub device here. Also note that the device is activated and the status is disabled. This means that the device was successfully registered in the IoT Center, but it does not have active connections.simulate-device
command. The simulate-device
command allows the tool to act as a device command simulator and device receive simulator. This can be used to send user-defined telemetry messages or commands on behalf of the device. The convenience of this functionality is manifested when testing the integrity of the developments on your device, as this will reduce the amount of code. You can simultaneously create messages and track the send / receive stream. The command also provides features such as send-interval, send-count
and receive-count
, which allow you to configure simulations. It is worth considering that this is not a tool to test the load or penetration, it can be used to conduct initial tests, anticipating more in-depth tests. Let's send a set of messages to the device we created (from part 1) and then accept the message with the command. niksac$ iothub-explorer simulate-device --send "Hello from IoT Hub Explorer" --device-connection-string "HostName=youriothubname.azure-devices.net;DeviceId=D1234;SharedAccessKey==" --send-count 5 --send-interval 2000
Message #0 sent successfully Message #1 sent successfully Message #2 sent successfully Message #3 sent successfully Message #4 sent successfully Device simulation finished.
iothub-explorer monitor-events --login "HostName=youriothub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=="
simulate-device --send
, the following result should appear in the terminal: Monitoring events from all devices... ==== From: D1234 ==== Hello from IoT Hub Explorer ==================== ==== From: D1234 ==== Hello from IoT Hub Explorer ==================== ==== From: D1234 ==== Hello from IoT Hub Explorer ==================== ==== From: D1234 ==== Hello from IoT Hub Explorer ==================== ==== From: D1234 ==== Hello from IoT Hub Explorer ====================
Source: https://habr.com/ru/post/343802/
All Articles