내용으로 건너뛰기

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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.