Merge 5fa0f8cd65944cfbf00a48c6c5ec74aa01b264a3 into db06cd73bd7aed24da05686144a4732afc069243

This commit is contained in:
Julio Poveda 2020-05-13 16:50:18 +00:00 committed by GitHub
commit e41a276e61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,12 +6,14 @@ In this short tutorial you will:
2. Create an *application resource* and corresponding *content instance* via the REST API
3. Using the REST API to get this *content instance*
Clone the OpenMTC repository
First, clone the OpenMTC GitHub repository:
```sh
git clone https://github.com/OpenMTC/OpenMTC OpenMTC
```
All following commands should be executed from within the repo folder
All following commands should be executed from within the repo folder:
```sh
cd OpenMTC
```
@ -19,7 +21,8 @@ cd OpenMTC
The next steps need Docker to be installed on your system. If you need help for
the installation, follow [this guide](various.md).
Build the gateway Image
Build the gateway image:
```sh
./create-binary-docker gateway
```
@ -30,28 +33,37 @@ To check if this step was successful run:
docker image ls
```
If there is an entry "openmtc/gateway" the image was created successfully.
If there is an "openmtc/gateway-amd64" or "openmtc/gateway-arm" entry, the image was created successfully.
Run the gateway Docker image
```sh
docker run -d --name gateway -p 0.0.0.0:8000:8000 \
-e "LOGGING_LEVEL=DEBUG" openmtc/gateway -vv
-e "LOGGING_LEVEL=DEBUG" openmtc/gateway-amd64 -vv
```
Create an application resource on your gateway
or
```sh
docker run -d --name gateway -p 0.0.0.0:8000:8000 \
-e "LOGGING_LEVEL=DEBUG" openmtc/gateway-arm -vv
```
Create an application resource on your gateway:
```sh
curl -X POST localhost:8000/onem2m/ -H "Content-Type: application/vnd.onem2m-res+json" \
-d '{"m2m:ae": {"rn": "EXAMPLE_APP_NAME", "api": "placeholder", "rr": "TRUE"}}'
```
Create a container resource on your gateway
Create a container resource on your gateway:
```sh
curl -X POST localhost:8000/onem2m/EXAMPLE_APP_NAME/ -H "Content-Type: application/vnd.onem2m-res+json" \
-d '{"m2m:cnt": {"rn": "EXAMPLE_CONTAINER_NAME"}}'
```
Create plain text content
Create plain text content:
```sh
curl -X POST localhost:8000/onem2m/EXAMPLE_APP_NAME/EXAMPLE_CONTAINER_NAME/ \
@ -59,8 +71,9 @@ curl -X POST localhost:8000/onem2m/EXAMPLE_APP_NAME/EXAMPLE_CONTAINER_NAME/ \
-d '{"m2m:cin": {"con": "EXAMPLE_VALUE", "cnf": "text/plain:0"}}'
```
Get the Content
Get the content:
```sh
curl -X GET localhost:8000/onem2m/EXAMPLE_APP_NAME/EXAMPLE_CONTAINER_NAME/latest
curl -X GET localhost:8000/onem2m/EXAMPLE_APP_NAME/EXAMPLE_CONTAINER_NAME/la
```