⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coordinator.c

📁 This demonstration shows how a ZigBee coordinator can be set up. This demo allows the Demonstratio
💻 C
字号:
/*
    Microchip ZigBee Stack

    Demo Coordinator

    This demonstration shows how a ZigBee coordinator can be set up.  This demo allows
    the Demonstration Board (PICDEM Z or Explorer 16) to act as either a "Switching Load 
    Controller" (e.g. a light) or a "Switching Remote Control" (e.g. a switch) as defined by
    the Home Controls, Lighting profile.  It is designed to interact with a second Demonstration 
    board programmed with the Demo RFD project.

    To give the Demo board "switch" capability, uncomment the I_AM_SWITCH definition
    below.  To give the Demo board "light" capability, uncomment the I_AM_LIGHT
    definition below.  The Demo board may have both capabilities enabled.  Be sure
    that the corresponding Demo RFD device is programmed with complementary
    capabilities.  NOTE - for simplicity, the ZigBee simple descriptors for this
    demonstration are fixed.

    If this node is configured as a "switch", it can discover the network address
    of the "light" using two methods.  If the USE_BINDINGS definition is
    uncommented below, then End Device Binding must be performed between the
    "switch" and the "light" before messages can be sent and received successfully.
    If USE_BINDINGS is commented out, then the node will default to the probable
    network address of the other node, and messages may be able to be sent
    immediately.  However, the node will also be capable of performing Device
    Discovery to discover the actual network address of the other node, in case
    the network was formed with alternate short address assignments.  NOTE: The
    USE_BINDINGS definition must be the same in both the RFD and the ZigBee
    Coordinator nodes.

    Switch functionality is as follows:
      PICDEM Z Board
        RB4, I_AM_SWITCH defined, sends a "toggle" message to the other node's "light"
        RB4, I_AM_SWITCH not defined, no effect
        RB5, USE_BINDINGS defined, sends an End Device Bind request
        RB5, USE_BINDINGS undefined, sends a NWK_ADDR_req for the MAC address specified
      Explorer 16 Board
        RD6, I_AM_SWITCH defined, sends a "toggle" message to the other node's "light"
        RD6, I_AM_SWITCH not defined, no effect
        RD7, USE_BINDINGS defined, sends an End Device Bind request
        RD7, USE_BINDINGS undefined, sends a NWK_ADDR_req for the MAC address specified

    End Device Binding
    ------------------
    If the USE_BINDINGS definition is uncommented, the "switch" will send an
    APS indirect message to toggle the "light".  In order for the message to
    reach its final destination, a binding must be created between the "switch"
    and the "light".  To do this, press RB5 on one PICDEM Z (or RD7 on one Explorer 16), 
    and then press RB5 on the other PICDEM Z (or RD7 on other Explore 16) within 5 seconds.  
    A message will be displayed indicating if binding was successful or not.  Note that End 
    Device Binding is a toggle function.  Performing the operation again will unbind the nodes, 
    and messages will not reach their final destination.

    Device Discovery
    ----------------
    If the USE_BINDINGS definition is not uncommented, pressing RB5 on PICDEM Z (or RD7 on 
    Explorer 16) will send a broadcast NWK_ADDR_req message.  The NWK_ADDR_req message contains 
    the MAC address of the desired node.  Be sure this address matches the address contained in 
    the other node's zigbee.def file.

    NOTE: To speed network formation, ALLOWED_CHANNELS has been set to
    channel 17 only.

 *********************************************************************
 * FileName:        Coordinator.c
 * Dependencies:
 * Processor:       PIC18 / PIC24 / dsPIC33
 * Complier:        MCC18 v3.00 or higher
 *                  MCC20 v2.05 or higher
 * Company:         Microchip Technology, Inc.
 *
 * Software License Agreement
 *
 * Copyright 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -