This documentation is for WSO2 IoT Server 3.1.0. View the documentation for the latest release.
Android Sense - IoT Server 3.1.0 - WSO2 Documentation
Skip to end of metadata
Go to start of metadata

In this tutorial, you will connect an Android device to WSO2 IoT Server and monitor the sensor data.

WSO2 IoT Server supports devices on Android version 4.2.x to 7.0 (Android Jelly Beans to Nougat)

The following subsections explain how you can work with the Android Sense device type:

Before you begin

 Start the WSO2 IoT Server broker, core and, analytics profiles in the given order. For more information, see how to start the WSO2 IoT Server.

cd <IOTS_HOME>/bin
------Linux/Mac OS/Solaris ----------

Enroll Android Sense

  1. Sign in to the Device Management console.

     Click here for more information.
    Follow the instructions below to sign in to the WSO2 IoT Server device management console:
    1. If you have not started the server previously, start the server.

    2. Access the device management console.

      • For access via HTTP: 

        For example: http://localhost:9763/devicemgt/
      • For access via secured HTTP: 
        For example: https://localhost:9443/devicemgt/ 
    3. Enter the username and password, and sign in.

      The system administrator will be able to log in using admin for both the username and password. However, other users will have to first register with WSO2 IoT Server before being able to log into the IoTS device management console. For more information on creating a new account, see Registering with WSO2 IoT Server.

    4. Click LOGIN. The respective device management console will change, based on the permissions assigned to the user.
      For example, the device management console for an administrator is as follows:

  2. Click Enroll New Device.

    If you are an Admin user, click the menu icon, and select DEVICE MANAGEMENT, to access the ENROLL DEVICE button.

  3. Click Android Sense to enroll a device of the type Android Sense.
  4. Enroll the device.

     Scan the QR code using your device, and the Android Sense agent will download on to your device.

    Prerequisite: If you click Scan QR code, you will need to have a QR scanner application on the device.

    1. Click Download APK.
    2. Copy the downloaded file to your mobile device.

    Configure the email settings to send out an invitation for users to register their device with WSO2 IoT Server.

     Click here for more information on configuring the email settings.

    Configure the email settings to send out registration confirmation emails to new users and invite existing users to register their device with WSO2 IoT Server.

    In WSO2 IoT Server, user registration confirmation emails are disabled by default, and the admin needs to provide the required configuration details to enable it.

    1. Create an email account to send out emails to users that register with WSO2 IoT Server (e.g., [email protected]).

    2. Open the <IoTS_HOME>/conf/axis2/axis2.xml file, uncomment the mailto transportSender section, and configure the WSO2 IoT Server email account.

      <transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
         <parameter name=""></parameter>
         <parameter name="mail.smtp.port">587</parameter>
         <parameter name="mail.smtp.starttls.enable">true</parameter>
         <parameter name="mail.smtp.auth">true</parameter>
         <parameter name="mail.smtp.user">synapse.demo.0</parameter>
         <parameter name="mail.smtp.password">mailpassword</parameter>
         <parameter name="mail.smtp.from">[email protected]</parameter>

      For mail.smtp.user, mail.smtp.password, and mail.smtp.from, use the username, password, and email address (respectively) from the email account you set up.


      <transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
         <parameter name=""></parameter>
         <parameter name="mail.smtp.port">587</parameter>
         <parameter name="mail.smtp.starttls.enable">true</parameter>
         <parameter name="mail.smtp.auth">true</parameter>
         <parameter name="mail.smtp.user">no-reply</parameter>
         <parameter name="mail.smtp.password">$foo1234</parameter>
         <parameter name="mail.smtp.from">[email protected]</parameter>

      After updating the Axis2 configurations, restart the core profile.

    3. Optionally, configure the email sender thread pool.
      Navigate to the email-sender-config.xml file, which is in the <IOTS_HOME>/conf/etc directory, and configure the following fields under <EmailSenderConfig>.

      • MinThreads: Defines the minimum number of threads that need to be available in the underlying thread pool when the email sender functionality is initialized.

      • MaxThreads : Defines the maximum number of threads that should serve email sending at any given time.

      • KeepAliveDuration : Defines the duration that a connection should be kept alive. If the thread pool has initialized more connections than what was defined in MinThreads, and they have been idle for more than the KeepAliveDuration, those idle connections will be terminated

      • ThreadQueueCapacity : Defines the maximum concurrent email sending tasks that can be queued up.


    4. Optionally, customize the email templates that are in the <IoTS_HOME>/repository/resources/email-templates directory. 

      The email templating functionality of WSO2 IoT Server is implemented on top of Apache Velocity, which is a free and open-source template engine.

      1. Open the email template that you wish to edit based on the requirement, such as the user-enrollment.vm or user-registration.vm file.
      2. Edit the <Subject> and <Body> to suit your requirement.
      • If you need to access HTTP or HTTPS base URLs of the server within your custom template configs, use the $base-url-http and $base-url-https variables, respectively.
      • You can update the look and feel of the email template via the WSO2 IoT Server management console too. For more information, see Customizing Email Templates for Tenants.

    1. Click Invite by Email.
    2. Enter the email address of the users who need to enroll their device with WSO2 IoT Server, and click Send Invite(s).
      If you entered your email address, you will receive the registration email.

      In this scenario, WSO2 IoT Server uses a third-party email account to send the email invite to the same/another email address. Make sure the settings of that third-party email account allows another entity (in this case it is WSO2 IoT Server) to send an email on its behalf.

  5. Open the downloaded file, tap NEXT, and tap INSTALL.

  6. Tap OPEN, once the WSO2-SenseAgent is installed.
  7. Enter your details and tap REGISTER DEVICE.
    • Username: Your WSO2 IoT Server username
    • Password: The password you used to sign into WSO2 IoT Server
    • Server URL: Provide the server URL in the https://<IOTS_HOST>:<IOTS_HTTPS_PORT> format.
  8. Try out the Android Sense application.

    • If you want to add sensors, tap add sensor , select the sensors you wish to add, and tap OK.

      For more information on configuring the accelerometer to work with Android Sense, see Configuring the Rapid Accelerometer of the Android Sense.

    • If you want to push the data to the WSO2 IoT Server so you can view the data in real time or check out the historical data, tap push data to device.

View device analytics

To monitor real-time device statistics,

  1. Click on the device icon available on the Devices page, and navigate to Device Details page.
  2. To view location-based device statistics, follow the steps below: 
    1. Install the geo extension feature to WSO2 IoT Server, by navigating to <IoTS_HOME>/wso2/analytics/scripts directory and running the following command. 

      mvn clean install -f siddhi-geo-extention-deployer.xml
    2. Enable the geo extension feature in WSO2 IoT Server, by opening the cdm-config.xml file in the <IoTS_HOME>/conf directory and setting the following properties under the <GeoLocationConfiguration> tag to true. 

    3. Restart the WSO2 IoT Server broker, core and, analytics profiles in the given order 

      cd <IOTS_HOME>/bin
      ------Linux/Mac OS/Solaris ----------
    4. Click on the Device Location tab. 

      For more information on location-based services, see Monitoring Devices Using Location Based Services

What's next

Follow the options given below to see what you can do next:

  • Try out building the Android Sense source. For more information, see Building the Android Sense Agent.

  • Navigate to the Device Management page to view all the created devices.

     Click here for more information on navigating to the Device Management page.
    1. Sign in to the Device Management console.
    2. Click the menu icon.
    3. Click Device Management.
  • Select a device from your device dashboard and check the available operations and monitor real-time data.

  • No labels