Is there a way to determine the Platform ID from firmware?

Is there an API to get the Platform ID from a device?

I would like to have 1 firmware that can be used on the P1 and the Electron


Have a look at how some of the more popular libraries implement this: