Git Product home page Git Product logo

xbeeioio's Introduction

#XBeeIOIO

Requirements: Android 2.2+ (API 8)

XBeeIOIO is an open-source library that allows the Android device to communicate with Xbee, a ZigBee module, through IOIO.

You can also use IOIO-OTG too.

XBeeIOIO is well documented, and the docs are available in the root folder of this repo.

##Setup

Connect the Xbee and the IOIO as follows:

Xbee IOIO
VIN 3.3V
GND GND
DIN UART Pin
DOUT UART Pin

Add the IOIO libraries to your workspace. Add then the XbeeIOIO library to your workspace and add it to your project's java build path.

Don't forget to clean your project.

##Usage

Declare an Xbee object, and in the setup method of the BaseIOIOLooper initialize it:

	xbee = new Xbee(ioio_,45,46,9600);

Where 45 and 46 are UART compatible pins.

To configure your XBee:

    xbee.configure(
        new XbeeConfiguration(xbee).setBaudRate()
        .setDestinationAddress(0x4F)
        .setSourceAddress(0x32)
        .setPanID(0x12).writeToNonVolatileMemory(), null);

Where the baud rate is the set baud rate at declaration (9600), destination address is 0x4F, source address is 0x32 and Personal Area Network (PAN) ID is 0x32. Write to non-volatile memory.

Optionally, set up the onDataReceivedListener, and the onDataSentListener:

	xbee.setOnDataReceivedListener(new OnDataReceivedListener() {
						@Override
						public void onDataReceived(String data) {
							// Use data
						}
					});

	xbee.setOnDataSentListener(new OnDataSentListener() {
						@Override
						public void onDataSent(String data) {
							// Use data
						}
					});

To write to the output stream use:

	xbee.writeLine("Writing this to output stream");

##More options

  • To put your data into a packet format, you can construct packet format using JSON. Example:
	/** Constructs a JSON-formatted packet.
	 * 
	 * @param data Data of the packet.
	 * @return A readable string of the JSON object.
	 */
	private String constructPacket(String data) {

		JSONObject jPacket = new JSONObject();

		try {
			jPacket.put("src", SOURCE_ADDRESS);
			jPacket.put("dest", DESTINATION_ADDRESS);
			jPacket.put("data", data);
			jPacket.put("fcs", getCRC(data));
		} catch (JSONException e) {
			e.printStackTrace();
		}

		return jPacket.toString();

	}
  • To enable CRC checking, you may use the following methods:-
	/**
	 * 
	 * @param data The data to get its CRC.
	 * @return A hex string of the CRC value (FCS).
	 */
	public String getCRC(String data){
		CRC32 crc = new CRC32();
		crc.update(data.getBytes());
		String FCS = Long.toHexString(crc.getValue());
		crc.reset();
		return FCS;
	}

The returned value (FCS) from this method must be added separately to the data sent in order to check it on the receiver side. On the receiver side, run getCRC on the received data, if the FCS equals the returned value, then the data received is correct.

##Credits

This project is developed by Zaid Daba'een and is licensed under GNU GPLv2.

xbeeioio's People

Contributors

zaiddabaeen avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

xbeeioio's Issues

Documentation

Its a interesting project since we are using IOIO for few years. As you mentioned, there is some documents available for XBeeIOIO. But I could not able to find any one on the root folder. Can you please point the same?. So that I can also contribute to prepare some docs.

Thanks in adv,
Prakash

How to test the demo app?

Hi. This is a great project to boostup IOIO feature list and appreciate your efforts on open source. I have few queries before I would like to give a try. Due to my heavy work load I was struggling to test this library for some time.

[1] Digi has many XBee modules. Please specify which module we need to buy.
[2] What are the minimum hardware requirement to test the demo application?. Do I need another set of XBEE+IOIO or any other sensors?. This is not clearly mentioned on this documentation area.
[3] How about other manufacturer's zigbee modules can use this libraries?

-Prakash

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.