OpenMTC/doc/openmtc-get-started.md
2017-11-07 15:05:35 +01:00

1.7 KiB

Quick Start

In this short tutorial you will:

  1. Setup an OpenMTC Gateway
  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

git clone https://github.com/OpenMTC/OpenMTC OpenMTC

All following commands should be executed from within the repo folder

cd OpenMTC

The next steps need Docker to be installed on your system. If you need help for the installation, follow this guide.

Build the gateway Image

./create-binary-docker gateway

To check if this step was successful run:

docker image ls

If there is an entry "openmtc/gateway" the image was created successfully.

Run the gateway Docker image

docker run -d --name gateway  -p 0.0.0.0:8000:8000  \
    -e "LOGGING_LEVEL=DEBUG"    openmtc/gateway -vv

Create an application resource on your gateway

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

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

curl -X POST localhost:8000/onem2m/EXAMPLE_APP_NAME/EXAMPLE_CONTAINER_NAME/ \
     -H "Content-Type: application/vnd.onem2m-res+json" \
     -d '{"m2m:cin": {"con": "EXAMPLE_VALUE", "cnf": "text/plain:0"}}'

Get the Content

curl -X GET localhost:8000/onem2m/EXAMPLE_APP_NAME/EXAMPLE_CONTAINER_NAME/latest