Claiming device and Option to Auto Lock firmware

@Dave

I am wondering if its possible to add a setting to allow devices when claimed to have the Console to automatically lock the firmware to the current released firmware version.

This would save a ton of time. Currently, each device after being claimed need to be clicked on to edit. There’s a total of 7 mouse clicks required to lock a device.

Thanks!

Hi @wesner0019,

Is your firmware released to the general product group? It should automatically get that firmware without needing to be locked to the current version? Or is the goal to only use the current version of firmware on a device after its first activation?

Thanks,
David

Its being claimed with a product ID and once it comes on-line it shows up in the console where I then click to claim it. Once claimed it is unlocked. We want to lock all of our devices as they come online.

So,

The goal is to only use the current version of firmware on a device after its first activation.

Another option is to use a script. This is a node.js script that claims a device and locks its firmware. You create a file of device IDs (one per line), then call it like:

node claim-and-lock.js --productId=1319 --firmware=23 deviceIds.txt
2 Likes

@rickkas7, i just tried the .js as above but from the console it is in the quarntine state.

I dont see in the .js example anywhere that assigns the ID to a product with:

addDeviceToProduct
https://docs.particle.io/reference/javascript/#adddevicetoproduct

Is the example missing this?

particle.claimDevice({ deviceId: deviceId, auth:config.get('AUTH_TOKEN') }).then(
		function(data) {
			console.log("  success!");
			if (firmware) {
				console.log("locking " + deviceId + " to " + firmware + "...");
				particle.lockDeviceProductFirmware({deviceId: deviceId, auth:config.get('AUTH_TOKEN'), product:productId, desiredFirmwareVersion:firmware, flash:true}).then(
						function(data) {
							console.log("  success!");
							claimNext();														
						},
						function(err) {
							console.log("  failed " + deviceId, err);
							claimNext();							
						}
						);
				
			}
			else {
				claimNext();				
			}
		},
		function(err) {
			console.log("  failed " + deviceId, err);
			claimNext();
		}
		);

Now that you mention it, that would make a lot of sense. I modified the script so it now also adds the devices to the product so you don’t have to upload the device IDs file separately. The updated version is on Github.