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

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

?? ubcsp.c

?? BlueZ源碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
 *
 *  BlueZ - Bluetooth protocol stack for Linux
 *
 *  Copyright (C) 2000-2005  CSR Ltd.
 *
 *
 *  Permission is hereby granted, free of charge, to any person obtaining
 *  a copy of this software and associated documentation files (the
 *  "Software"), to deal in the Software without restriction, including
 *  without limitation the rights to use, copy, modify, merge, publish,
 *  distribute, sublicense, and/or sell copies of the Software, and to
 *  permit persons to whom the Software is furnished to do so, subject to
 *  the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included
 *  in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 *  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 *  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/**                                                                         **/
/** ubcsp,c                                                                 **/
/**                                                                         **/
/** MicroBCSP - a very low cost implementation of the BCSP protocol         **/
/**                                                                         **/
/*****************************************************************************/

#include "ubcsp.h"

#if SHOW_PACKET_ERRORS || SHOW_LE_STATES
#include <stdio.h>
#include <windows.h>
#endif

static uint16 ubcsp_calc_crc (uint8 ch, uint16 crc);
static uint16 ubcsp_crc_reverse (uint16);

/*****************************************************************************/
/**                                                                         **/
/** Constant Data - ROM                                                     **/
/**                                                                         **/
/*****************************************************************************/

/* This is the storage for the link establishment messages */

static const uint8 ubcsp_le_buffer[4][4] =
	{
		{ 0xDA, 0xDC, 0xED, 0xED },
		{ 0xAC, 0xAF, 0xEF, 0xEE },
		{ 0xAD, 0xEF, 0xAC, 0xED },
		{ 0xDE, 0xAD, 0xD0, 0xD0 },
	};

/* These are the link establishment headers */
/* The two version are for the CRC and non-CRC varients */

#if UBCSP_CRC
static const uint8 ubcsp_send_le_header[4] = 
	{
		0x40, 0x41, 0x00, 0x7E
	};
#else
static const uint8 ubcsp_send_le_header[4] = 
	{
		0x00, 0x41, 0x00, 0xBE
	};
#endif

/*****************************************************************************/
/**                                                                         **/
/** Static Data - RAM                                                       **/
/**                                                                         **/
/*****************************************************************************/

/* This is the storage for all state data for ubcsp */

static struct ubcsp_configuration ubcsp_config;

/* This is the ACK packet header - this will be overwritten when
   we create an ack packet */

static uint8 ubcsp_send_ack_header[4] = 
	{
		0x00, 0x00, 0x00, 0x00
	};

/* This is the deslip lookup table */

static const uint8 ubcsp_deslip[2] =
	{
		SLIP_FRAME, SLIP_ESCAPE,
	};

/* This is a state machine table for link establishment */

static uint8 next_le_packet[16] =
	{
		ubcsp_le_sync,			// uninit
		ubcsp_le_conf,			// init
		ubcsp_le_none,			// active
		ubcsp_le_none,
		ubcsp_le_sync_resp,		// sync_resp
		ubcsp_le_sync_resp,
		ubcsp_le_none,
		ubcsp_le_none,
		ubcsp_le_none,			// conf_resp
		ubcsp_le_conf_resp,
		ubcsp_le_conf_resp,
		ubcsp_le_none,
	};

/* This is the storage required for building send and crc data */

static uint8 ubcsp_send_header[4];
static uint8 ubcsp_send_crc[2];

/* This is where the receive header is stored before the payload arrives */

static uint8 ubcsp_receive_header[4];

/*****************************************************************************/
/**                                                                         **/
/** Code - ROM or RAM                                                       **/
/**                                                                         **/
/*****************************************************************************/

/*****************************************************************************/
/**                                                                         **/
/** ubcsp_initialize                                                        **/
/**                                                                         **/
/** This initializes the state of the ubcsp engine to a known values        **/
/**                                                                         **/
/*****************************************************************************/

void ubcsp_initialize (void)
{
	ubcsp_config.ack_number = 0;
	ubcsp_config.sequence_number = 0;
	ubcsp_config.send_ptr = 0;
	ubcsp_config.send_size = 0;
	ubcsp_config.receive_index = -4;

	ubcsp_config.delay = 0;

#if SHOW_LE_STATES
	printf ("Hello Link Uninitialized\n");
#endif

	ubcsp_config.link_establishment_state = ubcsp_le_uninitialized;
	ubcsp_config.link_establishment_packet = ubcsp_le_sync;
}

/*****************************************************************************/
/**                                                                         **/
/** ubcsp_send_packet                                                       **/
/**                                                                         **/
/** This sends a packet structure for sending to the ubcsp engine           **/
/** This can only be called when the activity indication from ubcsp_poll    **/
/** indicates that a packet can be sent with UBCSP_PACKET_SENT              **/
/**                                                                         **/
/*****************************************************************************/

void ubcsp_send_packet (struct ubcsp_packet *send_packet)
{
	/* Initialize the send data to the packet we want to send */

	ubcsp_config.send_packet = send_packet;

	/* we cannot send the packet at the moment
	   when we can at the moment, just set things to 0 */

	ubcsp_config.send_size = 0;
	ubcsp_config.send_ptr = 0;
}

/*****************************************************************************/
/**                                                                         **/
/** ubcsp_receive_packet                                                    **/
/**                                                                         **/
/** This sends a packet structure for receiving to the ubcsp engine         **/
/** This can only be called when the activity indication from ubcsp_poll    **/
/** indicates that a packet can be sent with UBCSP_PACKET_RECEIVED          **/
/**                                                                         **/
/*****************************************************************************/

void ubcsp_receive_packet (struct ubcsp_packet *receive_packet)
{
	/* Initialize the receive data to the packet we want to receive */

	ubcsp_config.receive_packet = receive_packet;

	/* setup to receive the header first */

	ubcsp_config.receive_index = -4;
}

/*****************************************************************************/
/**                                                                         **/
/** ubcsp_calc_crc                                                          **/
/**                                                                         **/
/** Takes the next 8 bit value ch, and updates the crc with this value      **/
/**                                                                         **/
/*****************************************************************************/


#ifdef UBCSP_CRC

static uint16 ubcsp_calc_crc (uint8 ch, uint16 crc)
{
	/* Calculate the CRC using the above 16 entry lookup table */

	static const uint16 crc_table[] =
		{
			0x0000, 0x1081, 0x2102, 0x3183,
			0x4204, 0x5285, 0x6306, 0x7387,
			0x8408, 0x9489, 0xa50a, 0xb58b,
			0xc60c, 0xd68d, 0xe70e, 0xf78f
		};

	/* Do this four bits at a time - more code, less space */

    crc = (crc >> 4) ^ crc_table[(crc ^ ch) & 0x000f];
    crc = (crc >> 4) ^ crc_table[(crc ^ (ch >> 4)) & 0x000f];

	return crc;
}

/*****************************************************************************/
/**                                                                         **/
/** ubcsp_crc_reverse                                                       **/
/**                                                                         **/
/** Reserves the bits in crc and returns the new value                      **/
/**                                                                         **/
/*****************************************************************************/

static uint16 ubcsp_crc_reverse (uint16 crc)
{
	int32
		b,
		rev;

	/* Reserse the bits to compute the actual CRC value */

	for (b = 0, rev=0; b < 16; b++)
	{
		rev = rev << 1;
		rev |= (crc & 1);
		crc = crc >> 1;
	}

	return rev;
}

#endif

/*****************************************************************************/
/**                                                                         **/
/** ubcsp_put_slip_uart                                                     **/
/**                                                                         **/
/** Outputs a single octet to the uart                                      **/
/** If the octet needs to be escaped, then output the escape value          **/
/** and then store the second octet to be output later                      **/
/**                                                                         **/
/*****************************************************************************/

static void ubcsp_put_slip_uart (uint8 ch)
{
	/* output a single UART octet */

	/* If it needs to be escaped, then output the escape octet
	   and set the send_slip_escape so that the next time we
	   output the second octet for the escape correctly.
	   This is done right at the top of ubcsp_poll */

	if (ch == SLIP_FRAME)
	{
		put_uart (SLIP_ESCAPE);
		ubcsp_config.send_slip_escape = SLIP_ESCAPE_FRAME;
	}
	else if (ch == SLIP_ESCAPE)
	{
		put_uart (SLIP_ESCAPE);
		ubcsp_config.send_slip_escape = SLIP_ESCAPE_ESCAPE;
	}
	else
	{
		/* Not escaped, so just output octet */

		put_uart (ch);
	}
}

/*****************************************************************************/
/**                                                                         **/
/** ubcsp_which_le_payload                                                  **/
/**                                                                         **/
/** Check the payload of this packet, and determine which of the four       **/
/** link establishment packets this was.                                    **/
/** Can return 5 if it is not a valid link establishment packet             **/
/**                                                                         **/
/*****************************************************************************/

static uint32 ubcsp_which_le_payload (const uint8 *payload)
{
	static int32
		octet,
		loop;

	/* Search through the various link establishment payloads to find
	   which one we have received */

	for (loop = 0; loop < 4; loop ++)
	{
		for (octet = 0; octet < 4; octet ++)
		{
			if (payload[octet] != ubcsp_le_buffer[loop][octet])
			{
				/* Bad match, just to loop again */
				goto bad_match_loop;
			}
		}

		/* All the octets matched, return the value */

		return loop;

		/* Jumps out of octet loop if we got a bad match */
bad_match_loop:
		{}
	}

	/* Non of the link establishment payloads matched - return invalid value */

	return 5;
}

/*****************************************************************************/
/**                                                                         **/
/** ubcsp_recevied_packet                                                   **/
/**                                                                         **/
/** This function is called when we have a SLIP END octet and a full        **/
/** packet header and possibly data in the receive packet                   **/
/**                                                                         **/
/*****************************************************************************/

static uint8 ubcsp_recevied_packet (void)
{
	static uint8
		receive_crc,
		receive_seq,
		receive_ack,
		activity;

#if UBCSP_CRC
	static int32
		loop;

	static uint16
		crc;
#endif

	static uint16
		length;

	/* Keep track of what activity this received packet will cause */

	activity = 0;

	/*** Do all error checks that we can ***/

	/* First check the header checksum */

	if (((ubcsp_receive_header[0] + ubcsp_receive_header[1] + ubcsp_receive_header[2] + ubcsp_receive_header[3]) & 0xff) != 0xff)
	{
		/* Header Checksum Error */

#if SHOW_PACKET_ERRORS
		printf ("\n######################## Header Checksum Error %02X %02X %02X %02X\n",
			ubcsp_receive_header[0],
			ubcsp_receive_header[1],
			ubcsp_receive_header[2],
			ubcsp_receive_header[3]);
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲中文日韩久久av乱码| 亚洲国产欧美在线人成| 色狠狠综合天天综合综合| 肉肉av福利一精品导航| 国产欧美日本一区二区三区| 欧美三级电影在线看| 成人美女在线观看| 日韩福利电影在线观看| 一区二区三区免费| 国产精品色婷婷久久58| 日韩欧美国产三级| 欧美日韩国产欧美日美国产精品| 成人黄色综合网站| 国产综合色精品一区二区三区| 亚洲国产精品久久久久秋霞影院 | 99久久99久久免费精品蜜臀| 奇米亚洲午夜久久精品| 一区二区日韩av| 国产精品成人一区二区艾草 | 成人午夜激情片| 韩国三级在线一区| 蜜芽一区二区三区| 亚洲电影一区二区| 亚洲色图在线播放| 国产精品美女久久久久久久久| 日韩欧美色电影| 欧美一区二区在线免费观看| 精品视频一区二区不卡| 色吊一区二区三区| 972aa.com艺术欧美| 成人精品一区二区三区四区| 国产成人精品综合在线观看 | 午夜精品福利一区二区三区av| 日韩美女精品在线| 国产精品色哟哟| 国产精品夫妻自拍| 中文字幕在线播放不卡一区| 国产无一区二区| 国产亚洲美州欧州综合国 | 亚洲综合久久久久| 一区二区高清视频在线观看| 亚洲激情综合网| 亚洲人成网站精品片在线观看| 国产精品午夜在线观看| 中文字幕不卡在线观看| 中文字幕不卡在线播放| 亚洲视频一区在线观看| 亚洲自拍偷拍麻豆| 午夜精品久久久久久久久久久| 午夜电影久久久| 日韩成人免费在线| 精品一区二区在线视频| 精品一区二区在线免费观看| 国产a区久久久| 91麻豆精品秘密| 在线视频一区二区三区| 欧美男男青年gay1069videost| 91精品久久久久久蜜臀| 精品国产亚洲在线| 国产精品国产自产拍在线| 一二三四社区欧美黄| 亚洲va欧美va人人爽午夜| 美女mm1313爽爽久久久蜜臀| 国产精品18久久久久久久久久久久| 国产福利不卡视频| 91免费版pro下载短视频| 欧美视频自拍偷拍| 欧美一区二区在线看| 欧美—级在线免费片| 亚洲精品视频自拍| 免费观看在线综合| 国产成人鲁色资源国产91色综| 色婷婷国产精品| 日韩美女一区二区三区| 亚洲国产电影在线观看| 亚洲一级不卡视频| 久久不见久久见免费视频1 | 91精品欧美福利在线观看| 久久青草欧美一区二区三区| 亚洲日本在线视频观看| 午夜视频一区在线观看| 国产精品一区2区| 在线日韩一区二区| 久久久久97国产精华液好用吗| 亚洲黄色录像片| 久久99精品久久久久久动态图| 国产伦精品一区二区三区免费| 色先锋资源久久综合| 欧美成人性战久久| 夜夜嗨av一区二区三区| 国产真实乱对白精彩久久| 在线视频国产一区| 欧美韩国日本综合| 免费观看日韩av| 91成人看片片| 国产亚洲短视频| 全国精品久久少妇| 色播五月激情综合网| 中文字幕不卡在线| 久久99在线观看| 欧美日韩黄色一区二区| 国产精品色在线| 国产一区二区在线视频| 欧美喷水一区二区| 伊人开心综合网| 成人a免费在线看| 日韩欧美国产麻豆| 婷婷一区二区三区| 在线观看视频一区二区| 国产精品久久久久久一区二区三区| 精品在线亚洲视频| 欧美日韩一二三| 亚洲乱码日产精品bd| 成人一区二区三区视频在线观看| 欧美一级欧美三级在线观看| 亚洲第一电影网| 色94色欧美sute亚洲线路一久| 国产精品色在线| 国产超碰在线一区| 久久理论电影网| 蜜桃视频在线观看一区| 在线电影一区二区三区| 亚洲一级在线观看| 欧美三级三级三级| 亚洲综合自拍偷拍| 色狠狠色噜噜噜综合网| 亚洲另类春色国产| 一本一道波多野结衣一区二区| 国产精品色婷婷久久58| 成人午夜激情在线| 国产精品欧美久久久久一区二区| 国产精品羞羞答答xxdd| 久久伊99综合婷婷久久伊| 激情国产一区二区| 亚洲精品一区二区三区福利 | 国产精品美女久久久久久| 国产精品18久久久久久久网站| 久久网站最新地址| 国产精品一二三| 国产精品人妖ts系列视频| av亚洲产国偷v产偷v自拍| 中文字幕一区二区三区四区| 成人免费va视频| 伊人性伊人情综合网| 欧美日韩三级一区| 日本亚洲三级在线| 欧美videos中文字幕| 国产一区二三区好的| 国产精品少妇自拍| 91极品美女在线| 同产精品九九九| 精品处破学生在线二十三| 国产一区二区三区在线看麻豆| 国产三区在线成人av| www.欧美精品一二区| 一区二区三区欧美在线观看| 欧美日韩成人在线一区| 麻豆91在线播放| 国产香蕉久久精品综合网| 99国产精品视频免费观看| 亚洲综合一区二区三区| 日韩一级高清毛片| 国产精品一区二区久久精品爱涩| 亚洲欧洲无码一区二区三区| 欧美三区在线视频| 久久机这里只有精品| 国产精品网友自拍| 在线视频欧美精品| 国产专区欧美精品| 亚洲欧美日韩国产手机在线| 9191国产精品| 国产 欧美在线| 亚洲一区二区三区在线看| 欧美电影精品一区二区| 97久久精品人人做人人爽50路| 亚洲成人动漫一区| 国产午夜精品一区二区三区视频 | 免费观看一级欧美片| 国产日韩欧美在线一区| 色婷婷国产精品| 国产精品一区二区在线看| 亚洲一区在线视频| 久久九九久久九九| 欧美日免费三级在线| 国产精品一区二区在线观看不卡 | 8x8x8国产精品| 粉嫩av一区二区三区在线播放 | 天天综合日日夜夜精品| 日本一区二区三区免费乱视频| 欧美影院午夜播放| 国产福利一区二区三区视频| 三级在线观看一区二区| 亚洲三级免费电影| 久久久久一区二区三区四区| 欧美日韩国产免费一区二区| 成人av免费观看| 九九**精品视频免费播放| 国产精品久久久久一区| 精品免费一区二区三区| 欧美伊人精品成人久久综合97 |