This documentation is for WSO2 IoT Server 3.1.0. View the documentation for the latest release.
Server Communicating with the Device - IoT Server 3.1.0 - WSO2 Documentation
                                                                                                                                                                                                                                                                                                                                                                                                                                                   
||
Skip to end of metadata
Go to start of metadata

When you send a command to a device, it goes through the WSO2 IoT Server transport sender mechanism. For example, switching on or switching off the bulb on the RaspberryPi device type. To identify the flow of what happens when WSO2 IoT Server receives the command, and how it communicates take a look at the diagram given below:

Let's understand this clearly by using the RaspberryPi device type:

  1. Write the API to switch the bulb on. Once WSO2 IoT Server receives the command it will call the API you have written to switch the bulb on.

    For more more information, see Writing Device APIs.

  2. Define the operation type for the API in the <DEVICE_TYPE>SeviceImpl.java file. WSO2 IoT Server supports the following 4 operation types.

    • POLICY
    • COMMAND
    • CONFIG
    • PROFILE

    Example: The RaspberryPiServiceImpl.java file has configured the bulb switching on and off API as a COMMAND operation.

    Operation commandOp = new CommandOperation();
    commandOp.setCode("bulb");
    commandOp.setType(Operation.Type.COMMAND);
    commandOp.setEnabled(true);
    commandOp.setPayLoad(actualMessage);
  3. Assign the properties you defined in step 2 above to a publisher topic as done in the RaspberryPiServiceImpl.java file.

    Properties props = new Properties();
    props.setProperty(RaspberrypiConstants.MQTT_ADAPTER_TOPIC_PROPERTY_NAME, publishTopic);
    commandOp.setProperties(props);
  4. The command is then sent to the device.
    Follow the steps given below to find out if the device received the command: 

    1. Sign in to the WSO2 IoT Server device management console.

       Click here for more information.

      Follow the instructions given below to start WSO2 IoT Server, and sign into the device management console:

      1. Navigate to the WSO2 IoT Server pack's samples directory and run the device-plugins-deployer.xml file.

        Why is this needed?

        Before enrolling devices with WSO2 IoT Server you need to have the device type plugins created. The Android, Android Sense, Windows, and Android Virtual Device sample device type plugins are available by default on WSO2 IoT Server. You need to run the command given below to create the Raspberry Pi, Arduino, and Virtual Fire Alarm sample plugins.

        For more information on writing your own device plugin, see Writing Device Types.

        Example:

        cd <IOTS_HOME>/samples
        mvn clean install -f device-plugins-deployer.xml
      2. Start WSO2 IoT Server by starting the three profiles in the following order:

        1. Start the broker profile, which corresponds to the WSO2 Message Broker profile.

          cd <IOTS_HOME>/bin
          ./broker.sh
          cd <IOTS_HOME>\bin
          broker.bat

          The default port assigned for the broker is 9446.

        2. Start the core profile, which corresponds to the WSO2 Connected Device Management Framework (WSO2 CDMF) profile.

          ./iot-server.sh
          iot-server.bat

          The default port assigned for the core is 9443.

        3. Start the analytics profile, which corresponds to the WSO2 Data Analytics Server profile.

          ./analytics.sh
          analytics.bat

          The default port assigned for analytics is 9445.

      3. Access the device management console by navigating to https://<HTTPS_HOST>:<HTTPS_PORT>/devicemgt.
        Example: https://localhost:9443/devicemgt

      4. Enter your username and password.
        If you are new to using WSO2 IoT Server, you need to first register before you can to log into the WSO2 device management console.

         Click here for more information on registering with WSO2 IoT Server.

        Follow the instructions given below to register with WSO2 IoT Server:

        1. Click Create an account
        2. Fill out the registration form.

          • First Name: Provide your first name.
          • Last Name: Provide your last name.
          • Username: Provide a username. It should be at least 3 characters long with no white spaces.
          • Email: Provide a valid email address.
          • Password: Provide a password. It should be at least 8 characters long.
          • Confirm Password: Provide the password again to confirm it.
        3. Click Register.
      5. Click LOGIN

    2. Click the device you sent the command. 
      Example: Click virtual fire alarm. 
    3. Click Operation logs, to view the status of the command you sent.

      The operation status can be any of the following values:

      • IN-PROGRESS - The operation is processing on the IoTS server side and has not yet been delivered to the device.
      • PENDING - The operation is delivered to the device but the response from the device is pending.
      • COMPLETED - The operation is delivered to the device and the server has received a response back from the device.
      • ERROR - An error has occurred while carrying out the operation.

  • No labels