Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the Digi Xbee API #55 #56

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ script:
- mvn javadoc:javadoc
- cd ..
- cd coreserver
- mvn install:install-file -Dfile=./lib/XBJL-1.1.0/xbjlib-1.1.0.jar -DgroupId=xbj -DartifactId=xbj -Dversion=1.1.0 -Dpackaging=jar -DgeneratePom=true
- mvn install:install-file -Dfile=./lib/XBJL-1.1.0/extra-libs/rxtx-2.2.jar -DgroupId=rxtx -DartifactId=rxtx -Dversion=2.2.0 -Dpackaging=jar -DgeneratePom=true
- mvn install:install-file -Dfile=./lib/XBJL-1.1.0/extra-libs/slf4j-api-1.7.12.jar -DgroupId=slf4j-api -DartifactId=slf4j-api -Dversion=1.7.12 -Dpackaging=jar -DgeneratePom=true
- mvn install:install-file -Dfile=./lib/XBJL-1.1.0/extra-libs/slf4j-nop-1.7.12.jar -DgroupId=slf4j-nop -DartifactId=slf4j-nop -Dversion=1.7.12 -Dpackaging=jar -DgeneratePom=true
- mvn test
- mvn compile
- mvn javadoc:javadoc
Expand Down
9 changes: 8 additions & 1 deletion coreserver/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/XBJL-1.1.0/xbjlib-1.1.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/XBJL-1.1.0/xbjlib-1.1.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/XBJL-1.1.0/extra-libs/rxtx-2.2.jar">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="coreserver/lib/XBJL-1.1.0/extra-libs/native/Mac_OS_X"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/XBJL-1.1.0/extra-libs/slf4j-api-1.7.12.jar"/>
<classpathentry exported="true" kind="lib" path="lib/XBJL-1.1.0/extra-libs/slf4j-nop-1.7.12.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ protected void configure() {
// Environment
bind(Environment.class).to(EnvironmentManager.class).in(Singleton.class);
bind(DiscoveryService.class).to(DiscoveryJmdns.class);
//bind(DiscoveryService.class).to(DiscoveryZigbee.class);
bind(DeviceManager.class).to(DeviceMngr.class);
bind(DataManager.class).to(DataManagerNeo4j.class);
bind(AssetManager.class).to(AssetMngr.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/**
* DiscoveryZigbee.java
* coreserver
*
* Created by ericpinet on 2016-04-30.
* Copyright (c) 2016 ConnectLife (Eric Pinet). All rights reserved.
*
*/
package com.connectlife.coreserver.environment.discover;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.connectlife.coreserver.tools.errormanagement.StdOutErrLog;
import com.digi.xbee.api.XBeeDevice;
import com.digi.xbee.api.exceptions.XBeeException;

/**
* Zigbee discovery service.
*
* @author ericpinet
* <br> 2016-04-30
*/
public class DiscoveryZigbee implements DiscoveryService {

/**
* Logger use for this class.
*/
private static Logger m_logger = LogManager.getLogger(DiscoveryZigbee.class);

/**
* Port of the zigbee USB device
*/
private static final String _PORT_ = "/dev/tty.usbserial-DA01LPXS";

/**
* Baud rate of the zigbee device.
*/
private static final int _BAUD_RATE_ = 9600;

/**
* XbeeDevice to communicate with Xbee module
*/
XBeeDevice m_xbee;

/**
*
* @see com.connectlife.coreserver.environment.discover.DiscoveryService#start()
*/
@Override
public void start() {

// TODO: Remove this sample code
// start the xbee module
m_xbee = new XBeeDevice(_PORT_, _BAUD_RATE_);
try{
m_logger.info("Opening xbee module "+_PORT_+":"+_BAUD_RATE_+" ...");
m_xbee.open();
m_logger.info("Opened");


m_xbee.sendBroadcastData("XBee Eric Pinet".getBytes());

}
catch (XBeeException e) {
m_logger.error("Unable to open xbee module :"+e.getMessage());
StdOutErrLog.tieSystemOutAndErrToLog();
e.printStackTrace();
}
catch (Exception e){
m_logger.error("Unable to open xbee module :"+e.getMessage());
StdOutErrLog.tieSystemOutAndErrToLog();
e.printStackTrace();
}
finally {
m_xbee.close();
}
}

/**
*
* @see com.connectlife.coreserver.environment.discover.DiscoveryService#stop()
*/
@Override
public void stop() {
if(null != m_xbee)
m_xbee.close();
}

/**
* @param _listner
* @see com.connectlife.coreserver.environment.discover.DiscoveryService#addListner(com.connectlife.coreserver.environment.discover.DiscoveryListner)
*/
@Override
public void addListner(DiscoveryListner _listner) {
// TODO Auto-generated method stub

}

}