ʵսLinux Bluetooth±à³Ì£¨ËÄ£© L2CAP²ã±à³Ì
£¨L2CAPÐÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPÐÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼Á¬½Ó¿ØÖƺÍÊÊÅäÐÒé (L2CAP) ΪÉϲãÐÒéÌṩÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àÐÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãÐÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Êý¾Ý°ü¡£
¡¡¡¡L2CAP »ùÓÚ Í¨µÀ(channel) µÄ¸ÅÄî¡£ ͨµÀ (Channel) ÊÇλÓÚ»ù´ø (baseband) Á¬½ÓÖ®ÉϵÄÂß¼Á¬½Ó¡£Ã¿¸öͨµÀÒÔ¶à¶ÔÒ»µÄ·½Ê½°ó¶¨Ò»¸öµ¥Ò»ÐÒé (single protocol)¡£¶à¸öͨµÀ¿ÉÒÔ°ó¶¨Í¬Ò»¸öÐÒ飬µ«Ò»¸öͨµÀ²»¿ÉÒ԰󶨶à¸öÐÒé¡£ ÿ¸öÔÚͨµÀÀï½ÓÊÕµ½µÄ L2CAP Êý¾Ý°ü±»´«µ½ÏàÓ¦µÄÉϲãÐÒé¡£ ¶à¸öͨµÀ¿É¹²Ïíͬһ¸ö»ù´øÁ¬½Ó¡£
L2CAP´¦ÓÚBluetoothÐÒéÕ»µÄλÖÃÈçÏ£º
Ò²¾ÍÊÇ˵£¬ËùÓÐL2CAPÊý¾Ý¾ùͨ¹ýHCI´«Êäµ½Remote Device¡£ÇÒÉϲãÐÒéµÄÊý¾Ý£¬´ó¶¼Ò²Í¨¹ýL2CAPÀ´´«ËÍ¡£
L2CAP¿ÉÒÔ·¢ËÍCommand¡£ÀýÈçÁ¬½Ó£¬¶ÏÁ¬µÈµÈ¡£
ÏÂÃæ¿´CommandÀý×Ó£ºConnection Request:
ÆäÖÐPSM±È½ÏÐèҪעÒ⣬L2CAP ʹÓÃL2CAPÁ¬½ÓÇëÇó£¨Connection Request £©ÃüÁîÖеÄPSM×Ö¶ÎʵÏÖÐÒ鸴Óá£L2CAP¿ÉÒÔ¸´Ó÷¢¸øÉϲãÐÒéµÄÁ¬½ÓÇëÇó£¬ÕâЩÉϲãÐÒé°üÀ¨·þÎñ·¢ÏÖÐÒéSDP£¨PSM = 0x0001£©¡¢RFCOMM£¨PSM = 0x0003£©ºÍµç»°¿ØÖÆ£¨PSM = 0x0005£©µÈ¡£
ProtocolPSMReference
SDP
0x0001
See Bluetooth Service Discovery Protocol (SDP), Bluetooth SIG.
RFCOMM
0x0003
See RFCOMM with TS 07.10, Bluetooth SIG.
TCS-BIN
0x0005
See Bluetooth Telephony Control Specification / TCS Binary, Bluetooth SIG.
TCS-BIN-CORDLESS
0x0007
See Bluetooth Telephony Control Specification / TCS Binary, Bluetooth SIG.
BNEP
0x000F
See Bluetooth Network Encapsulation Protocal, Bluetooth SIG.
HID_Control
0x0011
See Human Interface Device , Bluetooth SIG.
HID_Interrupt
0x0013
See Human Interface Device, Bluetooth SIG.
UPnP
0x0015
See [ESDP] , Bluetooth SIG.
AVCTP
0x0017
See Audio/Video Control Transport Protocol , Bluetooth SIG.
AVDTP
0x0019
See Audio/Video Distribution Transport Protocol , Bluetooth SIG.
AVCTP_Browsing
0x001B
See Audio/Video Remote Control Profile, Bluetooth SIG
UDI_C-Plane
0x001D
See the Unrestricted Digital Information Profile [UDI], Bluetooth SIG
¶þ£ºL
Ïà¹ØÎĵµ£º
½ñÌ칫˾ÓиöͬÊÂŪÁ˸öRed Hat Enterprise 5×°£¬ÏµÍ³×°ºÃºó£¬·¢ÏÖtelnet²»ÄÜÓã¬sshÊÇ¿ÉÒԵġ£¸ãÁ˺þ㬲Ÿø¸ã¶¨£¬½áºÏÒÔǰժϵĹØÓÚÕâ·½ÃæµÄ×ÊÁÏ£¬²Î¿¼ÈçÏ£º
1¡£¸ÅÊöLinuxÌṩ·þÎñÊÇÓÉÔËÐÐÔÚºǫ́µÄÊØ»¤³ÌÐò£¨daemon£©À´Ö´Ðеġ£
ÊØ»¤½ø³ÌµÄ¹¤×÷¾ÍÊÇ´ò¿ª1¸ö¶Ë¿Ú£¨port£©£¬µÈ´ý£¨listen£©½øÈëµÄÁ¬½Ó¡£ÔÚC/SģʽÖУ¬Èç¹ ......
×î½üÒ»¸öÏîÄ¿µÄϵͳÓõÄÊÇSolaris 10£¬ËäÈ»ÒÔÇ°ÓõĶ¼ÊÇ Linuxϵͳ£¬µ«ÊÇLinuxϵͳÖеÄһЩÃüÁîºÍSolarisϵͳÊÇͨÓõģ¬ÎªÁË·½±ãÎÒÏÖÔÚÁгö²¿·Ö£¬ÒÔºó½Ðø¸üС£
¡¡1£© ²é¿´¿ª·Å¶Ë¿Ú
¡¡
¡¡¡¡Linux£º netstat -atn
¡¡
¡¡¡¡Solaris£º netstat -P tcp -f inet -an
¡¡
¡¡¡¡2£© ²é¿´Íø¿¨/ÍøÂç״̬
¡¡
¡¡¡¡ ......
ʲôÊÇ LVM
LVM ÊÇÂß¼Å̾í¹ÜÀí£¨Logical Volume Manager£©µÄ¼ò³Æ£¬ËüÊÇ Linux »·¾³Ï¶ԴÅÅÌ·ÖÇø½øÐйÜÀíµÄÒ»ÖÖ»úÖÆ£¬LVM
Êǽ¨Á¢ÔÚÓ²Å̺ͷÖÇøÖ®ÉϵÄÒ»¸öÂß¼²ã£¬À´ÎªÎļþϵͳÆÁ±Îϲã´ÅÅÌ·ÖÇø²¼¾Ö£¬´Ó¶øÌá¸ß´ÅÅÌ·ÖÇø¹ÜÀíµÄÁé»îÐÔ¡£Í¨¹ý LVM
ϵͳ¹ÜÀíÔ±¿ÉÒÔÇáËɹÜÀí´ÅÅÌ·ÖÇø£¬È磺½«Èô¸É¸ö´ÅÅÌ·ÖÇøÁ¬½ÓΪһ¸öÕû¿éµÄ¾í×é ......
Ç°Ãæ½²ÁËʹÓà ioctl·¢ËÍHCI CommandµÄ·½·¨¡£µ«HCI protocol»¹ÓÐһЩCommand£¬±ÈÈçInquiryµÈ£¬ËûÃÇÔò²»ÐèҪʹÓÃioctlÀ´·¢ËÍ¡£blueZ Ö±½ÓÌṩÁËÖ§³Ö£¬ËäÈ»ËûÃǵÄ×îÖÕ¶¼ÊÇÓÃͬÑù°ì·¨ÊµÏֵġ£
ÔÚÓ¦ÓóÌÐòÖУº
hci_inquiry(dev_id, length, num_rsp, NULL, &info, flags);
ÕâÑùÐèÒª°üº¬blueZ Í·ÎļþÈçÏ£º
#include //BT ......
1. HCI²ãÐÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI) ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈÐÒé ......