Configure device using RM Interface

This page guides user to configure reader using Reader Management Interface.

Important

This guide uses Postman Tool for sending API calls to reader.

Import Certificates and Generate Endpoint Configuration

  1. Import Azure device certificates into reader.

  • Method-1: Using SCP.

    • Copy mydevkitkey.pem, mydevkitcertificate.pem `` and ``ca.pem created in Azure IoT Hub Setup into reader. (copy to desired folder inside /apps/).

    ../../_images/AZURE4.png
  • Method-2: Using reader certificate webpage.

    • Create PFX file from certificate generated in Azure IoT Hub Setup.

    • Import Certificates into reader using certificate page.

  • Method-3: pass certificates contents along with Endpoint Config.

  1. Create AZURE Endpoint JSON object (when used Method-1 or Method-2 for importing certificates).

Edit Example AZURE endpoint JSON object shown below.

{
    "name": "AZURE #1",
    "description": "AZURE Dev Zebra",
    "type": "AZURE",
    "configuration": {
        "connectionParams": {
            "hubName": "{IoTHubName}",
            "deviceName": "{IoTDeviceID}",
            "port": 8883,
            "debug": false
        },
        "security": {
            "useLocalCerts": true,
            "certificates": {
                "certificatePath": "{certificatePath}",
                "certAlgorithm": "RS256",
                "certFormat": "PEM",
                "privateKeyPath": "{PrivateKeyPath}",
                "CACertificatePath": "{CAPath}"
            },
            "verifyServerCertificate": true
        },
        "topics": {
            "tagEvents": {
                "topic": "devices/{IoTDeviceID}/messages/events/",
                "qos": 0,
                "retain": true
            },
            "managementEvents": {
                "topic": "devices/{IoTDeviceID}/messages/events/",
                "qos": 0,
                "retain": true
            },
            "management": {
                "command": {
                    "topic": "devices/{IoTDeviceID}/messages/devicebound/#",
                    "qos": 0,
                    "retain": true
                },
                "response": {
                    "topic": "devices/{IoTDeviceID}/messages/events/",
                    "qos": 0,
                    "retain": true
                }
            },
            "control": {
                "command": {
                    "topic": "devices/{IoTDeviceID}/messages/devicebound/#",
                    "qos": 0,
                    "retain": true
                },
                "response": {
                    "topic": "devices/{IoTDeviceID}/messages/events/",
                    "qos": 0,
                    "retain": true
                }
            }
        }
    }
}
  • Replace {IoTHubName} string with IoT Hub name created.

  • Replace {IoTDeviceID} string with IoT device name created.

  • Replace {certificatePath} string with path of mydevkitcertificate.pem inside reader.

    • If certificates are imported using Method-1: Replace the string with /apps/ mydevkitcertificate.pem.

    • If certificates are imported using Method-2: Replace the string with /readerConfig/keystore/mydevkitcertificate.pem.

  • Replace {PrivateKeyPath} string with path of mydevkitkey.pem inside reader.

    • If certificates are imported using Method-1: Replace the string with /apps/ mydevkitkey.pem.

    • If certificates are imported using Method-2: Replace the string with /readerConfig/keystore/mydevkitkey.pem.

  • Replace {CAPath} string with path of ca.pem inside reader.

    • If certificates are imported using Method-1: Replace the string with /apps/ca.pem

    • If certificates are imported using Method-2: Replace the string with /readerConfig/keystore/ca.pem

  1. Create AZURE Endpoint JSON object without local certificates (when used Method-3 for importing certificates).

Edit Example AZURE endpoint JSON object shown below.

{
    "name": "AZURE #1",
    "description": "AZURE Dev Zebra",
    "type": "AZURE",
    "configuration": {
        "connectionParams": {
            "hubName": "{IoTHubName}",
            "deviceName": "{IoTDeviceID}",
            "port": 8883,
            "debug": false
        },
        "security": {
            "useLocalCerts": false,
            "certificates": {
                "certificateContent": "{certificateContent}",
                "certAlgorithm": "RS256",
                "certFormat": "PEM",
                "privateKeyContent": "{privateKeyContent}",
                "CACertificateContent": "{CACertificateContent}"
            },
            "verifyServerCertificate": true
        },
        "topics": {
            "tagEvents": {
                "topic": "devices/{IoTDeviceID}/messages/events/",
                "qos": 0,
                "retain": true
            },
            "managementEvents": {
                "topic": "devices/{IoTDeviceID}/messages/events/",
                "qos": 0,
                "retain": true
            },
            "management": {
                "command": {
                    "topic": "devices/{IoTDeviceID}/messages/devicebound/#",
                    "qos": 0,
                    "retain": true
                },
                "response": {
                    "topic": "devices/{IoTDeviceID}/messages/events/",
                    "qos": 0,
                    "retain": true
                }
            },
            "control": {
                "command": {
                    "topic": "devices/{IoTDeviceID}/messages/devicebound/#",
                    "qos": 0,
                    "retain": true
                },
                "response": {
                    "topic": "devices/{IoTDeviceID}/messages/events/",
                    "qos": 0,
                    "retain": true
                }
            }
        }
    }
}
  • Replace {IoTHubName} string with IoT Hub name created.

  • Replace {IoTDeviceID} string with IoT device name created.

  • Replace {certificateContent} with content of mydevkitcertificate.pem.

  • Replace {privateKeyContent} with content of mydevkitkey.pem.

  • Replace {CACertificateContent} with content of ca.pem.

In certificate content replace newline \\n character with \\r\\n characters as shown below for proper JSON object.

../../_images/AZURE5.png

Note

tagEvents
  • Reader uses this topic to send tag read events.

managementEvents
  • Reader uses this topic to send asynchronous events like heartbeats, GPI, userapp, errors and warnings.

command
  • Reader will subscribe to this topic and listening for commands from cloud.

response
  • Reader uses this topic to send responses to commands.

Important

For control, tagEvents, managementEvents, and management topics, current configuration used default Azure IoT hub topics. These can be changed.

Import Configuration into Reader

  1. Download and import postman collections Cloud Connect Enhanced UI.postman_collection.json and Cloud Connect - RM-commands.postman_collection.json.

  2. Create an environment variables protocol (http/https) and reader-ip (10.17.231.7).

  3. Execute Login API.

    Important

    change username and password field in the body with readers username and password configured.

    ../../_images/AZURE6.png
  4. Goto ADD endpoint (AZURE) API and replace the JSON object between <motorm:data> </motorm:data> with the AWS Endpoint JSON object created in Import Certificates and Generate Endpoint Configuration.

    ../../_images/AZURE7.png
    • The response 200 OK indicate the endpoint got added successfully.

    • Status other than 200 indicate error and response contain the failure reason and check reader syslog to get more info on error.

  5. Create Endpoint Mapping for AZURE.

    • Goto UPDATE endpoint mapping API and edit control, data, event, and management endpoints to the name used in AZURE endpoint JSON object.

    Important

    Reader is configured to AZURE endpoint for all the interfaces.

    ../../_images/AZURE8.png
    • The response 200 OK indicate the endpoint got added successfully.

    • Status other than 200 indicate error and response contain the failure reason and check reader syslog to get more info on error.

Connect to Cloud

  1. Goto isEnrolledToCloud and check if reader is enrolled for IoT connect or not.

../../_images/AZURE9.png
  1. If device is not enrolled currently, Send EnrollToCloud API.

../../_images/AZURE10.png
  1. If device is already enrolled, Send disconnectFromCloud API and connectToCloud API.

disconnectFromCloud API:

../../_images/AZURE11.png

connectToCloud API:

../../_images/AZURE12.png

Verify Cloud Connection

  1. Check Cloud Connection Status using isConnectedToCloud API.

../../_images/AZURE13.png