How to generate a serial number for my app

First, Resin is awesome! I’m looking forward to creating some cool stuff with it.

Quick question regarding generation of a serial number for my app. I was wondering if anyone had done something similar to below and if so had a different approach…

A Customer receives a box (Pi 3) running Resin, on boot-up, the app asks the user to type in a serial number written on the back of the box. This serial number registers the application with our servers and uniquely identifies it against our DB. We now know what company the box belongs to as we match the number to the one in our DB. We also use the number as a key to generate a JWT on the box.

hey @spakry. The user connects the Pi to a screen or some other way can see an entry field?

I guess one possibility might be that if your application can display that entry form when it doesn’t have the required credentials, and handles the registration with that service. In that case, you can use resin preload (here’s the docs using resin-cli.

1 Like

?> The user connects the Pi to a screen or some other way can see an entry field?

Yes, Pi will be connected to a screen, the app (container) will be running. I need the app to identify the company/user. For this, I will ask them for a unique code to be entered. I could generate one randomly on the image, or if Resin has a code that’s unique I could use that?

@sparky wouldn’t RESIN_DEVICE_UUID be just the thing for that use-case?

1 Like

Could be, under what circumstances could RESIN_DEVICE_UUID change?

PS, the resin preload stuff looks good too, I could write something that generates a UUID for the customer on the first bootup

Why not use the Raspi serial number? Then user does not even have to fill it in, your app can just get it from the device:

1 Like

The device UUID never changes, that is basically “the device”. In the dashboard we use the first 7 digits of it, which should be already unique as well (1 in 16^7 unique), but you could add a few more digits, and you should be fine. The preloaded application would also help you to set things up available on the first run without any download (your application, the registration, etc such as resin-wifi-connect to help connectivity).

One thing to make sure, when the device starts up the preloaded application on first boot, whether it has that UUID already available for the application container (e.g. even before the device could register with resin), will check and report back on that too.

The Raspberry pi serial number from @FransvanHoogstraten is a good idea, that’s available to check in the user container as well, just as mentioned in the linked post:

cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2
1 Like