Claiming a Photon from the command line

photon
Tags: #<Tag:0x00007f038f6f17d0>

#1

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
Gary


#2

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.


#3

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


#4

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>

#5

@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()

SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);

#6

OK, hold that, based on @ScruffR post https://community.particle.io/t/where-can-i-find-the-device-claim-code/20011/2 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> https://api.particle.io/v1/devices/

# Unclaim a device
curl -d access_token=<access_token>  -X DELETE https://api.particle.io/v1/devices/<device id>

# With access token taken from settings tab in https://build.particle.io 
# and device ID from particle serial identify

#7

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.