用于Iter车辆通信的Zigbee程序?

用于Iter车辆通信的Zigbee程序?,zigbee,Zigbee,我尝试使用zigbee协议,在两辆车之间建立通信,作为车辆间通信的一部分,如在VANET中。因此,由于我对这一点非常陌生,我想知道: a。我是否必须编程我的Zigbee接口来建立通信? B是否可以编程zigbee接口? C有谁能给我一个关于如何在两个Zigbee之间建立(使用编程语言)通信的总体概念吗 任何帮助都将不胜感激。要建立连接并执行简单的发送/接收数据(在2个接口/模块之间),您不需要编程ZigBee接口(例如XBee)。只需使用XCTU配置它们。但是,如果你想让他们按照你喜欢的方式(按

我尝试使用zigbee协议,在两辆车之间建立通信,作为车辆间通信的一部分,如在VANET中。因此,由于我对这一点非常陌生,我想知道:

a。我是否必须编程我的Zigbee接口来建立通信? B是否可以编程zigbee接口? C有谁能给我一个关于如何在两个Zigbee之间建立(使用编程语言)通信的总体概念吗


任何帮助都将不胜感激。要建立连接并执行简单的发送/接收数据(在2个接口/模块之间),您不需要编程ZigBee接口(例如XBee)。只需使用XCTU配置它们。但是,如果你想让他们按照你喜欢的方式(按照你自己的规则)彼此交流,你必须对他们进行编程

b。如果您有XBee模块,那么您可以使用基于Java的XBee模块。对于其他模块,请查看您模块的文档

c。此示例取自使用Java编程语言的web页面(示例代码)。此代码所做的是搜索附近的所有模块(节点发现):

/**
*版权所有(c)2008安德鲁·拉普。版权所有。
*  
*此文件是XBee API的一部分。
*  
*XBee API是免费软件:您可以重新发布和/或修改它
*它是根据GNU通用公共许可证的条款发布的
*自由软件基金会,或者许可证的第3版,或者
*(由您选择)任何更高版本。
*  
*XBee API的发布是希望它会有用,
*但无任何保证;甚至没有任何关于
*适销性或适合某一特定目的。见
*有关更多详细信息,请参阅GNU通用公共许可证。
*  
*您应该已经收到GNU通用公共许可证的副本
*以及XBee API。如果没有,请参阅。
*/
包com.rappologic.xbee.examples.zigbee;
导入java.util.List;
导入org.apache.log4j.Logger;
导入org.apache.log4j.propertyConfiguration;
导入com.rappologic.xbee.api.apid;
导入com.rapplogic.xbee.api.AtCommand;
导入com.rapplogic.xbee.api.AtCommandResponse;
导入com.rapplogic.xbee.api.PacketListener;
导入com.rapplogic.xbee.api.xbee;
导入com.rapplogic.xbee.api.XBeeException;
导入com.rapplogic.xbee.api.xbeResponse;
导入com.rapplogic.xbee.api.zigbee.zbNodeDiscovery;
导入com.rapplogic.xbee.util.ByteUtils;
/**
*为系列2 XBEE执行节点发现的示例。
*您必须连接到协调器才能运行此示例,并且
*具有一个或多个关联的终端设备/路由器。
*
*@作者安德鲁
*
*/
公共类zbNodeDiscoveryExample{
私有最终静态记录器log=Logger.getLogger(ZBNodeDiscoverExample.class);
私有XBee XBee=新XBee();
public zbNodeDiscoveryExample()引发XBeeException、InterruptedException{
试一试{
//替换为串行端口
xbee.open(“/dev/tty.usbserial-A6005v5M”,9600);
//获取节点发现超时
xbee.sendAsynchronous(新的AtCommand(“NT”));
AtCommandResponse nodeTimeout=(AtCommandResponse)xbee.getResponse();
//默认值为6秒
int nodeDiscoveryTimeout=ByteUtils.convertMultiBytePoint(nodeTimeout.getValue())*100;
log.info(“节点发现超时为”+nodeDiscoveryTimeout+“毫秒”);
log.info(“发送节点发现命令”);
sendAsynchronous(新的AtCommand(“ND”));
//注意:如果没有看到报告的所有节点,请增加NT
列表
/**
 * Copyright (c) 2008 Andrew Rapp. All rights reserved.
 *  
 * This file is part of XBee-API.
 *  
 * XBee-API is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *  
 * XBee-API is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *  
 * You should have received a copy of the GNU General Public License
 * along with XBee-API.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.rapplogic.xbee.examples.zigbee;

import java.util.List;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import com.rapplogic.xbee.api.ApiId;
import com.rapplogic.xbee.api.AtCommand;
import com.rapplogic.xbee.api.AtCommandResponse;
import com.rapplogic.xbee.api.PacketListener;
import com.rapplogic.xbee.api.XBee;
import com.rapplogic.xbee.api.XBeeException;
import com.rapplogic.xbee.api.XBeeResponse;
import com.rapplogic.xbee.api.zigbee.ZBNodeDiscover;
import com.rapplogic.xbee.util.ByteUtils;

/**
 * Example of performing a node discover for Series 2 XBees.
 * You must connect to the coordinator to run this example and
 * have one or more end device/routers that are associated.
 *
 * @author andrew
 *
 */
public class ZBNodeDiscoverExample {

        private final static Logger log = Logger.getLogger(ZBNodeDiscoverExample.class);

        private XBee xbee = new XBee();

        public ZBNodeDiscoverExample() throws XBeeException, InterruptedException {

                try {
                        // replace with your serial port
                        xbee.open("/dev/tty.usbserial-A6005v5M", 9600);


                        // get the Node discovery timeout
                        xbee.sendAsynchronous(new AtCommand("NT"));
                        AtCommandResponse nodeTimeout = (AtCommandResponse) xbee.getResponse();

                        // default is 6 seconds
                        int nodeDiscoveryTimeout = ByteUtils.convertMultiByteToInt(nodeTimeout.getValue()) * 100;                      
                        log.info("Node discovery timeout is " + nodeDiscoveryTimeout + " milliseconds");

                        log.info("Sending Node Discover command");
                        xbee.sendAsynchronous(new AtCommand("ND"));

                        // NOTE: increase NT if you are not seeing all your nodes reported

                        List<? extends XBeeResponse> responses = xbee.collectResponses(nodeDiscoveryTimeout);

                        log.info("Time is up!  You should have heard back from all nodes by now.  If not make sure all nodes are associated and/or try increasing the node timeout (NT)");

                        for (XBeeResponse response : responses) {
                                if (response instanceof AtCommandResponse) {
                                        AtCommandResponse atResponse = (AtCommandResponse) response;

                                        if (atResponse.getCommand().equals("ND") && atResponse.getValue() != null && atResponse.getValue().length > 0) {
                                                ZBNodeDiscover nd = ZBNodeDiscover.parse((AtCommandResponse)response);
                                                log.info("Node Discover is " + nd);                                                    
                                        }
                                }
                        }
                } finally {
                        xbee.close();
                }
        }

        public static void main(String[] args) throws XBeeException, InterruptedException {
                PropertyConfigurator.configure("log4j.properties");
                new ZBNodeDiscoverExample();
        }
}