GithubHelp home page GithubHelp logo

particle-iot / particle-cli Goto Github PK

View Code? Open in Web Editor NEW
212.0 58.0 92.0 56.3 MB

Command Line Interface for Particle Cloud and devices

License: Apache License 2.0

Makefile 0.02% JavaScript 92.46% Shell 0.46% C++ 6.37% C 0.03% Handlebars 0.05% NSIS 0.62%
particle photon electron cli iot argon boron bsom b5som tracker

particle-cli's Introduction

npm GitHub Actions License

Particle's full-stack Internet of Things (IoT) device platform gives you everything you need to securely and reliably connect your IoT devices to the web. For more details please visit www.particle.io.

Particle CLI

The Particle CLI is a powerful tool for interacting with your IoT devices and the Particle Cloud. The CLI uses node.js and can run on Windows, Mac OS X, and Linux. It's also open source so you can edit and change it, and even send in your changes as pull requests if you want to share!

Table of Contents

Installing

For end-users, the most up-to-date installation instructions can be found here: macOS / Linux | Windows

Note: Some commands may require openssl to be installed on your system. You can install it using your package manager (e.g. brew install openssl on macOS).

Getting Started

These next two commands are all you need to get started setting up an account, claiming a device, and discovering new features.

particle setup

Guides you through creating a new account, and claiming your device!

$ particle setup

particle help

Shows you what commands are available, and how to use them. You can also give the name of a command for detailed help.

$ particle help
$ particle help keys

particle update

If you wish to easily update Device OS on your device to a later version, you can use the particle update command. You can specify a version with the --target argument.

  1. Connect your device via USB
  2. Run particle update.

Command Reference

For the full list of commands, please see the CLI command reference.

Known Issues

  • The Wireless Photon Setup Wizard will only automatically switch networks on OS X. Users of other operating systems will need to manually connect their computer to the Photon's Wi-Fi. You will be prompted during the wizard when this is required.

Development

Currently development is supported on macOS only!

Installing

  1. Install Node.js [[email protected] and [email protected] are required]
  2. Clone this repository $ git clone [email protected]:particle-iot/particle-cli.git && cd ./particle-cli
  3. Install external tools: openssl (e.g. brew install openssl)
  4. Install dependencies $ npm install
  5. View available commands $ npm run
  6. Run the tests $ npm test
  7. Run the CLI $ npm start
  8. Start Hacking!

Running

When developing, run individual commands using:

$ npm start -- <command> <options> - e.g. $ npm start -- library view dotstar --readme

Anything after the -- delimiter is passed directly to the CLI (docs).

To test the source as it will be published:

  1. Register the particle command globally: $ npm link
  2. Run commands: $ particle --help (using standard argument formatting)

Testing

The Particle CLI has a number of automated test suites and related commands. The most important are:

  • npm test - run all tests (NOTE: End-To-End tests require additional setup)
  • npm run lint - run the linter and print any errors to your terminal
  • npm run test:ci - run all tests excluding device-dependent end-to-end test as CI does
  • npm run test:unit - run unit tests
  • npm run test:integration - run integration tests
  • npm run coverage - report code coverage stats

All tests use mocha, chai, and sinon with coverage handled by nyc.

We recommend running locally if you can as it greatly shortens your feedback loop. However, CI also runs against every PR and error reporting is publicly available.

CLI Packaging and Distribution

  • Cli is packaged using pkg. The packaging is done using GitHub Actions and the executables are uploaded to binaries.particle.io/particle-cli.
  • There are two installers that are created for the CLI:
    • Windows installer: particle-cli-setup.exe (This is an NSIS installer for Windows). You can see the installer script here ParticleCLISetup.nsi
    • Unix installer: install-cli (This is a shell script that installs the CLI on Unix systems). You can see the installer script here install-cli.sh
  • The installers are created using GitHub Actions and are uploaded to binaries.particle.io/particle-cli/installer.
  • The current supported platforms for the CLI are:
    • Windows
      • x64
    • macOS
      • x64
      • arm64
    • Linux
      • x64
      • arm64
      • arm

Releasing a new version

See RELEASE.md.

particle-cli's People

Contributors

avtolstoy avatar brycekahle avatar busticated avatar carloshdez avatar darcyparker avatar debbiegillespie avatar derekmpeterson avatar dmiddlecamp avatar endorama avatar harrisonhjones avatar hugomontero avatar hypnopompia avatar jameshagerman avatar joegoggins avatar keeramis avatar kennethlimcp avatar kylemarsh avatar m-mcgowan avatar markterrill avatar mebrunet avatar monkbroc avatar nikeee avatar rwaldron avatar scott-brust avatar sergeuz avatar suda avatar technobly avatar towynlin avatar wgbartley avatar wraithan avatar

Stargazers

 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

particle-cli's Issues

[Photon] `particle setup` crashes when entering an empty SSID

$ particle setup wifi
? Should I scan for nearby Wi-Fi networks? No
? SSID: 
? Security Type: WPA2
? Wi-Fi Password: 

/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:579
    throw e;
          ^
TypeError: Cannot read property 'ssid' of undefined
    at PromptUI.completed (/usr/local/lib/node_modules/particle-cli/commands/SerialCommand.js:349:41)
    at PromptUI.onCompletion (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/lib/ui/prompt.js:69:10)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.completed (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:1793:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:1730:14)
    at AnonymousObserver.tryCatcher (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:567:29)
    at AutoDetachObserverPrototype.completed (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:5288:56)
    at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:1730:14)
    at InnerObserver.onCompleted (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:3425:65)
    at InnerObserver.tryCatcher (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:567:29)
    at AutoDetachObserverPrototype.completed (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:5288:56)

It make no sense to continue with an empty SSID nor an empty password (with a "secured" WPA2, WPA or WEP security type).

It also crashes when choosing an empty SSID with an Unsecured security type (without password).

$ particle setup wifi
? Should I scan for nearby Wi-Fi networks? No
? SSID: 
? Security Type: Unsecured

/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:579
    throw e;
          ^
TypeError: Cannot read property 'ssid' of undefined
    at PromptUI.completed (/usr/local/lib/node_modules/particle-cli/commands/SerialCommand.js:349:41)
    at PromptUI.onCompletion (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/lib/ui/prompt.js:69:10)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.completed (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:1793:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:1730:14)
    at AnonymousObserver.tryCatcher (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:567:29)
    at AutoDetachObserverPrototype.completed (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:5288:56)
    at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:1730:14)
    at InnerObserver.onCompleted (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:3425:65)
    at InnerObserver.tryCatcher (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:567:29)
    at AutoDetachObserverPrototype.completed (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:5288:56)

Standardize wifi setup workflow

Using particle serial wifi on a Photon,

SSID --> Security --> Password

Using particle setup on a Photon,

SSID --> Password --> Security

`particle setup` doesn't work for a core

Setup process is broken for the Spark Core. Saw this issue on released 1.5.6 and 1.5.8. To reproduce error:

  1. particle setup
  2. Would you like to log in with a different account? No
  3. The program just exits, instead of proceeding to setup the core.

I did this with the CLI configured to the staging cloud (in case it's relevant)

`particle setup` without WiFi card

By default the particle setup tries to configure the Photon by WiFi using the Soft-AP mode, but I guess this option should not appear when the computer has no WiFi network interface.

In my case I'm running OSX without a WiFi card, and when running the particle setup I would have not other option than choosing No to the latest question shown below:

$ particle setup
                  _   _      _        _
 _ __   __ _ _ __| |_(_) ___| | ___  (_) ___
| '_ \ / _` | '__| __| |/ __| |/ _ \ | |/ _ \
| |_) | (_| | |  | |_| | (__| |  __/_| | (_) |
| .__/ \__,_|_|   \__|_|\___|_|\___(_)_|\___/
|_|                     https://particle.io/

> Setup is easy! Let's get started...
> It appears as though you are already logged in as [email protected]
? Would you like to log in with a different account? No

! PROTIP: Hold the MODE/SETUP button on your device until it blinks blue!
! PROTIP: Please make sure you are connected to the internet. 

> I have detected a Photon connected via USB.
? Would you like to continue with this one? Yes
! The Photon supports secure Wi-Fi setup. We'll try that first.

! PROTIP: Wireless setup of Photons works like a wizard!
! PROTIP: We will automagically change the Wi-Fi network to which your computer is connected.
! PROTIP: You may lose your connection to the internet for a moment.

> No nearby Photons detected. Try the `particle help` command for more information.
? Would you like to wait and monitor for Photons entering setup mode? No

> Ok, bye! Don't forget `particle help` if you're stuck! <3

If I choose Yes to the latest question, the script attempts forever to find a Photon by an inexistent WiFi connection:

...
? Would you like to wait and monitor for Photons entering setup mode? Yes
> Monitoring nearby Wi-Fi networks for Photons. This may take up to a minute.
* Waiting for a wild Photon to appear... (press ctrl + C to exit)

So, if it's not possible to autodetect the presence of a WiFi card in the current computer, why don't you just enter in the manual WiFi credentials setup after choosing Noin the latest question... as it would apprear when executing particle setup wifi:

$ particle setup wifi
? Should I scan for nearby Wi-Fi networks? No
? SSID: XXXXXXX
? Security Type: WPA2
? Wi-Fi Password: *********

That is, the particle setup would make sense at least to continue like this, after choosing No in the latest question:

...
? Would you like to wait and monitor for Photons entering setup mode? No
? SSID: XXXXXXX
? Security Type: WPA2
? Wi-Fi Password: *********

Photon OTA using particle-cli

Can Particle-cli be used for photon OTA? --usb does work for me but not the OTA. No error it just causes my photon to rest to factory firmware.

Tried exact same code on Cloud IDE and it works fine

update binaries

  • rename spark_tinker.bin to core_tinker.bin
  • add in photon_tinker.bin
  • check that device is a core before cc3000 patch

Test list

  • binaries are referenced with absolute path and not relative
  • sudo setting for dfu uses it when executing dfu-util
  • mock the dfu devices and test --usb flashing

No such file, when trying

It used to be a common tip for users to reflash tinker via CLI if something got a bit hairy, but recently it seems to have stopped working
When trying particle flash --usb tinker, I get this

C:\Users\Andy>particle flash --usb tinker
Found DFU device 2b04:d006
checking file  binaries/photon_tinker.bin
running dfu-util -d 2b04:d006 -a 0 -i 0 -s 0x080A0000:leave -D binaries/photon_tinker.bin

Error writing firmware...Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "dfu-util -d 2b04:d006 -a 0 -i 0 -s 0x080A0000:leave -D binaries/photon_tinker.bin"
No such file or directory: Could not open file binaries/photon_tinker.bin for reading

And for the Core respectively.

Update tinker binary

  1. There should be a user-part only tinker for Photon since it's supporting fast OTA of only user code now
  2. The better option might be to check which device you are trying to flash and select the correct tinker binary from the โ˜๏ธ or local copy.
  • If it is a core, use a tinker firmware with the full tinker firmware compiled for core
  • If it is a photon, flash a user-part tinker
  1. change the name from spark_tinker.bin to particle_tinker.bin

Particle setup not working for Cores

simply plug in a core in Listening mode and type particle setup.

You can check that the core is indeed connected with particle serial list

@emilyrose, might want to fix this real quick or people with unclaimed cores will go through a lot of hassle just to claim it.Particle setup not working for Cores #195

Incomplete use of 'sudo' when running 'dfu-util'

In my setup I need to use sudo to properly run dfu-util -l ( the setup has been created following the guide provided in the Readme of this repository ).

There is a configuration option ( useSudoForDfu ) that I presume should be used in this cases, but currently doesn't run dfu-util -l with sudo ( actually is used only for reading from the device, not for listing or writing ), as you can see from the lines in lib/dfu.js:

This makes the commands like keys crash ( in particular I wasn't able to complete step 7 of spark-server installation process ).

Is this the intended behaviour? I tried changing the code to use sudo and everything seemed to work fine.

I can submit a PR to fix this.
Thank you

Line breaks are ignored in OS X terminal

When I compile using particle-cli in OS X terminal, errors are spewed out all in one giant line, with "\n" instead of line breaks. Is there a way to control the output such that the terminal will recognize the line breaks?

Provide option to skip or turn off automagic WiFi setup

Our company is never going to want a Photon to operate on the same WiFi network as the machine that is setting it up.

The downsides to simply waiting for the automagic WiFi setup are:

  1. Long wait time
  2. When it fails, it goes into 'multiple nearby photons' select mode even though we want to set up over USB, not WiFi. As it stands, it seems to be impossible to do a manual WiFi setup over USB like we did with the Core. I'm not able to set up a Photon either on the public cloud or our local cloud.

Error when compiling: Target device blinky.ino is not valid

There probably some obvious thing I'm missing, but I cannot find a single page on the internet about this error.

When I navigate to the directory containing blinky.ino and type particle compile blinky.ino I get the error Target device blinky.ino is not valid

This happens with any sketch I try.

Interestingly, if I substitute flash [my device name] in place of compile, it compiles and flashes.

CLI exits when selecting from multiple devices to setup

version 1.5.11

Ran particle setup with two photons connected. Failed right after I selected one of them when prompted.

> Setup is easy! Let's get started...
> It appears as though you are already logged in as [email protected]
? Would you like to log in with a different account? No

! PROTIP: Hold the MODE/SETUP button on your device until it blinks blue!
! PROTIP: Please make sure you are connected to the internet.

> I have detected a Photon connected via USB.
? Would you like to continue with this one? Yes
! The Photon supports secure Wi-Fi setup. We'll try that first.

! PROTIP: Wireless setup of Photons works like a wizard!
! PROTIP: We will automagically change the Wi-Fi network to which your computer is connected.
! PROTIP: You may lose your connection to the internet for a moment.

Potentially unhandled rejection [2] Serial timed out (WARNING: non-Error used)
? Multiple Photons detected nearby. Would you like to select one to setup now? Yes
? Please select which Photons you would like to setup at this time. Photon-B397


/Users/bwkahle/.nvm/v0.10.38/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:579
    throw e;
          ^
TypeError: Object Photon-B397 has no method 'pop'
    at setup (/Users/bwkahle/.nvm/v0.10.38/lib/node_modules/particle-cli/commands/WirelessCommand/index.js:336:75)
    at PromptUI.multipleAnswers [as completed] (/Users/bwkahle/.nvm/v0.10.38/lib/node_modules/particle-cli/commands/WirelessCommand/index.js:245:16)
    at PromptUI.onCompletion (/Users/bwkahle/.nvm/v0.10.38/lib/node_modules/particle-cli/node_modules/inquirer/lib/ui/prompt.js:69:10)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.completed (/Users/bwkahle/.nvm/v0.10.38/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:1793:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted (/Users/bwkahle/.nvm/v0.10.38/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:1730:14)
    at AnonymousObserver.tryCatcher (/Users/bwkahle/.nvm/v0.10.38/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:567:29)
    at AutoDetachObse%

Failed setup report on new Photon on Windows

From a tech support ticket. User was eventually able to setup using serial on his computer.

C:\>particle setup

                  _   _      _        _
 _ __   __ _ _ __| |_(_) ___| | ___  (_) ___
| '_ \ / _` | '__| __| |/ __| |/ _ \ | |/ _ \
| |_) | (_| | |  | |_| | (__| |  __/_| | (_) |
| .__/ \__,_|_|   \__|_|\___|_|\___(_)_|\___/
|_|                     https://particle.io/

> Setup is easy! Let's get started...
> It appears as though you are already logged in as [email protected]
? Would you like to log in with a different account? No
! PROTIP: Hold the MODE/SETUP button on your device until it blinks blue!
! PROTIP: Please make sure you are connected to the internet.
> I have detected a Photon connected via USB.
? Would you like to continue with this one? Yes
! The Photon supports secure Wi-Fi setup. We'll try that first.
! PROTIP: Wireless setup of Photons works like a wizard!
! PROTIP: We will automagically change the Wi-Fi network to which your computer is connected.
! PROTIP: You may lose your connection to the internet for a moment.
Potentially unhandled rejection [2] Serial timed out (WARNING: non-Error used)
? Found "Photon-D45P". Would you like to perform setup on this one now? Yes
! PROTIP: You will need to know the password for your Wi-Fi network (if any) to proceed.
! PROTIP: You can press ctrl + C to quit setup at any time.
! Woops. Something went wrong connecting to Photon-D45P. Please manually re-connect to your Wi-Fi network.

Travis CI warnings / issues

Our firmware build is using Travis and the CLI to do test builds, but it looks like maybe something is off about the two combined. Any chance we can fix this part of the build? Is it just a matter of not using the deprecated module, and using the new one?

https://travis-ci.org/spark/firmware/builds/64131560

Thanks! :)

edit: reviewed this some more, looks like the CLI is adapting and skipping modules it can't find dependencies for. Looks like the thing failing the build is:

!!! Install it now by running npm install -g particle-cli
12580
spark variable did not return an integer. Network connectivity problems?

particle setup doesnt work without a driver on Windows 10

Windows 10 has a usb serial driver so you didn't need to install the Windows Driver. I made a change that made this work with the spark core by checking the vendor id right in the pnpid string. This doesn't work with the photon since there's a new vendor and product id for the photon.

git dependency causing install issue

@brycekahle, using git to grab the node packages is a breaking change for users where some of them do not have git installed and unable to install the new particle-cli. Can we do something about it instead of getting them to install more tools?

DFU verbose not showing

Seems like commit #65 broke the default showing of stdout on the console and we have to fix that while using another strategy to eventually allow users to turn off all verbose via a settings flag.

[Photon] `particle setup` fails on OSX due to hardcoded Wi-Fi interface

I just received my Photon today. After connecting it to my computer via USB, installing the particle cli and running particle setup, I encountered the following problem:

! Woops. Something went wrong connecting to Photon-JTTY. Please manually re-connect to your Wi-Fi network.

After digging through the code, I isolated the problem to a bug in WirelessCommand/connect/darwin.js:

    var params = 'networksetup -setairportnetwork en0 ' + opts.ssid;
    if(opts.password) { params += ' ' + opts.password; }

    // TODO: something with opts & interfaces?
    exec(params, results);
    function results(err, stdin, stderr) {

        if(err || stderr) {

            // TODO: more research into failure modes of this command
            return cb(err || stderr);
        }
        cb(null, opts);
    };

Here, the particle cli is trying to connect to a particular Wi-Fi network using the networksetup utility. The problem is that on certain Darwin machines, en0 is not a valid Wi-Fi interface, and thus this method fails every time it's called. In turn, this causes the following code in WirelessCommand/index.js to consistently fail:

        if(!self.__manual) {

            self.newSpin('Attempting to connect to ' + photon + '...').start();
            mgr.connect({ ssid: photon }, connected);
        }

...

    function connected(err, opts) {

        self.stopSpin();
        if(err) {
            // TODO: Max retries, help output when reached.
            console.log(
                chalk.bold.red('!'),
                chalk.bold.white('Woops. Something went wrong connecting to ' + photon + '. Please manually re-connect to your Wi-Fi network.')
            );
            return;
        }
        console.log(
            arrow,
            'Hey! We successfully connected to',
            chalk.bold.cyan(opts.ssid)
        );
        self.__configure(opts.ssid, done);
    };

Running networksetup -listallhardwareports shows me that en1 is the correct hardware port for the Wi-Fi interface on my machine:

$  ~  networksetup -listallhardwareports

Hardware Port: Bluetooth DUN
Device: Bluetooth-Modem
Ethernet Address: N/A

Hardware Port: Ethernet
Device: en0
Ethernet Address: ac:87:a3:2e:bf:ef

Hardware Port: Wi-Fi
Device: en1
Ethernet Address: b8:09:8a:d3:5e:2f

Hardware Port: Bluetooth PAN
Device: en4
Ethernet Address: b8:09:8a:d3:5e:30

Hardware Port: Thunderbolt 1
Device: en2
Ethernet Address: 32:00:1a:a0:80:00

Hardware Port: Thunderbolt 2
Device: en3
Ethernet Address: 32:00:1a:a0:80:01

Hardware Port: Thunderbolt Bridge
Device: bridge0
Ethernet Address: N/A

VLAN Configurations
===================

Changing en0 to en1 allowed me to complete particle setup without any further trouble.

Fixing this issue would require a reliable method of obtaining the correct hardware port. Parsing the output of networksetup -listallhardwareports or networksetup -listnetworkserviceorder seems to work, but this is ugly.

`particle setup wifi` often fails on Core

On our cores running a FW program w/ WiFi in MANUAL_MODE, if we

  1. Place an already happy/connected core running our FW into listening mode
  2. run particle setup wifi and enter SSID, Security, PW
    we time out w/ the message:
    Attempting to configure Wi-Fi on /dev/cu.usbmodem1411
    I said: w
    timed out on SSID:
    Something went wrong Serial prompt timed out - Please try restarting your device

At this time the Core's LED either goes blank or becomes solid blue, and wifi credentials are not transferred.

Add public key to CLI

We should do this and make it available under the particle keys server ... command

`particle serial info`

Adding a command to retrieve the system information for the Photon and the Electron will be easily than getting people to open up a serial terminal and hit "s"

inquirer crash

C:\Users\username>particle setup


_ __ __ _ _ | |() _| | ___ () ___
| '
\ / _` | '
| | |/ __| |/ _ \ | |/ _ \
| |) | (| | | | |_| | (
| | /| | () |
| .
/ ,|| ||||()|__/
|
| https://particle.io/

Setup is easy! Let's get started...
? Hello Stranger! This seems to be your first time here. What would you like to
? Hello Stranger! This seems to be your first time here. What would you like to
? Hello Stranger! This seems to be your first time here. What would you like to
do? Login
Let's get you logged in!
? Please enter your email address: [email protected]
? Please enter your password: *********
Successfully completed login!

! PROTIP: Hold the MODE/SETUP button on your device until it blinks blue!
! PROTIP: Please make sure you are connected to the internet.

I have detected a Spark Core connected via USB.
? Would you like to continue with this one? Yes
? Should I scan for nearby Wi-Fi networks? Yes
? Select the Wi-Fi network with which you wish to connect your device: (Use arro
? Select the Wi-Fi network with which you wish to connect your device: lshome
? Should I try to auto-detect the wireless security type? Yes

C:\Users\username\AppData\Roaming\npm\node_modules\particle-cli\node_modules\in
quirer\node_modules\rx\dist\rx.js:579
throw e;
^
TypeError: Cannot call method 'indexOf' of undefined
at Object.inquirer.prompt.when (C:\Users\username\AppData\Roaming\npm\node_
modules\particle-cli\commands\SerialCommand.js:339:60)
at Object.utils.runAsync (C:\Users\username\AppData\Roaming\npm\node_module
s\particle-cli\node_modules\inquirer\lib\utils\utils.js:29:22)
at C:\Users\username\AppData\Roaming\npm\node_modules\particle-cli\node_mod
ules\inquirer\lib\ui\prompt.js:131:13
at tryCatcher (C:\Users\username\AppData\Roaming\npm\node_modules\particle-
cli\node_modules\inquirer\node_modules\rx\dist\rx.js:567:29)
at setDisposable (C:\Users\username\AppData\Roaming\npm\node_modules\partic
le-cli\node_modules\inquirer\node_modules\rx\dist\rx.js:4977:36)
at AnonymousObservable.s [as _subscribe](C:UsersusernameAppDataRoaming
npmnode_modulesparticle-clinode_modulesinquirernode_modulesrxdistrx.js:
4994:11)
at AnonymousObservable.Rx.Observable.observableProto.subscribe.observablePro
to.forEach (C:\Users\username\AppData\Roaming\npm\node_modules\particle-cli\nod
e_modules\inquirer\node_modules\rx\dist\rx.js:2160:19)
at C:\Users\username\AppData\Roaming\npm\node_modules\particle-cli\node_mod
ules\inquirer\node_modules\rx\dist\rx.js:2403:21
at tryCatcher (C:\Users\username\AppData\Roaming\npm\node_modules\particle-
cli\node_modules\inquirer\node_modules\rx\dist\rx.js:567:29)
at setDisposable (C:\Users\username\AppData\Roaming\npm\node_modules\partic
le-cli\node_modules\inquirer\node_modules\rx\dist\rx.js:4977:36)

C:\Users\username>

Particle Login gives : ECONNREFUSED

: particle cloud login

? Please enter your email address: XXXXXXXX
? Please enter your password: ********
! There was an error logging you in! Let's try again.
! Login Failed: Error: connect ECONNREFUSED

Thoughts?

Running on MacBook 10.10

`list` command erroring out.

When I run $ particle list I get this output instead of a list of my devices:

* Retrieving device functions and variables.../usr/local/lib/node_modules/particle-cli/lib/ApiClient.js:799
        error = error || body.error;
                             ^
TypeError: Cannot read property 'error' of undefined
    at Object.ApiClient.hasBadToken (/usr/local/lib/node_modules/particle-cli/lib/ApiClient.js:799:24)
    at Request._callback (/usr/local/lib/node_modules/particle-cli/lib/ApiClient.js:363:10)
    at Request.self.callback (/usr/local/lib/node_modules/particle-cli/node_modules/request/request.js:197:22)
    at Request.emit (events.js:110:17)
    at Request.<anonymous> (/usr/local/lib/node_modules/particle-cli/node_modules/request/request.js:1050:14)
    at Request.emit (events.js:129:20)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/particle-cli/node_modules/request/request.js:996:12)
    at IncomingMessage.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11)

Running v1.5.16, and I am logged in.

Wifi scan not working

I happened to have internet sharing via Wifi turned on for MBP and attempted a scan:
(ie. Wifi device not available for scan)

The user should be aware of this but this still should not threw an unknown error to the user.

KENMBP:~ kennethlimcp$ particle setup wifi
? Should I scan for nearby Wi-Fi networks? Yes

se arrow keys)



/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:579
    throw e;
          ^
TypeError: Cannot read property 'name' of undefined
    at Prompt.render (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/lib/prompts/list.js:99:69)
    at Prompt.onSubmit (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/lib/prompts/list.js:122:16)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.next (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:1962:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:1894:35)
    at AnonymousObserver.tryCatcher (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:567:29)
    at AutoDetachObserverPrototype.next (/usr/local/lib/node_modules/particle-cli/node_modules/inquirer/node_modules/rx/dist/rx.js:5018:51)

Complaining to Emily: Non-broadcast networks

Our home network is non-broadcast, so I look forward to an update which makes these accessible.

Also, it would be good to report the core ID during the set-up process, as before.

wrong value for invalid_grant

@dmiddlecamp,

while trying to fix another issue, i saw that the implementation for bad token check seems to be incorrect.

The server is returning invalid_token while the check is looking for invalid_grant at https://github.com/spark/particle-cli/blob/master/lib/ApiClient.js#L800

Can you confirm the actual response for invalid token?

Also, seems like the function hasBadToken() is called, but the return value is not checked so the bad token case is not caught. Related to: #69

Standardized command verb

Proposing:

Webhook

  • add (sounds a little funny, original is create)
  • remove

this is in line with particle device

  • particle device add
  • particle device remove

Fails silently when access token is expired

It seems that any of the online commands will fail silently when the access token expires. Wifi setup commands (particle serial wifi) works fine, but something like particle subscribe mine spits out the following and immediately goes back to command prompt.

Garretts-MacBook-Pro:Desktop garrett$ particle subscribe mine
Subscribing to all events from my personal stream (my devices only) 
Listening to: /v1/devices/events
Garretts-MacBook-Pro:Desktop garrett$

npm update not working

using sudo npm update -g particle-cli, there's an error:

npm ERR! Refusing to delete: /usr/local/bin/spark not in /usr/local/lib/node_modules/particle-cli
File exists: /usr/local/bin/spark
Move it away, and try again. 

npm ERR! System Darwin 13.4.0
npm ERR! command "node" "/usr/local/bin/npm" "update" "-g" "particle-cli" "--verbose"
npm ERR! cwd /Users/kennethlimcp
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! path /usr/local/bin/spark
npm ERR! code EEXIST
npm verb exit [ 1, true ]
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/kennethlimcp/npm-debug.log
npm ERR! not ok code 0

Seems like an issue if you have spark-cli already installed

`keys doctor` and `flash --usb` report failure for the Photon even when successful

If I'm missing something obvious, please be kind. I looked at all the documentation I could find. I've done this successfully in the past with a local server and Cores.

When the Photon is in DFU mode and I run keys doctor, I get:

Downloading to address = 0x00000022, size = 610
Download [=========================] 100% 610 bytes
Download done.
File downloaded successfully
Error during download get_status
Error saving key to device...
Make sure your device is in DFU mode (blinking yellow), and that your computer is online.
Error -

keys server works just fine.

flash --usb tinker gives:

Downloading to address = 0x080a0000, size = 79996
Download [=========================] 100% 79996 bytes
Download done.
File downloaded successfully
Error during download get_status
Error writing firmware...

I relied on both these steps when I used to do Cores. As it is, I have not yet been successful at connecting a Photon to the local server.

As I understand it, I should execute:

  1. particle keys server default_key.pub.pem SERVER-MACHINE-IP (working)
  2. particle keys doctor COREID (broken)
  3. particle serial wifi (working)
  4. particle core add COREID (might be working?)

I'm stuck on step 2. I did a very similar sequence a while back when I had Cores. Am I doing this the wrong way?

[Photon] `particle monitor` not working

$ particle monitor 3a003000034XXXXXXXXXXXXX
Hit CTRL-C to stop!
polling server to see what devices are online, and what variables are available
Which variable did you want?
Potentially unhandled rejection [1] ReferenceError: foundCore is not defined
    at /usr/local/lib/node_modules/particle-cli/commands/VariableCommand.js:94:22
    at tryCatchReject (/usr/local/lib/node_modules/particle-cli/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/usr/local/lib/node_modules/particle-cli/node_modules/when/lib/makePromise.js:804:4)
    at Fulfilled.when (/usr/local/lib/node_modules/particle-cli/node_modules/when/lib/makePromise.js:592:4)
    at Pending.run (/usr/local/lib/node_modules/particle-cli/node_modules/when/lib/makePromise.js:483:13)
    at Scheduler._drain (/usr/local/lib/node_modules/particle-cli/node_modules/when/lib/Scheduler.js:62:19)
    at Scheduler.drain (/usr/local/lib/node_modules/particle-cli/node_modules/when/lib/Scheduler.js:27:9)
    at process._tickCallback (node.js:355:11)

I have the latest particle-cli version:

$ particle --version
1.5.16

And I'm testing it over a Photon with a user-application on top of the develop firmware version 0.4.2.

`particle flash` add `--system` flag

It gets tedious trying to flash a new system firmware to a Photon since the current CLI does not support it.

  • particle flash --system xxx.bin
  • system address: 0x8020000 + -a 0

Error flashing "cc3000" or "tinker"

Whenever I try and flash cc3000 or tinker, I get an error that says I'm trying to flash an object instead of a string filepath:

Found DFU device 2b04:d006
checking file  [object Object]
running dfu-util -d 2b04:d006 -a 0 -i 0 -s 0x080A0000:leave -D [object Object]
Error writing firmware... Error: Command failed: /bin/sh -c dfu-util -d 2b04:d006 -a 0 -i 0 -s 0x080A0000:leave -D [object Object]
dfu-util: Could not open file [object for reading: No such file or directory

Error: Unable to obtain claim code

I get Error: Unable to obtain claim code when trying to claim my photon.

russ$ particle setup
                  _   _      _        _
 _ __   __ _ _ __| |_(_) ___| | ___  (_) ___
| '_ \ / _` | '__| __| |/ __| |/ _ \ | |/ _ \
| |_) | (_| | |  | |_| | (__| |  __/_| | (_) |
| .__/ \__,_|_|   \__|_|\___|_|\___(_)_|\___/
|_|                     https://particle.io/

> Setup is easy! Let's get started...
> It appears as though you are already logged in as [email protected]
? Would you like to log in with a different account? No

! PROTIP: Hold the MODE/SETUP button on your device until it blinks blue!
! PROTIP: Please make sure you are connected to the internet. 

> No devices detected via USB.
? Would you like to scan for nearby Photons in Wi-Fi setup mode? Yes

! PROTIP: Wireless setup of Photons works like a wizard!
! PROTIP: We will automagically change the Wi-Fi network to which your computer is connected.
! PROTIP: You may lose your connection to the internet for a moment.

? Found "Photon-EWVK". Would you like to perform setup on this one now? Yes

! PROTIP: You will need to know the password for your Wi-Fi network (if any) to proceed.
! PROTIP: You can press ctrl + C to quit setup at any time.

> > [Error: Unable to obtain claim code]
! PROTIP: We need an active internet connection to successfully complete setup.
! PROTIP: Are you currently connected to the internet? Please double-check and try again.

I found this, but there is no solution there.

Any ideas?

I'm on a 2012 MBP Retina, running 10.10.3. particle cli version info;

$ npm info particle-cli

{ name: 'particle-cli',
  description: 'Simple Node commandline application for working with your Particle devices and using the Particle Cloud',
  'dist-tags': { latest: '1.5.11' },
  versions: 
   [ '1.5.0',
     '1.5.1',
     '1.5.2',
     '1.5.3',
     '1.5.4',
     '1.5.5',
     '1.5.6',
     '1.5.7',
     '1.5.8',
     '1.5.9',
     '1.5.10',
     '1.5.11' ],
  maintainers: 
   [ 'nexxy <[email protected]>',
     'brycekahle <[email protected]>' ],
  time: 
   { modified: '2015-05-28T20:22:12.441Z',
     created: '2015-05-15T04:30:10.272Z',
     '1.5.0': '2015-05-15T04:30:10.272Z',
     '1.5.1': '2015-05-15T22:24:23.845Z',
     '1.5.2': '2015-05-16T00:42:54.971Z',
     '1.5.3': '2015-05-16T07:31:02.698Z',
     '1.5.4': '2015-05-18T00:32:09.649Z',
     '1.5.5': '2015-05-18T22:14:21.533Z',
     '1.5.6': '2015-05-19T00:59:47.326Z',
     '1.5.7': '2015-05-20T00:14:47.082Z',
     '1.5.8': '2015-05-20T00:23:31.297Z',
     '1.5.9': '2015-05-22T02:19:09.094Z',
     '1.5.10': '2015-05-22T02:25:27.158Z',
     '1.5.11': '2015-05-28T20:22:12.441Z' },
  homepage: 'https://github.com/spark/particle-cli#readme',
  repository: 
   { type: 'git',
     url: 'git+https://github.com/spark/particle-cli.git' },
  contributors: 
   [ 'Kenneth Lim (https://github.com/kennethlimcp)',
     'David Washington (https://github.com/dwcares)',
     'TJ Hunter (https://github.com/Hypnopompia)',
     'Udo Kramer (https://github.com/optikfluffel)',
     'vk2tds (https://github.com/vk2tds)',
     'Emily Rose (https://github.com/emilyrose)',
     'Kyle Marsh (https://github.com/kylemarsh)',
     'Harrison Jones (https://github.com/harrisonhjones)',
     'Bryce Kahle (https://github.com/brycekahle)' ],
  author: 'David Middlecamp',
  bugs: { url: 'https://github.com/spark/particle-cli/issues' },
  readmeFilename: 'README.md',
  license: 'LGPL-3.0',
  version: '1.5.11',
  bin: { particle: './bin/particle.js' },
  main: './app.js',
  engines: { node: '^0.10.0' },
  dependencies: 
   { chalk: '^1.0.0',
     'cli-spinner': '^0.2.1',
     glob: '^4.2.1',
     'hogan.js': '^2.0.0',
     inquirer: '^0.8.2',
     moment: '^2.9.0',
     'node-wifiscanner2': '^1.0.0',
     request: '^2.46.0',
     serialport: '^1.5.0',
     'softap-setup': '^1.1.4',
     when: '^3.7.2',
     xtend: '^4.0.0' },
  preferGlobal: true,
  gitHead: '579715a0f46ea5d17bb3cc3b0a12e929c91ae3be',
  scripts: {},
  dist: 
   { shasum: '769d9f4ac86977f4901a0beb790f833adfa13ecc',
     tarball: 'http://registry.npmjs.org/particle-cli/-/particle-cli-1.5.11.tgz' },
  directories: {} }

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.