-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.py
executable file
·45 lines (38 loc) · 1.15 KB
/
boot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
#
# Copyright (c) 2019, Pycom Limited.
#
# This software is licensed under the GNU GPL version 3 or any
# later version, with permitted additional terms. For more information
# see the Pycom Licence v1.0 document supplied with this file, or
# available at https://www.pycom.io/opensource/licensing
#
from machine import UART
import machine
import os
import ustruct, ubinascii, uhashlib
uart = UART(0, baudrate=115200)
os.dupterm(uart)
# machine.main('main.py')
'''
Implemented of LoPy4/Fipy with 1.18 pycom-micropython version
'''
######### Utility Functions #######################
def get_node_id(hex=False):
"""
Get node id, which consists of four bytes unsigned int.
Return as hex, according to parameter.
"""
node_id = ubinascii.hexlify(uhashlib.sha1(
machine.unique_id()).digest()).decode("utf-8")[-8:]
if hex:
return node_id
else:
return int(node_id, 16)
######### Own node's information #####################
if get_node_id() == 235968217:
print('I am node Mac1')
elif get_node_id() == 829745241:
print('I am node Mac2')
elif get_node_id() == 50989579:
print('I am node Mac3')