蓝牙技术规范

蓝牙技术规范和工具

    ====================================================================================
    蓝牙协议栈学习笔记(序)
        https://blog.youkuaiyun.com/ylangeia/article/details/87100460

    蓝牙Profile的概念和常见种类
        https://blog.youkuaiyun.com/sam0535/article/details/82967766

    蓝牙BLE: GATT Profile 简介(GATT 与 GAP)
        https://blog.youkuaiyun.com/weixin_30501857/article/details/101869241?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.compare&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.compare
    
    蓝牙SDP协议概述
        https://www.cnblogs.com/libs-liu/p/9498952.html
====================================================================================

l2cap gatt

 

 

 

bluez源码编译:

bluez-5.52$ ./configure --prefix=/tmp/bluez5 --enable-deprecated --enable-android --enable-mesh --enable-testing --enable-health --enable-btpclient

wireshark过滤:

    bthci_evt.bd_addr==22:79:30:f7:1c:dc
btmgmt:
    le on
    discov yes
    add-adv / rm-adv 1-5
    advinfo
hcitool:
    scan
    lescan
    ...
hciconfig:
    piscan
    leadv

命令:

brcm_patchram_plus - 初始化BT芯片

hci*:
    hciattach - HCI UART driver initialization utility
    hciconfig - HCI device configuration utility
        piscan
        leadv
    hcitool - HCI Tool ver 5.xx
    hcidump - HCI sniffer - Bluetooth packet analyzer ver 5.xx

bt*:
    btmon - Bluetooth monitor
    btattach - Bluetooth serial utility
        Usage:
            btattach [options]
        options:
            -B, --bredr <device>   Attach Primary controller
            -A, --amp <device>     Attach AMP controller
            -P, --protocol <proto> Specify protocol type
            -S, --speed <baudrate> Specify which baudrate to use
            -N, --noflowctl        Disable flow control
            -h, --help             Show help options
    btmgmt - 蓝牙控制器管理工具
        le on
        discov yes
        add-adv / rm-adv 1-5
        advinfo
blue*:
    bluemoon  -  Bluemoon configuration utility        
    bluetoothctl - 搜索、连接、配对、读写、使能notify蓝牙低功耗设备    
    bluetoothd  - 蓝牙核心服务   /usr/libexec/bluetooth/bluetoothd --compat -f /app/etc/bluetooth/main.conf &
    bluetooth-sendto   -
    bluetooth-wizard   -

hci

=========================================================================
hci command : ogf(6b)  ocf(10b) len

p1:
00000001 00000011 00001100 00000000
    00000001 : 0x01 -> command
        
    0000110000000011 : 000011(ogf=0x03) , 0000000011(ocf=0x03)

    00000000 : len=0

00000100 00001110 00000100 00000001 00000011 00001100 00000000
    00000100 : 0x04 -> event

    00001110 : 0xE0 -> event code

    00000100 : 0x04 -> parameter total length(以Byte为单位)
    根据Core手册查询:
    code=0xE0 Command Complete event
        Num_HCI_Command_Packets : 00000001
        Command_Opcode :    0000110000000011 = 000011(ogf=0x03) , 0000000011(ocf=0x03)
        Return_Parameter(s): : 00000000   
p2:
00000001 00000101 00010000 00000000
    00000001 : 0x01 -> command
        
    0001000000000101 : 000100(ogf=0x04) , 0000000101(ocf=0x05)

    00000000 : len=0

=========================================================================
                    LINK CONTROL COMMANDS(ogf=0x01)
=========================================================================
    参考Core5.0 Vol2-PartE-7-7.1
    1. Inquire
        hcitool inq
        hcitool cmd 0x01 0x0001 0x33 0x8b 0x9e 0x08 0x00
            < HCI Command: Inq.. (0x01|0x0001) plen 5  #1 [hci0] 2020-06-03 13:58:44.880247
                    Access code: 0x9e8b33 (General Inquiry)
                    Length: 10.24s (0x08)
                    Num responses: 0
            > HCI Event: Command Status (0x0f) plen 4  #2 [hci0] 2020-06-03 13:58:44.882925
                  Inquiry (0x01|0x0001) ncmd 1
                    Status: Success (0x00)

    2. Inquiry Cancel
        hcitool cmd 0x01 0x0002
            < HCI Command: I.. (0x01|0x0002) plen 0  #465 [hci0] 2020-06-03 14:12:51.074086
            > HCI Event: Command Co.. (0x0e) plen 4  #466 [hci0] 2020-06-03 14:12:51.077576
                  Inquiry Cancel (0x01|0x0002) ncmd 1
                    Status: Success (0x00)

    3. Start/Exit periodic inquiry
        hcitool spinq
        hcitool cmd 0x01 0x0003 0x10 0x0a 0x33 0x8b 0x9e 0x08 0x00
            < HCI Command: P.. (0x01|0x0003) plen 9  #266 [hci0] 2020-06-03 14:10:02.459051
                    Max period: 20.48s (0x10)
                    Min period: 12.80s (0x0a)
                    Access code: 0x9e8b33 (General Inquiry)
                    Length: 10.24s (0x08)
                    Num responses: 0
                hcitool epinq
        hcitool cmd 0x01 0x0004
            < HCI Command: E.. (0x01|0x0004) plen 0  #516 [hci0] 2020-06-03 14:15:41.174729
            > HCI Event: Command Co.. (0x0e) plen 4  #517 [hci0] 2020-06-03 14:15:41.178144
                  Exit Periodic Inquiry Mode (0x01|0x0004) ncmd 1
                    Status: Success (0x00)

    4. Connection
        hcitool cc/dc  01:02:03:04:05:06
        hcitool cmd 0x01 0x0005 0x06 0x05 0x04 0x03 0x02 0x01 0x18 0xcc 0x02 0x00 0x00 0x00 0x01
        hcitool cmd 0x01 0x0006 0x00 0x12(handle) 0x13(reason)
        hcitool cmd 0x01 0x0008 0x06 0x05 0x04 0x03 0x02 0x01    (Create Connection Cancel Command)
        hcitool cmd 0x01 0x0009 0x06 0x05 0x04 0x03 0x02 0x01 0x00/0x01(master/slave)     (Accept Connection Request Command)
        hcitool cmd 0x01 0x000A 0x06 0x05 0x04 0x03 0x02 0x01 0x0D-0x0F(reason)     (Reject Connection Request Command)
            < HCI Command: Cr.. (0x01|0x0005) plen 13  #1 [hci0] 2020-06-03 14:18:39.243445
                    Address: 01:02:03:04:05:06 (OUI 01-02-03)
                    Packet type: 0xcc18
                      DM1 may be used
                      DH1 may be used
                      DM3 may be used
                      DH3 may be used
                      DM5 may be used
                      DH5 may be used
                    Page scan repetition mode: R2 (0x02)
                    Page scan mode: Mandatory (0x00)
                    Clock offset: 0x0000
                    Role switch: Allow slave (0x01)
            > HCI Event: Command Status (0x0f) plen 4  #2 [hci0] 2020-06-03 14:18:39.247349
                  Create Connection (0x01|0x0005) ncmd 1
                    Status: Success (0x00)
            > HCI Event: Connect Com.. (0x03) plen 11  #5 [hci0] 2020-06-03 14:18:44.371686
                    Status: Page Timeout (0x04)
                    Handle: 12
                    Address: 01:02:03:04:05:06 (OUI 01-02-03)
                    Link type: ACL (0x01)
                    Encryption: Disabled (0x00)
            @ Connect Failed: 01:02:03:04:05:06 (0) status 0x04

    5. Features(connected remote devices)
        Read Remote Supported Features Command
            hcitool cmd 0x01 0x001B 0x00 0x12(handle)
            hcitool info 01:02:03:04:05:06
            hcitool scan
        Read Remote Extended Features Command
            hcitool cmd 0x01 0x001C 0x00 0x12(handle) 0x00-0xFF(page number)
            hcitool info 01:02:03:04:05:06
        Read Remote Version Information Command
            hcitool cmd 0x01 0x001D 0x00 0x12(handle)
            hcitool scan
            hcitool info 01:02:03:04:05:06
            hcitool leinfo 01:02:03:04:05:06
    6. Read LMP Handle Command
        hcitool cmd 0x01 0x0020 0x00 0x12(handle)
        hcisecfilter

    
=========================================================================
                    LINK POLICY COMMANDS(ogf=0x02)
=========================================================================
    参考Core5.0 Vol2-PartE-7-7.2
    1. Switch Role Command
        hcitool cmd 0x02 0x000B 0x06 0x05 0x04 0x03 0x02 0x01 0x00/0x01(master/slave)
        hcitool sr 01:02:03:04:05:06 0/1
    2. Read Link Policy Settings Command
        hcitool cmd 0x02 0x000C 0x00 0x12(handle)
        hcitool lp 01:02:03:04:05:06
    3. Write Link Policy Settings Command
        hcitool cmd 0x02 0x000D 0x00 0x12(handle) 0x0000/0x0001/0x0002/0x0004
        hcitool lp 01:02:03:04:05:06 NONE/RSWITCH/HOLD/SNIFF/PARK(0x0008)
    
=========================================================================
                    CONTROLLER & BASEBAND COMMANDS(ogf=0x03)
=========================================================================
    参考Core5.0 Vol2-PartE-7-7.3

=========================================================================
                    INFORMATIONAL PARAMETERS(ogf=0x04)
=========================================================================
    参考Core5.0 Vol2-PartE-7-7.4

=========================================================================
                    STATUS PARAMETERS(ogf=0x05)
=========================================================================
    参考Core5.0 Vol2-PartE-7-7.5

=========================================================================
                    TESTING COMMANDS(ogf=0x06)
=========================================================================
    参考Core5.0 Vol2-PartE-7-7.6

=========================================================================
                    EVENTS(ogf=0x07)
=========================================================================
    参考Core5.0 Vol2-PartE-7-7.7

=========================================================================
                    LE CONTROLLER COMMANDS(ogf=0x08)
=========================================================================
    参考Core5.0 Vol2-PartE-7-7.8

 

蓝牙经典连接

 

 

蓝牙ble连接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值