This section will guide you on how to configure configure the Android Sense to get alerts on rapid accelerations and device turns. The The accelerometer sensor on the Android Sense device type helps the user identify sudden vigorous movements of the device if it exceeds 60 kph (kilometer per hour), and notify the user of such incidents via email.
Panel | ||
---|---|---|
| ||
|
Follow the steps given below to configure the accelerometer sensor:
Configure the turn and speed subscriber emails address.
Info When the Android Sense detects that the device has exceeded the acceleration of 60 kph it notifies WSO2 IoTS, which then notifies the user via email. The email will be sent to the email address that is configured here.
Navigate to the
<CDM-PLUGINS>/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_publisher/
file and configure the email settings.
speed_publisher.xmlExpand title Click here for more information. Panel borderColor #6A98FA bgColor #ffffff borderWidth 1 Code Block <eventPublisher xmlns="http://wso2.org/carbon/eventpublisher" name="speed_publisher" statistics="disable" trace="disable"> <from streamName="org.wso2.iot.devices.speed" version="1.0.0" /> <mapping customMapping="disable" type="text" /> <to eventAdapterType="email"> <property name="email.subject">Email Alerts Speed</property> <property name="email.address">{ENTER YOUR EMAIL ADDRESS}</property> <property name="email.type">text/html</property> </to> </eventPublisher>
Example:
Code Block <eventPublisher xmlns="http://wso2.org/carbon/eventpublisher" name="speed_publisher" statistics="disable" trace="disable"> <from streamName="org.wso2.iot.devices.speed" version="1.0.0" /> <mapping customMapping="disable" type="text" /> <to eventAdapterType="email"> <property name="email.subject">Email Alerts Speed</property> <property name="email.address">bob@gmail.com</property> <property name="smtp">text/html</property> </to> </eventPublisher>
Navigate to the
<CDM-PLUGINS>/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_publisher/
file and configure the email settings.
turn_publisher.xmlExpand title Click here for more information. Panel borderColor #6A98FA bgColor #ffffff borderWidth 1 Code Block <eventPublisher xmlns="http://wso2.org/carbon/eventpublisher" name="turn_publisher" statistics="disable" trace="disable"> <from streamName="org.wso2.iot.devices.turn" version="1.0.0" /> <mapping customMapping="disable" type="text" /> <to eventAdapterType="email"> <property name="email.subject">Email Alerts Turn</property> <property name="email.address">{DEFINE THE EMAIL ADDRESS}</property> <property name="email.type">text/html</property> </to> </eventPublisher>
Example:
Code Block <eventPublisher xmlns="http://wso2.org/carbon/eventpublisher" name="turn_publisher" statistics="disable" trace="disable"> <from streamName="org.wso2.iot.devices.turn" version="1.0.0" /> <mapping customMapping="disable" type="text" /> <to eventAdapterType="email"> <property name="email.subject">Email Alerts Turn</property> <property name="email.address">user@gmail.com</property> <property name="email.type">text/html</property> </to> </eventPublisher>
Adapter Property Description Configurationfileproperty Example Email Address Email address of the client. Register the publisher for multiple email IDs' by separating them with commas. email.address
Subject The subject of the email to be sent to the defined email address email.subject
This is a test mail.
Email Type The email format to be sent to the defined email address.
Tip If you select
text/html
for this parameter, the message body should be in a valid HTML format.email.type
text/plain
Navigate to the
<CDM-PLUGINS>/components/
iot-plugins/
iot-analytics
directory via the terminal and build it.Code Block mvn clean install
- Copy the
speed.car
file andturn.car
files from the<CDM_PLUGINS>/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/target/carbonapps
directory. - Paste the copied .car files in the
<IoTS_HOME>/repository/deployment/server/carbonapps
directory. Configure the email adapter settings that is under
<adapterConfig type="email">
in the<IoTS_HOME>/repository/conf/output-event-adapters.xml
file.Note You may need to enable the "Allow less secure apps" option in the Gmail account security settings, to connectaccount to WSO2 products.
Expand title Click here for more information. Panel borderColor #6A98FA bgColor #ffffff borderWidth 1 Code Block <adapterConfig type="email"> <!-- Comment mail.smtp.user and mail.smtp.password properties to support connecting SMTP servers which use trust based authentication rather username/password authentication --> <property key="mail.smtp.from">abcd@gmail.com</property> <property key="mail.smtp.user">abcd</property> <property key="mail.smtp.password">xxxx</property> <property key="mail.smtp.host">smtp.gmail.com</property> <property key="mail.smtp.port">587</property> <property key="mail.smtp.starttls.enable">true</property> <property key="mail.smtp.auth">true</property> <!-- Thread Pool Related Properties --> <property key="minThread">8</property> <property key="maxThread">100</property> <property key="keepAliveTimeInMillis">20000</property> <property key="jobQueueSize">10000</property> </adapterConfig>
MinThreads
: Defines the minimum number of threads that needs 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.KeepAliveTimeInMillis
: Defines the duration a connection should be kept alive. If the thread pool has initialized more connections than what was defined inMinThreads
, and they have been idle for more than theKeepAliveDuration
, those idle connections will be terminatedJobQueueSize
: Defines the maximum concurrent email sending tasks that can be queued up.
Example:
Code Block <adapterConfig type="email"> <!-- Comment mail.smtp.user and mail.smtp.password properties to support connecting SMTP servers which use trust based authentication rather username/password authentication --> <property key="mail.smtp.from">no-reply@foo.com</property> <property key="mail.smtp.user">foo</property> <property key="mail.smtp.password">$foo1234</property> <property key="mail.smtp.host">smtp.gmail.com</property> <property key="mail.smtp.port">587</property> <property key="mail.smtp.starttls.enable">true</property> <property key="mail.smtp.auth">true</property> <!-- Thread Pool Related Properties --> <property key="minThread">8</property> <property key="maxThread">100</property> <property key="keepAliveTimeInMillis">20000</property> <property key="jobQueueSize">10000</property> </adapterConfig>
Restart WSO2 IoTS.
Code Block ./wso2server.sh
- Install the Android Sense
.apk
and publish data.