Argon CLI Setup Tool

@gusgonnet - Yeah, I’ve done a few things using a single Python Script to provision a Boron out of the box. I’d assume the Python Script could be modified for Argon provisioning as well. I personally think the fastest/easiest way to provision is via Using SWD/JTAG | Reference | Particle

This is basically how I do it. It’s a bit piecemealed but has really sped up the provisioning process for me. Here are the rough steps I currently do. Happy to share the pythons script itself if others would find it useful.

One time Pre-Work:

  • Bulk add all devices to the product. I personally use a 2D Barcode reader to scan a batch of them into a .txt file and then use the console to add devices in bulk to an existing product (i.e. 1, 10, or even 50 at a time). A USB 2D barcode reader as outlined here is very handy. Lookup Tools | Tools | Particle By the way… I personally wish I got a wireless USB 2D barcode scanner.
  • Create a .HEX file of your application and DeviceOS Particle Hex File Generator

Physical steps per device:

  1. Remove from package and install antenna
  2. Plug in the JTAG/SWD programmer to device
  3. Apply power (Plug in a battery, plug in USB, add to carrier board that has power, etc.)
  4. Run the script outlined below
  5. Scan in the Particle Device ID using a barcode scanner
  6. Scan in my specific hexadecimal ID using barcode scanner

When I execute the python script it automates the following steps:

  1. Ask the user to input the 2D barcode on the particle device. I click in the input field and use the USB scanner to scan it in from the Boron.
  2. Given the device serial number as scanned in from the barcode, make a call to the particle cloud API to obtain the device’s device_id
  3. Ask the user to scan in the 2D barcode/serial number unique to my product. This is a 2D barcode I physically print and located on the exterior of the product. I need to match this to the device_id in my backend. (10 digit hexadecimal). I use my own 10 digit hexadecimal as not all devices in my database are Particle.IO devices. This allows an end customer to use the same process to associate a device to a particular customer weather it’s a particle.io device or not.
  4. Using SQL Alchemy - call a stored procedure within my SQL database that adds the device to my SQL database given parameters of device_id, device type, and 10 digit hexadecimal. This adds the device to all necessary SQL tables in my “backend” data storage, device settings, device management, database as used by other aspects of the application.
  5. Make a call to the Particle Cloud API to claim the device to an “admin” account. I currently claim all devices to a single admin account.
  6. Make a call to the Particle cloud API to update the device notes and device name for that device. I use device name and device notes to add a little context to the particle console of what customer purchased each device and what type of device it is. In this case, I just set notes to “status”:“unclaimed” and the device name to the 10 digit hexadecimal value I reference earlier.
  7. Finally, flash the hex file to the device. My application code also clears the setup done flag if it is not set. Setup Done Flag in Setup - OK to leave in with production Firmware? - #5 by rickkas7 This takes 1-2 seconds to flash everything.

Flashing is this line of code and it flashes it all in just 2-3 seconds:

#Now Flash the Device OS
os.chdir(r"C:\Users\Particle\hex")
os.system("nrfjprog -f NRF52 --program Boron_V27.hex --chiperase --reset")

I never timed myself, but with this process I think I can commission a device in 1-2 minutes each. It becomes… plug in a device, hit run on the script, scan in the particle barcode, scan in the 10 digit hexadecimal barcode and in 10 second or less the script is done. I spend more time taking a device out of the box and attaching the antenna and plugging it in then the actual script running.

Happy to share the entire script if others think it’ll help. It’s a blend between custom for my own application and SQL backend and particle specific stuff. With spaces and comments it’s only 120 lines long so not much to it. Just let me know and I could probably post it to github for others to use as a reference.

Now that I think about it a bit… a few other changes I could make could be:

  1. Add the device to the product automatically as part of the script vs having to do that in advance manually. Not sure why I did it separately as I assume the particle cloud API could do it as well.
  2. Create a basic of basic flask app user interface around the python script. This could provide a better “user interface” rather than just the command line of a python environment. Or put some sort of interface around it all and use an easy button ICON to kick the process off instead of just the python command prompt.
    image

Are there any other ideas how to make it even easier faster? I know there is some node.JS application note or something out there on this right? I went down this path just because I am the most familiar with Python but I’m sure could be done other ways as well.

2 Likes