[原创] 【Atmel SAM R21创意大赛周计划】+物联网小区智能网盒2周 无线通信第一步,跑例子

damiaa   2014-12-21 10:21 楼主
拿到这款板子最有意思的主要还是它的无线通信功能。于是熟悉玩开发环境跑个LED之后就直奔无线通信来了。 起先有人跑了这个例子。我也跟着玩玩。哈哈 第一步:打开ASTUDIO6.2 ,选择一个现有的工程:Peer2Peer 第二步:config.h改地址为0,编译,运行。然后退出。 拔下板子 这里说明一下。这个例子是这么要求的,为什么呢,因为ZIGBEE是有协调器,路由器,终端设备的区分的,协调器地址必须为0.它是管理总个网络的中心。没它玩不了。这个里面引入了ZIGBEE的一些思想,MAC通信格式都一样,估计用ZIGBEE抓包工具都可以抓到。 另外:最后那个我上传的文档 里解释了为什么要0,1,2,3,4.。。初始化简化了。 4。3.2.1 In Lightweight Mesh with the native routing algorithm there is no special route discovery procedure; routes are discovered as part of normal data delivery. This way, the penalty of not having a route is very low and comparable to the cost of sending a regular broadcast frame. Route discovery algorithm is illustrated below. Nodes marked “1”, “2” and “3” are routing nodes. This example makes the following assumptions:  Node 1 wants to send data to node 3  Routing Tables on all nodes are empty  There is no direct path between node 1 and node 3 Initial network configuration is shown on the Figure 4-9. Figure 4-9. Initial network configuration. QQ图片20141221105549.png Figure 4-10. First step of a data transfer involving route discovery. QQ图片20141221105651.png 1. Node 1 sends a frame with the Network Destination Address set to 3, and the MAC Destination Address set to 0xffff. 2. Node 2 receives this frame, and adds the entry for node 1 to its Routing Table. Figure 4-11. Second step of a data transfer involving route discovery. QQ图片20141221111627.png 3. Node 2 broadcasts the frame (because MAC Destination Address is set to 0xffff). 4. Node 3 receives this frame, and adds the entry for node 2 to its Routing Table. 5. Node 3 adds an entry for node 1 to its Routing Table (from a Network Source Address). Figure 4-12. Third step of a data transfer involving route discovery. QQ图片20141221105727.png 6. Node 3 handles the frame and sends an Acknowledgment frame, even if one was not requested. This is done to establish a reverse route. Node 3 now knows the route to node 1, so a unicast frame is sent. Figure 4-13. Final step of a data transfer involving route discovery. QQ图片20141221105738.png 7. Node 2 receives the frame and adds the route to node 3 to its Routing Table. 8. Node 2 has a route entry for node 1, so it routes the received frame to its final destination. 9. Node 1 receives the frame and adds the route to node 3 to its Routing Table. Figure 4-14. Final network configuration after a data transfer involving route discovery. QQ图片20141221111440.png Now a route between node 1 and node 3 is established and it will be used for the following frames. Note that during route discovery, all nodes along the route learned how to route data to the destination node. Those route entries will be used for routing purposes without further route discovery. Eventually, given big enough Routing Tables, all nodes in the network will discover all possible (used) routes. Also note that for some nodes discovery of one route created more than one entry in the Routing Table. This is a common property of the routing algorithms and it should be kept in mind when selecting Route Table size for nodes that are expected to route a lot of traffic. At the same time there is an upper bound on the number of entries in the routing table which is the maximum number of nodes in the network /*- Definitions ------------------------------------------------------------*/ /* Address must be set to 0 for the first device, and to 1 for the second one. */ #define APP_ADDR 1// #define APP_PANID 0x4567 #define APP_ENDPOINT 1 #define APP_SECURITY_KEY "TestSecurityKey0" #define APP_FLUSH_TIMER_INTERVAL 20 第三步:config.h改地址为1。编译,运行。然后退出。 这里要注意,新的模块的EDBG不一样。运行时要选择,它会提示的。 第四部:验证: 1,打开调试软件,我选的是STC的那个烧写+串口调试的软件STC-ISP 波特率都是9600。 2,插上两个板子到USB口,注意这里连到板子那端还是EDBG口,不是另一个USB口 到?wINxp系统设备里面看,生成两个虚拟串口, 3,调试软件选择串口。这里是12,13,打开串口。 4,直接发送数据,一边发点。看到两边收到数据就OK了。 QQ图片20141221101858.jpg QQ图片20141221095046.jpg QQ图片20141221095910.jpg 这个就是Lightweight Mesh Protocol 上个手册:
AVR2130_LWMesh_Developer_Guide_v1.2.1.pdf (841.23 KB)
(下载次数: 10, 2014-12-21 10:31 上传)
描述: The current implementation of the Lightweight Mesh protocol has the following features:  Simplicity of configuration and use  Up to 65535 nodes in one network (theoretical limit)  Up to 65535 separate PANs on one channel  15 independent application endpoints  No dedicated node is required to start a network  No periodic service traffic occupying bandwidth  Two distinct types of nodes:  Routing (network address < 0x8000)  Non-routing (network address ≥ 0x8000)  Once powered on node is ready to send and receive data; no special joining procedure is required  No child-parent relationship between the nodes  Non-routing nodes can send and receive data to/from any other node (including non-routing nodes), but they will never be used for routing purposes  Route discovery happens automatically if route to the destination is not known  Routing table is updated automatically based on the data from the received and transmitted frames  Optional support for AODV routing  Optional support for multicast communication  Duplicate frames (broadcast or multipath unicast) are rejected  Small footprint (8KB of Flash and 4KB of RAM for a typical application) 这里有几个概念需要了解: PINID channel nodes network address 本帖最后由 damiaa 于 2014-12-27 18:48 编辑

回复评论 (1)

给楼主赞一个
点赞  2014-12-21 12:06
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复