tingbot / tingbot-python

🔩 Python APIs to write apps for Tingbot
Other
18 stars 9 forks source link

Hardware API addition: get_serial_number() #54

Open njh opened 7 years ago

njh commented 7 years ago

Hello,

I am interesting in getting a unique identifier for a Tingbot device, so that it can be used as a connection identifier when an app is installed on multiple devices.

A couple of options I have considered:

I am leaning towards the second option, because it should work with the simulator too.

What do you think? Would you accept a Pull Request?

Thanks,

nick.

joerick commented 7 years ago

Hey @njh! The MAC address option has a small problem that users might try it alongside get_ip_address() and not realise that they refer to different interfaces.

So the serial number is my preferred option. Happy to accept PR for that. Would your use case be okay with the Simulator returning a serial number '0000000000000000', or would that cause problems?

njh commented 7 years ago

Thanks Joe!

Yes, lets start with that.

Alternatives might be to either generate (and persist) a random number in the simulator. Or include part of the first network interface MAC address in the simulator. I'm not sure if it is worth contacting Raspberry Pi and asking if there is a structure to the serial number - and if some space could be reserved for 'fake pis'?

joerick commented 7 years ago

A generated/persisted number would be a handy workaround!

I wouldn't expect these numbers to be used for anything except direct comparisons, so we could design our own identifier scheme for the simulator tbsimulator-0123456789abcdef or something.

furbrain commented 7 years ago

You could use a uuid for this - see the python uuid module for more details

On 14 Nov 2016 09:54, "Joe Rickerby" notifications@github.com wrote:

A generated/persisted number would be a handy workaround!

I wouldn't expect these numbers to be used for anything except direct comparisons, so we could design our own identifier scheme for the simulator tbsimulator-0123456789abcdef or something.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tingbot/tingbot-python/issues/54#issuecomment-260292730, or mute the thread https://github.com/notifications/unsubscribe-auth/AC233RGtIH17PuQ4dfGx7DpGYXETwwKCks5q-C_NgaJpZM4Kwuix .

WhistleMaster commented 7 years ago

That's what I'm using in a one of my app:

import uuid
str(uuid.uuid4())