-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgasom2m.py
More file actions
33 lines (28 loc) · 891 Bytes
/
gasom2m.py
File metadata and controls
33 lines (28 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
import requests
import json
OM2M_IP = "127.0.0.1" # Replace with your OM2M IP if different
HEADERS = {
"X-M2M-Origin": "admin:admin",
"Content-Type": "application/json;ty=2" # AE creation
}
# Create AE (Application Entity)
ae_data = {
"m2m:ae": {
"rn": "gas_sensor",
"api": "app-gas",
"rr": True
}
}
ae_url = f"http://{OM2M_IP}:8080/~/in-cse/in-name"
resp = requests.post(ae_url, headers=HEADERS, data=json.dumps(ae_data))
print("AE Creation:", resp.status_code, resp.text)
# Create container 'data' inside gas_sensor
HEADERS["Content-Type"] = "application/json;ty=3" # Container creation
cnt_data = {
"m2m:cnt": {
"rn": "data"
}
}
cnt_url = f"http://{OM2M_IP}:8080/~/in-cse/in-name/gas_sensor"
resp = requests.post(cnt_url, headers=HEADERS, data=json.dumps(cnt_data))
print("Container Creation:", resp.status_code, resp.text)