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

📄 network.h

📁 关于zigbee厂家jennic的zigbee通信模块JN5139的一些示例程序。
💻 H
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************/
/*!
 *\MODULE              Wireless UART with Flow Control
 *
 *\COMPONENT           $RCSfile: Network.h,v $
 *
 *\VERSION             $Name:  $
 *
 *\REVISION            $Revision: 1.8 $
 *
 *\DATED               $Date: 2008/03/26 14:40:44 $
 *
 *\STATUS              $State: Exp $
 *
 *\AUTHOR              Martin Looker
 *
 *\DESCRIPTION         Network - public interface.
 *
 * Contains the network configuration settings and the public function prototypes
 * for the common network functions.
 */
/*\CHANGE HISTORY
 *
 * $Log: Network.h,v $
 * Revision 1.8  2008/03/26 14:40:44  mlook
 * Now scans channels
 *
 * Revision 1.7  2008/03/20 10:39:38  mlook
 * Removed header values for Respiratronics.
 *
 * Revision 1.6  2008/03/20 09:53:19  mlook
 * Button start for Respiratronics
 *
 * Revision 1.5  2008/03/05 10:07:25  mlook
 * *** empty log message ***
 *
 * Revision 1.4  2008/03/05 09:47:29  mlook
 * Added option for binding with buttons
 *
 * Revision 1.3  2008/03/05 09:33:17  mlook
 * Added option for binding with buttons
 *
 * Revision 1.2  2008/01/21 15:00:29  mlook
 * Updated network id for official app note number
 *
 * Revision 1.1  2008/01/21 10:15:04  mlook
 * Initial checkin
 *
 *
 *
 *\LAST MODIFIED BY    $Author: mlook $
 *                     $Modtime: $
 *
 ****************************************************************************
 *
 * This software is owned by Jennic and/or its supplier and is protected
 * under applicable copyright laws. All rights are reserved. We grant You,
 * and any third parties, a license to use this software solely and
 * exclusively on Jennic products. You, and any third parties must reproduce
 * the copyright and warranty notice and any other legend of ownership on each
 * copy or partial copy of the software.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS". JENNIC MAKES NO WARRANTIES, WHETHER
 * EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
 * ACCURACY OR LACK OF NEGLIGENCE. JENNIC SHALL NOT, IN ANY CIRCUMSTANCES,
 * BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, SPECIAL,
 * INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER.
 *
 * Copyright Jennic Ltd 2007. All rights reserved
 *
 ****************************************************************************/

#ifndef  NETWORK_H_INCLUDED
#define  NETWORK_H_INCLUDED

#if defined __cplusplus
extern "C" {
#endif

/****************************************************************************/
/***        Include files                                                 ***/
/****************************************************************************/
#include <jendefs.h>
#include <jenie.h>

/****************************************************************************/
/***        Macro Definitions                                             ***/
/****************************************************************************/
#define NETWORK_VERSION				10			/**< Network version */
#define NETWORK_PAN_ID				0x1083			/**< Network ID             */
#define NETWORK_APPLICATION_ID		0x10831083	/**< Application ID         */
#define NETWORK_CHANNEL				0			/**< Channel				*/
#define NETWORK_SCAN_CHANNELS		0x07FFF800	/**< Scan channels (only used when CHANNEL is 0) */
#define NETWORK_POLL_PERIOD			20			/**< Polling period in 10ms intervals for end device */
#define NETWORK_MAX_CHILDREN		10			/**< Default max children - can't be larger than 10 */
#define NETWORK_MAX_SOURCE			1			/**< Maximum number of source services */
#define NETWORK_TXOPTION			0			/**< Transmit options */
#define NETWORK_LED					TRUE		/**< Use LEDs to indicate status */
#define NETWORK_BUTTON_BIND			FALSE		/**< Use button 0 to bind devices */
#define NETWORK_BUTTON_START		FALSE		/**< Dont start until button pressed, 0 for coord, 1 for router */

#define NETWORK_DEBUG				FALSE 	  	/**< Debug network activity to UART */

/* Network transmit queue definitions, (used by direct transmit, not source service transmit) */
#define NETWORK_TX_DATA_SIZE		15			/**< Max size of data packets in Tx queue */
#define NETWORK_TX_QUEUE_SIZE		10			/**< Max number of data packets in Tx queue */
#define NETWORK_TX_RETRIES			3			/**< Number of retries for a Tx queue item */
#define NETWORK_TX_TIMEOUT			20			/**< In 10ms intervals */

/****************************************************************************/
/***        Exported Function Prototypes                                  ***/
/****************************************************************************/
PUBLIC void 				vNetwork_ConfigureNetwork 		(teJenieDeviceType, uint8);
PUBLIC void 				vNetwork_Init 			 		(bool_t, bool_t);
PUBLIC void 				vNetwork_Start 			  		(void);
PUBLIC void 				vNetwork_Main 			  		(void);
PUBLIC void 				vNetwork_StackMgmtEvent   		(teEventType, void *);
PUBLIC void 				vNetwork_StackDataEvent   		(teEventType, void *);
PUBLIC void 				vNetwork_HwEvent 		  		(uint32, uint32);
PUBLIC bool_t 				bNetwork_Tx 					(uint64, uint8, uint16, uint8 *);
PUBLIC void 				vNetwork_Rx						(uint64, uint16, uint8 *);
PUBLIC void					vDevice_Rx						(uint64, uint16, uint8 *);
PUBLIC teJenieStatusCode 	eNetwork_Sleep 					(uint32, bool_t);
PUBLIC teJenieStatusCode 	eNetwork_SetPermitJoin 			(bool_t);
PUBLIC void					vNetwork_PollPeriod			    (uint16);
PUBLIC uint16			  u16Network_PollPeriod			    (void);

PUBLIC bool_t 				bNetwork_Up 					(void);
PUBLIC bool_t 				bNetwork_UartUp 				(void);
PUBLIC teJenieDeviceType 	eNetwork_DeviceType				(void);
PUBLIC uint64			  u64Network_LastRxAddress			(void);

PUBLIC uint32 			  u32Network_Service_Mask		 	(uint8);

PUBLIC bool_t				bNetwork_Source_Bound			(uint8);
PUBLIC teJenieStatusCode 	eNetwork_Sources_Enabled 		(uint8, uint32, uint8);
PUBLIC teJenieStatusCode 	eNetwork_Source_Enabled 		(uint8, uint8, uint8);
PUBLIC bool_t 				bNetwork_Source_Enabled 		(uint8, uint8);
PUBLIC teJenieStatusCode 	eNetwork_Sources_Limit 			(uint8, uint32, uint8);
PUBLIC teJenieStatusCode 	eNetwork_Source_Limit 			(uint8, uint8, uint8);
PUBLIC uint8 			   u8Network_Source_Limit 			(uint8, uint8);
PUBLIC uint8 			   u8Network_Source_Count 			(uint8, uint8);

PUBLIC bool_t				bNetwork_Destination_Bound		(uint8);
PUBLIC teJenieStatusCode 	eNetwork_Destinations_Enabled 	(uint32, uint8);
PUBLIC teJenieStatusCode 	eNetwork_Destination_Enabled 	(uint8, uint8);
PUBLIC bool_t 				bNetwork_Destination_Enabled 	(uint8);
PUBLIC teJenieStatusCode 	eNetwork_Destinations_Limit 	(uint32, uint8);
PUBLIC teJenieStatusCode 	eNetwork_Destination_Limit 		(uint8, uint8);
PUBLIC uint8 			   u8Network_Destination_Limit 		(uint8);
PUBLIC uint8 			   u8Network_Destination_Count 		(uint8);

PUBLIC teJenieStatusCode	eNetwork_Source_Tx				(uint8, uint16, uint8 *);
PUBLIC void 				vNetwork_Destination_Rx			(uint64, uint8, uint16, uint8 *);
PUBLIC void					 vDevice_Destination_Rx			(uint64, uint8, uint16, uint8 *);

PUBLIC void 				vNetwork_BinToHex 				(uint8 *, uint32, uint8);
PUBLIC uint32 			  u32Network_HexToBin 				(uint8 *, uint8);
#if NETWORK_DEBUG
PUBLIC bool_t 				bNetwork_IsString				(uint16, uint8 *);
#endif

#if defined __cplusplus
}
#endif

#endif  /* NETWORK_H_INCLUDED */

/***************************************************************************/
/*!
 *\mainpage Wireless UART with Flow Control
 *
 *\section Introduction Introduction
 *
 * This Application Note describes how to create a wireless UART link between
 * the UARTs on two development kit boards. The features of the application
 * include:
 *
 * - Replacement of serial cables with wireless connectivity.
 * - Quick addition of low-cost wireless connectivity to products using a
 *   UART link for communications.
 * - UART hardware flow control using the RTS/CTS lines to control the flow
 *   of data into and out of the UART.
 * - Radio flow control using a simple protocol to control the flow of
 *   data over the radio.
 *
 * The software used to devlop this application was developed using the Jenie
 * API available free of charge from <a href="http://www.jennic.com">Jennic Ltd</a>.
 *
 *\section Application_Overview Application Overview
 *
 * The application uses a pair of development kit boards to form a wireless
 * network. Data received by a UART on one board is transmitted via the
 * wireless radio link to the second board and output by the second board's
 * UART and vice versa.This allows two devices, (such as PCs), to communicate
 * via a wireless radio link.
 *
 * This is illustrated in the figure below:
 *
 * [IMAGE]
 *
 * Two different binaries are built as part of this application:
 *
 * -# The Coordinator initially creates the network, then runs in the same way as the Router.
 * -# The Router application initially joins the network, then runs in the same way as the Coordinator.
 *
 * It is assumed that a permament power source is available at both ends of
 * the wireless link allowing the radio to always be active and ready to
 * transmit or receive data.
 *
 *\subsection Starting Starting the Application
 *
 * Connect each board to a PC using the serial cables provided with the
 * evaluation kit, UART 0 on the boards is used by default.
 *
 * When the boards are first powered on LED 1 is lit.
 *
 * When the network is started by the Coordinator or joined by the Router
 * LED 2 is turned on.
 *
 * When the Jenie service that receives data has been bound to LED 1 is
 * turned off.
 *
 * When the Jenie service that transmits data has bound to its destination
 * LED 2 is turned off.
 *
 * The time between LED 2 being turned on and the LEDs being turned off may be very short.
 * Once both LEDs have been turned off the application is running and ready
 * to send and receive data.
 *
 *\subsection Running Running the Application
 *
 * Ensure the Flash Programmer software is disconnected from the serial port on the PC
 * if using the same serial port for programming and running the application.
 *
 * A terminal emulator such as HyperTerminal can be used to send data between
 * the boards. The serial connection is 115200 bps, 8 data bits, no parity,
 * 1 stop bit with hardware flow control by default.
 *
 * Data entered into one board's UART should be transmitted from the other
 * board's UART.
 *
 * Whenever data is received LED 0 is flashed briefly, whenever data is
 * transmitted LED 1 is flashed briefly.
 *
 *\subsection LCD LCD
 *
 * When the Coordinator or Router binary is loaded into a controller board
 * with LCD, the LCD will display a looping count of the data bytes
 * transmitted and received to and from the UART and over the radio link.
 *
 * \section Software_Design Software Design
 *
 * Apart from the creation and joining of the network, the software contained
 * in each sensor board is identical.
 *
 * The source files required to build the application are described below:
 *
 * - Coordinator.c
 * - Router.c
 * - Network.c
 * - SerialQ.c
 * - Uart.c
 * - Protocol.c
 * - Display.c
 * - WUartDisp.c
 *
 ***************************************************************************/
/*
 *\dot
 * digraph G {
 * label="Wireless UART Link"
 * compound=true;
 * rankdir="TB";
 * ranksep=1.0;
 * fontname="FreeSans.ttf";
 * fontsize=10;
 * labelfontname="FreeSans.ttf";
 * labelfontsize=10;
 *
 * edge	     [fontname="FreeSans.ttf", fontsize=8,  labelfontname="FreeSans.ttf", labelfontsize=8];
 * node 	 [fontname="FreeSans.ttf", fontsize=10, labelfontname="FreeSans.ttf", labelfontsize=10,shape="box",height=0.2,width=2.0];
 * edge	     [color="Black"];
 *
 * subgraph cluster_AB {
 * rank=same;
 * subgraph cluster_deviceA {
 * 		label="Device 1";
 *   	labelloc = "top";
 * 		uartA [label="UART"];
 * }
 *
 * subgraph cluster_deviceB {
 * 		label="Device 2";
 *   	labelloc = "top";
 * 		uartB [label="UART"];
 * }
 * }
 *
 * subgraph cluster_XY {
 * rank=same;
 * subgraph cluster_boardX {
 *   label="Sensor Board 1";

⌨️ 快捷键说明

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