亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? endpoint.c

?? Dynamic C 程式語言源碼 嵌入式控制系統 Xbee蜂群網路~
?? C
字號:
/***************************************************************************

   endpoint.c
	Digi International, Copyright (C) 2007-2008.  All rights reserved.

   Description
   ===========

   This sample shows how to set up and use endpoints with the Rabbit
   XBee_API.lib library. It is meant to be run with another Rabbit
   XBee-enabled board.

	Note: A node with JN set to 1 will send a broadcast frame when it joins
	the network.  If this sample receives one of those frames, it will print
	"Unknown message arrived" and display a hex dump of the frame.

	Having JN set to 1 is the default configuration and should be expected on
	ZNet XBee firmware.  ZB firmware defaults to a JN setting of 0.

   Usage
   ======

   	-	Compile this sample to two Rabbit XBee-enabled boards.
      -	If you are not using the Digi XBee USB device as a coordinator,
      	configure one board as a coordinator and the other as an end device
      	or router.
   	-	Use the DIAG connector on a programming cable to connect one board to
   		your PC.
   	-	Using a serial terminal application such as HyperTerminal or Moni,
   		connect to the serial port at 57600 baud.
   	-	Connect a separate programming cable to the second Rabbit's
   		programming port.  You will use the stdio window for this board.
   	-	After compiling to the second board, it will send messages to the
   		first board, and both boards will produce output.
   	-	You can reset the first board, and after it initializes it will send
   		messages to the second board, also producing output from both boards.
   		(Do not reset the board attached to Dynamic C, as this will cause
   		a target-communication failure.  Instead, use the key sequence
   		Stop (Ctrl+Q), Reset Program (Ctrl+F2), Run (F9).

*****************************************************************************/

// Set XBEE_ROLE to NODE_TYPE_COORD, NODE_TYPE_ROUTER or NODE_TYPE_ENDDEV to
// match your XBee's firmware.  View the function help (Ctrl+H) on XBEE_ROLE
// for additional information on setting up an XBee network.
// XBee-enabled Rabbit products ship with the module set to router.
#define XBEE_ROLE			NODE_TYPE_ROUTER

// Set a Node ID to identify this node on the network.
#define NODEID_STR			"Rabbit EndPoint"

// Set the WHO macro to the NODE ID you want to send to.  For this demo, both
// boards are compiled with the same name, so we'll just re-use NODEID_STR.
#define WHO						NODEID_STR

// ------------------------------------------------------
//
// Serial Cable Communication:
//
// The following definitions redirect stdio to serial port A when
// the core module is not attached to the PROG connector of the
// programming cable.  Use the DIAG connector of the programming cable
// to access serial port A.  See Samples\STDIO_SERIAL.C for more details
// on redirecting stdio.
//

#define	STDIO_DEBUG_SERIAL	SADR
#define	STDIO_DEBUG_BAUD		57600
#define	STDIO_DEBUG_ADDCR

// ------------------------------------------------------

#memmap xmem

#use "xbee_api.lib"

void recvString(char *data, int len);
int sendString(char *who, char *data);

// These structures define what an endpoint can do.
// The cluster numbers represent the functions that
// are available on the endpoint. Multiple endpoints
// can use the same cluster IDs, thus performing the
// same functions.

#define CLUSTER_ID 7
#define PROFILE_ID 42
#define ENDPOINT 2

RabbitClusterIDList_t const StringInCluster = {
        { CLUSTER_ID },
        { recvString }
};

// The endpoint table defines what endpoints the application
// has and what Cluster IDs are associated with it. Each
// endpoint is associated with a profile and a device. The
// device is not important, but the profile is very
// important. A profile defines what commands and data formats
// and functions are available on a network. Any device
// implementing some or all of these items may join the network
// and be used or use other devices. A device may support more
// than one profile.

// Applications using the Rabbit XBee_API.lib library must define an
// endpoint table, even if it is empty.  For more information,
// perform a function lookup (ctrl-H) on ENDPOINT_TABLE_BEGIN.
ENDPOINT_TABLE_BEGIN
//                   Endpt  desc, profile  device  flags  IC  OC  \
//		 	ICL			 		OCL
ENDPOINT_TABLE_ENTRY(ENDPOINT, 0, PROFILE_ID,   1,    0,   1,  0, \
        &StringInCluster, NULL)
ENDPOINT_TABLE_END

int msgSent;
char testString[48];

// number of seconds between node discovery attempts
#define RETRY_DISCOVER 30

void main (void)
{
	int tickres;
	unsigned long last_discover;
	int initres;	// Result of xbee_init()
	unsigned long join_start;
	int loop;
	int error;
	int node_discover;

	printf("Starting program....\n\n");

	// *** Initialization ***

	// Initialize the radio portion of the board
	join_start = 0;
	while ( (initres = xbee_init()) == -EBUSY)
	{
		if (! join_start)
		{
	      join_start = SEC_TIMER;
	      printf( "Waiting for sleeping XBee to wake before continuing.");
		}
      if (join_start != SEC_TIMER)
      {
         join_start = SEC_TIMER;
         printf( ".");
      }
	}
	printf( "\n");

	if (initres) {
		printf("xbee_init failed.  result code: %d (%ls)\n",
				initres, error_message(initres));
		exit(initres);
	}
	// Join the network.  For more information on ZB_JOINING_NETWORK,
	// perform a function lookup (ctrl-H) on ZB_LAST_STATUS().
	printf("Waiting to join network...\n");
	join_start = MS_TIMER;
	while (ZB_JOINING_NETWORK()) {
		// If unable to join a network, timeout after arbitrary time
		if (MS_TIMER - join_start > XBEE_JOIN_TIMEOUT) {
	      // There was an error, do something about it
	      printf("\n*** Error ***\n");
	      printf("Timed out while trying to join a network, halting.\n");
	      exit(-ETIME);
	   }
	}
	printf( "Done (%s network)\n", xbee_protocol());

	last_discover = SEC_TIMER;

	// Wait for node discovery (6-7 seconds, can do something else between calls
	printf( "Waiting for node discovery...\n");
	while (ZB_ND_RUNNING());
	printf( "Discovery done.\n\n");
	// *** End Initialization ***

   msgSent = 0;
   loop = 0;
   node_discover = 0;
	// Send 10 messages "Test String 0" .. "Test String 9"
	while ( 1 )
	{
		switch (node_discover)
		{
			case 1:		// need to perform discovery
				if (SEC_TIMER - last_discover > RETRY_DISCOVER)
				{
					printf( "Starting node discovery...\n");
					xb_send_command( xb_ND);
					last_discover = SEC_TIMER;
					node_discover = 2;
				}
				break;

			case 2:		// waiting for discovery to complete
	         if (!ZB_ND_RUNNING())
	         {
	            node_discover = 0;
	         }
				break;
		}

		if ( ZB_LAST_STATUS() == ZB_JOINED && !msgSent && !node_discover)
		{
			if (loop < 10)
			{
				sprintf( testString, "Test String %d", loop);
				error = sendString( WHO, testString);
				if (error == 1)
				{
					printf( "Waiting %d seconds before retrying node discovery.\n",
						RETRY_DISCOVER - (SEC_TIMER - last_discover));
					node_discover = 1;
				}
				else if (! error)
				{
					loop++;
					msgSent = 1;
            }
			}
		}

		// Let the library advance its state
      tickres = zb_tick();
	   if (tickres == ZB_MESSAGE)
	   {
			printf("Unknown message arrived\n");
			xb_hexdump( ZB_LAST_MSG_DATA(), ZB_LAST_MSG_DATALEN() );
		}
      else if (tickres==ZB_RADIO_STAT)
		{
         printf("Radio status change: %s\n", ZB_LAST_STATUS()==ZB_JOINED ?
				"joined" : "unjoined");
		}
      else if (tickres == ZB_MSG_STAT)
		{
			printf("Transmission Status received: %d\n",ZB_XMIT_STATUS());
		}
	}
} //main()


/*--------------------------------------------------------------------------

	recvString

	Endpoint 2 input function 7: receive a string. This function is called by
	the XBee_API.lib library's message interpreter. The interpreter looks through
	the endpoint database to find a matching endpoint and cluster ID to those
	in the message. If a match is found and there is a function defined that
	function is called with the message data and its length.

	PARAMETER1:     RF payload (the string).

	PARAMETER2:     Number of bytes in the payload.

	RETURN VALUE:  none.

--------------------------------------------------------------------------*/
void recvString(char *data, int len)
{
	// if the string ends with an "R", it's a response to our original message
	if ( data[len-2] == 'R' )
	{
		printf( "Got Response: %s\n", data);
		msgSent = 0;
	}
	else
	{
		printf( "Received Message: %s\n", data);
		// append "R" to the string and send it back as a response
		data[len-1] = 'R';
		data[len] = 0;
		zb_reply( data, len+1);
	}
}

/*--------------------------------------------------------------------------

	sendString

	Endpoint 2 Output function 7: send a string.  This function
	always sets the source endpoint, destination endpoint and cluster ID
	using the macros ENDPOINT and CLUSTER_ID.

	PARAMETER1:		NODE ID of destination.

	PARAMETER2:		String to send to destination.

	RETURN VALUE:	1 if node wasn't found in node list; 0 if message sent.
						<0 error trying to send

--------------------------------------------------------------------------*/
int sendString(char *who, char *data)
{
	int index;
	int error;
	zb_sendAddress_t sendAddr;
	_zb_NodeData_t *node;

	index = 0;
	while ( node=GET_NODE_DATA(index) )
	{
		if ( !strcmp(node->remoteID,who) )
		{
			break;
		}
      ++index;
	}
	if ( node )
	{
   	zb_MakeEndpointClusterAddr( index, ENDPOINT, ENDPOINT, CLUSTER_ID,
   		&sendAddr);
		sendAddr.msg = data;
		sendAddr.msglen = strlen( data)+1;
		if ( (error = zb_send( &sendAddr)) )
		{
	      printf( "Error %d trying to send.\n", error);
	      return error;
		}
		else
		{
	      printf( "%s : ", data);
	      return 0;
	   }
	}
   else
   {
      printf( "Can't find [%s] in node table.\n", who);
   	return 1;
   }
} //sendString()

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区不卡老阿姨| 久久综合九色综合欧美98| 开心九九激情九九欧美日韩精美视频电影| 国产欧美一二三区| 久久久久久久久久久99999| 日韩女同互慰一区二区| 日韩视频免费观看高清在线视频| 欧美色中文字幕| 精品视频一区 二区 三区| 在线免费视频一区二区| 色综合 综合色| 欧美私模裸体表演在线观看| 在线播放欧美女士性生活| 777久久久精品| 久久蜜桃av一区二区天堂| 国产日韩三级在线| 亚洲男人天堂一区| 国产乱一区二区| 精油按摩中文字幕久久| 日韩电影在线一区| 日本中文字幕一区二区视频| 免费人成黄页网站在线一区二区 | 亚洲自拍偷拍九九九| 亚洲成在人线免费| 久久精品国产久精国产| 国产精品1区二区.| 色综合网站在线| 日韩一区二区三区高清免费看看| 欧美成人女星排名| 国产精品电影一区二区三区| 亚洲小说欧美激情另类| 精品中文av资源站在线观看| 丁香婷婷综合激情五月色| 亚洲人精品一区| 国产精品久久久久9999吃药| wwwwww.欧美系列| 国产精品灌醉下药二区| 亚洲一线二线三线视频| 久久精品国产99国产精品| 国产成人在线网站| 欧美日韩国产综合一区二区三区| 91精品国产综合久久久久久| 国产性色一区二区| 五月婷婷久久综合| 成人免费视频免费观看| 欧美日本不卡视频| 国产精品久久久久aaaa樱花| 日精品一区二区| 91玉足脚交白嫩脚丫在线播放| 欧美日韩一区在线观看| 欧美高清在线一区二区| 琪琪一区二区三区| 国产一区二区伦理| 麻豆传媒一区二区三区| 99久久夜色精品国产网站| 91精品在线观看入口| 国产精品国产馆在线真实露脸| 日韩激情在线观看| 欧美亚洲国产一区二区三区| 欧美激情一区二区三区四区| 免费美女久久99| 欧美日韩第一区日日骚| 亚洲精品伦理在线| 高清日韩电视剧大全免费| 欧美变态tickling挠脚心| 亚洲mv在线观看| 91官网在线观看| 成人欧美一区二区三区视频网页| 精品黑人一区二区三区久久| 亚洲国产精品久久久久秋霞影院 | 中文字幕一区二区三区不卡| 免费人成精品欧美精品| 欧美日本一区二区三区四区| 亚洲婷婷国产精品电影人久久| 国产精品亚洲第一区在线暖暖韩国| 欧美电影在线免费观看| 亚洲成a人v欧美综合天堂下载| 在线免费观看日韩欧美| 一区二区三区在线免费观看| 91亚洲精品久久久蜜桃| 亚洲视频小说图片| 色屁屁一区二区| 亚洲一区二区三区精品在线| 在线免费观看一区| 日韩三级伦理片妻子的秘密按摩| 久久伊99综合婷婷久久伊| 卡一卡二国产精品 | 亚洲一区二区三区四区在线| 国产+成+人+亚洲欧洲自线| 久久久精品黄色| 高潮精品一区videoshd| 国产视频一区不卡| 99久久精品99国产精品| 一区二区三区在线视频观看58| 在线观看www91| 青娱乐精品视频在线| xfplay精品久久| av网站一区二区三区| 一级中文字幕一区二区| 欧美精品丝袜中出| 国产精品夜夜嗨| 亚洲精品一卡二卡| 国产精品一区二区男女羞羞无遮挡| 亚洲免费在线电影| 91九色最新地址| 午夜精品福利一区二区蜜股av | 亚洲精品一卡二卡| 欧美一级二级三级乱码| 国产成人免费av在线| 亚洲一区二区三区精品在线| 日韩一区二区视频在线观看| 国产精品自拍三区| 亚洲午夜视频在线| 久久亚洲影视婷婷| 欧美无砖砖区免费| 国产在线看一区| 一区二区三区高清不卡| 欧美xxxxxxxxx| 91成人网在线| 国产精品一品二品| 午夜精品福利一区二区三区av| 久久免费电影网| 欧美日韩国产一级片| 成人黄色小视频| 韩国一区二区视频| 欧美韩国日本不卡| 777久久久精品| av午夜精品一区二区三区| 免费成人你懂的| 一区二区三区欧美久久| 久久久久97国产精华液好用吗| 91啪亚洲精品| 国产精品一品视频| 蜜臀精品一区二区三区在线观看 | 欧美日韩激情在线| 99热这里都是精品| 激情成人综合网| 日韩不卡手机在线v区| 一区二区三区在线播放| 中文成人综合网| 国产午夜亚洲精品不卡 | 国产一区久久久| 在线观看网站黄不卡| 国产一级精品在线| 麻豆精品一二三| 五月天激情小说综合| 亚洲人成网站精品片在线观看| 2021中文字幕一区亚洲| 日韩一卡二卡三卡国产欧美| 欧美日韩一级片在线观看| 91社区在线播放| 91丨porny丨蝌蚪视频| jlzzjlzz亚洲日本少妇| 波多野结衣中文一区| 顶级嫩模精品视频在线看| 国产不卡视频一区二区三区| 狠狠狠色丁香婷婷综合久久五月| 蜜桃在线一区二区三区| 日本欧洲一区二区| 麻豆精品视频在线观看| 国产综合色产在线精品| 国产精品中文字幕一区二区三区| 美腿丝袜一区二区三区| 美腿丝袜亚洲综合| 国产一区二区三区在线观看免费 | 欧美一卡二卡三卡| 在线视频观看一区| 在线观看成人小视频| 一本大道久久a久久精品综合| 成人av资源网站| 99久久99久久综合| 欧美在线影院一区二区| 欧美精品vⅰdeose4hd| 日韩欧美的一区二区| 日本一区二区免费在线| 亚洲天堂a在线| 午夜日韩在线观看| 久久国产精品露脸对白| 国产乱子轮精品视频| 成人精品视频一区二区三区| 99久久久国产精品| 91.麻豆视频| 中文在线资源观看网站视频免费不卡 | 欧美一级二级三级乱码| 亚洲欧美经典视频| 亚洲激情综合网| 蜜臀av性久久久久蜜臀aⅴ四虎| 免费久久精品视频| 顶级嫩模精品视频在线看| 欧美性大战久久久久久久蜜臀| 制服丝袜在线91| 欧美国产日本韩| 香蕉久久夜色精品国产使用方法| 久久99精品国产麻豆婷婷洗澡| 粉嫩高潮美女一区二区三区| 欧美性淫爽ww久久久久无| 国产日韩欧美不卡在线| 视频一区二区中文字幕| 成人av动漫在线| 日韩视频免费观看高清完整版在线观看 |