-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_schc_compress.py
More file actions
36 lines (24 loc) · 891 Bytes
/
gen_schc_compress.py
File metadata and controls
36 lines (24 loc) · 891 Bytes
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
from SCHCPParserTool.parser import SCHCParser
import binascii
# Exaple with LoRaWAN -- IPv6/UDP
# First we create an object called parser with the rules we will test (lorawan.json)
parser = SCHCParser()
#parser.rule_file = "lorawan.json"
#parser.rm.Add(file=parser.rule_file)
#parser.rm.Print() # To Check the Rule
# We add a DevEUI and AppSKey to the parser object:
DevEUI = '1122334455667788'
AppSKey = '00AABBCCDDEEFF00AABBCCDDEEFFAABB'
parser.changeDevEUI (DevEUI=DevEUI)
parser.changeAppSKey (AppSKey=AppSKey)
# Now, we will define the parameters necessary to create the SCHC Packet
comp_ruleID = 101
dev_prefix = "fe80::"
app_prefix = "fe80::"
json = parser.generate_schc_comp(comp_ruleID, dev_prefix, app_prefix)
print(json)
comp_ruleID = 100
dev_prefix = "Aaaa::"
app_prefix = "Cccc::"
json = parser.generate_schc_comp(comp_ruleID, dev_prefix, app_prefix)
print(json)