Skip to content

Commit

Permalink
Update to add all dongles
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <chris@cd-jackson.com>
  • Loading branch information
cdjackson committed Mar 6, 2018
1 parent add0692 commit 235450a
Show file tree
Hide file tree
Showing 104 changed files with 1,079 additions and 6,090 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target/
bin/
*/OSGI-INF/*.xml
Binary file not shown.
Binary file added lib/com.zsmartsystems.zigbee-1.0.5-SNAPSHOT.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions org.openhab.binding.zigbee.cc2531/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.openhab.binding.zigbee"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
1 change: 1 addition & 0 deletions org.openhab.binding.zigbee.cc2531/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
33 changes: 33 additions & 0 deletions org.openhab.binding.zigbee.cc2531/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.zigbee.cc2531</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
34 changes: 34 additions & 0 deletions org.openhab.binding.zigbee.cc2531/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Manifest-Version: 1.0
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-ManifestVersion: 2
Bundle-Name: ZigBee Ember Binding
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.openhab.binding.zigbee.cc2531;singleton:=true
Bundle-Vendor: openHAB
Bundle-Version: 2.3.0.qualifier
Export-Package:
org.openhab.binding.zigbee.cc2531,
org.openhab.binding.zigbee.cc2531.handler
Import-Package: com.zsmartsystems.zigbee,
com.zsmartsystems.zigbee.dongle.cc2531,
com.zsmartsystems.zigbee.serialization,
com.zsmartsystems.zigbee.transport,
gnu.io,
org.eclipse.jdt.annotation;resolution:=optional,
org.eclipse.smarthome.config.core,
org.eclipse.smarthome.config.discovery,
org.eclipse.smarthome.core.i18n,
org.eclipse.smarthome.core.library.types,
org.eclipse.smarthome.core.thing,
org.eclipse.smarthome.core.thing.binding,
org.eclipse.smarthome.core.thing.binding.builder,
org.eclipse.smarthome.core.thing.binding.firmware,
org.eclipse.smarthome.core.thing.type,
org.eclipse.smarthome.core.types,
org.openhab.binding.zigbee,
org.openhab.binding.zigbee.discovery,
org.openhab.binding.zigbee.handler,
org.osgi.framework,
org.slf4j
Service-Component: OSGI-INF/*.xml
1 change: 1 addition & 0 deletions org.openhab.binding.zigbee.cc2531/OSGI-INF/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.xml
32 changes: 32 additions & 0 deletions org.openhab.binding.zigbee.cc2531/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>

<p>March 30, 2017</p>
<h3>License</h3>

<p>
The openHAB community makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.
</p>

<p>
If you did not receive this Content directly from the openHAB community, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.openhab.org/">openhab.org</a>.
</p>

</body>
</html>
6 changes: 6 additions & 0 deletions org.openhab.binding.zigbee.cc2531/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source..=src/main/java/
output..=target/classes
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
ESH-INF/
26 changes: 26 additions & 0 deletions org.openhab.binding.zigbee.cc2531/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openhab.binding.zigbee</groupId>
<artifactId>org.openhab.binding.zigbee.parent</artifactId>
<version>2.3.0-SNAPSHOT</version>
</parent>

<groupId>org.openhab.binding</groupId>
<artifactId>org.openhab.binding.zigbee.cc2531</artifactId>

<name>ZigBee CC2531 Coordinator Binding</name>
<packaging>eclipse-plugin</packaging>

<dependencies>
<dependency>
<groupId>com.zsmartsystems.zigbee</groupId>
<artifactId>com.zsmartsystems.zigbee.dongle.cc2531</artifactId>
<version>${zigbee.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (c) 2014,2018 by the respective copyright holders.
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.zigbee.cc2531;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.thing.ThingTypeUID;

/**
* The {@link CC2531BindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Chris Jackson - Initial contribution
*/
@NonNullByDefault
public class CC2531BindingConstants {

private static final String BINDING_ID = "zigbee";

public final static String CONFIGURATION_ZNP_MAGICNUMBER = "zigbee_znp_magicnumber";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_CC2531 = new ThingTypeUID(BINDING_ID, "coordinator_cc2531");

}
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
/**
* Copyright (c) 2014-2017 by the respective copyright holders.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* Copyright (c) 2014,2018 by the respective copyright holders.
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.zigbee.handler;
package org.openhab.binding.zigbee.cc2531.handler;

import java.math.BigDecimal;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.smarthome.core.thing.Bridge;
import org.eclipse.smarthome.core.thing.ChannelUID;
import org.eclipse.smarthome.core.thing.ThingStatus;
import org.eclipse.smarthome.core.thing.ThingStatusDetail;
import org.eclipse.smarthome.core.thing.binding.firmware.Firmware;
import org.eclipse.smarthome.core.thing.binding.firmware.FirmwareUpdateHandler;
import org.eclipse.smarthome.core.thing.binding.firmware.ProgressCallback;
import org.eclipse.smarthome.core.thing.binding.firmware.ProgressStep;
import org.eclipse.smarthome.core.types.Command;
import org.openhab.binding.zigbee.ZigBeeBindingConstants;
import org.openhab.binding.zigbee.internal.ZigBeeSerialPort;
import org.openhab.binding.zigbee.cc2531.internal.CC2531Configuration;
import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler;
import org.openhab.binding.zigbee.handler.ZigBeeSerialPort;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.zsmartsystems.zigbee.dongle.ember.ZigBeeDongleEzsp;
import com.zsmartsystems.zigbee.dongle.cc2531.ZigBeeDongleTiCc2531;
import com.zsmartsystems.zigbee.serialization.DefaultDeserializer;
import com.zsmartsystems.zigbee.serialization.DefaultSerializer;
import com.zsmartsystems.zigbee.transport.ConcentratorConfig;
import com.zsmartsystems.zigbee.transport.ConcentratorType;
import com.zsmartsystems.zigbee.transport.TransportConfig;
import com.zsmartsystems.zigbee.transport.TransportConfigOption;
import com.zsmartsystems.zigbee.transport.ZigBeePort;
import com.zsmartsystems.zigbee.transport.ZigBeePort.FlowControl;
import com.zsmartsystems.zigbee.transport.ZigBeeTransportFirmwareCallback;
Expand All @@ -39,66 +37,43 @@
import com.zsmartsystems.zigbee.transport.ZigBeeTransportTransmit;

/**
* The {@link ZigBeeCoordinatorEmberHandler} is responsible for handling
* commands, which are sent to one of the channels.
* The {@link CC2531Handler} is responsible for handling commands, which are
* sent to one of the channels.
*
* @author Chris Jackson - Initial contribution
*/
public class ZigBeeCoordinatorEmberHandler extends ZigBeeCoordinatorHandler implements FirmwareUpdateHandler {
private Logger logger = LoggerFactory.getLogger(ZigBeeCoordinatorEmberHandler.class);

private final int DEFAULT_BAUD = 115200;

private String portId;
private int portBaud;
// @NonNullByDefault
public class CC2531Handler extends ZigBeeCoordinatorHandler implements FirmwareUpdateHandler {
private final Logger logger = LoggerFactory.getLogger(CC2531Handler.class);

public ZigBeeCoordinatorEmberHandler(@NonNull Bridge coordinator) {
public CC2531Handler(Bridge coordinator) {
super(coordinator);
}

@Override
public void handleCommand(ChannelUID channelUID, Command command) {
// Not required - yet!
}

@Override
public void initialize() {
logger.debug("Initializing ZigBee Ember serial bridge handler.");
logger.debug("Initializing ZigBee CC2531 serial bridge handler.");

// Call the parent to finish any global initialisation
super.initialize();

portId = (String) getConfig().get(ZigBeeBindingConstants.CONFIGURATION_PORT);
CC2531Configuration config = getConfigAs(CC2531Configuration.class);

if (getConfig().get(ZigBeeBindingConstants.CONFIGURATION_BAUD) != null) {
portBaud = ((BigDecimal) getConfig().get(ZigBeeBindingConstants.CONFIGURATION_BAUD)).intValue();
} else {
portBaud = DEFAULT_BAUD;
}
ZigBeePort serialPort = new ZigBeeSerialPort(portId, portBaud, FlowControl.FLOWCONTROL_OUT_RTSCTS);
final ZigBeeTransportTransmit dongle = new ZigBeeDongleEzsp(serialPort);
ZigBeePort serialPort = new ZigBeeSerialPort(config.zigbee_port, config.zigbee_baud,
FlowControl.FLOWCONTROL_OUT_RTSCTS);
final ZigBeeTransportTransmit dongle = new ZigBeeDongleTiCc2531(serialPort);

logger.debug("ZigBee Coordinator Ember opening Port:'{}' PAN:{}, EPAN:{}, Channel:{}", portId,
logger.debug("ZigBee CC2531 Coordinator opening Port:'{}' PAN:{}, EPAN:{}, Channel:{}", config.zigbee_port,
Integer.toHexString(panId), extendedPanId, Integer.toString(channelId));

TransportConfig config = new TransportConfig();
TransportConfig transportConfig = new TransportConfig();

// Configure the concentrator
// Max Hops defaults to system max
ConcentratorConfig concentratorConfig = new ConcentratorConfig();
concentratorConfig.setType(ConcentratorType.LOW_RAM);
concentratorConfig.setMaxFailures(8);
concentratorConfig.setMaxHops(0);
concentratorConfig.setRefreshMinimum(60);
concentratorConfig.setRefreshMaximum(3600);
config.addOption(TransportConfigOption.CONCENTRATOR_CONFIG, concentratorConfig);

startZigBee(dongle, config, DefaultSerializer.class, DefaultDeserializer.class);
startZigBee(dongle, transportConfig, DefaultSerializer.class, DefaultDeserializer.class);
}

@Override
public void updateFirmware(Firmware firmware, ProgressCallback progressCallback) {
logger.debug("Ember coordinator: update firmware with {}", firmware.getVersion());
logger.debug("CC2531 coordinator: update firmware with {}", firmware.getVersion());

updateStatus(ThingStatus.OFFLINE);
zigbeeTransport.shutdown();
Expand All @@ -111,7 +86,7 @@ public void updateFirmware(Firmware firmware, ProgressCallback progressCallback)
firmwareUpdate.updateFirmware(firmware.getInputStream(), new ZigBeeTransportFirmwareCallback() {
@Override
public void firmwareUpdateCallback(ZigBeeTransportFirmwareStatus status) {
logger.debug("Ember dongle firmware status: {}", status);
logger.debug("CC2531 dongle firmware status: {}", status);
switch (status) {
case FIRMWARE_UPDATE_STARTED:
// ProgressStep.DOWNLOADING
Expand Down Expand Up @@ -147,7 +122,7 @@ public void firmwareUpdateCallback(ZigBeeTransportFirmwareStatus status) {

@Override
public void cancel() {
logger.debug("Ember coordinator: cancel firmware update");
logger.debug("CC2531 coordinator: cancel firmware update");
ZigBeeTransportFirmwareUpdate firmwareUpdate = (ZigBeeTransportFirmwareUpdate) zigbeeTransport;
firmwareUpdate.cancelUpdateFirmware();
}
Expand All @@ -161,4 +136,5 @@ public boolean isUpdateExecutable() {
// firmware.
return true;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2014,2018 by the respective copyright holders.
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.zigbee.cc2531.internal;

/**
* The {@link CC2531Configuration} class contains fields mapping thing configuration
* parameters.
*
* @author Chris Jackson - Initial contribution
*/
public class CC2531Configuration {
public String zigbee_port;
public Integer zigbee_baud;
}
Loading

0 comments on commit 235450a

Please sign in to comment.