This commit is contained in:
JOLIMAITRE Matthieu 2024-03-10 21:35:34 +01:00
parent 22eb5c7ad3
commit a9e60a9ba0
12 changed files with 129 additions and 0 deletions

2
iot/tp1/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
acme-onem2m
venv

0
iot/tp1/main.py Normal file
View file

0
iot/tp1/requirements.txt Normal file
View file

12
iot/tp1/run.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/sh
set -e
cd "$(dirname "$(realpath "$0")")"
if ! [ -d acme-onem2m ]
then ./setup.sh
fi
cd acme-onem2m
python3 -m acme

41
iot/tp1/setup.sh Executable file
View file

@ -0,0 +1,41 @@
#!/bin/sh
set -e
cd "$(dirname "$(realpath "$0")")"
rm -fr ./venv
rm -fr acme-onem2m
python -m venv ./venv
source ./venv/bin/activate
git clone https://github.com/ankraft/ACME-oneM2M-CSE.git acme-onem2m
python -m pip install --requirement=./acme-onem2m/requirements.txt
python -m pip install --requirement=./requirements.txt
echo "
[basic.config]
cseType=IN
cseID=id-in
cseName=cse-in
adminID=CAdmin
dataDirectory=\${baseDirectory}
networkInterface=0.0.0.0
cseHost=10.75.69.114
httpPort=8080
logLevel=debug
databaseInMemory=True
consoleTheme=dark
[cse.registration]
; Edit this to add more allowed originators.
allowedCSROriginators=id-in,id-mn,id-asn
[textui]
startWithTUI=false
[cse.operation.requests]
enable=true
[http]
enableUpperTesterEndpoint=true
enableStructureEndpoint=true
" > acme-onem2m/acme.ini

10
iot/tp1/src/part_2/step_a.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
curl -X POST \
-H 'X-M2M-Origin:Cmysensor' \
-H 'X-M2M-RI:123' \
-H 'X-M2M-RVI:3' \
-H'Content-Type:application/json;ty=2' \
-H 'Accept:application/json' \
-d '{"m2m:ae": {"rn":"MySensor", "api": "NMysensor", "rr": true, "srv": ["3"]}}' \
http://127.0.0.1:8080/cse-in

10
iot/tp1/src/part_2/step_b.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
curl -X POST \
-H 'X-M2M-Origin:Cmysensor' \
-H 'X-M2M-RI:123' \
-H 'X-M2M-RVI:3' \
-H 'Content-Type:application/json;ty=3' \
-H 'Accept:application/json' \
-d '{"m2m:cnt": {"rn":"Container"}}' \
http://127.0.0.1:8080/cse-in/MySensor

10
iot/tp1/src/part_2/step_c.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
curl -X POST \
-H 'X-M2M-Origin:Cmysensor' \
-H 'X-M2M-RI:123' \
-H 'X-M2M-RVI:3' \
-H 'Content-Type:application/json;ty=4' \
-H 'Accept:application/json' \
-d '{"m2m:cin": {"cnf": "text/plain:0","con": "{\"unit\": \"celsius\", \"value\": \"22\"}"}}' \
http://localhost:8080/cse-in/MySensor/Container

9
iot/tp1/src/part_2/step_d.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
curl -X GET \
-H 'X-M2M-Origin:Cmysensor' \
-H 'X-M2M-RI:123' \
-H 'X-M2M-RVI:3' \
-H 'Content-Type:application/json' \
-H 'Accept:application/json' \
http://localhost:8080/cse-in/MySensor/Container/la

3
iot/tp1/src/part_2/step_e.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
curl -X PUT -H 'X-M2M-Origin:Cmysensor' -H 'X-M2M-RI:123' -H 'X-M2M-RVI:3' -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"m2m:cnt": {"mni": 10}}' http://localhost:8080/cse-in/MySensor/Container

4
iot/tp1/src/part_2/step_f.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
set -e
curl -X DELETE -H 'X-M2M-Origin:Cmysensor' -H 'X-M2M-RI:123' -H 'X-M2M-RVI:3' -H 'Content-Type:application/json' -H 'Accept:application/json' http://localhost:8080/cse-in/MySensor/Container

28
iot/tp1/src/part_3/step_a.sh Executable file
View file

@ -0,0 +1,28 @@
#!/bin/sh
set -e
alias log="echo '
[step_a.sh]'"
RN_NAME="CINwithLabel"
log creates container
curl -X POST \
-H 'X-M2M-Origin:Cmysensor' \
-H 'X-M2M-RI:123' \
-H 'X-M2M-RVI:3' \
-H'Content-Type:application/json;ty=2' \
-H 'Accept:application/json' \
-d '{"m2m:ae": {"rn":"'$RN_NAME'", "api": "NMysensor", "rr": true, "srv": ["3"]}}' \
http://127.0.0.1:8080/cse-in
log emit notification
curl -X POST \
-H 'X-M2M-Origin:Cmysensor' \
-H 'X-M2M-RI:123' \
-H 'X-M2M-RVI:3' \
-H 'Content-Type:application/json;ty=4' \
-H 'Accept:application/json' \
-d '{"m2m:cin": {"rn":"CINwithLabel", "lbl": ["tag:temperature"], "cnf": "text/plain:0", "con": "{\"unit\": \"celsius\",\"value\": \"22\"}"}}' \
http://127.0.0.1:8080/cse-in/MySensor/Container