跳至內容

Local IoT device's unique value

0

How do you get a specific local IoT device's unique value?
for example, IP address or MAC address.

My local IoT device is Raspberry Pi.
v1.9 and node.js lambda functions.

已提問 6 年前檢視次數 260 次
3 個答案
0

Not sure about JS, but in Python you can do this:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('10.255.255.255', 1))  # any address works
ip_addr = s.getsockname()[0]
import uuid
hex_val = '{:012x}'.format(uuid.getnode())
mac_addr = ':'.join(hex_val[i: i + 2] for i in range(0, 11, 2))

You can also get the CPU serial number from:

cat //proc/cpuinfo | grep Serial

Edited by: JennaSys on Jun 26, 2019 4:17 PM added imports

已回答 6 年前
0

You can use process mode to get those information

已回答 6 年前
0

Thank you!!!

I got it.

const serial = require('proc-cpuinfo')()["Serial"][0];
已回答 6 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。