Giter VIP home page Giter VIP logo

iotc-explorer's Introduction

PLEASE NOTE, THIS PROJECT HAS BEEN DEPRECATED

iotc-explorer is soon to be retired, and has been replaced by the Azure CLI IoT Extension.

iotc-explorer

Build Status NPM version

Command-line interface for interacting with Azure IoT Central devices and applications.

Prerequisites

  • Node.js version 8.x or higher - https://nodejs.org
  • You will need Administrator access in IoT Central to generate an access token

Installing iotc-explorer

Run the following command from your command line to install:

npm install -g iotc-explorer

NOTE: You will typically need to run the install command with sudo in Unix-like environments.

Once installed, you can run iotc-explorer --help to verify everything is working and get an overview of the available commands:

$ iotc-explorer --help

iotc-explorer <command>

Commands:
  iotc-explorer config                       Manage configuration values for the CLI
  iotc-explorer get-twin <deviceId>          Get the IoT Hub device twin for a specific device
  iotc-explorer login [token]                Log in to an Azure IoT Central application
  iotc-explorer logout                       Log out of the Azure IoT Central application by clearing
                                             the saved login token
  iotc-explorer monitor-messages [deviceId]  Monitor messages being sent to a specific device (if
                                             device id is provided), or all devices

Options:
  --version  Show version number                                                           [boolean]
  --help     Show help                                                                     [boolean]

Running iotc-explorer

Below are some commands and common options that you can run when using iotc-explorer. To view the full set of commands and options, you can pass --help to iotc-explorer or any of its subcommands.

Login

Before you get going, you need to have an administrator of your IoT Central application to get an access token for you to use. The administrator takes the following steps:

  • Go to Administration/Access Tokens.
  • Click Generate, and enter a Token name.
  • Click Next, and copy the Token value.

NOTE: The token value will only be shown once, so it must be copied before closing the dialog. After closing the dialog, it will never be shown again.

You can then use that token to log in to the CLI by running:

iotc-explorer login "<Token value>"

If you would rather not have the token persisted in your shell history, you can leave the token out and instead provide it when prompted:

iotc-explorer login

Monitor Device Messages

You can watch the messages coming from either a specific device or all devices in your application using the monitor-messages command. This will start a watcher that will continuously output new messages as they come in.

To watch all devices in your application, run the following command:

iotc-explorer monitor-messages

To watch a specific device, just add the Device ID to the end of the command:

iotc-explorer monitor-messages <your-device-id>

You can also have the command output a more machine-friendly format by adding the --raw option to the command:

iotc-explorer monitor-messages --raw

You can also turn off colored output by adding the --no-color option to the command:

iotc-explorer monitor-messages --no-color

Get Device Twin

You can use the get-twin command to get the contents of the twin for an IoT Central device. To do so, run the following command:

iotc-explorer get-twin <your-device-id>

As with monitor-messages, you can get a more machine-friendly output by passing the --raw option:

iotc-explorer get-twin <your-device-id> --raw

As with monitor-messages, you can also turn off colored output by passing the --no-color option:

iotc-explorer get-twin <your-device-id> --no-color

Config

To set, get, remove or list config settings, run the following commands:

iotc-explorer config set <key> <value>
iotc-explorer config get <key>
iotc-explorer config delete <key>
iotc-explorer config list

Allowed config values:

Config key Config value type Description
log.color boolean Default value on whether to print JSON data in colored format. Can be overwritten for an individual CLI call by setting --color/--no-color option.
log.raw boolean Default value on whether to print JSON data in raw format. Can be overwritten for an individual CLI call by setting --raw/--no-raw option.

Logout

To remove your saved login credentials, run the following command:

iotc-explorer logout

Contributing

Developer Setup

For your first time setup, make sure you've done the following:

  1. Make sure you have the prerequisites installed.
  2. Clone this repository to wherever you want to develop.
  3. Run cd iotc-explorer to enter the repository folder.
  4. Run npm install, then npm run build to get things configured.

Writing Code

Once you're ready to start changing code, it is recommended that you link your project to the iotc-explorer executable by running the following (may require sudo):

npm link

Now, when you run iotc-explorer, it will point to the code in your development folder. To make the executable reflect your changes as they're made, set up a watch task in a terminal window to the side:

npm run watch

Now, whenever you make edits to the code you will be able to use them by running the iotc-explorer command on your machine.

When you're ready to stop local development, you can remove your connection to the iotc-explorer executable by running the following (may require sudo):

npm unlink

Committing

This project uses the Angular commit style for generating changelogs and determining release versions. Any pull request with commits that don't follow this style will fail continuous integration. If you're not familiar with the style, you can run the following instead of the standard git commit to get a guided walkthrough to generating your commit message:

npm run commit

Releasing

When it's time to cut a new release, run the following from the repository folder. This will (1) fetch the latest updates, (2) automatically update the package version and the changelog, (3) publish the package and (4) push the changes back into the repository:

git checkout master
git pull
npm test
npm run release
git push --follow-tags
npm publish

Contributor License Agreement

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

iotc-explorer's People

Contributors

jackbk avatar microsoftopensource avatar msftgits avatar princjef avatar rahulch95 avatar viv-liu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iotc-explorer's Issues

Can not connect preview application

When connect to (pnp) preview application, I got error.

C:\>iotc-explorer login "SharedAccessSignature sr=xxxxxxxx-933c-420d-9ba6-7191c2c306b6&sig=HsQBv5EsQiiAUNW9Yiea%2B1MrWma8%2BVG8DLm%2BwhlJbWM%3D&skn=test&se=1607599693562"
Error: IoT Central API call failed with message Authorization token does not have access to path. [IOTC_API_ERROR]

C:\>

Confusing error when not logged in

When a user has never logged in (or has logged out), they receive the following error when trying to run a command that requires them to be logged in:

Error: Invalid credentials. Please login and then retry this action [INVALID_CREDENTIALS]

This is confusing because it implies that the user has logged in but their credentials are invalid, when the real error is that there are no credentials. We should distinguish between these two cases so that the messaging is clearer.

Details

  • Operating System type and version: Windows 10
  • Output of iotc-explorer --version: 1.0.1
  • Output of node -v: 8.12.0

Steps to reproduce

  1. Run iotc-explorer logout if you were logged in.
  2. Run iotc-explorer get-twin abc to see the error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.