Claiming a Photon from the command line

I have a box of Photons what I want set to a specific firmware version, claim to an account and then install our application binary.

particle serial identify  
particle flash --serial bootloader-0.7.0-photon.bin   
particle flash --serial system-part1-0.7.0-photon.bin   
particle flash --serial system-part2-0.7.0-photon.bin  

So the above does the first bit.

For claiming, I could run the particle setup but I do not want to have to enter the Office WIFI credentials at this stage.

Is it possible to claim a Photon from the command line (presumably from it’s ID) essentially keeping the device off-line?

Many Thanks

It is not possible to claim a device unless it’s online and breathing cyan.

It is possible to set the Wi-Fi credentials from the CLI, let the device get online, claim it, then remove the Wi-Fi credentials.

You can install your application binary to an unclaimed device too.
And this way you can do what Rick said

OK, so I used the following to set the WIFI credentials and it’s breathing Cyan.

particle serial wifi --file wifi.json

How do I now claim the device. I see there is a claim option for particle serial but it required a claim code. Presumably this has to be generated somehow.

Usage: particle serial claim [options] <claimCode>

@scruffr do you know if using a binary on an unclaimed Photon is stable?

Presumably using the following will ensure that the system thread will never attempt connection to the Particle Cloud (which we’re not using in this instance) unless we do something like Particle.connect()


OK, hold that, based on @ScruffR post I worked through the API calls required.

Wow, you can do a lot via the API …

For reference:

# Claim an online device
curl -d access_token=<access token> -d id=<device id>

# Unclaim a device
curl -d access_token=<access_token>  -X DELETE<device id>

# With access token taken from settings tab in 
# and device ID from particle serial identify

It is just as stable as on a claimed device. When it comes to running the firmware the device itself is ignorant of its claiming status.

You can connect unclaimed device to the cloud too. That would only make it susceptible to being claimed by someone else and Particle.function(), Particle.variable(), Particle.publish(..., PRIVATE) and Particle.subscribe(..., MY_DEVICES) would be of no use since these are features that require an account to communicate with.

1 Like