Merge branch 'master' of https://github.com/wso2-incubator/product-iot-server
@ -1,59 +0,0 @@
|
||||
<!--/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>component</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>${groupId}.doormanager.agent</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>${groupId}.doormanager.agent</name>
|
||||
<packaging>war</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${wso2.maven.compiler.source}</source>
|
||||
<target>${wso2.maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>${maven-war-plugin.version}</version>
|
||||
<configuration>
|
||||
<warName>${groupId}.doormanager.agent_agent</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,23 +0,0 @@
|
||||
<!--/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/-->
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
<display-name>Sample-Agent-Webapp</display-name>
|
||||
</web-app>
|
@ -1,22 +0,0 @@
|
||||
<%--/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/--%>
|
||||
<html>
|
||||
<body>
|
||||
<h2>Hello World!</h2>
|
||||
</body>
|
||||
</html>
|
@ -1,62 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<EventStoreConfiguration>
|
||||
<Source>
|
||||
<StreamId>org.wso2.iot.devices.sensor:1.0.0</StreamId>
|
||||
</Source>
|
||||
<RecordStoreName>EVENT_STORE</RecordStoreName>
|
||||
<TableSchema>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_owner</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_deviceType</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_deviceId</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_time</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>LONG</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>sensorValue</Name>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>FLOAT</Type>
|
||||
</ColumnDefinition>
|
||||
</TableSchema>
|
||||
</EventStoreConfiguration>
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "org.wso2.iot.devices.sensor",
|
||||
"version": "1.0.0",
|
||||
"nickName": "Flow Rate Data",
|
||||
"description": "Sensor data received from the Device",
|
||||
"metaData": [
|
||||
{"name":"owner","type":"STRING"},
|
||||
{"name":"deviceType","type":"STRING"},
|
||||
{"name":"deviceId","type":"STRING"},
|
||||
{"name":"time","type":"LONG"}
|
||||
],
|
||||
"payloadData": [
|
||||
{
|
||||
"name": "sensorValue","type": "FLOAT"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<EventStoreConfiguration>
|
||||
<Source>
|
||||
<StreamId>org.wso2.iot.devices.smartLock:1.0.0</StreamId>
|
||||
</Source>
|
||||
<RecordStoreName>EVENT_STORE</RecordStoreName>
|
||||
<TableSchema>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_owner</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_deviceType</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_deviceId</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_time</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>LONG</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>smartLock</Name>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>FLOAT</Type>
|
||||
</ColumnDefinition>
|
||||
</TableSchema>
|
||||
</EventStoreConfiguration>
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "org.wso2.iot.devices.smartLock",
|
||||
"version": "1.0.0",
|
||||
"nickName": "smartLock",
|
||||
"description": "smartLock data received from the Device",
|
||||
"metaData": [
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "deviceType",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "deviceId",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "time",
|
||||
"type": "LONG"
|
||||
}
|
||||
],
|
||||
"payloadData": [
|
||||
{
|
||||
"name": "smartLock",
|
||||
"type": "FLOAT"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.doormanager.manager.api.util;
|
||||
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
|
||||
/**
|
||||
* This class provides utility functions used by REST-API.
|
||||
*/
|
||||
public class APIUtil {
|
||||
|
||||
public static String getAuthenticatedUser() {
|
||||
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
String username = threadLocalCarbonContext.getUsername();
|
||||
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
|
||||
if (username.endsWith(tenantDomain)) {
|
||||
return username.substring(0, username.lastIndexOf("@"));
|
||||
}
|
||||
return username;
|
||||
}
|
||||
|
||||
public static String getTenantDomainOfUser() {
|
||||
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
return threadLocalCarbonContext.getTenantDomain();
|
||||
}
|
||||
|
||||
public static DeviceManagementProviderService getDeviceManagementService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
DeviceManagementProviderService deviceManagementProviderService =
|
||||
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||
if (deviceManagementProviderService == null) {
|
||||
String msg = "Device Management service has not initialized.";
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return deviceManagementProviderService;
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.doormanager.manager.api.util;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class ResponsePayload {
|
||||
|
||||
private int statusCode;
|
||||
private String messageFromServer;
|
||||
private Object responseContent;
|
||||
|
||||
public static ResponsePayload.ResponsePayloadBuilder statusCode(int statusCode) {
|
||||
ResponsePayload message = new ResponsePayload();
|
||||
return message.getBuilder().statusCode(statusCode);
|
||||
}
|
||||
|
||||
public static ResponsePayload.ResponsePayloadBuilder messageFromServer(
|
||||
String messageFromServer) {
|
||||
ResponsePayload message = new ResponsePayload();
|
||||
return message.getBuilder().messageFromServer(messageFromServer);
|
||||
}
|
||||
|
||||
public static ResponsePayload.ResponsePayloadBuilder responseContent(String responseContent) {
|
||||
ResponsePayload message = new ResponsePayload();
|
||||
return message.getBuilder().responseContent(responseContent);
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public void setStatusCode(int statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getMessageFromServer() {
|
||||
return messageFromServer;
|
||||
}
|
||||
|
||||
public void setMessageFromServer(String messageFromServer) {
|
||||
this.messageFromServer = messageFromServer;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Object getResponseContent() {
|
||||
return responseContent;
|
||||
}
|
||||
|
||||
public void setResponseContent(Object responseContent) {
|
||||
this.responseContent = responseContent;
|
||||
}
|
||||
|
||||
private ResponsePayload.ResponsePayloadBuilder getBuilder() {
|
||||
return new ResponsePayload.ResponsePayloadBuilder();
|
||||
}
|
||||
|
||||
public class ResponsePayloadBuilder {
|
||||
|
||||
private int statusCode;
|
||||
private String messageFromServer;
|
||||
private Object responseContent;
|
||||
|
||||
public ResponsePayloadBuilder statusCode(int statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponsePayloadBuilder messageFromServer(String messageFromServer) {
|
||||
this.messageFromServer = messageFromServer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponsePayloadBuilder responseContent(String responseContent) {
|
||||
this.responseContent = responseContent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponsePayload build() {
|
||||
ResponsePayload payload = new ResponsePayload();
|
||||
payload.setStatusCode(statusCode);
|
||||
payload.setMessageFromServer(messageFromServer);
|
||||
payload.setResponseContent(responseContent);
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<!-- This file contains the list of permissions that are associated with URL end points
|
||||
of the web app. Each permission should contain the name, permission path ,API path
|
||||
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||
it will result 403 error at the runtime.
|
||||
-->
|
||||
<PermissionConfiguration>
|
||||
<APIVersion></APIVersion>
|
||||
<!-- Device related APIs -->
|
||||
<Permission>
|
||||
<name>Get device</name>
|
||||
<path>/device-mgt/user/devices/list</path>
|
||||
<url>/manager/device/*</url>
|
||||
<method>GET</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Add device</name>
|
||||
<path>/device-mgt/user/devices/add</path>
|
||||
<url>/manager/device/register</url>
|
||||
<method>PUT</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Download device</name>
|
||||
<path>/device-mgt/user/devices/add</path>
|
||||
<url>/manager/device/doormanager/download</url>
|
||||
<method>GET</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Generate link to download</name>
|
||||
<path>/device-mgt/user/devices/add</path>
|
||||
<url>/manager/device/doormanager/generate_link</url>
|
||||
<method>GET</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Update device</name>
|
||||
<path>/device-mgt/user/devices/update</path>
|
||||
<url>/manager/device/update/*</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Remove device</name>
|
||||
<path>/device-mgt/user/devices/remove</path>
|
||||
<url>/manager/device/remove/*</url>
|
||||
<method>DELETE</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
</PermissionConfiguration>
|
@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.doormanager.plugin.impl;
|
||||
|
||||
import org.homeautomation.doormanager.plugin.constants.DoorManagerConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManager;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DoorManagerManagerService implements DeviceManagementService{
|
||||
private DeviceManager deviceManager;
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return DoorManagerConstants.DEVICE_TYPE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getProviderTenantDomain() {
|
||||
return "carbon.super";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSharedWithAllTenants() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSharedTenantsDomain() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws DeviceManagementException {
|
||||
this.deviceManager=new DoorManagerManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceManager getDeviceManager() {
|
||||
return deviceManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationManager getApplicationManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOperationToDevices(Operation operation, List<DeviceIdentifier> deviceIds)
|
||||
throws DeviceManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Application[] getApplications(String domain, int pageNumber, int size)
|
||||
throws ApplicationManagementException {
|
||||
return new Application[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateApplicationStatus(DeviceIdentifier deviceId, Application application,
|
||||
String status) throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getApplicationStatus(DeviceIdentifier deviceId, Application application)
|
||||
throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForDevices(Operation operation, List<DeviceIdentifier> deviceIdentifiers)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForUsers(Operation operation, List<String> userNameList)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForUserRoles(Operation operation, List<String> userRoleList)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.doormanager.plugin.impl;
|
||||
|
||||
import org.homeautomation.doormanager.plugin.constants.DoorManagerConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManager;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DoorManagerService implements DeviceManagementService {
|
||||
private DeviceManager deviceManager;
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return DoorManagerConstants.DEVICE_TYPE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getProviderTenantDomain() {
|
||||
return "carbon.super";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSharedWithAllTenants() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSharedTenantsDomain() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws DeviceManagementException {
|
||||
this.deviceManager = new DoorManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceManager getDeviceManager() {
|
||||
return deviceManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationManager getApplicationManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOperationToDevices(Operation operation, List<DeviceIdentifier> deviceIds)
|
||||
throws DeviceManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Application[] getApplications(String domain, int pageNumber, int size)
|
||||
throws ApplicationManagementException {
|
||||
return new Application[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateApplicationStatus(DeviceIdentifier deviceId, Application application,
|
||||
String status) throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getApplicationStatus(DeviceIdentifier deviceId, Application application)
|
||||
throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForDevices(Operation operation, List<DeviceIdentifier> deviceIdentifiers)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForUsers(Operation operation, List<String> userNameList)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForUserRoles(Operation operation, List<String> userRoleList)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.doormanager.plugin.impl.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Contains utility methods used by Door Opener plugin.
|
||||
*/
|
||||
public class DoorManagerUtils {
|
||||
|
||||
private static Log log = LogFactory.getLog(DoorManagerUtils.class);
|
||||
public static String getDeviceProperty(Map<String, String> deviceProperties, String property) {
|
||||
String deviceProperty = deviceProperties.get(property);
|
||||
if (deviceProperty == null) {
|
||||
return "";
|
||||
}
|
||||
return deviceProperty;
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 29 KiB |
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
var deviceType = $("#details").data("devicetype");
|
||||
var deviceId = $(".device-id").data("deviceid");
|
||||
var monitor_operations = $("#details").data("monitor");
|
||||
var appContext = $("#details").data("appcontext");
|
||||
var publicURL =$("#details").data("unitpublicuri");
|
||||
|
||||
$(window).on('resize', function () {
|
||||
location.reload(false);
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
updateGraphs();
|
||||
});
|
||||
|
||||
function updateGraphs() {
|
||||
var tv = 2000;
|
||||
var iv = setInterval(function () {
|
||||
var getStatsRequest = $.ajax({
|
||||
url: appContext + "/api/operations/" + deviceType + "/stats?deviceId=" + deviceId,
|
||||
method: "get"
|
||||
});
|
||||
getStatsRequest.done(function (data) {
|
||||
var data = data.data;
|
||||
if(data[0].door_locker_state){
|
||||
var currentStateOfTheLock=data[0].door_locker_state;
|
||||
console.log(currentStateOfTheLock);
|
||||
if( currentStateOfTheLock == "UNLOCKED"){
|
||||
$("#lockerCurrentState").attr("src", publicURL+"/images/unlock.png");
|
||||
}else{
|
||||
$("#lockerCurrentState").attr("src", publicURL+"/images/lock.png");
|
||||
}
|
||||
}else{
|
||||
console.log("Backend server not available");
|
||||
}
|
||||
});
|
||||
}, tv);
|
||||
}
|
Before Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 46 KiB |
@ -1,16 +1,3 @@
|
||||
#/*
|
||||
# * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
# * WSO2 Inc. licenses this file to you under the Apache License,
|
||||
# * Version 2.0 (the "License"); you may not use this file except
|
||||
# * in compliance with the License.
|
||||
# * You may obtain a copy of the License at
|
||||
# * http://www.apache.org/licenses/LICENSE-2.0
|
||||
# * Unless required by applicable law or agreed to in writing,
|
||||
# * software distributed under the License is distributed on an
|
||||
# * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# * KIND, either express or implied. See the License for the
|
||||
# * specific language governing permissions and limitations
|
||||
# * under the License.
|
||||
# */
|
||||
templates=deviceConfig.properties
|
||||
zipfilename=doormanager.zip
|
||||
|
||||
|
@ -0,0 +1,194 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
/**
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import httplib
|
||||
import logging
|
||||
import logging.handlers
|
||||
import signal
|
||||
import ssl
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
from functools import wraps
|
||||
|
||||
import RPi.GPIO as GPIO
|
||||
|
||||
import MQTTHandler
|
||||
import RFIDReader
|
||||
import iotUtils
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Overriding the default SSL version used in some of the Python (2.7.x) versions
|
||||
# This is a known issue in earlier Python releases
|
||||
# But was fixed in later versions. Ex-2.7.11
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def sslwrap(func):
|
||||
@wraps(func)
|
||||
def bar(*args, **kw):
|
||||
kw['ssl_version'] = ssl.PROTOCOL_TLSv1
|
||||
return func(*args, **kw)
|
||||
|
||||
return bar
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
PUSH_INTERVAL = 5000 # time interval between successive data pushes in seconds
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Logger defaults
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
LOG_FILENAME = "DoorManagerAgent.log"
|
||||
logging_enabled = False
|
||||
LOG_LEVEL = logging.INFO # Could be e.g. "DEBUG" or "WARNING"
|
||||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Python version
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if sys.version_info < (2, 6, 0):
|
||||
sys.stderr.write("You need python 2.6.0 or later to run this script\n")
|
||||
exit(1)
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Define and parse command line arguments
|
||||
# If the log file is specified on the command line then override the default
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
parser = argparse.ArgumentParser(description="Python service to push RPi info to the Device Cloud")
|
||||
parser.add_argument("-l", "--log", help="file to write log to (default '" + LOG_FILENAME + "')")
|
||||
|
||||
help_string_for_data_push_interval = "time interval between successive locker status push to server(default '" + str(
|
||||
PUSH_INTERVAL) + "')"
|
||||
parser.add_argument("-i", "--interval", type=int, help=help_string_for_data_push_interval)
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.log:
|
||||
LOG_FILENAME = args.log
|
||||
|
||||
if args.interval:
|
||||
PUSH_INTERVAL = args.interval
|
||||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# A class we can use to capture stdout and sterr in the log
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
class IOTLogger(object):
|
||||
def __init__(self, logger, level):
|
||||
"""Needs a logger and a logger level."""
|
||||
self.logger = logger
|
||||
self.level = level
|
||||
|
||||
def write(self, message):
|
||||
if message.rstrip() != "": # Only log if there is a message (not just a new line)
|
||||
self.logger.log(self.level, message.rstrip())
|
||||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Configure logging to log to a file,
|
||||
# making a new file at midnight and keeping the last 3 day's data
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def configureLogger(loggerName):
|
||||
logger = logging.getLogger(loggerName)
|
||||
logger.setLevel(LOG_LEVEL) # Set the log level to LOG_LEVEL
|
||||
handler = logging.handlers.TimedRotatingFileHandler(LOG_FILENAME, when="midnight",
|
||||
backupCount=3) # Handler that writes to a file,
|
||||
# ~~~make new file at midnight and keep 3 backups
|
||||
formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s') # Format each log message like this
|
||||
handler.setFormatter(formatter) # Attach the formatter to the handler
|
||||
logger.addHandler(handler) # Attach the handler to the logger
|
||||
|
||||
if (logging_enabled):
|
||||
sys.stdout = IOTLogger(logger, logging.INFO) # Replace stdout with logging to file at INFO level
|
||||
sys.stderr = IOTLogger(logger, logging.ERROR) # Replace stderr with logging to file at ERROR level
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# This is a Thread object for reading RFID card
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
class ListenRFIDhread(object):
|
||||
def __init__(self):
|
||||
thread = threading.Thread(target=self.run, args=())
|
||||
thread.daemon = True # Daemonize thread
|
||||
thread.start() # Start the execution
|
||||
|
||||
def run(self):
|
||||
RFIDReader.main()
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# This is a Thread object for listening for MQTT Messages
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
class ListenMQTTThread(object):
|
||||
def __init__(self):
|
||||
thread = threading.Thread(target=self.run, args=())
|
||||
thread.daemon = True # Daemonize thread
|
||||
thread.start() # Start the execution
|
||||
|
||||
def run(self):
|
||||
MQTTHandler.main()
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# When sysvinit sends the TERM signal, cleanup before exiting
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def sigterm_handler(_signo, _stack_frame):
|
||||
print("[] received signal {}, exiting...".format(_signo))
|
||||
sys.exit(0)
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# This method used to initialize GPIO ports
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def initDoorLock():
|
||||
# GPIO.setmode(GPIO.BOARD)
|
||||
GPIO.setup(iotUtils.DOOR_LOCKER_1_PORT, GPIO.OUT, initial=GPIO.HIGH)
|
||||
GPIO.setup(iotUtils.DOOR_LOCKER_2_PORT, GPIO.OUT, initial=GPIO.HIGH)
|
||||
GPIO.setup(iotUtils.LOCK_STATE_ON_NOTIFY_PORT, GPIO.OUT, initial=GPIO.LOW)
|
||||
GPIO.setup(iotUtils.LOCK_STATE_OFF_NOTIFY_PORT, GPIO.OUT, initial=GPIO.LOW)
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# The Main method of the Automatic Door Locker Agent
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def main():
|
||||
configureLogger("AutomaticDoorLocker")
|
||||
ListenMQTTThread()
|
||||
ListenRFIDhread()
|
||||
initDoorLock()
|
||||
# registerUIDofRFIDCard() # Call the register endpoint and register Device I
|
||||
# ListenMQTTThread()
|
||||
while True:
|
||||
try:
|
||||
time.sleep(PUSH_INTERVAL)
|
||||
except (KeyboardInterrupt, Exception) as e:
|
||||
print "AutomaticDoorLockerStats: Exception in RaspberryAgentThread (either KeyboardInterrupt or Other)"
|
||||
print ("AutomaticDoorLockerStats: " + str(e))
|
||||
print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
|
||||
pass
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -0,0 +1,396 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf8 -*-
|
||||
|
||||
import RPi.GPIO as GPIO
|
||||
import spi
|
||||
import signal
|
||||
import time
|
||||
|
||||
class MFRC522:
|
||||
NRSTPD = 22
|
||||
|
||||
MAX_LEN = 16
|
||||
|
||||
PCD_IDLE = 0x00
|
||||
PCD_AUTHENT = 0x0E
|
||||
PCD_RECEIVE = 0x08
|
||||
PCD_TRANSMIT = 0x04
|
||||
PCD_TRANSCEIVE = 0x0C
|
||||
PCD_RESETPHASE = 0x0F
|
||||
PCD_CALCCRC = 0x03
|
||||
|
||||
PICC_REQIDL = 0x26
|
||||
PICC_REQALL = 0x52
|
||||
PICC_ANTICOLL = 0x93
|
||||
PICC_SElECTTAG = 0x93
|
||||
PICC_AUTHENT1A = 0x60
|
||||
PICC_AUTHENT1B = 0x61
|
||||
PICC_READ = 0x30
|
||||
PICC_WRITE = 0xA0
|
||||
PICC_DECREMENT = 0xC0
|
||||
PICC_INCREMENT = 0xC1
|
||||
PICC_RESTORE = 0xC2
|
||||
PICC_TRANSFER = 0xB0
|
||||
PICC_HALT = 0x50
|
||||
|
||||
MI_OK = 0
|
||||
MI_NOTAGERR = 1
|
||||
MI_ERR = 2
|
||||
|
||||
Reserved00 = 0x00
|
||||
CommandReg = 0x01
|
||||
CommIEnReg = 0x02
|
||||
DivlEnReg = 0x03
|
||||
CommIrqReg = 0x04
|
||||
DivIrqReg = 0x05
|
||||
ErrorReg = 0x06
|
||||
Status1Reg = 0x07
|
||||
Status2Reg = 0x08
|
||||
FIFODataReg = 0x09
|
||||
FIFOLevelReg = 0x0A
|
||||
WaterLevelReg = 0x0B
|
||||
ControlReg = 0x0C
|
||||
BitFramingReg = 0x0D
|
||||
CollReg = 0x0E
|
||||
Reserved01 = 0x0F
|
||||
|
||||
Reserved10 = 0x10
|
||||
ModeReg = 0x11
|
||||
TxModeReg = 0x12
|
||||
RxModeReg = 0x13
|
||||
TxControlReg = 0x14
|
||||
TxAutoReg = 0x15
|
||||
TxSelReg = 0x16
|
||||
RxSelReg = 0x17
|
||||
RxThresholdReg = 0x18
|
||||
DemodReg = 0x19
|
||||
Reserved11 = 0x1A
|
||||
Reserved12 = 0x1B
|
||||
MifareReg = 0x1C
|
||||
Reserved13 = 0x1D
|
||||
Reserved14 = 0x1E
|
||||
SerialSpeedReg = 0x1F
|
||||
|
||||
Reserved20 = 0x20
|
||||
CRCResultRegM = 0x21
|
||||
CRCResultRegL = 0x22
|
||||
Reserved21 = 0x23
|
||||
ModWidthReg = 0x24
|
||||
Reserved22 = 0x25
|
||||
RFCfgReg = 0x26
|
||||
GsNReg = 0x27
|
||||
CWGsPReg = 0x28
|
||||
ModGsPReg = 0x29
|
||||
TModeReg = 0x2A
|
||||
TPrescalerReg = 0x2B
|
||||
TReloadRegH = 0x2C
|
||||
TReloadRegL = 0x2D
|
||||
TCounterValueRegH = 0x2E
|
||||
TCounterValueRegL = 0x2F
|
||||
|
||||
Reserved30 = 0x30
|
||||
TestSel1Reg = 0x31
|
||||
TestSel2Reg = 0x32
|
||||
TestPinEnReg = 0x33
|
||||
TestPinValueReg = 0x34
|
||||
TestBusReg = 0x35
|
||||
AutoTestReg = 0x36
|
||||
VersionReg = 0x37
|
||||
AnalogTestReg = 0x38
|
||||
TestDAC1Reg = 0x39
|
||||
TestDAC2Reg = 0x3A
|
||||
TestADCReg = 0x3B
|
||||
Reserved31 = 0x3C
|
||||
Reserved32 = 0x3D
|
||||
Reserved33 = 0x3E
|
||||
Reserved34 = 0x3F
|
||||
|
||||
serNum = []
|
||||
|
||||
def __init__(self, dev='/dev/spidev0.0', spd=1000000):
|
||||
spi.openSPI(device=dev,speed=spd)
|
||||
GPIO.setmode(GPIO.BOARD)
|
||||
GPIO.setup(22, GPIO.OUT)
|
||||
GPIO.output(self.NRSTPD, 1)
|
||||
self.MFRC522_Init()
|
||||
|
||||
def MFRC522_Reset(self):
|
||||
self.Write_MFRC522(self.CommandReg, self.PCD_RESETPHASE)
|
||||
|
||||
def Write_MFRC522(self, addr, val):
|
||||
spi.transfer(((addr<<1)&0x7E,val))
|
||||
|
||||
def Read_MFRC522(self, addr):
|
||||
val = spi.transfer((((addr<<1)&0x7E) | 0x80,0))
|
||||
return val[1]
|
||||
|
||||
def SetBitMask(self, reg, mask):
|
||||
tmp = self.Read_MFRC522(reg)
|
||||
self.Write_MFRC522(reg, tmp | mask)
|
||||
|
||||
def ClearBitMask(self, reg, mask):
|
||||
tmp = self.Read_MFRC522(reg);
|
||||
self.Write_MFRC522(reg, tmp & (~mask))
|
||||
|
||||
def AntennaOn(self):
|
||||
temp = self.Read_MFRC522(self.TxControlReg)
|
||||
if(~(temp & 0x03)):
|
||||
self.SetBitMask(self.TxControlReg, 0x03)
|
||||
|
||||
def AntennaOff(self):
|
||||
self.ClearBitMask(self.TxControlReg, 0x03)
|
||||
|
||||
def MFRC522_ToCard(self,command,sendData):
|
||||
backData = []
|
||||
backLen = 0
|
||||
status = self.MI_ERR
|
||||
irqEn = 0x00
|
||||
waitIRq = 0x00
|
||||
lastBits = None
|
||||
n = 0
|
||||
i = 0
|
||||
|
||||
if command == self.PCD_AUTHENT:
|
||||
irqEn = 0x12
|
||||
waitIRq = 0x10
|
||||
if command == self.PCD_TRANSCEIVE:
|
||||
irqEn = 0x77
|
||||
waitIRq = 0x30
|
||||
|
||||
self.Write_MFRC522(self.CommIEnReg, irqEn|0x80)
|
||||
self.ClearBitMask(self.CommIrqReg, 0x80)
|
||||
self.SetBitMask(self.FIFOLevelReg, 0x80)
|
||||
|
||||
self.Write_MFRC522(self.CommandReg, self.PCD_IDLE);
|
||||
|
||||
while(i<len(sendData)):
|
||||
self.Write_MFRC522(self.FIFODataReg, sendData[i])
|
||||
i = i+1
|
||||
|
||||
self.Write_MFRC522(self.CommandReg, command)
|
||||
|
||||
if command == self.PCD_TRANSCEIVE:
|
||||
self.SetBitMask(self.BitFramingReg, 0x80)
|
||||
|
||||
i = 2000
|
||||
while True:
|
||||
n = self.Read_MFRC522(self.CommIrqReg)
|
||||
i = i - 1
|
||||
if ~((i!=0) and ~(n&0x01) and ~(n&waitIRq)):
|
||||
break
|
||||
|
||||
self.ClearBitMask(self.BitFramingReg, 0x80)
|
||||
|
||||
if i != 0:
|
||||
if (self.Read_MFRC522(self.ErrorReg) & 0x1B)==0x00:
|
||||
status = self.MI_OK
|
||||
|
||||
if n & irqEn & 0x01:
|
||||
status = self.MI_NOTAGERR
|
||||
|
||||
if command == self.PCD_TRANSCEIVE:
|
||||
n = self.Read_MFRC522(self.FIFOLevelReg)
|
||||
lastBits = self.Read_MFRC522(self.ControlReg) & 0x07
|
||||
if lastBits != 0:
|
||||
backLen = (n-1)*8 + lastBits
|
||||
else:
|
||||
backLen = n*8
|
||||
|
||||
if n == 0:
|
||||
n = 1
|
||||
if n > self.MAX_LEN:
|
||||
n = self.MAX_LEN
|
||||
|
||||
i = 0
|
||||
while i<n:
|
||||
backData.append(self.Read_MFRC522(self.FIFODataReg))
|
||||
i = i + 1;
|
||||
else:
|
||||
status = self.MI_ERR
|
||||
|
||||
return (status,backData,backLen)
|
||||
|
||||
|
||||
def MFRC522_Request(self, reqMode):
|
||||
status = None
|
||||
backBits = None
|
||||
TagType = []
|
||||
|
||||
self.Write_MFRC522(self.BitFramingReg, 0x07)
|
||||
|
||||
TagType.append(reqMode);
|
||||
(status,backData,backBits) = self.MFRC522_ToCard(self.PCD_TRANSCEIVE, TagType)
|
||||
|
||||
if ((status != self.MI_OK) | (backBits != 0x10)):
|
||||
status = self.MI_ERR
|
||||
|
||||
return (status,backBits)
|
||||
|
||||
|
||||
def MFRC522_Anticoll(self):
|
||||
backData = []
|
||||
serNumCheck = 0
|
||||
|
||||
serNum = []
|
||||
|
||||
self.Write_MFRC522(self.BitFramingReg, 0x00)
|
||||
|
||||
serNum.append(self.PICC_ANTICOLL)
|
||||
serNum.append(0x20)
|
||||
|
||||
(status,backData,backBits) = self.MFRC522_ToCard(self.PCD_TRANSCEIVE,serNum)
|
||||
|
||||
if(status == self.MI_OK):
|
||||
i = 0
|
||||
if len(backData)==5:
|
||||
while i<4:
|
||||
serNumCheck = serNumCheck ^ backData[i]
|
||||
i = i + 1
|
||||
if serNumCheck != backData[i]:
|
||||
status = self.MI_ERR
|
||||
else:
|
||||
status = self.MI_ERR
|
||||
|
||||
return (status,backData)
|
||||
|
||||
def CalulateCRC(self, pIndata):
|
||||
self.ClearBitMask(self.DivIrqReg, 0x04)
|
||||
self.SetBitMask(self.FIFOLevelReg, 0x80);
|
||||
i = 0
|
||||
while i<len(pIndata):
|
||||
self.Write_MFRC522(self.FIFODataReg, pIndata[i])
|
||||
i = i + 1
|
||||
self.Write_MFRC522(self.CommandReg, self.PCD_CALCCRC)
|
||||
i = 0xFF
|
||||
while True:
|
||||
n = self.Read_MFRC522(self.DivIrqReg)
|
||||
i = i - 1
|
||||
if not ((i != 0) and not (n&0x04)):
|
||||
break
|
||||
pOutData = []
|
||||
pOutData.append(self.Read_MFRC522(self.CRCResultRegL))
|
||||
pOutData.append(self.Read_MFRC522(self.CRCResultRegM))
|
||||
return pOutData
|
||||
|
||||
def MFRC522_SelectTag(self, serNum):
|
||||
backData = []
|
||||
buf = []
|
||||
buf.append(self.PICC_SElECTTAG)
|
||||
buf.append(0x70)
|
||||
i = 0
|
||||
while i<5:
|
||||
buf.append(serNum[i])
|
||||
i = i + 1
|
||||
pOut = self.CalulateCRC(buf)
|
||||
buf.append(pOut[0])
|
||||
buf.append(pOut[1])
|
||||
(status, backData, backLen) = self.MFRC522_ToCard(self.PCD_TRANSCEIVE, buf)
|
||||
|
||||
if (status == self.MI_OK) and (backLen == 0x18):
|
||||
print "Size: " + str(backData[0])
|
||||
return backData[0]
|
||||
else:
|
||||
return 0
|
||||
|
||||
def MFRC522_Auth(self, authMode, BlockAddr, Sectorkey, serNum):
|
||||
buff = []
|
||||
|
||||
# First byte should be the authMode (A or B)
|
||||
buff.append(authMode)
|
||||
|
||||
# Second byte is the trailerBlock (usually 7)
|
||||
buff.append(BlockAddr)
|
||||
|
||||
# Now we need to append the authKey which usually is 6 bytes of 0xFF
|
||||
i = 0
|
||||
while(i < len(Sectorkey)):
|
||||
buff.append(Sectorkey[i])
|
||||
i = i + 1
|
||||
i = 0
|
||||
|
||||
# Next we append the first 4 bytes of the UID
|
||||
while(i < 4):
|
||||
buff.append(serNum[i])
|
||||
i = i +1
|
||||
|
||||
# Now we start the authentication itself
|
||||
(status, backData, backLen) = self.MFRC522_ToCard(self.PCD_AUTHENT,buff)
|
||||
|
||||
# Check if an error occurred
|
||||
if not(status == self.MI_OK):
|
||||
print "AUTH ERROR!!"
|
||||
if not (self.Read_MFRC522(self.Status2Reg) & 0x08) != 0:
|
||||
print "AUTH ERROR(status2reg & 0x08) != 0"
|
||||
|
||||
# Return the status
|
||||
return status
|
||||
|
||||
def MFRC522_StopCrypto1(self):
|
||||
self.ClearBitMask(self.Status2Reg, 0x08)
|
||||
|
||||
def MFRC522_Read(self, blockAddr):
|
||||
recvData = []
|
||||
recvData.append(self.PICC_READ)
|
||||
recvData.append(blockAddr)
|
||||
pOut = self.CalulateCRC(recvData)
|
||||
recvData.append(pOut[0])
|
||||
recvData.append(pOut[1])
|
||||
(status, backData, backLen) = self.MFRC522_ToCard(self.PCD_TRANSCEIVE, recvData)
|
||||
if not(status == self.MI_OK):
|
||||
print "Error while reading!"
|
||||
i = 0
|
||||
if len(backData) == 16:
|
||||
print "Sector "+str(blockAddr)+" "+str(backData)
|
||||
|
||||
def MFRC522_Write(self, blockAddr, writeData):
|
||||
buff = []
|
||||
buff.append(self.PICC_WRITE)
|
||||
buff.append(blockAddr)
|
||||
crc = self.CalulateCRC(buff)
|
||||
buff.append(crc[0])
|
||||
buff.append(crc[1])
|
||||
(status, backData, backLen) = self.MFRC522_ToCard(self.PCD_TRANSCEIVE, buff)
|
||||
if not(status == self.MI_OK) or not(backLen == 4) or not((backData[0] & 0x0F) == 0x0A):
|
||||
status = self.MI_ERR
|
||||
|
||||
print str(backLen)+" backdata &0x0F == 0x0A "+str(backData[0]&0x0F)
|
||||
if status == self.MI_OK:
|
||||
i = 0
|
||||
buf = []
|
||||
while i < 16:
|
||||
buf.append(writeData[i])
|
||||
i = i + 1
|
||||
crc = self.CalulateCRC(buf)
|
||||
buf.append(crc[0])
|
||||
buf.append(crc[1])
|
||||
(status, backData, backLen) = self.MFRC522_ToCard(self.PCD_TRANSCEIVE,buf)
|
||||
if not(status == self.MI_OK) or not(backLen == 4) or not((backData[0] & 0x0F) == 0x0A):
|
||||
print "Error while writing"
|
||||
if status == self.MI_OK:
|
||||
print "Data written"
|
||||
|
||||
def MFRC522_DumpClassic1K(self, key, uid):
|
||||
i = 0
|
||||
while i < 64:
|
||||
status = self.MFRC522_Auth(self.PICC_AUTHENT1A, i, key, uid)
|
||||
# Check if authenticated
|
||||
if status == self.MI_OK:
|
||||
self.MFRC522_Read(i)
|
||||
else:
|
||||
print "Authentication error"
|
||||
i = i+1
|
||||
|
||||
def MFRC522_Init(self):
|
||||
GPIO.output(self.NRSTPD, 1)
|
||||
|
||||
self.MFRC522_Reset();
|
||||
|
||||
|
||||
self.Write_MFRC522(self.TModeReg, 0x8D)
|
||||
self.Write_MFRC522(self.TPrescalerReg, 0x3E)
|
||||
self.Write_MFRC522(self.TReloadRegL, 30)
|
||||
self.Write_MFRC522(self.TReloadRegH, 0)
|
||||
|
||||
self.Write_MFRC522(self.TxAutoReg, 0x40)
|
||||
self.Write_MFRC522(self.ModeReg, 0x3D)
|
||||
self.AntennaOn()
|
@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
/**
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
import RPi.GPIO as GPIO
|
||||
import paho.mqtt.client as mqtt
|
||||
import iotUtils
|
||||
|
||||
global mqttClient
|
||||
mqttClient = mqtt.Client()
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# The callback for when the client receives a CONNACK response from the server.
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def on_connect(mqttClient, userdata, flags, rc):
|
||||
print("MQTT_LISTENER: Connected with result code " + str(rc))
|
||||
# Subscribing in on_connect() means that if we lose the connection and
|
||||
# reconnect then subscriptions will be renewed.
|
||||
print ("MQTT_LISTENER: Subscribing with topic " + TOPIC_TO_SUBSCRIBE)
|
||||
mqttClient.subscribe(TOPIC_TO_SUBSCRIBE)
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# The callback for when a PUBLISH message is received from the server.
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def on_message(mqttClient, userdata, msg):
|
||||
print("MQTT_LISTENER: " + msg.topic + " " + str(msg.payload))
|
||||
request = str(msg.payload)
|
||||
resource = ""
|
||||
if (len(request.split(":")) == 2):
|
||||
resource = request.split(":")[0].upper()
|
||||
state = request.split(":")[1].upper()
|
||||
if state == "LOCK":
|
||||
GPIO.output(iotUtils.DOOR_LOCKER_2_PORT, GPIO.HIGH)
|
||||
GPIO.output(iotUtils.DOOR_LOCKER_1_PORT, GPIO.HIGH)
|
||||
GPIO.output(iotUtils.LOCK_STATE_OFF_NOTIFY_PORT, GPIO.HIGH)
|
||||
GPIO.output(iotUtils.LOCK_STATE_ON_NOTIFY_PORT, GPIO.LOW)
|
||||
mqttClient.publish(TOPIC_TO_PUBLISH, "Locker:LOCKED")
|
||||
print "Door is locked"
|
||||
elif state == "UNLOCK":
|
||||
GPIO.output(iotUtils.DOOR_LOCKER_2_PORT, GPIO.LOW)
|
||||
GPIO.output(iotUtils.DOOR_LOCKER_1_PORT, GPIO.LOW)
|
||||
GPIO.output(iotUtils.LOCK_STATE_OFF_NOTIFY_PORT, GPIO.LOW)
|
||||
GPIO.output(iotUtils.LOCK_STATE_ON_NOTIFY_PORT, GPIO.HIGH)
|
||||
mqttClient.publish(TOPIC_TO_PUBLISH, "Locker:UNLOCKED")
|
||||
print "Door is unlocked"
|
||||
else:
|
||||
print "MQTT message in the wrong format"
|
||||
print "MQTT_LISTENER: Resource- " + resource
|
||||
else:
|
||||
print "MQTT message in the wrong format"
|
||||
print "MQTT_LISTENER: Resource- " + resource
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# The callback for when a PUBLISH message to the server when door is open or close
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def on_publish(mqttClient, msg):
|
||||
mqttClient.publish(TOPIC_TO_PUBLISH, msg)
|
||||
|
||||
|
||||
def sendLockerStatus(msg):
|
||||
global mqttClient
|
||||
on_publish(mqttClient, msg)
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# The Main method of the server script
|
||||
# This method is invoked from DoorLockerAgent.py on a new thread
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def main():
|
||||
MQTT_ENDPOINT = iotUtils.MQTT_EP.split(":")
|
||||
MQTT_IP = MQTT_ENDPOINT[1].replace('//', '')
|
||||
MQTT_PORT = int(MQTT_ENDPOINT[2])
|
||||
|
||||
DEV_OWNER = iotUtils.DEVICE_OWNER
|
||||
DEV_ID = iotUtils.DEVICE_ID
|
||||
|
||||
global TOPIC_TO_SUBSCRIBE
|
||||
TOPIC_TO_SUBSCRIBE = "wso2/iot/" + DEV_OWNER + "/doormanager/" + DEV_ID + "/subscriber"
|
||||
global TOPIC_TO_PUBLISH
|
||||
TOPIC_TO_PUBLISH = "wso2/iot/" + DEV_OWNER + "/doormanager/" + DEV_ID + "/publisher"
|
||||
|
||||
print ("MQTT_LISTENER: MQTT_ENDPOINT is " + str(MQTT_ENDPOINT))
|
||||
print ("MQTT_LISTENER: MQTT_TOPIC is " + TOPIC_TO_SUBSCRIBE)
|
||||
global mqttClient
|
||||
mqttClient.on_connect = on_connect
|
||||
mqttClient.on_message = on_message
|
||||
|
||||
while True:
|
||||
try:
|
||||
mqttClient.connect(MQTT_IP, MQTT_PORT, 60)
|
||||
print "MQTT_LISTENER: " + time.asctime(), "Connected to MQTT Broker - %s:%s" % (MQTT_IP, MQTT_PORT)
|
||||
# Blocking call that processes network traffic, dispatches callbacks and
|
||||
# handles reconnecting.
|
||||
# Other loop*() functions are available that give a threaded interface and a
|
||||
# manual interface.
|
||||
mqttClient.loop_forever()
|
||||
|
||||
except (KeyboardInterrupt, Exception) as e:
|
||||
print "MQTT_LISTENER: Exception in MQTTServerThread (either KeyboardInterrupt or Other)"
|
||||
print ("MQTT_LISTENER: " + str(e))
|
||||
|
||||
mqttClient.disconnect()
|
||||
print "MQTT_LISTENER: " + time.asctime(), "Connection to Broker closed - %s:%s" % (MQTT_IP, MQTT_PORT)
|
||||
print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -0,0 +1,170 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
/**
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
"""
|
||||
|
||||
import signal
|
||||
|
||||
import RPi.GPIO as GPIO
|
||||
|
||||
import MFRC522
|
||||
import MQTTHandler
|
||||
import iotUtils
|
||||
import argparse
|
||||
import httplib
|
||||
import logging
|
||||
import logging.handlers
|
||||
import signal
|
||||
import ssl
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
from functools import wraps
|
||||
|
||||
CONTINUE_READING = True
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Overriding the default SSL version used in some of the Python (2.7.x) versions
|
||||
# This is a known issue in earlier Python releases
|
||||
# But was fixed in later versions. Ex-2.7.11
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def sslwrap(func):
|
||||
@wraps(func)
|
||||
def bar(*args, **kw):
|
||||
kw['ssl_version'] = ssl.PROTOCOL_TLSv1
|
||||
return func(*args, **kw)
|
||||
return bar
|
||||
|
||||
|
||||
# Capture SIGINT for cleanup when the script is aborted
|
||||
def end_read(signal,frame):
|
||||
global CONTINUE_READING
|
||||
print "Ctrl+C captured, ending read."
|
||||
CONTINUE_READING = False
|
||||
GPIO.cleanup()
|
||||
|
||||
# Hook the SIGINT
|
||||
signal.signal(signal.SIGINT, end_read)
|
||||
|
||||
# Create an object of the class MFRC522
|
||||
MIFAREReader = MFRC522.MFRC522()
|
||||
global RFID_CARD_UID
|
||||
RFID_CARD_UID = ""
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Endpoint specific settings to connect with the IoT Server
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
SERVER_ENDPOINT = iotUtils.HTTPS_EP.split(":")
|
||||
SERVER_IP = SERVER_ENDPOINT[1].replace('//', '')
|
||||
SERVER_PORT = int(SERVER_ENDPOINT[2])
|
||||
API_ENDPOINT_CONTEXT = iotUtils.CONTROLLER_CONTEXT
|
||||
REGISTER_ENDPOINT = str(API_ENDPOINT_CONTEXT) + '/register'
|
||||
APIM_SERVER_ENDPOINT = iotUtils.API_EP.split(":")
|
||||
APIM_SERVER_IP = APIM_SERVER_ENDPOINT[1].replace('//', '')
|
||||
APIM_SERVER_PORT = int(APIM_SERVER_ENDPOINT[2])
|
||||
MANAGER_API_CONTEXT = iotUtils.MANAGER_CONTEXT
|
||||
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# This method check whether the UID of RFID card is registered or not
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
def isRFIDCardRegistered( RFID_CARD_UID ):
|
||||
ssl.wrap_socket = sslwrap(ssl.wrap_socket) # using the overridden sslwrap that uses TLSv1
|
||||
print "Waiting to get UID of RFID card..."
|
||||
if sys.version_info<(2,7,9):
|
||||
dcConncection = httplib.HTTPSConnection(host=SERVER_IP, port=SERVER_PORT)
|
||||
else:
|
||||
dcConncection = httplib.HTTPSConnection(host=SERVER_IP, port=SERVER_PORT, context=ssl._create_unverified_context())
|
||||
dcConncection.set_debuglevel(1)
|
||||
dcConncection.connect()
|
||||
PUSH_DATA = iotUtils.DEVICE_INFO_WITH_OWNER + iotUtils.DEVICE_DATA + RFID_CARD_UID
|
||||
PUSH_DATA += '"}'
|
||||
print PUSH_DATA
|
||||
APIURL = str(MANAGER_API_CONTEXT)
|
||||
dcConncection.putrequest('POST', APIURL)
|
||||
dcConncection.putheader('Content-Type', 'application/json')
|
||||
dcConncection.putheader('Authorization', 'Bearer ' + iotUtils.AUTH_TOKEN)
|
||||
dcConncection.putheader('Content-Length', len(PUSH_DATA))
|
||||
dcConncection.endheaders()
|
||||
dcConncection.send(PUSH_DATA)
|
||||
dcResponse = dcConncection.getresponse()
|
||||
if(dcResponse.status < 250):
|
||||
print "You are allowed to open the door"
|
||||
isRegisteredUser = True
|
||||
else:
|
||||
isRegisteredUser = False
|
||||
print "You are not allowed to open the door"
|
||||
print ('DoorManager: ' + str(dcResponse.status))
|
||||
print ('DoorManager: ' + str(dcResponse.reason))
|
||||
print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
|
||||
print ('DoorManager: ' + str(APIURL))
|
||||
print ('DoorManager: Response Message')
|
||||
print str(dcResponse.msg)
|
||||
dcConncection.close()
|
||||
print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
|
||||
return isRegisteredUser
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~------
|
||||
# Read RFID card and if user is authorized to given RFID card, then open the lock
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~------
|
||||
def readUIDofRFID():
|
||||
print "-----------------------------------Starting MFRC522 chip reader---------------------------------------------"
|
||||
# This loop keeps checking for chips. If one is near it will get the UID and authenticate
|
||||
while CONTINUE_READING:
|
||||
# Scan for cards
|
||||
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
|
||||
# If a card is found
|
||||
# Get the UID of the card
|
||||
(status,uid) = MIFAREReader.MFRC522_Anticoll()
|
||||
# If we have the UID, continue
|
||||
if status == MIFAREReader.MI_OK:
|
||||
global RFID_CARD_UID
|
||||
RFID_CARD_UID = str(uid[0])+":"+str(uid[1])+":"+str(uid[2])+":"+str(uid[3])
|
||||
print "Card read UID: " + RFID_CARD_UID
|
||||
# This is the default key for authentication
|
||||
key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]
|
||||
# Select the scanned tag
|
||||
MIFAREReader.MFRC522_SelectTag(uid)
|
||||
# Authenticate
|
||||
status = MIFAREReader.MFRC522_Auth(MIFAREReader.PICC_AUTHENT1A, 8, key, uid)
|
||||
# Check if authenticated
|
||||
if status == MIFAREReader.MI_OK:
|
||||
MIFAREReader.MFRC522_Read(8)
|
||||
MIFAREReader.MFRC522_StopCrypto1()
|
||||
if(isRFIDCardRegistered(RFID_CARD_UID)):
|
||||
print "Authentication successful"
|
||||
GPIO.output(iotUtils.LOCK_STATE_OFF_NOTIFY_PORT, GPIO.LOW)
|
||||
GPIO.output(iotUtils.LOCK_STATE_ON_NOTIFY_PORT, GPIO.HIGH)
|
||||
GPIO.output(iotUtils.DOOR_LOCKER_2_PORT, GPIO.LOW)
|
||||
GPIO.output(iotUtils.DOOR_LOCKER_1_PORT, GPIO.LOW)
|
||||
MQTTHandler.on_publish(MQTTHandler.mqttClient,"Locker:UNLOCKED")
|
||||
return True
|
||||
|
||||
def main():
|
||||
global RFID_CARD_UID
|
||||
RFID_CARD_UID = ""
|
||||
readUIDofRFID()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
/**
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
"""
|
||||
|
||||
import ConfigParser
|
||||
import os
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Device specific info when pushing data to server
|
||||
# Read from a file "deviceConfig.properties" in the same folder level
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
configParser = ConfigParser.RawConfigParser()
|
||||
configFilePath = os.path.join(os.path.dirname(__file__), './deviceConfig.properties')
|
||||
configParser.read(configFilePath)
|
||||
|
||||
DEVICE_OWNER = configParser.get('Device-Configurations', 'owner')
|
||||
DEVICE_ID = configParser.get('Device-Configurations', 'deviceId')
|
||||
SERIAL_NUMBER = configParser.get('Device-Configurations', 'deviceId')
|
||||
MQTT_EP = configParser.get('Device-Configurations', 'mqtt-ep')
|
||||
AUTH_TOKEN = configParser.get('Device-Configurations', 'auth-token')
|
||||
USER_NAME = configParser.get('Device-Configurations', 'username')
|
||||
CONTROLLER_CONTEXT = configParser.get('Device-Configurations', 'controller-context')
|
||||
DEVICE_INFO = '{"owner":"' + DEVICE_OWNER + '","deviceId":"' + DEVICE_ID + '",'
|
||||
HTTPS_EP = configParser.get('Device-Configurations', 'https-ep')
|
||||
HTTP_EP = configParser.get('Device-Configurations', 'http-ep')
|
||||
DEVICE_INFO_WITH_OWNER = '{"serialNumber":"' + SERIAL_NUMBER + '", "userName":"'+ USER_NAME +'","deviceId":"' + SERIAL_NUMBER + '",'
|
||||
API_EP = configParser.get('Device-Configurations', 'apim-ep')
|
||||
MANAGER_CONTEXT = configParser.get('Device-Configurations', 'manager-context')
|
||||
DEVICE_DATA = '"cardNumber":"'
|
||||
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
global IS_REGISTERED
|
||||
IS_REGISTERED = False
|
||||
|
||||
DOOR_LOCKER_1_PORT = 16
|
||||
DOOR_LOCKER_2_PORT = 18
|
||||
LOCK_STATE_ON_NOTIFY_PORT = 11
|
||||
LOCK_STATE_OFF_NOTIFY_PORT = 13
|
||||
|
||||
def isEmpty (string):
|
||||
if string and string.strip():
|
||||
#string is not None AND string is not empty or blank
|
||||
return False
|
||||
#string is None OR string is empty or blank
|
||||
return True
|
||||
|
||||
|
||||
|
@ -0,0 +1,59 @@
|
||||
#"""
|
||||
#/**
|
||||
#* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
#*
|
||||
#* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
#* Version 2.0 (the "License"); you may not use this file except
|
||||
#* in compliance with the License.
|
||||
#* You may obtain a copy of the License at
|
||||
#*
|
||||
#* http://www.apache.org/licenses/LICENSE-2.0
|
||||
#*
|
||||
#* Unless required by applicable law or agreed to in writing,
|
||||
#* software distributed under the License is distributed on an
|
||||
#* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
#* KIND, either express or implied. See the License for the
|
||||
#* specific language governing permissions and limitations
|
||||
#* under the License.
|
||||
#**/
|
||||
#"""
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
echo "----------------------------------------------------------------"
|
||||
echo "| WSO2 IOT Door Manager "
|
||||
echo "| Agent "
|
||||
echo "| --------------------- "
|
||||
echo "| ....initializing startup-script "
|
||||
echo "----------------------------------------------------------------"
|
||||
|
||||
currentDir=$PWD
|
||||
|
||||
for f in ./deviceConfig.properties; do
|
||||
## Check if the glob gets expanded to existing files.
|
||||
## If not, f here will be exactly the pattern above
|
||||
## and the exists test will evaluate to false.
|
||||
if [ -e "$f" ]; then
|
||||
echo "Configuration file found......"
|
||||
else
|
||||
echo "'deviceConfig.properties' file does not exist in current path. \nExiting installation...";
|
||||
exit;
|
||||
fi
|
||||
## This is all we needed to know, so we can break after the first iteration
|
||||
break
|
||||
done
|
||||
|
||||
cd $currentDir
|
||||
|
||||
cp deviceConfig.properties ./src
|
||||
chmod +x ./src/DoorManagerAgent.py
|
||||
sudo python ./src/DoorManagerAgent.py
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not start the service..."
|
||||
exit;
|
||||
fi
|
||||
|
||||
echo "--------------------------------------"
|
||||
echo "| Successfully Started "
|
||||
echo "| -------------------------- "
|
@ -1,127 +0,0 @@
|
||||
<!--
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/-->
|
||||
{{#zone "topCss"}}
|
||||
<style>
|
||||
.thumbnail.icon:before {
|
||||
padding-top: 0;
|
||||
}
|
||||
</style>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "device-thumbnail"}}
|
||||
<img src="{{@unit.publicUri}}/images/current-sensor.png"/>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "operation-status"}}
|
||||
<div id="div-operation-status" class="hidden" align="center" style="padding: 10px; margin-bottom: 5px">
|
||||
</div>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "device-opetations"}}
|
||||
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
|
||||
Operations
|
||||
</div>
|
||||
<div class="add-margin-top-4x">
|
||||
{{unit "iot.unit.device.operation-bar" device=device}}
|
||||
</div>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "device-detail-properties"}}
|
||||
<div class="media">
|
||||
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
|
||||
<li class="active"><a class="list-group-item" href="#device_statistics" role="tab"
|
||||
data-toggle="tab" aria-controls="device_statistics">Device Statistics</a>
|
||||
</li>
|
||||
<ul class="list-group" role="tablist">
|
||||
<li><a class="list-group-item" href="#policies" role="tab"
|
||||
data-toggle="tab" aria-controls="policies">Policies</a>
|
||||
</li>
|
||||
<li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab"
|
||||
aria-controls="event_log">Operations Log</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="media-body add-padding-left-5x remove-padding-xs tab-content">
|
||||
<div class="panel-group tab-content">
|
||||
<div class="panel panel-default tab-pane active"
|
||||
id="device_statistics" role="tabpanel" aria-labelledby="device_statistics">
|
||||
<div class="panel-heading">Device Statistics</div>
|
||||
{{unit "iot.unit.device.stats" device=device}}
|
||||
</div>
|
||||
<div class="panel panel-default tab-pane" id="policy_compliance" role="tabpanel"
|
||||
aria-labelledby="policy_compliance">
|
||||
<div class="panel-heading">Policy Compliance <span><a href="#" id="refresh-policy">
|
||||
<i class="fw fw-refresh"></i></a></span></div>
|
||||
<div class="panel panel-default tab-pane" id="policies" role="tabpanel"
|
||||
aria-labelledby="policies">
|
||||
<div class="panel-heading">Policies</div>
|
||||
<div class="panel-body">
|
||||
<div id="policy-spinner" class="wr-advance-operations-init hidden">
|
||||
<br>
|
||||
|
||||
<i class="fw fw-settings fw-spin fw-2x"></i>
|
||||
|
||||
Loading Policies . . .
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
<div id="policy-list-container">
|
||||
<div class="panel-body">
|
||||
No policies found
|
||||
</div>
|
||||
<br class="c-both"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a class="padding-left"
|
||||
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-policy fw-stack-1x"></i>
|
||||
</span> Add device specific policy</a>
|
||||
</div>
|
||||
<div class="panel panel-default tab-pane" id="event_log" role="tabpanel"
|
||||
aria-labelledby="event_log">
|
||||
<div class="panel-heading">Operations Log <span><a href="#"
|
||||
id="refresh-operations"><i
|
||||
class="fw fw-refresh"></i></a></span></div>
|
||||
<div class="panel-body">
|
||||
<div id="operations-spinner" class="wr-advance-operations-init hidden">
|
||||
<br>
|
||||
|
||||
<i class="fw fw-settings fw-spin fw-2x"></i>
|
||||
|
||||
Loading Operations Log . . .
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
<div id="operations-log-container">
|
||||
<div class="panel-body">
|
||||
Not available yet
|
||||
</div>
|
||||
<br class="c-both"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/zone}}
|
||||
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function onRequest(context) {
|
||||
|
||||
var log = new Log("device-view.js");
|
||||
var deviceType = context.uriParams.deviceType;
|
||||
var deviceId = request.getParameter("id");
|
||||
|
||||
var getProperty = require("process").getProperty;
|
||||
var port = getProperty("carbon.https.port");
|
||||
var host = getProperty("carbon.local.ip");
|
||||
var sessionId = session.getId();
|
||||
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
|
||||
var deviceModule = require("/app/modules/device.js").deviceModule;
|
||||
var device = deviceModule.viewDevice(deviceType, deviceId);
|
||||
|
||||
if (device && device.status != "error") {
|
||||
log.info(device);
|
||||
return {"device": device, "port" : port, "host" : host , "sessionId" : sessionId};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 29 KiB |
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
var deviceType = $("#details").data("devicetype");
|
||||
var deviceId = $(".device-id").data("deviceid");
|
||||
var monitor_operations = $("#details").data("monitor");
|
||||
var appContext = $("#details").data("appcontext");
|
||||
var publicURL =$("#details").data("unitpublicuri");
|
||||
|
||||
$(window).on('resize', function () {
|
||||
location.reload(false);
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
updateGraphs();
|
||||
});
|
||||
|
||||
function updateGraphs() {
|
||||
var tv = 2000;
|
||||
var iv = setInterval(function () {
|
||||
var getStatsRequest = $.ajax({
|
||||
url: appContext + "/api/operations/" + deviceType + "/stats?deviceId=" + deviceId,
|
||||
method: "get"
|
||||
});
|
||||
getStatsRequest.done(function (data) {
|
||||
var data = data.data;
|
||||
if(data[0].door_locker_state){
|
||||
var currentStateOfTheLock=data[0].door_locker_state;
|
||||
console.log(currentStateOfTheLock);
|
||||
if( currentStateOfTheLock == "UNLOCKED"){
|
||||
$("#lockerCurrentState").attr("src", publicURL+"/images/unlock.png");
|
||||
}else{
|
||||
$("#lockerCurrentState").attr("src", publicURL+"/images/lock.png");
|
||||
}
|
||||
}else{
|
||||
console.log("Backend server not available");
|
||||
}
|
||||
});
|
||||
}, tv);
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<!--/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/-->
|
||||
{{unit "iot.unit.policy.edit"}}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<!--/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/-->
|
||||
{{unit "iot.unit.policy.view"}}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<!--/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/-->
|
||||
{{unit "iot.unit.policy.wizard"}}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 175 KiB |
Before Width: | Height: | Size: 48 KiB |
@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
var modalPopup = ".wr-modalpopup";
|
||||
var modalPopupContainer = modalPopup + " .modalpopup-container";
|
||||
var modalPopupContent = modalPopup + " .modalpopup-content";
|
||||
var body = "body";
|
||||
|
||||
/*
|
||||
* set popup maximum height function.
|
||||
*/
|
||||
function setPopupMaxHeight() {
|
||||
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
|
||||
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
|
||||
}
|
||||
|
||||
/*
|
||||
* show popup function.
|
||||
*/
|
||||
function showPopup() {
|
||||
$(modalPopup).show();
|
||||
setPopupMaxHeight();
|
||||
$('#downloadForm').validate({
|
||||
rules: {
|
||||
deviceName: {
|
||||
minlength: 4,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
highlight: function (element) {
|
||||
$(element).closest('.control-group').removeClass('success').addClass('error');
|
||||
},
|
||||
success: function (element) {
|
||||
$(element).closest('.control-group').removeClass('error').addClass('success');
|
||||
$('label[for=deviceName]').remove();
|
||||
}
|
||||
});
|
||||
var deviceType = "";
|
||||
$('.deviceType').each(function () {
|
||||
if (this.value != "") {
|
||||
deviceType = this.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* hide popup function.
|
||||
*/
|
||||
function hidePopup() {
|
||||
$('label[for=deviceName]').remove();
|
||||
$('.control-group').removeClass('success').removeClass('error');
|
||||
$(modalPopupContent).html('');
|
||||
$(modalPopup).hide();
|
||||
}
|
||||
|
||||
/*
|
||||
* DOM ready functions.
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
attachEvents();
|
||||
});
|
||||
|
||||
function attachEvents() {
|
||||
/**
|
||||
* Following click function would execute
|
||||
* when a user clicks on "Download" link
|
||||
* on Device Management page in WSO2 DC Console.
|
||||
*/
|
||||
$("a.download-link").click(function () {
|
||||
var sketchType = $(this).data("sketchtype");
|
||||
var deviceType = $(this).data("devicetype");
|
||||
var downloadDeviceAPI = "/devicemgt/api/devices/sketch/generate_link";
|
||||
var payload = {"sketchType": sketchType, "deviceType": deviceType};
|
||||
|
||||
console.log("-------------------------->"+JSON.stringify(payload));
|
||||
$(modalPopupContent).html($('#download-device-modal-content').html());
|
||||
showPopup();
|
||||
var deviceName;
|
||||
$("a#download-device-download-link").click(function () {
|
||||
$('.new-device-name').each(function () {
|
||||
if (this.value != "") {
|
||||
deviceName = this.value;
|
||||
}
|
||||
});
|
||||
$('label[for=deviceName]').remove();
|
||||
if (deviceName && deviceName.length >= 4) {
|
||||
payload.deviceName = deviceName;
|
||||
invokerUtil.post(
|
||||
downloadDeviceAPI,
|
||||
payload,
|
||||
function (data, textStatus, jqxhr) {
|
||||
doAction(data);
|
||||
},
|
||||
function (data) {
|
||||
doAction(data);
|
||||
}
|
||||
);
|
||||
}else if(deviceName){
|
||||
$('.controls').append('<label for="deviceName" generated="true" class="error" style="display: inline-block;">Please enter at least 4 characters.</label>');
|
||||
$('.control-group').removeClass('success').addClass('error');
|
||||
} else {
|
||||
$('.controls').append('<label for="deviceName" generated="true" class="error" style="display: inline-block;">This field is required.</label>');
|
||||
$('.control-group').removeClass('success').addClass('error');
|
||||
}
|
||||
});
|
||||
$("a#download-device-cancel-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function downloadAgent() {
|
||||
|
||||
var $inputs = $('#downloadForm :input');
|
||||
var values = {};
|
||||
$inputs.each(function() {
|
||||
values[this.name] = $(this).val();
|
||||
});
|
||||
var payload = {};
|
||||
payload.name = $inputs[0].value;
|
||||
payload.owner = $inputs[3].value;
|
||||
payload.serialNumber = $inputs[1].value;
|
||||
|
||||
var doorManagerRegisterURL = "/doormanager_mgt/manager/device/register?" +
|
||||
"name=" + encodeURI(payload.name) + "&owner=" + payload.owner + "&serialNumber=" + payload.serialNumber;
|
||||
|
||||
invokerUtil.post(
|
||||
doorManagerRegisterURL,
|
||||
payload,
|
||||
function (data, textStatus, jqxhr) {
|
||||
hidePopup();
|
||||
},
|
||||
function (data) {
|
||||
hidePopup();
|
||||
}
|
||||
);
|
||||
var deviceName;
|
||||
$('.new-device-name').each(function () {
|
||||
if (this.value != "") {
|
||||
deviceName = this.value;
|
||||
}
|
||||
});
|
||||
if (deviceName && deviceName.length >= 4) {
|
||||
setTimeout(function () {
|
||||
hidePopup();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function doAction(data) {
|
||||
if (data.status == null) {
|
||||
document.write(data);
|
||||
}
|
||||
if (data.status == "200") {
|
||||
$(modalPopupContent).html($('#download-device-modal-content-links').html());
|
||||
$("input#download-device-url").val(data.responseText);
|
||||
$("input#download-device-url").focus(function () {
|
||||
$(this).select();
|
||||
});
|
||||
showPopup();
|
||||
} else if (data.status == "401") {
|
||||
$(modalPopupContent).html($('#device-401-content').html());
|
||||
$("#device-401-link").click(function () {
|
||||
window.location = "/devicemgt/login";
|
||||
});
|
||||
showPopup();
|
||||
} else if (data == "403") {
|
||||
$(modalPopupContent).html($('#device-403-content').html());
|
||||
$("#device-403-link").click(function () {
|
||||
window.location = "/devicemgt/login";
|
||||
});
|
||||
showPopup();
|
||||
} else {
|
||||
$(modalPopupContent).html($('#device-unexpected-error-content').html());
|
||||
$("a#device-unexpected-error-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,282 +0,0 @@
|
||||
<div class="col-lg-12 margin-top-double">
|
||||
<h1 class="grey ">Door Manager</h1>
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4 padding-top">
|
||||
<img src="{{@unit.publicUri}}/images/doorManager-icon.png" class="img-responsive">
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8 padding-top">
|
||||
<!--todo need to change this url-->
|
||||
<h4 class="doc-link">Click <a href="https://docs.wso2.com/pages/viewpage.action?pageId=48289181"
|
||||
target="_blank">[ here ]</a> for latest instructions and troubleshooting.</h4>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8 padding-top">
|
||||
|
||||
<h3 class="uppercase">What it Does</h3>
|
||||
<hr>
|
||||
<p class="grey margin-top">Connect an Automatic Door Locker to WSO2 IoT Server and control and view current state
|
||||
of door locker.</p>
|
||||
<br>
|
||||
<h3 class="uppercase">What You Need</h3>
|
||||
<hr>
|
||||
<ul class="list-unstyled">
|
||||
<li class="padding-top-double"><span class="circle">ITEM 01</span> Electronic solenoid door
|
||||
lock - 2
|
||||
</li>
|
||||
<li class="padding-top-double"><span class="circle">ITEM 02</span> MFRC522 RFID Reader/Writer
|
||||
</li>
|
||||
<li class="padding-top-double"><span class="circle">ITEM 03</span> 2 Channel 5V Relay Module
|
||||
</li>
|
||||
<li class="padding-top-double"><span class="circle">ITEM 04</span> 12 Volt DC - 1 Amp (12V, 1A)
|
||||
Power Supply
|
||||
</li>
|
||||
<li class="padding-top-double"><span class="circle">ITEM 05</span> LED Bulbs (Red and Green)
|
||||
</li>
|
||||
<li class="padding-top-double"><span class="circle">ITEM 06</span> Resistors (333ohms) -2
|
||||
</li>
|
||||
<li class="padding-top-double"> Proceed to [Prepare] section.
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
<a href="/api-store/apis/info?name={{@uriParams.deviceType}}&version=1.0.0&provider=admin" class="btn-operations"
|
||||
target="_blank"><i class="fw fw-api"></i> View API</i> </a>
|
||||
<a href="#" class="download-link btn-operations"><i class="fw fw-download"></i>Register New Lock Safe</a>
|
||||
|
||||
<div id="download-device-modal-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 center-container">
|
||||
<h3>Enter your device name serial number and then register {{@uriParams.deviceType}} the agent from following link.</h3>
|
||||
<br/>
|
||||
<form id="downloadForm">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
Device Name: <input class="new-device-name" style="color:#3f3f3f;padding:5px"
|
||||
type="text"
|
||||
placeholder="Ex. drone"
|
||||
name="deviceName" size="60" required></br>
|
||||
Serial Number: <input style="color:#3f3f3f;padding:5px"
|
||||
type="text"
|
||||
placeholder="Ex. serial number"
|
||||
name="serialNumber" size="60" required>
|
||||
<br/>
|
||||
<input type="hidden" class="deviceType" name="deviceType"
|
||||
value="doormanager"/>
|
||||
<input type="hidden" class="owner" name="owner" value={{@user.username}} />
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<div class="buttons">
|
||||
<a class="btn-operations" onclick="downloadAgent()">Register Now</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-400-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-centered center-container">
|
||||
<h3>Exception at backend. Try Later.</h3>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-400-link" class="btn-operations">
|
||||
OK
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-401-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-centered center-container">
|
||||
<h3>You have to log in first.</h3><br/>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-401-link" class="blue-button">
|
||||
Goto Login Page
|
||||
</a>
|
||||
<a href="#" onclick="hidePopup();" class="btn-operations">
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-403-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-centered center-container">
|
||||
<h3>Action not permitted.</h3><br/>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-403-link" class="btn-operations">
|
||||
OK
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-409-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-centered center-container">
|
||||
<h3>Device Sketch does not exist.</h3><br/>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-409-link" class="btn-operations">
|
||||
OK
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-unexpected-error-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-centered center-container">
|
||||
<h3>Unexpected error.</h3><br/>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-unexpected-error-link" class="btn-operations">
|
||||
OK
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/><br/>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding-double grey-bg">
|
||||
<h3 class="uppercase">Prepare</h3>
|
||||
<hr>
|
||||
<ul class="list-unstyled">
|
||||
<li class="padding-top-double"><span class="circle">01</span> Get the basic setup done
|
||||
according to schematic below
|
||||
</li>
|
||||
<li class="padding-top-double"><span class="circle">02</span> Ensure your RaspberryPi Board
|
||||
can connect to Internet.
|
||||
</li>
|
||||
<li class="padding-top-double"><span class="circle">03</span> Click on
|
||||
[Download Agent] button above to get Automatic Door Locker agent.
|
||||
</li>
|
||||
<li class="padding-top-double"><span class="circle">04</span> Copy downloaded Agent into your
|
||||
RaspberryPi.
|
||||
</li>
|
||||
<li class="padding-top-double"><span class="circle">05</span> Run "Agent.sh" script with root privileges.
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 padding-double">
|
||||
<h3 class="uppercase">SCHEMATIC DIAGRAM</h3>
|
||||
<hr>
|
||||
<p class="grey margin-top">Click on the image to zoom</p>
|
||||
<center>
|
||||
<a href="{{@unit.publicUri}}/images/schematicsGuide.png" target="_blank">
|
||||
<img src="{{@unit.publicUri}}/images/schematicsGuide.png" class="img-responsive">
|
||||
</a>
|
||||
</center>
|
||||
<br/>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 padding-double">
|
||||
<h3 class="uppercase">Try Out</h3>
|
||||
<hr>
|
||||
<ul class="list-unstyled">
|
||||
<li class="padding-top-double"><span class="circle">01</span> You can view
|
||||
all your connected
|
||||
devices at <a
|
||||
href="{{@app.context}}/devices">[Device
|
||||
Management]</a>
|
||||
page.
|
||||
</li>
|
||||
<li class="padding-top-double"><span class="circle">02</span> Select one of
|
||||
connected devices and check for available control operations as well as current state of door locker
|
||||
</li>
|
||||
</ul>
|
||||
<br/>
|
||||
|
||||
<p class="grey margin-top">Click on the image to zoom</p>
|
||||
<center>
|
||||
<a href="{{@unit.publicUri}}/images/myDevices_analytics.png" target="_blank">
|
||||
<img src="{{@unit.publicUri}}/images/myDevices_analytics.png" class="img-responsive">
|
||||
</a>
|
||||
</center>
|
||||
|
||||
</div>
|
||||
|
||||
{{#zone "topCss"}}
|
||||
<style type="text/css">
|
||||
.circle {
|
||||
background: none repeat scroll 0 0 #191919;
|
||||
border-radius: 50px;
|
||||
height: 50px;
|
||||
padding: 10px;
|
||||
width: 50px;
|
||||
color: #fff;
|
||||
}
|
||||
.padding-top-double {
|
||||
padding-top: 20px;
|
||||
}
|
||||
.padding-double {
|
||||
padding: 20px;
|
||||
}
|
||||
.grey {
|
||||
color: #333;
|
||||
}
|
||||
hr {
|
||||
display: block;
|
||||
height: 1px;
|
||||
border: 0;
|
||||
border-top: 1px solid #7f7f7f;
|
||||
margin: 1em 0;
|
||||
padding: 0;
|
||||
opacity: 0.2;
|
||||
}
|
||||
.light-grey {
|
||||
color: #7c7c7c;
|
||||
}
|
||||
.uppercase {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.grey-bg {
|
||||
background-color: #f6f4f4;
|
||||
}
|
||||
.doc-link {
|
||||
background: #11375B;
|
||||
padding: 20px;
|
||||
color: white;
|
||||
margin-top: 0;
|
||||
}
|
||||
.doc-link a {
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "/js/download.js"}}
|
||||
{{js "/js/jquery.validate.js"}}
|
||||
{{/zone}}
|
@ -1,20 +0,0 @@
|
||||
/*<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->*/
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|