mirror of
https://github.com/DrHo1y/orangepi-build.git
synced 2026-10-11 21:06:38 +07:00
First Commit
This commit is contained in:
BIN
external/cache/debs/aptly/aptly_1.4.0+44+g24a0271_amd64.deb
vendored
Normal file
BIN
external/cache/debs/aptly/aptly_1.4.0+44+g24a0271_amd64.deb
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
external/cache/debs/extra/bionic-utils/hostapd_2.9-102~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/bionic-utils/hostapd_2.9-102~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/bionic-utils/hostapd_2.9-102~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/bionic-utils/hostapd_2.9-102~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/bionic-utils/htop_2.2.0-5~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/bionic-utils/htop_2.2.0-5~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/bionic-utils/htop_2.2.0-5~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/bionic-utils/htop_2.2.0-5~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/bionic-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/bionic-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/bionic-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/bionic-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/bionic-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/bionic-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/bionic-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/bionic-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
external/cache/debs/extra/buster-utils/hostapd_2.9-102~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/buster-utils/hostapd_2.9-102~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/buster-utils/htop_2.2.0-5~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/buster-utils/htop_2.2.0-5~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/buster-utils/htop_2.2.0-5~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/buster-utils/htop_2.2.0-5~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/buster-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/buster-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/buster-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/buster-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/buster-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/buster-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-desktop/libcedrus1-dev_1.0.1~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-desktop/libcedrus1-dev_1.0.1~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-desktop/libcedrus1-dev_1.0.1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-desktop/libcedrus1-dev_1.0.1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-desktop/libcedrus1_1.0.1~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-desktop/libcedrus1_1.0.1~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-desktop/libcedrus1_1.0.1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-desktop/libcedrus1_1.0.1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-desktop/libump-dev_3.0-0sunxi1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-desktop/libump-dev_3.0-0sunxi1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-desktop/libump_3.0-0sunxi1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-desktop/libump_3.0-0sunxi1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
external/cache/debs/extra/focal-desktop/xserver-xorg-video-fbturbo_0.4.4~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-desktop/xserver-xorg-video-fbturbo_0.4.4~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-desktop/xserver-xorg-video-fbturbo_0.4.4~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-desktop/xserver-xorg-video-fbturbo_0.4.4~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-utils/hostapd_2.9-102~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-utils/hostapd_2.9-102~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-utils/hostapd_2.9-102~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-utils/hostapd_2.9-102~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-utils/htop_2.2.0-5~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-utils/htop_2.2.0-5~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-utils/htop_2.2.0-5~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-utils/htop_2.2.0-5~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/focal-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/focal-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
external/cache/debs/extra/stretch-utils/hostapd_2.9-102~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/stretch-utils/hostapd_2.9-102~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/stretch-utils/hostapd_2.9-102~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/stretch-utils/hostapd_2.9-102~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/stretch-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/stretch-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/stretch-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/stretch-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/stretch-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/stretch-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/stretch-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/stretch-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-desktop/libcedrus1-dev_1.0.1~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-desktop/libcedrus1-dev_1.0.1~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-desktop/libcedrus1-dev_1.0.1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-desktop/libcedrus1-dev_1.0.1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-desktop/libcedrus1_1.0.1~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-desktop/libcedrus1_1.0.1~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-desktop/libcedrus1_1.0.1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-desktop/libcedrus1_1.0.1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-desktop/libglshim_0.9.2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-desktop/libglshim_0.9.2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-desktop/libmali-sunxi-dev_1.0-1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-desktop/libmali-sunxi-dev_1.0-1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-desktop/libmali-sunxi-r3p0_1.0-1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-desktop/libmali-sunxi-r3p0_1.0-1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-desktop/libump-dev_3.0-0sunxi1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-desktop/libump-dev_3.0-0sunxi1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-desktop/libump_3.0-0sunxi1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-desktop/libump_3.0-0sunxi1~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
external/cache/debs/extra/xenial-desktop/xserver-xorg-video-fbturbo_0.4.4~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-desktop/xserver-xorg-video-fbturbo_0.4.4~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-desktop/xserver-xorg-video-fbturbo_0.4.4~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-desktop/xserver-xorg-video-fbturbo_0.4.4~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-utils/hostapd_2.9-102~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-utils/hostapd_2.9-102~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-utils/hostapd_2.9-102~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-utils/hostapd_2.9-102~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-utils/mmc-utils_0~gita3d3331-3~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_arm64.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_arm64.deb
vendored
Normal file
Binary file not shown.
BIN
external/cache/debs/extra/xenial-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
BIN
external/cache/debs/extra/xenial-utils/sunxi-tools_1.4.2-2~orangepi2.0.8+1_armhf.deb
vendored
Normal file
Binary file not shown.
20
external/cache/sources/brcm_patchram_plus/Makefile
vendored
Executable file
20
external/cache/sources/brcm_patchram_plus/Makefile
vendored
Executable file
@@ -0,0 +1,20 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# Makefile for building tapp
|
||||
#
|
||||
#
|
||||
|
||||
CFLAGS = -Wall -O2
|
||||
CC = gcc
|
||||
INSTALL = install
|
||||
|
||||
TARGET = brcm_patchram_plus
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): brcm_patchram_plus.c
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
clean distclean:
|
||||
rm -rf *.o $(TARGET)
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
.PHONY: $(PHONY) install clean distclean
|
||||
890
external/cache/sources/brcm_patchram_plus/brcm_patchram_plus.c
vendored
Executable file
890
external/cache/sources/brcm_patchram_plus/brcm_patchram_plus.c
vendored
Executable file
@@ -0,0 +1,890 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2011 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
**
|
||||
** Name: brcm_patchram_plus.c
|
||||
**
|
||||
** Description: This program downloads a patchram files in the HCD format
|
||||
** to Broadcom Bluetooth based silicon and combo chips and
|
||||
** and other utility functions.
|
||||
**
|
||||
** It can be invoked from the command line in the form
|
||||
** <-d> to print a debug log
|
||||
** <--patchram patchram_file>
|
||||
** <--baudrate baud_rate>
|
||||
** <--bd_addr bd_address>
|
||||
** <--enable_lpm>
|
||||
** <--enable_hci>
|
||||
** <--use_baudrate_for_download>
|
||||
** <--scopcm=sco_routing,pcm_interface_rate,frame_type,
|
||||
** sync_mode,clock_mode,lsb_first,fill_bits,
|
||||
** fill_method,fill_num,right_justify>
|
||||
**
|
||||
** Where
|
||||
**
|
||||
** sco_routing is 0 for PCM, 1 for Transport,
|
||||
** 2 for Codec and 3 for I2S,
|
||||
**
|
||||
** pcm_interface_rate is 0 for 128KBps, 1 for
|
||||
** 256 KBps, 2 for 512KBps, 3 for 1024KBps,
|
||||
** and 4 for 2048Kbps,
|
||||
**
|
||||
** frame_type is 0 for short and 1 for long,
|
||||
**
|
||||
** sync_mode is 0 for slave and 1 for master,
|
||||
**
|
||||
** clock_mode is 0 for slabe and 1 for master,
|
||||
**
|
||||
** lsb_first is 0 for false aand 1 for true,
|
||||
**
|
||||
** fill_bits is the value in decimal for unused bits,
|
||||
**
|
||||
** fill_method is 0 for 0's and 1 for 1's, 2 for
|
||||
** signed and 3 for programmable,
|
||||
**
|
||||
** fill_num is the number or bits to fill,
|
||||
**
|
||||
** right_justify is 0 for false and 1 for true
|
||||
**
|
||||
** <--i2s=i2s_enable,is_master,sample_rate,clock_rate>
|
||||
**
|
||||
** Where
|
||||
**
|
||||
** i2s_enable is 0 for disable and 1 for enable,
|
||||
**
|
||||
** is_master is 0 for slave and 1 for master,
|
||||
**
|
||||
** sample_rate is 0 for 8KHz, 1 for 16Khz and
|
||||
** 2 for 4 KHz,
|
||||
**
|
||||
** clock_rate is 0 for 128KHz, 1 for 256KHz, 3 for
|
||||
** 1024 KHz and 4 for 2048 KHz.
|
||||
**
|
||||
** <--no2bytes skips waiting for two byte confirmation
|
||||
** before starting patchram download. Newer chips
|
||||
** do not generate these two bytes.>
|
||||
** <--tosleep=number of microsseconds to sleep before
|
||||
** patchram download begins.>
|
||||
** uart_device_name
|
||||
**
|
||||
** For example:
|
||||
**
|
||||
** brcm_patchram_plus -d --patchram \
|
||||
** BCM2045B2_002.002.011.0348.0349.hcd /dev/ttyHS0
|
||||
**
|
||||
** It will return 0 for success and a number greater than 0
|
||||
** for any errors.
|
||||
**
|
||||
** For Android, this program invoked using a
|
||||
** "system(2)" call from the beginning of the bt_enable
|
||||
** function inside the file
|
||||
** system/bluetooth/bluedroid/bluetooth.c.
|
||||
**
|
||||
** If the Android system property "ro.bt.bcm_bdaddr_path" is
|
||||
** set, then the bd_addr will be read from this path.
|
||||
** This is overridden by --bd_addr on the command line.
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
// TODO: Integrate BCM support into Bluez hciattach
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <termios.h>
|
||||
#else
|
||||
#include <sys/termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <cutils/properties.h>
|
||||
#define LOG_TAG "brcm_patchram_plus"
|
||||
#include <cutils/log.h>
|
||||
#undef printf
|
||||
#define printf ALOGD
|
||||
#undef fprintf
|
||||
#define fprintf(x, ...) \
|
||||
{ if(x==stderr) ALOGE(__VA_ARGS__); else fprintf(x, __VA_ARGS__); }
|
||||
|
||||
#endif //ANDROID
|
||||
|
||||
#ifndef N_HCI
|
||||
#define N_HCI 15
|
||||
#endif
|
||||
|
||||
#define HCIUARTSETPROTO _IOW('U', 200, int)
|
||||
#define HCIUARTGETPROTO _IOR('U', 201, int)
|
||||
#define HCIUARTGETDEVICE _IOR('U', 202, int)
|
||||
|
||||
#define HCI_UART_H4 0
|
||||
#define HCI_UART_BCSP 1
|
||||
#define HCI_UART_3WIRE 2
|
||||
#define HCI_UART_H4DS 3
|
||||
#define HCI_UART_LL 4
|
||||
|
||||
typedef unsigned char uchar;
|
||||
|
||||
int uart_fd = -1;
|
||||
int hcdfile_fd = -1;
|
||||
int termios_baudrate = 0;
|
||||
int bdaddr_flag = 0;
|
||||
int enable_lpm = 0;
|
||||
int enable_hci = 0;
|
||||
int use_baudrate_for_download = 0;
|
||||
int debug = 0;
|
||||
int scopcm = 0;
|
||||
int i2s = 0;
|
||||
int no2bytes = 0;
|
||||
int tosleep = 0;
|
||||
|
||||
struct termios termios;
|
||||
uchar buffer[1024];
|
||||
|
||||
uchar hci_reset[] = { 0x01, 0x03, 0x0c, 0x00 };
|
||||
|
||||
uchar hci_download_minidriver[] = { 0x01, 0x2e, 0xfc, 0x00 };
|
||||
|
||||
uchar hci_update_baud_rate[] = { 0x01, 0x18, 0xfc, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
uchar hci_write_bd_addr[] = { 0x01, 0x01, 0xfc, 0x06,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
uchar hci_write_sleep_mode[] = { 0x01, 0x27, 0xfc, 0x0c,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00 };
|
||||
|
||||
uchar hci_write_sco_pcm_int[] =
|
||||
{ 0x01, 0x1C, 0xFC, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
uchar hci_write_pcm_data_format[] =
|
||||
{ 0x01, 0x1e, 0xFC, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
uchar hci_write_i2spcm_interface_param[] =
|
||||
{ 0x01, 0x6d, 0xFC, 0x04, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
#ifdef SAMSUNG_BLUETOOTH
|
||||
char* get_samsung_bluetooth_type()
|
||||
{
|
||||
char buf[10];
|
||||
int fd = open("/data/.cid.info", O_RDONLY);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "couldn't open file /data/.cid.info for reading\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (read(fd, buf, sizeof(buf)) < 0) {
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
if (strncmp(buf, "murata", 6) == 0)
|
||||
return "_murata";
|
||||
|
||||
if (strncmp(buf, "semcove", 7) == 0)
|
||||
return "_semcove";
|
||||
|
||||
if (strncmp(buf, "semcosh", 7) == 0)
|
||||
return "_semcosh";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
parse_patchram(char *optarg)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (!(p = strrchr(optarg, '.'))) {
|
||||
fprintf(stderr, "file %s not an HCD file\n", optarg);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
p++;
|
||||
|
||||
if (strcasecmp("hcd", p) != 0) {
|
||||
fprintf(stderr, "file %s not an HCD file\n", optarg);
|
||||
exit(4);
|
||||
}
|
||||
|
||||
#ifdef SAMSUNG_BLUETOOTH
|
||||
char optarg2[256];
|
||||
char* type = get_samsung_bluetooth_type();
|
||||
char* fext = ".hcd";
|
||||
|
||||
if (type != NULL) {
|
||||
memset(optarg2, 0, 256);
|
||||
strncpy(optarg2, optarg, strlen(optarg) - 4);
|
||||
strcpy(optarg2 + strlen(optarg2), type);
|
||||
strcpy(optarg2 + strlen(optarg2), fext);
|
||||
optarg = optarg2;
|
||||
fprintf(stderr, "using %s as hcdfile\n", optarg);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((hcdfile_fd = open(optarg, O_RDONLY)) == -1) {
|
||||
fprintf(stderr, "file %s could not be opened, error %d\n", optarg, errno);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
BRCM_encode_baud_rate(uint baud_rate, uchar *encoded_baud)
|
||||
{
|
||||
if(baud_rate == 0 || encoded_baud == NULL) {
|
||||
fprintf(stderr, "Baudrate not supported!");
|
||||
return;
|
||||
}
|
||||
|
||||
encoded_baud[3] = (uchar)(baud_rate >> 24);
|
||||
encoded_baud[2] = (uchar)(baud_rate >> 16);
|
||||
encoded_baud[1] = (uchar)(baud_rate >> 8);
|
||||
encoded_baud[0] = (uchar)(baud_rate & 0xFF);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int baud_rate;
|
||||
int termios_value;
|
||||
} tBaudRates;
|
||||
|
||||
tBaudRates baud_rates[] = {
|
||||
{ 115200, B115200 },
|
||||
{ 230400, B230400 },
|
||||
{ 460800, B460800 },
|
||||
{ 500000, B500000 },
|
||||
{ 576000, B576000 },
|
||||
{ 921600, B921600 },
|
||||
{ 1000000, B1000000 },
|
||||
{ 1152000, B1152000 },
|
||||
{ 1500000, B1500000 },
|
||||
{ 2000000, B2000000 },
|
||||
{ 2500000, B2500000 },
|
||||
{ 3000000, B3000000 },
|
||||
#ifndef __CYGWIN__
|
||||
{ 3500000, B3500000 },
|
||||
{ 4000000, B4000000 }
|
||||
#endif
|
||||
};
|
||||
|
||||
int
|
||||
validate_baudrate(int baud_rate, int *value)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < (sizeof(baud_rates) / sizeof(tBaudRates)); i++) {
|
||||
if (baud_rates[i].baud_rate == baud_rate) {
|
||||
*value = baud_rates[i].termios_value;
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
parse_baudrate(char *optarg)
|
||||
{
|
||||
int baudrate = atoi(optarg);
|
||||
|
||||
if (validate_baudrate(baudrate, &termios_baudrate)) {
|
||||
BRCM_encode_baud_rate(baudrate, &hci_update_baud_rate[6]);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
parse_bdaddr(char *optarg)
|
||||
{
|
||||
int bd_addr[6];
|
||||
int i;
|
||||
|
||||
sscanf(optarg, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
&bd_addr[5], &bd_addr[4], &bd_addr[3],
|
||||
&bd_addr[2], &bd_addr[1], &bd_addr[0]);
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
hci_write_bd_addr[4 + i] = bd_addr[i];
|
||||
}
|
||||
|
||||
bdaddr_flag = 1;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
parse_enable_lpm(char *optarg)
|
||||
{
|
||||
enable_lpm = 1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
parse_use_baudrate_for_download(char *optarg)
|
||||
{
|
||||
use_baudrate_for_download = 1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
parse_enable_hci(char *optarg)
|
||||
{
|
||||
enable_hci = 1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
parse_scopcm(char *optarg)
|
||||
{
|
||||
int param[10];
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
ret = sscanf(optarg, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
|
||||
¶m[0], ¶m[1], ¶m[2], ¶m[3], ¶m[4],
|
||||
¶m[5], ¶m[6], ¶m[7], ¶m[8], ¶m[9]);
|
||||
|
||||
if (ret != 10) {
|
||||
return(1);
|
||||
}
|
||||
|
||||
scopcm = 1;
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
hci_write_sco_pcm_int[4 + i] = param[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
hci_write_pcm_data_format[4 + i] = param[5 + i];
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
parse_i2s(char *optarg)
|
||||
{
|
||||
int param[4];
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
ret = sscanf(optarg, "%d,%d,%d,%d", ¶m[0], ¶m[1], ¶m[2],
|
||||
¶m[3]);
|
||||
|
||||
if (ret != 4) {
|
||||
return(1);
|
||||
}
|
||||
|
||||
i2s = 1;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
hci_write_i2spcm_interface_param[4 + i] = param[i];
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
parse_no2bytes(char *optarg)
|
||||
{
|
||||
no2bytes = 1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
parse_tosleep(char *optarg)
|
||||
{
|
||||
tosleep = atoi(optarg);
|
||||
|
||||
if (tosleep <= 0) {
|
||||
return(1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
usage(char *argv0)
|
||||
{
|
||||
printf("Usage %s:\n", argv0);
|
||||
printf("\t<-d> to print a debug log\n");
|
||||
printf("\t<--patchram patchram_file>\n");
|
||||
printf("\t<--baudrate baud_rate>\n");
|
||||
printf("\t<--bd_addr bd_address>\n");
|
||||
printf("\t<--enable_lpm>\n");
|
||||
printf("\t<--enable_hci>\n");
|
||||
printf("\t<--use_baudrate_for_download> - Uses the\n");
|
||||
printf("\t\tbaudrate for downloading the firmware\n");
|
||||
printf("\t<--scopcm=sco_routing,pcm_interface_rate,frame_type,\n");
|
||||
printf("\t\tsync_mode,clock_mode,lsb_first,fill_bits,\n");
|
||||
printf("\t\tfill_method,fill_num,right_justify>\n");
|
||||
printf("\n\t\tWhere\n");
|
||||
printf("\n\t\tsco_routing is 0 for PCM, 1 for Transport,\n");
|
||||
printf("\t\t2 for Codec and 3 for I2S,\n");
|
||||
printf("\n\t\tpcm_interface_rate is 0 for 128KBps, 1 for\n");
|
||||
printf("\t\t256 KBps, 2 for 512KBps, 3 for 1024KBps,\n");
|
||||
printf("\t\tand 4 for 2048Kbps,\n");
|
||||
printf("\n\t\tframe_type is 0 for short and 1 for long,\n");
|
||||
printf("\t\tsync_mode is 0 for slave and 1 for master,\n");
|
||||
printf("\n\t\tclock_mode is 0 for slabe and 1 for master,\n");
|
||||
printf("\n\t\tlsb_first is 0 for false aand 1 for true,\n");
|
||||
printf("\n\t\tfill_bits is the value in decimal for unused bits,\n");
|
||||
printf("\n\t\tfill_method is 0 for 0's and 1 for 1's, 2 for\n");
|
||||
printf("\t\tsigned and 3 for programmable,\n");
|
||||
printf("\n\t\tfill_num is the number or bits to fill,\n");
|
||||
printf("\n\t\tright_justify is 0 for false and 1 for true\n");
|
||||
printf("\n\t<--i2s=i2s_enable,is_master,sample_rate,clock_rate>\n");
|
||||
printf("\n\t\tWhere\n");
|
||||
printf("\n\t\ti2s_enable is 0 for disable and 1 for enable,\n");
|
||||
printf("\n\t\tis_master is 0 for slave and 1 for master,\n");
|
||||
printf("\n\t\tsample_rate is 0 for 8KHz, 1 for 16Khz and\n");
|
||||
printf("\t\t2 for 4 KHz,\n");
|
||||
printf("\n\t\tclock_rate is 0 for 128KHz, 1 for 256KHz, 3 for\n");
|
||||
printf("\t\t1024 KHz and 4 for 2048 KHz.\n\n");
|
||||
printf("\t<--no2bytes skips waiting for two byte confirmation\n");
|
||||
printf("\t\tbefore starting patchram download. Newer chips\n");
|
||||
printf("\t\tdo not generate these two bytes.>\n");
|
||||
printf("\t<--tosleep=microseconds>\n");
|
||||
printf("\tuart_device_name\n");
|
||||
}
|
||||
|
||||
int
|
||||
parse_cmd_line(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int ret = 0;
|
||||
|
||||
typedef int (*PFI)();
|
||||
|
||||
PFI parse[] = { parse_patchram, parse_baudrate,
|
||||
parse_bdaddr, parse_enable_lpm, parse_enable_hci,
|
||||
parse_use_baudrate_for_download,
|
||||
parse_scopcm, parse_i2s, parse_no2bytes, parse_tosleep};
|
||||
|
||||
while (1) {
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"patchram", 1, 0, 0},
|
||||
{"baudrate", 1, 0, 0},
|
||||
{"bd_addr", 1, 0, 0},
|
||||
{"enable_lpm", 0, 0, 0},
|
||||
{"enable_hci", 0, 0, 0},
|
||||
{"use_baudrate_for_download", 0, 0, 0},
|
||||
{"scopcm", 1, 0, 0},
|
||||
{"i2s", 1, 0, 0},
|
||||
{"no2bytes", 0, 0, 0},
|
||||
{"tosleep", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long_only (argc, argv, "d", long_options,
|
||||
&option_index);
|
||||
|
||||
if (c == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case 0:
|
||||
if (debug) {
|
||||
printf ("option %s",
|
||||
long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
ret = (*parse[option_index])(optarg);
|
||||
|
||||
break;
|
||||
case 'd':
|
||||
debug = 1;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
//nobreak
|
||||
default:
|
||||
usage(argv[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
usage(argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
if (debug)
|
||||
printf ("%s \n", argv[optind]);
|
||||
if ((uart_fd = open(argv[optind], O_RDWR | O_NOCTTY)) == -1) {
|
||||
fprintf(stderr, "port %s could not be opened, error %d\n",
|
||||
argv[optind], errno);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
init_uart()
|
||||
{
|
||||
#ifdef BCM_INIT_DELAY
|
||||
usleep(150*1000);
|
||||
#endif
|
||||
tcflush(uart_fd, TCIOFLUSH);
|
||||
tcgetattr(uart_fd, &termios);
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
cfmakeraw(&termios);
|
||||
#else
|
||||
termios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
|
||||
| INLCR | IGNCR | ICRNL | IXON);
|
||||
termios.c_oflag &= ~OPOST;
|
||||
termios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
|
||||
termios.c_cflag &= ~(CSIZE | PARENB);
|
||||
termios.c_cflag |= CS8;
|
||||
#endif
|
||||
|
||||
termios.c_cflag |= CRTSCTS;
|
||||
tcsetattr(uart_fd, TCSANOW, &termios);
|
||||
tcflush(uart_fd, TCIOFLUSH);
|
||||
tcsetattr(uart_fd, TCSANOW, &termios);
|
||||
tcflush(uart_fd, TCIOFLUSH);
|
||||
tcflush(uart_fd, TCIOFLUSH);
|
||||
cfsetospeed(&termios, B115200);
|
||||
cfsetispeed(&termios, B115200);
|
||||
tcsetattr(uart_fd, TCSANOW, &termios);
|
||||
}
|
||||
|
||||
void
|
||||
dump(uchar *out, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (i && !(i % 16)) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "%02x ", out[i]);
|
||||
}
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
read_event(int fd, uchar *buffer)
|
||||
{
|
||||
int i = 0;
|
||||
int len = 3;
|
||||
int count;
|
||||
|
||||
while ((count = read(fd, &buffer[i], len)) < len) {
|
||||
i += count;
|
||||
len -= count;
|
||||
}
|
||||
|
||||
i += count;
|
||||
len = buffer[2];
|
||||
|
||||
while ((count = read(fd, &buffer[i], len)) < len) {
|
||||
i += count;
|
||||
len -= count;
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
count += i;
|
||||
|
||||
fprintf(stderr, "received %d\n", count);
|
||||
dump(buffer, count);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
hci_send_cmd(uchar *buf, int len)
|
||||
{
|
||||
if (debug) {
|
||||
fprintf(stderr, "writing\n");
|
||||
dump(buf, len);
|
||||
}
|
||||
|
||||
write(uart_fd, buf, len);
|
||||
}
|
||||
|
||||
void
|
||||
expired(int sig)
|
||||
{
|
||||
hci_send_cmd(hci_reset, sizeof(hci_reset));
|
||||
alarm(4);
|
||||
}
|
||||
|
||||
void
|
||||
proc_reset()
|
||||
{
|
||||
signal(SIGALRM, expired);
|
||||
|
||||
|
||||
hci_send_cmd(hci_reset, sizeof(hci_reset));
|
||||
|
||||
alarm(4);
|
||||
|
||||
read_event(uart_fd, buffer);
|
||||
|
||||
alarm(0);
|
||||
}
|
||||
|
||||
void
|
||||
proc_patchram()
|
||||
{
|
||||
int len;
|
||||
|
||||
hci_send_cmd(hci_download_minidriver, sizeof(hci_download_minidriver));
|
||||
|
||||
read_event(uart_fd, buffer);
|
||||
|
||||
if (!no2bytes) {
|
||||
read(uart_fd, &buffer[0], 2);
|
||||
}
|
||||
|
||||
if (tosleep) {
|
||||
usleep(tosleep);
|
||||
}
|
||||
|
||||
while (read(hcdfile_fd, &buffer[1], 3)) {
|
||||
buffer[0] = 0x01;
|
||||
|
||||
len = buffer[3];
|
||||
|
||||
read(hcdfile_fd, &buffer[4], len);
|
||||
|
||||
hci_send_cmd(buffer, len + 4);
|
||||
|
||||
read_event(uart_fd, buffer);
|
||||
}
|
||||
|
||||
if (use_baudrate_for_download) {
|
||||
cfsetospeed(&termios, B115200);
|
||||
cfsetispeed(&termios, B115200);
|
||||
tcsetattr(uart_fd, TCSANOW, &termios);
|
||||
}
|
||||
proc_reset();
|
||||
}
|
||||
|
||||
void
|
||||
proc_baudrate()
|
||||
{
|
||||
hci_send_cmd(hci_update_baud_rate, sizeof(hci_update_baud_rate));
|
||||
|
||||
read_event(uart_fd, buffer);
|
||||
|
||||
cfsetospeed(&termios, termios_baudrate);
|
||||
cfsetispeed(&termios, termios_baudrate);
|
||||
tcsetattr(uart_fd, TCSANOW, &termios);
|
||||
|
||||
if (debug) {
|
||||
fprintf(stderr, "Done setting baudrate\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
proc_bdaddr()
|
||||
{
|
||||
hci_send_cmd(hci_write_bd_addr, sizeof(hci_write_bd_addr));
|
||||
|
||||
read_event(uart_fd, buffer);
|
||||
}
|
||||
|
||||
void
|
||||
proc_enable_lpm()
|
||||
{
|
||||
hci_send_cmd(hci_write_sleep_mode, sizeof(hci_write_sleep_mode));
|
||||
|
||||
read_event(uart_fd, buffer);
|
||||
}
|
||||
|
||||
void
|
||||
proc_scopcm()
|
||||
{
|
||||
hci_send_cmd(hci_write_sco_pcm_int,
|
||||
sizeof(hci_write_sco_pcm_int));
|
||||
|
||||
read_event(uart_fd, buffer);
|
||||
|
||||
hci_send_cmd(hci_write_pcm_data_format,
|
||||
sizeof(hci_write_pcm_data_format));
|
||||
|
||||
read_event(uart_fd, buffer);
|
||||
}
|
||||
|
||||
void
|
||||
proc_i2s()
|
||||
{
|
||||
hci_send_cmd(hci_write_i2spcm_interface_param,
|
||||
sizeof(hci_write_i2spcm_interface_param));
|
||||
|
||||
read_event(uart_fd, buffer);
|
||||
}
|
||||
|
||||
void
|
||||
proc_enable_hci()
|
||||
{
|
||||
int i = N_HCI;
|
||||
int proto = HCI_UART_H4;
|
||||
if (ioctl(uart_fd, TIOCSETD, &i) < 0) {
|
||||
fprintf(stderr, "Can't set line discipline\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ioctl(uart_fd, HCIUARTSETPROTO, proto) < 0) {
|
||||
fprintf(stderr, "Can't set hci protocol\n");
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "Done setting line discpline\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
void
|
||||
read_default_bdaddr()
|
||||
{
|
||||
int sz;
|
||||
int fd;
|
||||
|
||||
char path[PROPERTY_VALUE_MAX];
|
||||
|
||||
char bdaddr[18];
|
||||
int len = 17;
|
||||
memset(bdaddr, 0, (len + 1) * sizeof(char));
|
||||
|
||||
property_get("ro.bt.bdaddr_path", path, "");
|
||||
if (path[0] == 0)
|
||||
return;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "open(%s) failed: %s (%d)", path, strerror(errno),
|
||||
errno);
|
||||
return;
|
||||
}
|
||||
|
||||
sz = read(fd, bdaddr, len);
|
||||
if (sz < 0) {
|
||||
fprintf(stderr, "read(%s) failed: %s (%d)", path, strerror(errno),
|
||||
errno);
|
||||
close(fd);
|
||||
return;
|
||||
} else if (sz != len) {
|
||||
fprintf(stderr, "read(%s) unexpected size %d", path, sz);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
printf("Read default bdaddr of %s\n", bdaddr);
|
||||
}
|
||||
|
||||
parse_bdaddr(bdaddr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
read_default_bdaddr();
|
||||
#endif
|
||||
|
||||
if (parse_cmd_line(argc, argv)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (uart_fd < 0) {
|
||||
exit(2);
|
||||
}
|
||||
|
||||
init_uart();
|
||||
|
||||
proc_reset();
|
||||
|
||||
if (use_baudrate_for_download) {
|
||||
if (termios_baudrate) {
|
||||
proc_baudrate();
|
||||
}
|
||||
}
|
||||
|
||||
if (hcdfile_fd > 0) {
|
||||
proc_patchram();
|
||||
}
|
||||
|
||||
if (termios_baudrate) {
|
||||
proc_baudrate();
|
||||
}
|
||||
|
||||
if (bdaddr_flag) {
|
||||
proc_bdaddr();
|
||||
}
|
||||
|
||||
if (enable_lpm) {
|
||||
proc_enable_lpm();
|
||||
}
|
||||
|
||||
if (scopcm) {
|
||||
proc_scopcm();
|
||||
}
|
||||
|
||||
if (i2s) {
|
||||
proc_i2s();
|
||||
}
|
||||
|
||||
if (enable_hci) {
|
||||
proc_enable_hci();
|
||||
|
||||
while (1) {
|
||||
sleep(UINT_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
95
external/cache/sources/hcitools/Makefile
vendored
Normal file
95
external/cache/sources/hcitools/Makefile
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
#CFLAGS := $(CFLAGS) -g
|
||||
CFLAGS = -I. -Ilib -Wall -DVERSION=\"5.10\" -Wno-strict-aliasing
|
||||
CFLAGS += -Ilib/bluetooth
|
||||
|
||||
# include rule.mk
|
||||
include ./rule.mk
|
||||
|
||||
# define objects collection variable
|
||||
lib = \
|
||||
lib/bluetooth.o \
|
||||
lib/hci.o \
|
||||
lib/sdp.o
|
||||
|
||||
hciattach_objs = \
|
||||
hciattach.o \
|
||||
hciattach_ath3k.o \
|
||||
hciattach_bcm43xx.o \
|
||||
hciattach_intel.o \
|
||||
hciattach_qualcomm.o \
|
||||
hciattach_st.o \
|
||||
hciattach_ti.o \
|
||||
hciattach_tialt.o \
|
||||
hciattach_rtk.o \
|
||||
hciattach_xr.o \
|
||||
hciattach_sprd.o
|
||||
|
||||
hciconfig_objs = \
|
||||
hciconfig.o \
|
||||
csr.o
|
||||
|
||||
hcitool_objs = \
|
||||
hcitool.o
|
||||
|
||||
btmon_objs = \
|
||||
monitor/main.o \
|
||||
monitor/mainloop.o \
|
||||
monitor/display.o \
|
||||
monitor/hcidump.o \
|
||||
monitor/btsnoop.o \
|
||||
monitor/control.o \
|
||||
monitor/packet.o \
|
||||
monitor/vendor.o \
|
||||
monitor/lmp.o \
|
||||
monitor/l2cap.o \
|
||||
monitor/uuid.o \
|
||||
monitor/sdp.o \
|
||||
monitor/crc.o \
|
||||
monitor/ll.o
|
||||
|
||||
# add your target(s) to all
|
||||
.PHONY: all
|
||||
all: hciattach_opi hciconfig hcitool btmon
|
||||
|
||||
# directory
|
||||
hciattach_opi: $(hciattach_objs) $(lib)
|
||||
$(LINK_MSG)
|
||||
$(LINKX)
|
||||
|
||||
hciconfig: $(hciconfig_objs) $(lib)
|
||||
$(LINK_MSG)
|
||||
$(LINKX)
|
||||
|
||||
hcitool: $(hcitool_objs) $(lib)
|
||||
$(LINK_MSG)
|
||||
$(LINKX)
|
||||
|
||||
btmon: $(btmon_objs) $(lib)
|
||||
$(LINK_MSG)
|
||||
$(LINKX)
|
||||
|
||||
# change objs to your objects collection variable
|
||||
$(hciattach_objs): %.o: %.c
|
||||
$(COMPILE_MSG)
|
||||
$(COMPILEX)
|
||||
|
||||
$(hciconfig_objs): %.o: %.c
|
||||
$(COMPILE_MSG)
|
||||
$(COMPILEX)
|
||||
|
||||
$(hcitool_objs): %.o: %.c
|
||||
$(COMPILE_MSG)
|
||||
$(COMPILEX)
|
||||
|
||||
$(btmon_objs): %.o: %.c
|
||||
$(COMPILE_MSG)
|
||||
$(COMPILEX)
|
||||
|
||||
# clean temp files
|
||||
clean:
|
||||
-rm -rf $(hciattach_objs) $(hciattach_objs:.o=.d)
|
||||
-rm -rf $(hciconfig_objs) $(hciconfig_objs:.o=.d)
|
||||
-rm -rf $(hcitool_objs) $(hcitool_objs:.o=.d)
|
||||
-rm -rf $(lib) $(lib:.o=.d)
|
||||
-rm -rf $(btmon_objs) $(btmon_objs:.o=.d)
|
||||
#-rm -rf output
|
||||
343
external/cache/sources/hcitools/NOTICE
vendored
Normal file
343
external/cache/sources/hcitools/NOTICE
vendored
Normal file
@@ -0,0 +1,343 @@
|
||||
All of these programs are made available under version 2 of the GNU General
|
||||
Public Licence.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
2853
external/cache/sources/hcitools/csr.c
vendored
Normal file
2853
external/cache/sources/hcitools/csr.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
553
external/cache/sources/hcitools/csr.h
vendored
Normal file
553
external/cache/sources/hcitools/csr.h
vendored
Normal file
@@ -0,0 +1,553 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <termios.h>
|
||||
|
||||
#define CSR_VARID_PS_CLR_ALL 0x000b /* valueless */
|
||||
#define CSR_VARID_PS_FACTORY_SET 0x000c /* valueless */
|
||||
#define CSR_VARID_PS_CLR_ALL_STORES 0x082d /* uint16 */
|
||||
#define CSR_VARID_BC01_STATUS 0x2801 /* uint16 */
|
||||
#define CSR_VARID_BUILDID 0x2819 /* uint16 */
|
||||
#define CSR_VARID_CHIPVER 0x281a /* uint16 */
|
||||
#define CSR_VARID_CHIPREV 0x281b /* uint16 */
|
||||
#define CSR_VARID_INTERFACE_VERSION 0x2825 /* uint16 */
|
||||
#define CSR_VARID_RAND 0x282a /* uint16 */
|
||||
#define CSR_VARID_MAX_CRYPT_KEY_LENGTH 0x282c /* uint16 */
|
||||
#define CSR_VARID_CHIPANAREV 0x2836 /* uint16 */
|
||||
#define CSR_VARID_BUILDID_LOADER 0x2838 /* uint16 */
|
||||
#define CSR_VARID_BT_CLOCK 0x2c00 /* uint32 */
|
||||
#define CSR_VARID_PS_NEXT 0x3005 /* complex */
|
||||
#define CSR_VARID_PS_SIZE 0x3006 /* complex */
|
||||
#define CSR_VARID_CRYPT_KEY_LENGTH 0x3008 /* complex */
|
||||
#define CSR_VARID_PICONET_INSTANCE 0x3009 /* complex */
|
||||
#define CSR_VARID_GET_CLR_EVT 0x300a /* complex */
|
||||
#define CSR_VARID_GET_NEXT_BUILDDEF 0x300b /* complex */
|
||||
#define CSR_VARID_PS_MEMORY_TYPE 0x3012 /* complex */
|
||||
#define CSR_VARID_READ_BUILD_NAME 0x301c /* complex */
|
||||
#define CSR_VARID_COLD_RESET 0x4001 /* valueless */
|
||||
#define CSR_VARID_WARM_RESET 0x4002 /* valueless */
|
||||
#define CSR_VARID_COLD_HALT 0x4003 /* valueless */
|
||||
#define CSR_VARID_WARM_HALT 0x4004 /* valueless */
|
||||
#define CSR_VARID_INIT_BT_STACK 0x4005 /* valueless */
|
||||
#define CSR_VARID_ACTIVATE_BT_STACK 0x4006 /* valueless */
|
||||
#define CSR_VARID_ENABLE_TX 0x4007 /* valueless */
|
||||
#define CSR_VARID_DISABLE_TX 0x4008 /* valueless */
|
||||
#define CSR_VARID_RECAL 0x4009 /* valueless */
|
||||
#define CSR_VARID_PS_FACTORY_RESTORE 0x400d /* valueless */
|
||||
#define CSR_VARID_PS_FACTORY_RESTORE_ALL 0x400e /* valueless */
|
||||
#define CSR_VARID_PS_DEFRAG_RESET 0x400f /* valueless */
|
||||
#define CSR_VARID_KILL_VM_APPLICATION 0x4010 /* valueless */
|
||||
#define CSR_VARID_HOPPING_ON 0x4011 /* valueless */
|
||||
#define CSR_VARID_CANCEL_PAGE 0x4012 /* valueless */
|
||||
#define CSR_VARID_PS_CLR 0x4818 /* uint16 */
|
||||
#define CSR_VARID_MAP_SCO_PCM 0x481c /* uint16 */
|
||||
#define CSR_VARID_SINGLE_CHAN 0x482e /* uint16 */
|
||||
#define CSR_VARID_RADIOTEST 0x5004 /* complex */
|
||||
#define CSR_VARID_PS_CLR_STORES 0x500c /* complex */
|
||||
#define CSR_VARID_NO_VARIABLE 0x6000 /* valueless */
|
||||
#define CSR_VARID_CONFIG_UART 0x6802 /* uint16 */
|
||||
#define CSR_VARID_PANIC_ARG 0x6805 /* uint16 */
|
||||
#define CSR_VARID_FAULT_ARG 0x6806 /* uint16 */
|
||||
#define CSR_VARID_MAX_TX_POWER 0x6827 /* int8 */
|
||||
#define CSR_VARID_DEFAULT_TX_POWER 0x682b /* int8 */
|
||||
#define CSR_VARID_PS 0x7003 /* complex */
|
||||
|
||||
#define CSR_PSKEY_BDADDR 0x0001 /* bdaddr / uint16[] = { 0x00A5A5, 0x5b, 0x0002 } */
|
||||
#define CSR_PSKEY_COUNTRYCODE 0x0002 /* uint16 */
|
||||
#define CSR_PSKEY_CLASSOFDEVICE 0x0003 /* bdcod */
|
||||
#define CSR_PSKEY_DEVICE_DRIFT 0x0004 /* uint16 */
|
||||
#define CSR_PSKEY_DEVICE_JITTER 0x0005 /* uint16 */
|
||||
#define CSR_PSKEY_MAX_ACLS 0x000d /* uint16 */
|
||||
#define CSR_PSKEY_MAX_SCOS 0x000e /* uint16 */
|
||||
#define CSR_PSKEY_MAX_REMOTE_MASTERS 0x000f /* uint16 */
|
||||
#define CSR_PSKEY_ENABLE_MASTERY_WITH_SLAVERY 0x0010 /* bool */
|
||||
#define CSR_PSKEY_H_HC_FC_MAX_ACL_PKT_LEN 0x0011 /* uint16 */
|
||||
#define CSR_PSKEY_H_HC_FC_MAX_SCO_PKT_LEN 0x0012 /* uint8 */
|
||||
#define CSR_PSKEY_H_HC_FC_MAX_ACL_PKTS 0x0013 /* uint16 */
|
||||
#define CSR_PSKEY_H_HC_FC_MAX_SCO_PKTS 0x0014 /* uint16 */
|
||||
#define CSR_PSKEY_LC_FC_BUFFER_LOW_WATER_MARK 0x0015 /* lc_fc_lwm */
|
||||
#define CSR_PSKEY_LC_MAX_TX_POWER 0x0017 /* int16 */
|
||||
#define CSR_PSKEY_TX_GAIN_RAMP 0x001d /* uint16 */
|
||||
#define CSR_PSKEY_LC_POWER_TABLE 0x001e /* power_setting[] */
|
||||
#define CSR_PSKEY_LC_PEER_POWER_PERIOD 0x001f /* TIME */
|
||||
#define CSR_PSKEY_LC_FC_POOLS_LOW_WATER_MARK 0x0020 /* lc_fc_lwm */
|
||||
#define CSR_PSKEY_LC_DEFAULT_TX_POWER 0x0021 /* int16 */
|
||||
#define CSR_PSKEY_LC_RSSI_GOLDEN_RANGE 0x0022 /* uint8 */
|
||||
#define CSR_PSKEY_LC_COMBO_DISABLE_PIO_MASK 0x0028 /* uint16[] */
|
||||
#define CSR_PSKEY_LC_COMBO_PRIORITY_PIO_MASK 0x0029 /* uint16[] */
|
||||
#define CSR_PSKEY_LC_COMBO_DOT11_CHANNEL_PIO_BASE 0x002a /* uint16 */
|
||||
#define CSR_PSKEY_LC_COMBO_DOT11_BLOCK_CHANNELS 0x002b /* uint16 */
|
||||
#define CSR_PSKEY_LC_MAX_TX_POWER_NO_RSSI 0x002d /* int8 */
|
||||
#define CSR_PSKEY_LC_CONNECTION_RX_WINDOW 0x002e /* uint16 */
|
||||
#define CSR_PSKEY_LC_COMBO_DOT11_TX_PROTECTION_MODE 0x0030 /* uint16 */
|
||||
#define CSR_PSKEY_LC_ENHANCED_POWER_TABLE 0x0031 /* enhanced_power_setting[] */
|
||||
#define CSR_PSKEY_LC_WIDEBAND_RSSI_CONFIG 0x0032 /* wideband_rssi_config */
|
||||
#define CSR_PSKEY_LC_COMBO_DOT11_PRIORITY_LEAD 0x0033 /* uint16 */
|
||||
#define CSR_PSKEY_BT_CLOCK_INIT 0x0034 /* uint32 */
|
||||
#define CSR_PSKEY_TX_MR_MOD_DELAY 0x0038 /* uint8 */
|
||||
#define CSR_PSKEY_RX_MR_SYNC_TIMING 0x0039 /* uint16 */
|
||||
#define CSR_PSKEY_RX_MR_SYNC_CONFIG 0x003a /* uint16 */
|
||||
#define CSR_PSKEY_LC_LOST_SYNC_SLOTS 0x003b /* uint16 */
|
||||
#define CSR_PSKEY_RX_MR_SAMP_CONFIG 0x003c /* uint16 */
|
||||
#define CSR_PSKEY_AGC_HYST_LEVELS 0x003d /* agc_hyst_config */
|
||||
#define CSR_PSKEY_RX_LEVEL_LOW_SIGNAL 0x003e /* uint16 */
|
||||
#define CSR_PSKEY_AGC_IQ_LVL_VALUES 0x003f /* IQ_LVL_VAL[] */
|
||||
#define CSR_PSKEY_MR_FTRIM_OFFSET_12DB 0x0040 /* uint16 */
|
||||
#define CSR_PSKEY_MR_FTRIM_OFFSET_6DB 0x0041 /* uint16 */
|
||||
#define CSR_PSKEY_NO_CAL_ON_BOOT 0x0042 /* bool */
|
||||
#define CSR_PSKEY_RSSI_HI_TARGET 0x0043 /* uint8 */
|
||||
#define CSR_PSKEY_PREFERRED_MIN_ATTENUATION 0x0044 /* uint8 */
|
||||
#define CSR_PSKEY_LC_COMBO_DOT11_PRIORITY_OVERRIDE 0x0045 /* bool */
|
||||
#define CSR_PSKEY_LC_MULTISLOT_HOLDOFF 0x0047 /* TIME */
|
||||
#define CSR_PSKEY_FREE_KEY_PIGEON_HOLE 0x00c9 /* uint16 */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR0 0x00ca /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR1 0x00cb /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR2 0x00cc /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR3 0x00cd /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR4 0x00ce /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR5 0x00cf /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR6 0x00d0 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR7 0x00d1 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR8 0x00d2 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR9 0x00d3 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR10 0x00d4 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR11 0x00d5 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR12 0x00d6 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR13 0x00d7 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR14 0x00d8 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LINK_KEY_BD_ADDR15 0x00d9 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_ENC_KEY_LMIN 0x00da /* uint16 */
|
||||
#define CSR_PSKEY_ENC_KEY_LMAX 0x00db /* uint16 */
|
||||
#define CSR_PSKEY_LOCAL_SUPPORTED_FEATURES 0x00ef /* uint16[] = { 0xffff, 0xfe8f, 0xf99b, 0x8000 }*/
|
||||
#define CSR_PSKEY_LM_USE_UNIT_KEY 0x00f0 /* bool */
|
||||
#define CSR_PSKEY_HCI_NOP_DISABLE 0x00f2 /* bool */
|
||||
#define CSR_PSKEY_LM_MAX_EVENT_FILTERS 0x00f4 /* uint8 */
|
||||
#define CSR_PSKEY_LM_USE_ENC_MODE_BROADCAST 0x00f5 /* bool */
|
||||
#define CSR_PSKEY_LM_TEST_SEND_ACCEPTED_TWICE 0x00f6 /* bool */
|
||||
#define CSR_PSKEY_LM_MAX_PAGE_HOLD_TIME 0x00f7 /* uint16 */
|
||||
#define CSR_PSKEY_AFH_ADAPTATION_RESPONSE_TIME 0x00f8 /* uint16 */
|
||||
#define CSR_PSKEY_AFH_OPTIONS 0x00f9 /* uint16 */
|
||||
#define CSR_PSKEY_AFH_RSSI_RUN_PERIOD 0x00fa /* uint16 */
|
||||
#define CSR_PSKEY_AFH_REENABLE_CHANNEL_TIME 0x00fb /* uint16 */
|
||||
#define CSR_PSKEY_NO_DROP_ON_ACR_MS_FAIL 0x00fc /* bool */
|
||||
#define CSR_PSKEY_MAX_PRIVATE_KEYS 0x00fd /* uint8 */
|
||||
#define CSR_PSKEY_PRIVATE_LINK_KEY_BD_ADDR0 0x00fe /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_PRIVATE_LINK_KEY_BD_ADDR1 0x00ff /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_PRIVATE_LINK_KEY_BD_ADDR2 0x0100 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_PRIVATE_LINK_KEY_BD_ADDR3 0x0101 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_PRIVATE_LINK_KEY_BD_ADDR4 0x0102 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_PRIVATE_LINK_KEY_BD_ADDR5 0x0103 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_PRIVATE_LINK_KEY_BD_ADDR6 0x0104 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_PRIVATE_LINK_KEY_BD_ADDR7 0x0105 /* LM_LINK_KEY_BD_ADDR_T */
|
||||
#define CSR_PSKEY_LOCAL_SUPPORTED_COMMANDS 0x0106 /* uint16[] = { 0xffff, 0x03ff, 0xfffe, 0xffff, 0xffff, 0xffff, 0x0ff3, 0xfff8, 0x003f } */
|
||||
#define CSR_PSKEY_LM_MAX_ABSENCE_INDEX 0x0107 /* uint8 */
|
||||
#define CSR_PSKEY_DEVICE_NAME 0x0108 /* uint16[] */
|
||||
#define CSR_PSKEY_AFH_RSSI_THRESHOLD 0x0109 /* uint16 */
|
||||
#define CSR_PSKEY_LM_CASUAL_SCAN_INTERVAL 0x010a /* uint16 */
|
||||
#define CSR_PSKEY_AFH_MIN_MAP_CHANGE 0x010b /* uint16[] */
|
||||
#define CSR_PSKEY_AFH_RSSI_LP_RUN_PERIOD 0x010c /* uint16 */
|
||||
#define CSR_PSKEY_HCI_LMP_LOCAL_VERSION 0x010d /* uint16 */
|
||||
#define CSR_PSKEY_LMP_REMOTE_VERSION 0x010e /* uint8 */
|
||||
#define CSR_PSKEY_HOLD_ERROR_MESSAGE_NUMBER 0x0113 /* uint16 */
|
||||
#define CSR_PSKEY_DFU_ATTRIBUTES 0x0136 /* uint8 */
|
||||
#define CSR_PSKEY_DFU_DETACH_TO 0x0137 /* uint16 */
|
||||
#define CSR_PSKEY_DFU_TRANSFER_SIZE 0x0138 /* uint16 */
|
||||
#define CSR_PSKEY_DFU_ENABLE 0x0139 /* bool */
|
||||
#define CSR_PSKEY_DFU_LIN_REG_ENABLE 0x013a /* bool */
|
||||
#define CSR_PSKEY_DFUENC_VMAPP_PK_MODULUS_MSB 0x015e /* uint16[] */
|
||||
#define CSR_PSKEY_DFUENC_VMAPP_PK_MODULUS_LSB 0x015f /* uint16[] */
|
||||
#define CSR_PSKEY_DFUENC_VMAPP_PK_M_DASH 0x0160 /* uint16 */
|
||||
#define CSR_PSKEY_DFUENC_VMAPP_PK_R2N_MSB 0x0161 /* uint16[] */
|
||||
#define CSR_PSKEY_DFUENC_VMAPP_PK_R2N_LSB 0x0162 /* uint16[] */
|
||||
#define CSR_PSKEY_BCSP_LM_PS_BLOCK 0x0192 /* BCSP_LM_PS_BLOCK */
|
||||
#define CSR_PSKEY_HOSTIO_FC_PS_BLOCK 0x0193 /* HOSTIO_FC_PS_BLOCK */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO0 0x0194 /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO1 0x0195 /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO2 0x0196 /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO3 0x0197 /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO4 0x0198 /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO5 0x0199 /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO6 0x019a /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO7 0x019b /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO8 0x019c /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO9 0x019d /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO10 0x019e /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO11 0x019f /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO12 0x01a0 /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO13 0x01a1 /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO14 0x01a2 /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_PROTOCOL_INFO15 0x01a3 /* PROTOCOL_INFO */
|
||||
#define CSR_PSKEY_HOSTIO_UART_RESET_TIMEOUT 0x01a4 /* TIME */
|
||||
#define CSR_PSKEY_HOSTIO_USE_HCI_EXTN 0x01a5 /* bool */
|
||||
#define CSR_PSKEY_HOSTIO_USE_HCI_EXTN_CCFC 0x01a6 /* bool */
|
||||
#define CSR_PSKEY_HOSTIO_HCI_EXTN_PAYLOAD_SIZE 0x01a7 /* uint16 */
|
||||
#define CSR_PSKEY_BCSP_LM_CNF_CNT_LIMIT 0x01aa /* uint16 */
|
||||
#define CSR_PSKEY_HOSTIO_MAP_SCO_PCM 0x01ab /* bool */
|
||||
#define CSR_PSKEY_HOSTIO_AWKWARD_PCM_SYNC 0x01ac /* bool */
|
||||
#define CSR_PSKEY_HOSTIO_BREAK_POLL_PERIOD 0x01ad /* TIME */
|
||||
#define CSR_PSKEY_HOSTIO_MIN_UART_HCI_SCO_SIZE 0x01ae /* uint16 */
|
||||
#define CSR_PSKEY_HOSTIO_MAP_SCO_CODEC 0x01b0 /* bool */
|
||||
#define CSR_PSKEY_PCM_CVSD_TX_HI_FREQ_BOOST 0x01b1 /* uint16 */
|
||||
#define CSR_PSKEY_PCM_CVSD_RX_HI_FREQ_BOOST 0x01b2 /* uint16 */
|
||||
#define CSR_PSKEY_PCM_CONFIG32 0x01b3 /* uint32 */
|
||||
#define CSR_PSKEY_USE_OLD_BCSP_LE 0x01b4 /* uint16 */
|
||||
#define CSR_PSKEY_PCM_CVSD_USE_NEW_FILTER 0x01b5 /* bool */
|
||||
#define CSR_PSKEY_PCM_FORMAT 0x01b6 /* uint16 */
|
||||
#define CSR_PSKEY_CODEC_OUT_GAIN 0x01b7 /* uint16 */
|
||||
#define CSR_PSKEY_CODEC_IN_GAIN 0x01b8 /* uint16 */
|
||||
#define CSR_PSKEY_CODEC_PIO 0x01b9 /* uint16 */
|
||||
#define CSR_PSKEY_PCM_LOW_JITTER_CONFIG 0x01ba /* uint32 */
|
||||
#define CSR_PSKEY_HOSTIO_SCO_PCM_THRESHOLDS 0x01bb /* uint16[] */
|
||||
#define CSR_PSKEY_HOSTIO_SCO_HCI_THRESHOLDS 0x01bc /* uint16[] */
|
||||
#define CSR_PSKEY_HOSTIO_MAP_SCO_PCM_SLOT 0x01bd /* uint16 */
|
||||
#define CSR_PSKEY_UART_BAUDRATE 0x01be /* uint16 */
|
||||
#define CSR_PSKEY_UART_CONFIG_BCSP 0x01bf /* uint16 */
|
||||
#define CSR_PSKEY_UART_CONFIG_H4 0x01c0 /* uint16 */
|
||||
#define CSR_PSKEY_UART_CONFIG_H5 0x01c1 /* uint16 */
|
||||
#define CSR_PSKEY_UART_CONFIG_USR 0x01c2 /* uint16 */
|
||||
#define CSR_PSKEY_UART_TX_CRCS 0x01c3 /* bool */
|
||||
#define CSR_PSKEY_UART_ACK_TIMEOUT 0x01c4 /* uint16 */
|
||||
#define CSR_PSKEY_UART_TX_MAX_ATTEMPTS 0x01c5 /* uint16 */
|
||||
#define CSR_PSKEY_UART_TX_WINDOW_SIZE 0x01c6 /* uint16 */
|
||||
#define CSR_PSKEY_UART_HOST_WAKE 0x01c7 /* uint16[] */
|
||||
#define CSR_PSKEY_HOSTIO_THROTTLE_TIMEOUT 0x01c8 /* TIME */
|
||||
#define CSR_PSKEY_PCM_ALWAYS_ENABLE 0x01c9 /* bool */
|
||||
#define CSR_PSKEY_UART_HOST_WAKE_SIGNAL 0x01ca /* uint16 */
|
||||
#define CSR_PSKEY_UART_CONFIG_H4DS 0x01cb /* uint16 */
|
||||
#define CSR_PSKEY_H4DS_WAKE_DURATION 0x01cc /* uint16 */
|
||||
#define CSR_PSKEY_H4DS_MAXWU 0x01cd /* uint16 */
|
||||
#define CSR_PSKEY_H4DS_LE_TIMER_PERIOD 0x01cf /* uint16 */
|
||||
#define CSR_PSKEY_H4DS_TWU_TIMER_PERIOD 0x01d0 /* uint16 */
|
||||
#define CSR_PSKEY_H4DS_UART_IDLE_TIMER_PERIOD 0x01d1 /* uint16 */
|
||||
#define CSR_PSKEY_ANA_FTRIM 0x01f6 /* uint16 */
|
||||
#define CSR_PSKEY_WD_TIMEOUT 0x01f7 /* TIME */
|
||||
#define CSR_PSKEY_WD_PERIOD 0x01f8 /* TIME */
|
||||
#define CSR_PSKEY_HOST_INTERFACE 0x01f9 /* phys_bus */
|
||||
#define CSR_PSKEY_HQ_HOST_TIMEOUT 0x01fb /* TIME */
|
||||
#define CSR_PSKEY_HQ_ACTIVE 0x01fc /* bool */
|
||||
#define CSR_PSKEY_BCCMD_SECURITY_ACTIVE 0x01fd /* bool */
|
||||
#define CSR_PSKEY_ANA_FREQ 0x01fe /* uint16 */
|
||||
#define CSR_PSKEY_PIO_PROTECT_MASK 0x0202 /* uint16 */
|
||||
#define CSR_PSKEY_PMALLOC_SIZES 0x0203 /* uint16[] */
|
||||
#define CSR_PSKEY_UART_BAUD_RATE 0x0204 /* uint16 */
|
||||
#define CSR_PSKEY_UART_CONFIG 0x0205 /* uint16 */
|
||||
#define CSR_PSKEY_STUB 0x0207 /* uint16 */
|
||||
#define CSR_PSKEY_TXRX_PIO_CONTROL 0x0209 /* uint16 */
|
||||
#define CSR_PSKEY_ANA_RX_LEVEL 0x020b /* uint16 */
|
||||
#define CSR_PSKEY_ANA_RX_FTRIM 0x020c /* uint16 */
|
||||
#define CSR_PSKEY_PSBC_DATA_VERSION 0x020d /* uint16 */
|
||||
#define CSR_PSKEY_PCM0_ATTENUATION 0x020f /* uint16 */
|
||||
#define CSR_PSKEY_LO_LVL_MAX 0x0211 /* uint16 */
|
||||
#define CSR_PSKEY_LO_ADC_AMPL_MIN 0x0212 /* uint16 */
|
||||
#define CSR_PSKEY_LO_ADC_AMPL_MAX 0x0213 /* uint16 */
|
||||
#define CSR_PSKEY_IQ_TRIM_CHANNEL 0x0214 /* uint16 */
|
||||
#define CSR_PSKEY_IQ_TRIM_GAIN 0x0215 /* uint16 */
|
||||
#define CSR_PSKEY_IQ_TRIM_ENABLE 0x0216 /* iq_trim_enable_flag */
|
||||
#define CSR_PSKEY_TX_OFFSET_HALF_MHZ 0x0217 /* int16 */
|
||||
#define CSR_PSKEY_GBL_MISC_ENABLES 0x0221 /* uint16 */
|
||||
#define CSR_PSKEY_UART_SLEEP_TIMEOUT 0x0222 /* uint16 */
|
||||
#define CSR_PSKEY_DEEP_SLEEP_STATE 0x0229 /* deep_sleep_state */
|
||||
#define CSR_PSKEY_IQ_ENABLE_PHASE_TRIM 0x022d /* bool */
|
||||
#define CSR_PSKEY_HCI_HANDLE_FREEZE_PERIOD 0x0237 /* TIME */
|
||||
#define CSR_PSKEY_MAX_FROZEN_HCI_HANDLES 0x0238 /* uint16 */
|
||||
#define CSR_PSKEY_PAGETABLE_DESTRUCTION_DELAY 0x0239 /* TIME */
|
||||
#define CSR_PSKEY_IQ_TRIM_PIO_SETTINGS 0x023a /* uint8 */
|
||||
#define CSR_PSKEY_USE_EXTERNAL_CLOCK 0x023b /* bool */
|
||||
#define CSR_PSKEY_DEEP_SLEEP_WAKE_CTS 0x023c /* uint16 */
|
||||
#define CSR_PSKEY_FC_HC2H_FLUSH_DELAY 0x023d /* TIME */
|
||||
#define CSR_PSKEY_RX_HIGHSIDE 0x023e /* bool */
|
||||
#define CSR_PSKEY_TX_PRE_LVL 0x0240 /* uint8 */
|
||||
#define CSR_PSKEY_RX_SINGLE_ENDED 0x0242 /* bool */
|
||||
#define CSR_PSKEY_TX_FILTER_CONFIG 0x0243 /* uint32 */
|
||||
#define CSR_PSKEY_CLOCK_REQUEST_ENABLE 0x0246 /* uint16 */
|
||||
#define CSR_PSKEY_RX_MIN_ATTEN 0x0249 /* uint16 */
|
||||
#define CSR_PSKEY_XTAL_TARGET_AMPLITUDE 0x024b /* uint8 */
|
||||
#define CSR_PSKEY_PCM_MIN_CPU_CLOCK 0x024d /* uint16 */
|
||||
#define CSR_PSKEY_HOST_INTERFACE_PIO_USB 0x0250 /* uint16 */
|
||||
#define CSR_PSKEY_CPU_IDLE_MODE 0x0251 /* cpu_idle_mode */
|
||||
#define CSR_PSKEY_DEEP_SLEEP_CLEAR_RTS 0x0252 /* bool */
|
||||
#define CSR_PSKEY_RF_RESONANCE_TRIM 0x0254 /* uint16 */
|
||||
#define CSR_PSKEY_DEEP_SLEEP_PIO_WAKE 0x0255 /* uint16 */
|
||||
#define CSR_PSKEY_DRAIN_BORE_TIMERS 0x0256 /* uint32[] */
|
||||
#define CSR_PSKEY_DRAIN_TX_POWER_BASE 0x0257 /* uint16 */
|
||||
#define CSR_PSKEY_MODULE_ID 0x0259 /* uint32 */
|
||||
#define CSR_PSKEY_MODULE_DESIGN 0x025a /* uint16 */
|
||||
#define CSR_PSKEY_MODULE_SECURITY_CODE 0x025c /* uint16[] */
|
||||
#define CSR_PSKEY_VM_DISABLE 0x025d /* bool */
|
||||
#define CSR_PSKEY_MOD_MANUF0 0x025e /* uint16[] */
|
||||
#define CSR_PSKEY_MOD_MANUF1 0x025f /* uint16[] */
|
||||
#define CSR_PSKEY_MOD_MANUF2 0x0260 /* uint16[] */
|
||||
#define CSR_PSKEY_MOD_MANUF3 0x0261 /* uint16[] */
|
||||
#define CSR_PSKEY_MOD_MANUF4 0x0262 /* uint16[] */
|
||||
#define CSR_PSKEY_MOD_MANUF5 0x0263 /* uint16[] */
|
||||
#define CSR_PSKEY_MOD_MANUF6 0x0264 /* uint16[] */
|
||||
#define CSR_PSKEY_MOD_MANUF7 0x0265 /* uint16[] */
|
||||
#define CSR_PSKEY_MOD_MANUF8 0x0266 /* uint16[] */
|
||||
#define CSR_PSKEY_MOD_MANUF9 0x0267 /* uint16[] */
|
||||
#define CSR_PSKEY_DUT_VM_DISABLE 0x0268 /* bool */
|
||||
#define CSR_PSKEY_USR0 0x028a /* uint16[] */
|
||||
#define CSR_PSKEY_USR1 0x028b /* uint16[] */
|
||||
#define CSR_PSKEY_USR2 0x028c /* uint16[] */
|
||||
#define CSR_PSKEY_USR3 0x028d /* uint16[] */
|
||||
#define CSR_PSKEY_USR4 0x028e /* uint16[] */
|
||||
#define CSR_PSKEY_USR5 0x028f /* uint16[] */
|
||||
#define CSR_PSKEY_USR6 0x0290 /* uint16[] */
|
||||
#define CSR_PSKEY_USR7 0x0291 /* uint16[] */
|
||||
#define CSR_PSKEY_USR8 0x0292 /* uint16[] */
|
||||
#define CSR_PSKEY_USR9 0x0293 /* uint16[] */
|
||||
#define CSR_PSKEY_USR10 0x0294 /* uint16[] */
|
||||
#define CSR_PSKEY_USR11 0x0295 /* uint16[] */
|
||||
#define CSR_PSKEY_USR12 0x0296 /* uint16[] */
|
||||
#define CSR_PSKEY_USR13 0x0297 /* uint16[] */
|
||||
#define CSR_PSKEY_USR14 0x0298 /* uint16[] */
|
||||
#define CSR_PSKEY_USR15 0x0299 /* uint16[] */
|
||||
#define CSR_PSKEY_USR16 0x029a /* uint16[] */
|
||||
#define CSR_PSKEY_USR17 0x029b /* uint16[] */
|
||||
#define CSR_PSKEY_USR18 0x029c /* uint16[] */
|
||||
#define CSR_PSKEY_USR19 0x029d /* uint16[] */
|
||||
#define CSR_PSKEY_USR20 0x029e /* uint16[] */
|
||||
#define CSR_PSKEY_USR21 0x029f /* uint16[] */
|
||||
#define CSR_PSKEY_USR22 0x02a0 /* uint16[] */
|
||||
#define CSR_PSKEY_USR23 0x02a1 /* uint16[] */
|
||||
#define CSR_PSKEY_USR24 0x02a2 /* uint16[] */
|
||||
#define CSR_PSKEY_USR25 0x02a3 /* uint16[] */
|
||||
#define CSR_PSKEY_USR26 0x02a4 /* uint16[] */
|
||||
#define CSR_PSKEY_USR27 0x02a5 /* uint16[] */
|
||||
#define CSR_PSKEY_USR28 0x02a6 /* uint16[] */
|
||||
#define CSR_PSKEY_USR29 0x02a7 /* uint16[] */
|
||||
#define CSR_PSKEY_USR30 0x02a8 /* uint16[] */
|
||||
#define CSR_PSKEY_USR31 0x02a9 /* uint16[] */
|
||||
#define CSR_PSKEY_USR32 0x02aa /* uint16[] */
|
||||
#define CSR_PSKEY_USR33 0x02ab /* uint16[] */
|
||||
#define CSR_PSKEY_USR34 0x02ac /* uint16[] */
|
||||
#define CSR_PSKEY_USR35 0x02ad /* uint16[] */
|
||||
#define CSR_PSKEY_USR36 0x02ae /* uint16[] */
|
||||
#define CSR_PSKEY_USR37 0x02af /* uint16[] */
|
||||
#define CSR_PSKEY_USR38 0x02b0 /* uint16[] */
|
||||
#define CSR_PSKEY_USR39 0x02b1 /* uint16[] */
|
||||
#define CSR_PSKEY_USR40 0x02b2 /* uint16[] */
|
||||
#define CSR_PSKEY_USR41 0x02b3 /* uint16[] */
|
||||
#define CSR_PSKEY_USR42 0x02b4 /* uint16[] */
|
||||
#define CSR_PSKEY_USR43 0x02b5 /* uint16[] */
|
||||
#define CSR_PSKEY_USR44 0x02b6 /* uint16[] */
|
||||
#define CSR_PSKEY_USR45 0x02b7 /* uint16[] */
|
||||
#define CSR_PSKEY_USR46 0x02b8 /* uint16[] */
|
||||
#define CSR_PSKEY_USR47 0x02b9 /* uint16[] */
|
||||
#define CSR_PSKEY_USR48 0x02ba /* uint16[] */
|
||||
#define CSR_PSKEY_USR49 0x02bb /* uint16[] */
|
||||
#define CSR_PSKEY_USB_VERSION 0x02bc /* uint16 */
|
||||
#define CSR_PSKEY_USB_DEVICE_CLASS_CODES 0x02bd /* usbclass */
|
||||
#define CSR_PSKEY_USB_VENDOR_ID 0x02be /* uint16 */
|
||||
#define CSR_PSKEY_USB_PRODUCT_ID 0x02bf /* uint16 */
|
||||
#define CSR_PSKEY_USB_MANUF_STRING 0x02c1 /* unicodestring */
|
||||
#define CSR_PSKEY_USB_PRODUCT_STRING 0x02c2 /* unicodestring */
|
||||
#define CSR_PSKEY_USB_SERIAL_NUMBER_STRING 0x02c3 /* unicodestring */
|
||||
#define CSR_PSKEY_USB_CONFIG_STRING 0x02c4 /* unicodestring */
|
||||
#define CSR_PSKEY_USB_ATTRIBUTES 0x02c5 /* uint8 */
|
||||
#define CSR_PSKEY_USB_MAX_POWER 0x02c6 /* uint16 */
|
||||
#define CSR_PSKEY_USB_BT_IF_CLASS_CODES 0x02c7 /* usbclass */
|
||||
#define CSR_PSKEY_USB_LANGID 0x02c9 /* uint16 */
|
||||
#define CSR_PSKEY_USB_DFU_CLASS_CODES 0x02ca /* usbclass */
|
||||
#define CSR_PSKEY_USB_DFU_PRODUCT_ID 0x02cb /* uint16 */
|
||||
#define CSR_PSKEY_USB_PIO_DETACH 0x02ce /* uint16 */
|
||||
#define CSR_PSKEY_USB_PIO_WAKEUP 0x02cf /* uint16 */
|
||||
#define CSR_PSKEY_USB_PIO_PULLUP 0x02d0 /* uint16 */
|
||||
#define CSR_PSKEY_USB_PIO_VBUS 0x02d1 /* uint16 */
|
||||
#define CSR_PSKEY_USB_PIO_WAKE_TIMEOUT 0x02d2 /* uint16 */
|
||||
#define CSR_PSKEY_USB_PIO_RESUME 0x02d3 /* uint16 */
|
||||
#define CSR_PSKEY_USB_BT_SCO_IF_CLASS_CODES 0x02d4 /* usbclass */
|
||||
#define CSR_PSKEY_USB_SUSPEND_PIO_LEVEL 0x02d5 /* uint16 */
|
||||
#define CSR_PSKEY_USB_SUSPEND_PIO_DIR 0x02d6 /* uint16 */
|
||||
#define CSR_PSKEY_USB_SUSPEND_PIO_MASK 0x02d7 /* uint16 */
|
||||
#define CSR_PSKEY_USB_ENDPOINT_0_MAX_PACKET_SIZE 0x02d8 /* uint8 */
|
||||
#define CSR_PSKEY_USB_CONFIG 0x02d9 /* uint16 */
|
||||
#define CSR_PSKEY_RADIOTEST_ATTEN_INIT 0x0320 /* uint16 */
|
||||
#define CSR_PSKEY_RADIOTEST_FIRST_TRIM_TIME 0x0326 /* TIME */
|
||||
#define CSR_PSKEY_RADIOTEST_SUBSEQUENT_TRIM_TIME 0x0327 /* TIME */
|
||||
#define CSR_PSKEY_RADIOTEST_LO_LVL_TRIM_ENABLE 0x0328 /* bool */
|
||||
#define CSR_PSKEY_RADIOTEST_DISABLE_MODULATION 0x032c /* bool */
|
||||
#define CSR_PSKEY_RFCOMM_FCON_THRESHOLD 0x0352 /* uint16 */
|
||||
#define CSR_PSKEY_RFCOMM_FCOFF_THRESHOLD 0x0353 /* uint16 */
|
||||
#define CSR_PSKEY_IPV6_STATIC_ADDR 0x0354 /* uint16[] */
|
||||
#define CSR_PSKEY_IPV4_STATIC_ADDR 0x0355 /* uint32 */
|
||||
#define CSR_PSKEY_IPV6_STATIC_PREFIX_LEN 0x0356 /* uint8 */
|
||||
#define CSR_PSKEY_IPV6_STATIC_ROUTER_ADDR 0x0357 /* uint16[] */
|
||||
#define CSR_PSKEY_IPV4_STATIC_SUBNET_MASK 0x0358 /* uint32 */
|
||||
#define CSR_PSKEY_IPV4_STATIC_ROUTER_ADDR 0x0359 /* uint32 */
|
||||
#define CSR_PSKEY_MDNS_NAME 0x035a /* char[] */
|
||||
#define CSR_PSKEY_FIXED_PIN 0x035b /* uint8[] */
|
||||
#define CSR_PSKEY_MDNS_PORT 0x035c /* uint16 */
|
||||
#define CSR_PSKEY_MDNS_TTL 0x035d /* uint8 */
|
||||
#define CSR_PSKEY_MDNS_IPV4_ADDR 0x035e /* uint32 */
|
||||
#define CSR_PSKEY_ARP_CACHE_TIMEOUT 0x035f /* uint16 */
|
||||
#define CSR_PSKEY_HFP_POWER_TABLE 0x0360 /* uint16[] */
|
||||
#define CSR_PSKEY_DRAIN_BORE_TIMER_COUNTERS 0x03e7 /* uint32[] */
|
||||
#define CSR_PSKEY_DRAIN_BORE_COUNTERS 0x03e6 /* uint32[] */
|
||||
#define CSR_PSKEY_LOOP_FILTER_TRIM 0x03e4 /* uint16 */
|
||||
#define CSR_PSKEY_DRAIN_BORE_CURRENT_PEAK 0x03e3 /* uint32[] */
|
||||
#define CSR_PSKEY_VM_E2_CACHE_LIMIT 0x03e2 /* uint16 */
|
||||
#define CSR_PSKEY_FORCE_16MHZ_REF_PIO 0x03e1 /* uint16 */
|
||||
#define CSR_PSKEY_CDMA_LO_REF_LIMITS 0x03df /* uint16 */
|
||||
#define CSR_PSKEY_CDMA_LO_ERROR_LIMITS 0x03de /* uint16 */
|
||||
#define CSR_PSKEY_CLOCK_STARTUP_DELAY 0x03dd /* uint16 */
|
||||
#define CSR_PSKEY_DEEP_SLEEP_CORRECTION_FACTOR 0x03dc /* int16 */
|
||||
#define CSR_PSKEY_TEMPERATURE_CALIBRATION 0x03db /* temperature_calibration */
|
||||
#define CSR_PSKEY_TEMPERATURE_VS_DELTA_INTERNAL_PA 0x03da /* temperature_calibration[] */
|
||||
#define CSR_PSKEY_TEMPERATURE_VS_DELTA_TX_PRE_LVL 0x03d9 /* temperature_calibration[] */
|
||||
#define CSR_PSKEY_TEMPERATURE_VS_DELTA_TX_BB 0x03d8 /* temperature_calibration[] */
|
||||
#define CSR_PSKEY_TEMPERATURE_VS_DELTA_ANA_FTRIM 0x03d7 /* temperature_calibration[] */
|
||||
#define CSR_PSKEY_TEST_DELTA_OFFSET 0x03d6 /* uint16 */
|
||||
#define CSR_PSKEY_RX_DYNAMIC_LVL_OFFSET 0x03d4 /* uint16 */
|
||||
#define CSR_PSKEY_TEST_FORCE_OFFSET 0x03d3 /* bool */
|
||||
#define CSR_PSKEY_RF_TRAP_BAD_DIVISION_RATIOS 0x03cf /* uint16 */
|
||||
#define CSR_PSKEY_RADIOTEST_CDMA_LO_REF_LIMITS 0x03ce /* uint16 */
|
||||
#define CSR_PSKEY_INITIAL_BOOTMODE 0x03cd /* int16 */
|
||||
#define CSR_PSKEY_ONCHIP_HCI_CLIENT 0x03cc /* bool */
|
||||
#define CSR_PSKEY_RX_ATTEN_BACKOFF 0x03ca /* uint16 */
|
||||
#define CSR_PSKEY_RX_ATTEN_UPDATE_RATE 0x03c9 /* uint16 */
|
||||
#define CSR_PSKEY_SYNTH_TXRX_THRESHOLDS 0x03c7 /* uint16 */
|
||||
#define CSR_PSKEY_MIN_WAIT_STATES 0x03c6 /* uint16 */
|
||||
#define CSR_PSKEY_RSSI_CORRECTION 0x03c5 /* int8 */
|
||||
#define CSR_PSKEY_SCHED_THROTTLE_TIMEOUT 0x03c4 /* TIME */
|
||||
#define CSR_PSKEY_DEEP_SLEEP_USE_EXTERNAL_CLOCK 0x03c3 /* bool */
|
||||
#define CSR_PSKEY_TRIM_RADIO_FILTERS 0x03c2 /* uint16 */
|
||||
#define CSR_PSKEY_TRANSMIT_OFFSET 0x03c1 /* int16 */
|
||||
#define CSR_PSKEY_USB_VM_CONTROL 0x03c0 /* bool */
|
||||
#define CSR_PSKEY_MR_ANA_RX_FTRIM 0x03bf /* uint16 */
|
||||
#define CSR_PSKEY_I2C_CONFIG 0x03be /* uint16 */
|
||||
#define CSR_PSKEY_IQ_LVL_RX 0x03bd /* uint16 */
|
||||
#define CSR_PSKEY_MR_TX_FILTER_CONFIG 0x03bb /* uint32 */
|
||||
#define CSR_PSKEY_MR_TX_CONFIG2 0x03ba /* uint16 */
|
||||
#define CSR_PSKEY_USB_DONT_RESET_BOOTMODE_ON_HOST_RESET 0x03b9 /* bool */
|
||||
#define CSR_PSKEY_LC_USE_THROTTLING 0x03b8 /* bool */
|
||||
#define CSR_PSKEY_CHARGER_TRIM 0x03b7 /* uint16 */
|
||||
#define CSR_PSKEY_CLOCK_REQUEST_FEATURES 0x03b6 /* uint16 */
|
||||
#define CSR_PSKEY_TRANSMIT_OFFSET_CLASS1 0x03b4 /* int16 */
|
||||
#define CSR_PSKEY_TX_AVOID_PA_CLASS1_PIO 0x03b3 /* uint16 */
|
||||
#define CSR_PSKEY_MR_PIO_CONFIG 0x03b2 /* uint16 */
|
||||
#define CSR_PSKEY_UART_CONFIG2 0x03b1 /* uint8 */
|
||||
#define CSR_PSKEY_CLASS1_IQ_LVL 0x03b0 /* uint16 */
|
||||
#define CSR_PSKEY_CLASS1_TX_CONFIG2 0x03af /* uint16 */
|
||||
#define CSR_PSKEY_TEMPERATURE_VS_DELTA_INTERNAL_PA_CLASS1 0x03ae /* temperature_calibration[] */
|
||||
#define CSR_PSKEY_TEMPERATURE_VS_DELTA_EXTERNAL_PA_CLASS1 0x03ad /* temperature_calibration[] */
|
||||
#define CSR_PSKEY_TEMPERATURE_VS_DELTA_TX_PRE_LVL_MR 0x03ac /* temperature_calibration[] */
|
||||
#define CSR_PSKEY_TEMPERATURE_VS_DELTA_TX_BB_MR_HEADER 0x03ab /* temperature_calibration[] */
|
||||
#define CSR_PSKEY_TEMPERATURE_VS_DELTA_TX_BB_MR_PAYLOAD 0x03aa /* temperature_calibration[] */
|
||||
#define CSR_PSKEY_RX_MR_EQ_TAPS 0x03a9 /* uint16[] */
|
||||
#define CSR_PSKEY_TX_PRE_LVL_CLASS1 0x03a8 /* uint8 */
|
||||
#define CSR_PSKEY_ANALOGUE_ATTENUATOR 0x03a7 /* bool */
|
||||
#define CSR_PSKEY_MR_RX_FILTER_TRIM 0x03a6 /* uint16 */
|
||||
#define CSR_PSKEY_MR_RX_FILTER_RESPONSE 0x03a5 /* int16[] */
|
||||
#define CSR_PSKEY_PIO_WAKEUP_STATE 0x039f /* uint16 */
|
||||
#define CSR_PSKEY_MR_TX_IF_ATTEN_OFF_TEMP 0x0394 /* int16 */
|
||||
#define CSR_PSKEY_LO_DIV_LATCH_BYPASS 0x0393 /* bool */
|
||||
#define CSR_PSKEY_LO_VCO_STANDBY 0x0392 /* bool */
|
||||
#define CSR_PSKEY_SLOW_CLOCK_FILTER_SHIFT 0x0391 /* uint16 */
|
||||
#define CSR_PSKEY_SLOW_CLOCK_FILTER_DIVIDER 0x0390 /* uint16 */
|
||||
#define CSR_PSKEY_USB_ATTRIBUTES_POWER 0x03f2 /* bool */
|
||||
#define CSR_PSKEY_USB_ATTRIBUTES_WAKEUP 0x03f3 /* bool */
|
||||
#define CSR_PSKEY_DFU_ATTRIBUTES_MANIFESTATION_TOLERANT 0x03f4 /* bool */
|
||||
#define CSR_PSKEY_DFU_ATTRIBUTES_CAN_UPLOAD 0x03f5 /* bool */
|
||||
#define CSR_PSKEY_DFU_ATTRIBUTES_CAN_DOWNLOAD 0x03f6 /* bool */
|
||||
#define CSR_PSKEY_UART_CONFIG_STOP_BITS 0x03fc /* bool */
|
||||
#define CSR_PSKEY_UART_CONFIG_PARITY_BIT 0x03fd /* uint16 */
|
||||
#define CSR_PSKEY_UART_CONFIG_FLOW_CTRL_EN 0x03fe /* bool */
|
||||
#define CSR_PSKEY_UART_CONFIG_RTS_AUTO_EN 0x03ff /* bool */
|
||||
#define CSR_PSKEY_UART_CONFIG_RTS 0x0400 /* bool */
|
||||
#define CSR_PSKEY_UART_CONFIG_TX_ZERO_EN 0x0401 /* bool */
|
||||
#define CSR_PSKEY_UART_CONFIG_NON_BCSP_EN 0x0402 /* bool */
|
||||
#define CSR_PSKEY_UART_CONFIG_RX_RATE_DELAY 0x0403 /* uint16 */
|
||||
#define CSR_PSKEY_UART_SEQ_TIMEOUT 0x0405 /* uint16 */
|
||||
#define CSR_PSKEY_UART_SEQ_RETRIES 0x0406 /* uint16 */
|
||||
#define CSR_PSKEY_UART_SEQ_WINSIZE 0x0407 /* uint16 */
|
||||
#define CSR_PSKEY_UART_USE_CRC_ON_TX 0x0408 /* bool */
|
||||
#define CSR_PSKEY_UART_HOST_INITIAL_STATE 0x0409 /* hwakeup_state */
|
||||
#define CSR_PSKEY_UART_HOST_ATTENTION_SPAN 0x040a /* uint16 */
|
||||
#define CSR_PSKEY_UART_HOST_WAKEUP_TIME 0x040b /* uint16 */
|
||||
#define CSR_PSKEY_UART_HOST_WAKEUP_WAIT 0x040c /* uint16 */
|
||||
#define CSR_PSKEY_BCSP_LM_MODE 0x0410 /* uint16 */
|
||||
#define CSR_PSKEY_BCSP_LM_SYNC_RETRIES 0x0411 /* uint16 */
|
||||
#define CSR_PSKEY_BCSP_LM_TSHY 0x0412 /* uint16 */
|
||||
#define CSR_PSKEY_UART_DFU_CONFIG_STOP_BITS 0x0417 /* bool */
|
||||
#define CSR_PSKEY_UART_DFU_CONFIG_PARITY_BIT 0x0418 /* uint16 */
|
||||
#define CSR_PSKEY_UART_DFU_CONFIG_FLOW_CTRL_EN 0x0419 /* bool */
|
||||
#define CSR_PSKEY_UART_DFU_CONFIG_RTS_AUTO_EN 0x041a /* bool */
|
||||
#define CSR_PSKEY_UART_DFU_CONFIG_RTS 0x041b /* bool */
|
||||
#define CSR_PSKEY_UART_DFU_CONFIG_TX_ZERO_EN 0x041c /* bool */
|
||||
#define CSR_PSKEY_UART_DFU_CONFIG_NON_BCSP_EN 0x041d /* bool */
|
||||
#define CSR_PSKEY_UART_DFU_CONFIG_RX_RATE_DELAY 0x041e /* uint16 */
|
||||
#define CSR_PSKEY_AMUX_AIO0 0x041f /* ana_amux_sel */
|
||||
#define CSR_PSKEY_AMUX_AIO1 0x0420 /* ana_amux_sel */
|
||||
#define CSR_PSKEY_AMUX_AIO2 0x0421 /* ana_amux_sel */
|
||||
#define CSR_PSKEY_AMUX_AIO3 0x0422 /* ana_amux_sel */
|
||||
#define CSR_PSKEY_LOCAL_NAME_SIMPLIFIED 0x0423 /* local_name_complete */
|
||||
#define CSR_PSKEY_EXTENDED_STUB 0x2001 /* uint16 */
|
||||
|
||||
char *csr_builddeftostr(uint16_t def);
|
||||
char *csr_buildidtostr(uint16_t id);
|
||||
char *csr_chipvertostr(uint16_t ver, uint16_t rev);
|
||||
char *csr_pskeytostr(uint16_t pskey);
|
||||
char *csr_pskeytoval(uint16_t pskey);
|
||||
|
||||
int csr_open_hci(char *device);
|
||||
int csr_read_hci(uint16_t varid, uint8_t *value, uint16_t length);
|
||||
int csr_write_hci(uint16_t varid, uint8_t *value, uint16_t length);
|
||||
void csr_close_hci(void);
|
||||
|
||||
int csr_open_usb(char *device);
|
||||
int csr_read_usb(uint16_t varid, uint8_t *value, uint16_t length);
|
||||
int csr_write_usb(uint16_t varid, uint8_t *value, uint16_t length);
|
||||
void csr_close_usb(void);
|
||||
|
||||
int csr_open_bcsp(char *device, speed_t bcsp_rate);
|
||||
int csr_read_bcsp(uint16_t varid, uint8_t *value, uint16_t length);
|
||||
int csr_write_bcsp(uint16_t varid, uint8_t *value, uint16_t length);
|
||||
void csr_close_bcsp(void);
|
||||
|
||||
int csr_open_h4(char *device);
|
||||
int csr_read_h4(uint16_t varid, uint8_t *value, uint16_t length);
|
||||
int csr_write_h4(uint16_t varid, uint8_t *value, uint16_t length);
|
||||
void csr_close_h4(void);
|
||||
|
||||
int csr_open_3wire(char *device);
|
||||
int csr_read_3wire(uint16_t varid, uint8_t *value, uint16_t length);
|
||||
int csr_write_3wire(uint16_t varid, uint8_t *value, uint16_t length);
|
||||
void csr_close_3wire(void);
|
||||
|
||||
int csr_write_varid_valueless(int dd, uint16_t seqnum, uint16_t varid);
|
||||
int csr_write_varid_complex(int dd, uint16_t seqnum, uint16_t varid, uint8_t *value, uint16_t length);
|
||||
int csr_read_varid_complex(int dd, uint16_t seqnum, uint16_t varid, uint8_t *value, uint16_t length);
|
||||
int csr_read_varid_uint16(int dd, uint16_t seqnum, uint16_t varid, uint16_t *value);
|
||||
int csr_read_varid_uint32(int dd, uint16_t seqnum, uint16_t varid, uint32_t *value);
|
||||
int csr_read_pskey_complex(int dd, uint16_t seqnum, uint16_t pskey, uint16_t stores, uint8_t *value, uint16_t length);
|
||||
int csr_write_pskey_complex(int dd, uint16_t seqnum, uint16_t pskey, uint16_t stores, uint8_t *value, uint16_t length);
|
||||
int csr_read_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t stores, uint16_t *value);
|
||||
int csr_write_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t stores, uint16_t value);
|
||||
int csr_read_pskey_uint32(int dd, uint16_t seqnum, uint16_t pskey, uint16_t stores, uint32_t *value);
|
||||
int csr_write_pskey_uint32(int dd, uint16_t seqnum, uint16_t pskey, uint16_t stores, uint32_t value);
|
||||
|
||||
int psr_put(uint16_t pskey, uint8_t *value, uint16_t size);
|
||||
int psr_get(uint16_t *pskey, uint8_t *value, uint16_t *size);
|
||||
int psr_read(const char *filename);
|
||||
int psr_print(void);
|
||||
1513
external/cache/sources/hcitools/hciattach.c
vendored
Normal file
1513
external/cache/sources/hcitools/hciattach.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
96
external/cache/sources/hcitools/hciattach.h
vendored
Normal file
96
external/cache/sources/hcitools/hciattach.h
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <termios.h>
|
||||
|
||||
#include <bluetooth.h>
|
||||
|
||||
#ifndef N_HCI
|
||||
#define N_HCI 15
|
||||
#endif
|
||||
|
||||
#define HCIUARTSETPROTO _IOW('U', 200, int)
|
||||
#define HCIUARTGETPROTO _IOR('U', 201, int)
|
||||
#define HCIUARTGETDEVICE _IOR('U', 202, int)
|
||||
#define HCIUARTSETFLAGS _IOW('U', 203, int)
|
||||
#define HCIUARTGETFLAGS _IOR('U', 204, int)
|
||||
|
||||
#define HCI_UART_H4 0
|
||||
#define HCI_UART_BCSP 1
|
||||
#define HCI_UART_3WIRE 2
|
||||
#define HCI_UART_H4DS 3
|
||||
#define HCI_UART_LL 4
|
||||
#define HCI_UART_ATH3K 5
|
||||
|
||||
#define HCI_UART_RAW_DEVICE 0
|
||||
#define HCI_UART_RESET_ON_INIT 1
|
||||
#define HCI_UART_CREATE_AMP 2
|
||||
|
||||
struct uart_t {
|
||||
char *type;
|
||||
int m_id;
|
||||
int p_id;
|
||||
int proto;
|
||||
int init_speed;
|
||||
int speed;
|
||||
int flags;
|
||||
int pm;
|
||||
char *bdaddr;
|
||||
int (*init) (int fd, struct uart_t *u, struct termios *ti);
|
||||
int (*post) (int fd, struct uart_t *u, struct termios *ti);
|
||||
};
|
||||
|
||||
#define FLOW_CTL 0x0001
|
||||
#define AMP_DEV 0x0002
|
||||
#define ENABLE_PM 1
|
||||
#define DISABLE_PM 0
|
||||
|
||||
int read_hci_event(int fd, unsigned char *buf, int size);
|
||||
int set_speed(int fd, struct termios *ti, int speed);
|
||||
int uart_speed(int speed);
|
||||
|
||||
int texas_init(int fd, int *speed, struct termios *ti);
|
||||
int texas_post(int fd, struct termios *ti);
|
||||
int texasalt_init(int fd, int speed, struct termios *ti);
|
||||
int stlc2500_init(int fd, bdaddr_t *bdaddr);
|
||||
int bgb2xx_init(int dd, bdaddr_t *bdaddr);
|
||||
int ath3k_init(int fd, int speed, int init_speed, char *bdaddr,
|
||||
struct termios *ti);
|
||||
int ath3k_post(int fd, int pm);
|
||||
int qualcomm_init(int fd, int speed, struct termios *ti, const char *bdaddr);
|
||||
int intel_init(int fd, int init_speed, int *speed, struct termios *ti);
|
||||
int bcm43xx_init(int fd, int speed, struct termios *ti, const char *bdaddr);
|
||||
|
||||
//Realtek_add_start
|
||||
//add realtek init and post process for realtek Bluetooth chip
|
||||
int rtk_init(int fd, int proto, int speed, struct termios *ti);
|
||||
int rtk_post(int fd, int proto, struct termios *ti);
|
||||
//Realtek_add_end
|
||||
|
||||
// add xradio init and post process for xradio Bluetooth chip (xr829)
|
||||
int xr_init(int fd, struct uart_t *u, struct termios *ti);
|
||||
int xr_post(int fd, struct uart_t *u, struct termios *ti);
|
||||
|
||||
// add sprd init and post process for sprd Bluetooth chip (UWE5622)
|
||||
int sprd_config_init(int fd, struct uart_t *u, struct termios *ti);
|
||||
int sprd_config_post(int fd, struct uart_t *u, struct termios *ti);
|
||||
1044
external/cache/sources/hcitools/hciattach_ath3k.c
vendored
Normal file
1044
external/cache/sources/hcitools/hciattach_ath3k.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
378
external/cache/sources/hcitools/hciattach_bcm43xx.c
vendored
Normal file
378
external/cache/sources/hcitools/hciattach_bcm43xx.c
vendored
Normal file
@@ -0,0 +1,378 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2014 Intel Corporation. All rights reserved.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/hci.h>
|
||||
#include <bluetooth/hci_lib.h>
|
||||
|
||||
#include "hciattach.h"
|
||||
|
||||
#ifndef FIRMWARE_DIR
|
||||
#define FIRMWARE_DIR "/etc/firmware"
|
||||
#endif
|
||||
|
||||
#define FW_EXT ".hcd"
|
||||
|
||||
#define BCM43XX_CLOCK_48 1
|
||||
#define BCM43XX_CLOCK_24 2
|
||||
|
||||
#define CMD_SUCCESS 0x00
|
||||
|
||||
#define CC_MIN_SIZE 7
|
||||
|
||||
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
|
||||
|
||||
static int bcm43xx_read_local_name(int fd, char *name, size_t size)
|
||||
{
|
||||
unsigned char cmd[] = { HCI_COMMAND_PKT, 0x14, 0x0C, 0x00 };
|
||||
unsigned char *resp;
|
||||
unsigned int name_len;
|
||||
|
||||
resp = malloc(size + CC_MIN_SIZE);
|
||||
if (!resp)
|
||||
return -1;
|
||||
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
|
||||
if (write(fd, cmd, sizeof(cmd)) != sizeof(cmd)) {
|
||||
fprintf(stderr, "Failed to write read local name command\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (read_hci_event(fd, resp, size) < CC_MIN_SIZE) {
|
||||
fprintf(stderr, "Failed to read local name, invalid HCI event\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (resp[4] != cmd[1] || resp[5] != cmd[2] || resp[6] != CMD_SUCCESS) {
|
||||
fprintf(stderr, "Failed to read local name, command failure\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
name_len = resp[2] - 1;
|
||||
|
||||
strncpy(name, (char *) &resp[7], MIN(name_len, size));
|
||||
name[size - 1] = 0;
|
||||
|
||||
free(resp);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
free(resp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int bcm43xx_reset(int fd)
|
||||
{
|
||||
unsigned char cmd[] = { HCI_COMMAND_PKT, 0x03, 0x0C, 0x00 };
|
||||
unsigned char resp[CC_MIN_SIZE];
|
||||
|
||||
if (write(fd, cmd, sizeof(cmd)) != sizeof(cmd)) {
|
||||
fprintf(stderr, "Failed to write reset command\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (read_hci_event(fd, resp, sizeof(resp)) < CC_MIN_SIZE) {
|
||||
fprintf(stderr, "Failed to reset chip, invalid HCI event\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (resp[4] != cmd[1] || resp[5] != cmd[2] || resp[6] != CMD_SUCCESS) {
|
||||
fprintf(stderr, "Failed to reset chip, command failure\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bcm43xx_set_bdaddr(int fd, const char *bdaddr)
|
||||
{
|
||||
unsigned char cmd[] =
|
||||
{ HCI_COMMAND_PKT, 0x01, 0xfc, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00 };
|
||||
unsigned char resp[CC_MIN_SIZE];
|
||||
|
||||
printf("Set BDADDR UART: %s\n", bdaddr);
|
||||
|
||||
if (str2ba(bdaddr, (bdaddr_t *) (&cmd[4])) < 0) {
|
||||
fprintf(stderr, "Incorrect bdaddr\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
|
||||
if (write(fd, cmd, sizeof(cmd)) != sizeof(cmd)) {
|
||||
fprintf(stderr, "Failed to write set bdaddr command\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (read_hci_event(fd, resp, sizeof(resp)) < CC_MIN_SIZE) {
|
||||
fprintf(stderr, "Failed to set bdaddr, invalid HCI event\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (resp[4] != cmd[1] || resp[5] != cmd[2] || resp[6] != CMD_SUCCESS) {
|
||||
fprintf(stderr, "Failed to set bdaddr, command failure\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bcm43xx_set_speed(int fd, uint32_t speed)
|
||||
{
|
||||
unsigned char cmd[] =
|
||||
{ HCI_COMMAND_PKT, 0x18, 0xfc, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00 };
|
||||
unsigned char resp[CC_MIN_SIZE];
|
||||
|
||||
printf("Set Controller UART speed to %d bit/s\n", speed);
|
||||
|
||||
cmd[6] = (uint8_t) (speed);
|
||||
cmd[7] = (uint8_t) (speed >> 8);
|
||||
cmd[8] = (uint8_t) (speed >> 16);
|
||||
cmd[9] = (uint8_t) (speed >> 24);
|
||||
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
|
||||
if (write(fd, cmd, sizeof(cmd)) != sizeof(cmd)) {
|
||||
fprintf(stderr, "Failed to write update baudrate command\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (read_hci_event(fd, resp, sizeof(resp)) < CC_MIN_SIZE) {
|
||||
fprintf(stderr, "Failed to update baudrate, invalid HCI event\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (resp[4] != cmd[1] || resp[5] != cmd[2] || resp[6] != CMD_SUCCESS) {
|
||||
fprintf(stderr, "Failed to update baudrate, command failure\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bcm43xx_set_clock(int fd, unsigned char clock)
|
||||
{
|
||||
unsigned char cmd[] = { HCI_COMMAND_PKT, 0x45, 0xfc, 0x01, 0x00 };
|
||||
unsigned char resp[CC_MIN_SIZE];
|
||||
|
||||
printf("Set Controller clock (%d)\n", clock);
|
||||
|
||||
cmd[4] = clock;
|
||||
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
|
||||
if (write(fd, cmd, sizeof(cmd)) != sizeof(cmd)) {
|
||||
fprintf(stderr, "Failed to write update clock command\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (read_hci_event(fd, resp, sizeof(resp)) < CC_MIN_SIZE) {
|
||||
fprintf(stderr, "Failed to update clock, invalid HCI event\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (resp[4] != cmd[1] || resp[5] != cmd[2] || resp[6] != CMD_SUCCESS) {
|
||||
fprintf(stderr, "Failed to update clock, command failure\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bcm43xx_load_firmware(int fd, const char *fw)
|
||||
{
|
||||
unsigned char cmd[] = { HCI_COMMAND_PKT, 0x2e, 0xfc, 0x00 };
|
||||
struct timespec tm_mode = { 0, 50000 };
|
||||
struct timespec tm_ready = { 0, 2000000 };
|
||||
unsigned char resp[CC_MIN_SIZE];
|
||||
unsigned char tx_buf[1024];
|
||||
int len, fd_fw, n;
|
||||
|
||||
printf("Flash firmware %s\n", fw);
|
||||
|
||||
fd_fw = open(fw, O_RDONLY);
|
||||
if (fd_fw < 0) {
|
||||
fprintf(stderr, "Unable to open firmware (%s)\n", fw);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
|
||||
if (write(fd, cmd, sizeof(cmd)) != sizeof(cmd)) {
|
||||
fprintf(stderr, "Failed to write download mode command\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (read_hci_event(fd, resp, sizeof(resp)) < CC_MIN_SIZE) {
|
||||
fprintf(stderr, "Failed to load firmware, invalid HCI event\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (resp[4] != cmd[1] || resp[5] != cmd[2] || resp[6] != CMD_SUCCESS) {
|
||||
fprintf(stderr, "Failed to load firmware, command failure\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Wait 50ms to let the firmware placed in download mode */
|
||||
nanosleep(&tm_mode, NULL);
|
||||
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
|
||||
while ((n = read(fd_fw, &tx_buf[1], 3))) {
|
||||
if (n < 0) {
|
||||
fprintf(stderr, "Failed to read firmware\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
tx_buf[0] = HCI_COMMAND_PKT;
|
||||
|
||||
len = tx_buf[3];
|
||||
|
||||
if (read(fd_fw, &tx_buf[4], len) < 0) {
|
||||
fprintf(stderr, "Failed to read firmware\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (write(fd, tx_buf, len + 4) != (len + 4)) {
|
||||
fprintf(stderr, "Failed to write firmware\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
read_hci_event(fd, resp, sizeof(resp));
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
}
|
||||
|
||||
/* Wait for firmware ready */
|
||||
nanosleep(&tm_ready, NULL);
|
||||
|
||||
close(fd_fw);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
close(fd_fw);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int bcm43xx_locate_patch(const char *dir_name,
|
||||
const char *chip_name, char *location)
|
||||
{
|
||||
DIR *dir;
|
||||
int ret = -1;
|
||||
|
||||
dir = opendir(dir_name);
|
||||
if (!dir) {
|
||||
fprintf(stderr, "Cannot open directory '%s': %s\n",
|
||||
dir_name, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Recursively look for a BCM43XX*.hcd */
|
||||
while (1) {
|
||||
struct dirent *entry = readdir(dir);
|
||||
if (!entry)
|
||||
break;
|
||||
|
||||
if (entry->d_type & DT_DIR) {
|
||||
char path[PATH_MAX];
|
||||
|
||||
if (!strcmp(entry->d_name, "..") || !strcmp(entry->d_name, "."))
|
||||
continue;
|
||||
|
||||
snprintf(path, PATH_MAX, "%s/%s", dir_name, entry->d_name);
|
||||
|
||||
ret = bcm43xx_locate_patch(path, chip_name, location);
|
||||
if (!ret)
|
||||
break;
|
||||
} else if (!strncmp(chip_name, entry->d_name, strlen(chip_name))) {
|
||||
unsigned int name_len = strlen(entry->d_name);
|
||||
size_t curs_ext = name_len - sizeof(FW_EXT) + 1;
|
||||
|
||||
if (curs_ext > name_len)
|
||||
break;
|
||||
|
||||
if (strncmp(FW_EXT, &entry->d_name[curs_ext], sizeof(FW_EXT)))
|
||||
break;
|
||||
|
||||
/* found */
|
||||
snprintf(location, PATH_MAX, "%s/%s", dir_name, entry->d_name);
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bcm43xx_init(int fd, int speed, struct termios *ti, const char *bdaddr)
|
||||
{
|
||||
char chip_name[20];
|
||||
char fw_path[PATH_MAX];
|
||||
|
||||
printf("bcm43xx_init\n");
|
||||
|
||||
if (bcm43xx_reset(fd))
|
||||
return -1;
|
||||
|
||||
if (bcm43xx_read_local_name(fd, chip_name, sizeof(chip_name)))
|
||||
return -1;
|
||||
|
||||
if (bcm43xx_locate_patch(FIRMWARE_DIR, chip_name, fw_path)) {
|
||||
fprintf(stderr, "Patch not found, continue anyway\n");
|
||||
} else {
|
||||
if (bcm43xx_load_firmware(fd, fw_path))
|
||||
return -1;
|
||||
|
||||
if (bcm43xx_reset(fd))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bdaddr)
|
||||
bcm43xx_set_bdaddr(fd, bdaddr);
|
||||
|
||||
if (speed > 3000000 && bcm43xx_set_clock(fd, BCM43XX_CLOCK_48))
|
||||
return -1;
|
||||
|
||||
if (bcm43xx_set_speed(fd, speed))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
595
external/cache/sources/hcitools/hciattach_intel.c
vendored
Normal file
595
external/cache/sources/hcitools/hciattach_intel.c
vendored
Normal file
@@ -0,0 +1,595 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2012 Intel Corporation. All rights reserved.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/hci.h>
|
||||
#include <bluetooth/hci_lib.h>
|
||||
|
||||
#include "hciattach.h"
|
||||
|
||||
#ifdef INTEL_DEBUG
|
||||
#define DBGPRINT(fmt, args...) printf("DBG: " fmt "\n", ## args)
|
||||
#define PRINT_PACKET(buf, len, msg) { \
|
||||
int i; \
|
||||
printf("%s\n", msg); \
|
||||
for (i = 0; i < len; i++) \
|
||||
printf("%02X ", buf[i]); \
|
||||
printf("\n"); \
|
||||
}
|
||||
#else
|
||||
#define DBGPRINT(fmt, args...)
|
||||
#define PRINT_PACKET(buf, len, msg)
|
||||
#endif
|
||||
|
||||
#define PATCH_SEQ_EXT ".bseq"
|
||||
#define PATCH_FILE_PATH "/lib/firmware/intel/"
|
||||
#define PATCH_MAX_LEN 260
|
||||
#define PATCH_TYPE_CMD 1
|
||||
#define PATCH_TYPE_EVT 2
|
||||
|
||||
#define INTEL_VER_PARAM_LEN 9
|
||||
#define INTEL_MFG_PARAM_LEN 2
|
||||
|
||||
/**
|
||||
* A data structure for a patch entry.
|
||||
*/
|
||||
struct patch_entry {
|
||||
int type;
|
||||
int len;
|
||||
unsigned char data[PATCH_MAX_LEN];
|
||||
};
|
||||
|
||||
/**
|
||||
* A structure for patch context
|
||||
*/
|
||||
struct patch_ctx {
|
||||
int dev;
|
||||
int fd;
|
||||
int patch_error;
|
||||
int reset_enable_patch;
|
||||
};
|
||||
|
||||
/**
|
||||
* Send HCI command to the controller
|
||||
*/
|
||||
static int intel_write_cmd(int dev, unsigned char *buf, int len)
|
||||
{
|
||||
int ret;
|
||||
|
||||
PRINT_PACKET(buf, len, "<----- SEND CMD: ");
|
||||
|
||||
ret = write(dev, buf, len);
|
||||
if (ret < 0)
|
||||
return -errno;
|
||||
|
||||
if (ret != len)
|
||||
return -1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the event from the controller
|
||||
*/
|
||||
static int intel_read_evt(int dev, unsigned char *buf, int len)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = read_hci_event(dev, buf, len);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
PRINT_PACKET(buf, ret, "-----> READ EVT: ");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate HCI events
|
||||
*/
|
||||
static int validate_events(struct patch_entry *event,
|
||||
struct patch_entry *entry)
|
||||
{
|
||||
if (event == NULL || entry == NULL) {
|
||||
DBGPRINT("invalid patch entry parameters");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (event->len != entry->len) {
|
||||
DBGPRINT("lengths are mismatched:[%d|%d]",
|
||||
event->len, entry->len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (memcmp(event->data, entry->data, event->len)) {
|
||||
DBGPRINT("data is mismatched");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next patch entry one line at a time
|
||||
*/
|
||||
static int get_next_patch_entry(int fd, struct patch_entry *entry)
|
||||
{
|
||||
int size;
|
||||
char rb;
|
||||
|
||||
if (read(fd, &rb, 1) <= 0)
|
||||
return 0;
|
||||
|
||||
entry->type = rb;
|
||||
|
||||
switch (entry->type) {
|
||||
case PATCH_TYPE_CMD:
|
||||
entry->data[0] = HCI_COMMAND_PKT;
|
||||
|
||||
if (read(fd, &entry->data[1], 3) < 0)
|
||||
return -1;
|
||||
|
||||
size = (int)entry->data[3];
|
||||
|
||||
if (read(fd, &entry->data[4], size) < 0)
|
||||
return -1;
|
||||
|
||||
entry->len = HCI_TYPE_LEN + HCI_COMMAND_HDR_SIZE + size;
|
||||
|
||||
break;
|
||||
|
||||
case PATCH_TYPE_EVT:
|
||||
entry->data[0] = HCI_EVENT_PKT;
|
||||
|
||||
if (read(fd, &entry->data[1], 2) < 0)
|
||||
return -1;
|
||||
|
||||
size = (int)entry->data[2];
|
||||
|
||||
if (read(fd, &entry->data[3], size) < 0)
|
||||
return -1;
|
||||
|
||||
entry->len = HCI_TYPE_LEN + HCI_EVENT_HDR_SIZE + size;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "invalid patch entry(%d)\n", entry->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return entry->len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the patch set to the controller and verify the event
|
||||
*/
|
||||
static int intel_download_patch(struct patch_ctx *ctx)
|
||||
{
|
||||
int ret;
|
||||
struct patch_entry entry;
|
||||
struct patch_entry event;
|
||||
|
||||
DBGPRINT("start patch downloading");
|
||||
|
||||
do {
|
||||
ret = get_next_patch_entry(ctx->fd, &entry);
|
||||
if (ret <= 0) {
|
||||
ctx->patch_error = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (entry.type) {
|
||||
case PATCH_TYPE_CMD:
|
||||
ret = intel_write_cmd(ctx->dev,
|
||||
entry.data,
|
||||
entry.len);
|
||||
if (ret <= 0) {
|
||||
fprintf(stderr, "failed to send cmd(%d)\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
|
||||
case PATCH_TYPE_EVT:
|
||||
ret = intel_read_evt(ctx->dev, event.data,
|
||||
sizeof(event.data));
|
||||
if (ret <= 0) {
|
||||
fprintf(stderr, "failed to read evt(%d)\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
event.len = ret;
|
||||
|
||||
if (validate_events(&event, &entry) < 0) {
|
||||
DBGPRINT("events are mismatched");
|
||||
ctx->patch_error = 1;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unknown patch type(%d)\n",
|
||||
entry.type);
|
||||
return -1;
|
||||
}
|
||||
} while (1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int open_patch_file(struct patch_ctx *ctx, char *fw_ver)
|
||||
{
|
||||
char patch_file[PATH_MAX];
|
||||
|
||||
snprintf(patch_file, PATH_MAX, "%s%s%s", PATCH_FILE_PATH,
|
||||
fw_ver, PATCH_SEQ_EXT);
|
||||
DBGPRINT("PATCH_FILE: %s", patch_file);
|
||||
|
||||
ctx->fd = open(patch_file, O_RDONLY);
|
||||
if (ctx->fd < 0) {
|
||||
DBGPRINT("cannot open patch file. go to post patch");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the controller for patching.
|
||||
*/
|
||||
static int pre_patch(struct patch_ctx *ctx)
|
||||
{
|
||||
int ret, i;
|
||||
struct patch_entry entry;
|
||||
char fw_ver[INTEL_VER_PARAM_LEN * 2];
|
||||
|
||||
DBGPRINT("start pre_patch");
|
||||
|
||||
entry.data[0] = HCI_COMMAND_PKT;
|
||||
entry.data[1] = 0x11;
|
||||
entry.data[2] = 0xFC;
|
||||
entry.data[3] = 0x02;
|
||||
entry.data[4] = 0x01;
|
||||
entry.data[5] = 0x00;
|
||||
entry.len = HCI_TYPE_LEN + HCI_COMMAND_HDR_SIZE + INTEL_MFG_PARAM_LEN;
|
||||
|
||||
ret = intel_write_cmd(ctx->dev, entry.data, entry.len);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "failed to send cmd(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = intel_read_evt(ctx->dev, entry.data, sizeof(entry.data));
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "failed to read evt(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
entry.len = ret;
|
||||
|
||||
if (entry.data[6] != 0x00) {
|
||||
DBGPRINT("command failed. status=%02x", entry.data[6]);
|
||||
ctx->patch_error = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
entry.data[0] = HCI_COMMAND_PKT;
|
||||
entry.data[1] = 0x05;
|
||||
entry.data[2] = 0xFC;
|
||||
entry.data[3] = 0x00;
|
||||
entry.len = HCI_TYPE_LEN + HCI_COMMAND_HDR_SIZE;
|
||||
|
||||
ret = intel_write_cmd(ctx->dev, entry.data, entry.len);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "failed to send cmd(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = intel_read_evt(ctx->dev, entry.data, sizeof(entry.data));
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "failed to read evt(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
entry.len = ret;
|
||||
|
||||
if (entry.data[6] != 0x00) {
|
||||
DBGPRINT("command failed. status=%02x", entry.data[6]);
|
||||
ctx->patch_error = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < INTEL_VER_PARAM_LEN; i++)
|
||||
sprintf(&fw_ver[i*2], "%02x", entry.data[7+i]);
|
||||
|
||||
if (open_patch_file(ctx, fw_ver) < 0) {
|
||||
ctx->patch_error = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* check the event is startup event
|
||||
*/
|
||||
static int is_startup_evt(unsigned char *buf)
|
||||
{
|
||||
if (buf[1] == 0xFF && buf[2] == 0x01 && buf[3] == 0x00)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize the patch process and reset the controller
|
||||
*/
|
||||
static int post_patch(struct patch_ctx *ctx)
|
||||
{
|
||||
int ret;
|
||||
struct patch_entry entry;
|
||||
|
||||
DBGPRINT("start post_patch");
|
||||
|
||||
entry.data[0] = HCI_COMMAND_PKT;
|
||||
entry.data[1] = 0x11;
|
||||
entry.data[2] = 0xFC;
|
||||
entry.data[3] = 0x02;
|
||||
entry.data[4] = 0x00;
|
||||
if (ctx->reset_enable_patch)
|
||||
entry.data[5] = 0x02;
|
||||
else
|
||||
entry.data[5] = 0x01;
|
||||
|
||||
entry.len = HCI_TYPE_LEN + HCI_COMMAND_HDR_SIZE + INTEL_MFG_PARAM_LEN;
|
||||
|
||||
ret = intel_write_cmd(ctx->dev, entry.data, entry.len);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "failed to send cmd(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = intel_read_evt(ctx->dev, entry.data, sizeof(entry.data));
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "failed to read evt(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
entry.len = ret;
|
||||
|
||||
if (entry.data[6] != 0x00) {
|
||||
fprintf(stderr, "cmd failed. st=%02x\n", entry.data[6]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
do {
|
||||
ret = intel_read_evt(ctx->dev, entry.data,
|
||||
sizeof(entry.data));
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "failed to read cmd(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
entry.len = ret;
|
||||
} while (!is_startup_evt(entry.data));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main routine that handles the device patching process.
|
||||
*/
|
||||
static int intel_patch_device(struct patch_ctx *ctx)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = pre_patch(ctx);
|
||||
if (ret < 0) {
|
||||
if (!ctx->patch_error) {
|
||||
fprintf(stderr, "I/O error: pre_patch failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
DBGPRINT("patch failed. proceed to post patch");
|
||||
goto post_patch;
|
||||
}
|
||||
|
||||
ret = intel_download_patch(ctx);
|
||||
if (ret < 0) {
|
||||
if (!ctx->patch_error) {
|
||||
fprintf(stderr, "I/O error: download_patch failed\n");
|
||||
close(ctx->fd);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
DBGPRINT("patch done");
|
||||
ctx->reset_enable_patch = 1;
|
||||
}
|
||||
|
||||
close(ctx->fd);
|
||||
|
||||
post_patch:
|
||||
ret = post_patch(ctx);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "post_patch failed(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_rts(int dev, int rtsval)
|
||||
{
|
||||
int arg;
|
||||
|
||||
if (ioctl(dev, TIOCMGET, &arg) < 0) {
|
||||
perror("cannot get TIOCMGET");
|
||||
return -errno;
|
||||
}
|
||||
if (rtsval)
|
||||
arg |= TIOCM_RTS;
|
||||
else
|
||||
arg &= ~TIOCM_RTS;
|
||||
|
||||
if (ioctl(dev, TIOCMSET, &arg) == -1) {
|
||||
perror("cannot set TIOCMGET");
|
||||
return -errno;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned char get_intel_speed(int speed)
|
||||
{
|
||||
switch (speed) {
|
||||
case 9600:
|
||||
return 0x00;
|
||||
case 19200:
|
||||
return 0x01;
|
||||
case 38400:
|
||||
return 0x02;
|
||||
case 57600:
|
||||
return 0x03;
|
||||
case 115200:
|
||||
return 0x04;
|
||||
case 230400:
|
||||
return 0x05;
|
||||
case 460800:
|
||||
return 0x06;
|
||||
case 921600:
|
||||
return 0x07;
|
||||
case 1843200:
|
||||
return 0x08;
|
||||
case 3250000:
|
||||
return 0x09;
|
||||
case 2000000:
|
||||
return 0x0A;
|
||||
case 3000000:
|
||||
return 0x0B;
|
||||
default:
|
||||
return 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if it failed to change to new baudrate, it will rollback
|
||||
* to initial baudrate
|
||||
*/
|
||||
static int change_baudrate(int dev, int init_speed, int *speed,
|
||||
struct termios *ti)
|
||||
{
|
||||
int ret;
|
||||
unsigned char br;
|
||||
unsigned char cmd[5];
|
||||
unsigned char evt[7];
|
||||
|
||||
DBGPRINT("start baudrate change");
|
||||
|
||||
ret = set_rts(dev, 0);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "failed to clear RTS\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
cmd[0] = HCI_COMMAND_PKT;
|
||||
cmd[1] = 0x06;
|
||||
cmd[2] = 0xFC;
|
||||
cmd[3] = 0x01;
|
||||
|
||||
br = get_intel_speed(*speed);
|
||||
if (br == 0xFF) {
|
||||
fprintf(stderr, "speed %d is not supported\n", *speed);
|
||||
return -1;
|
||||
}
|
||||
cmd[4] = br;
|
||||
|
||||
ret = intel_write_cmd(dev, cmd, sizeof(cmd));
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "failed to send cmd(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* wait for buffer to be consumed by the controller
|
||||
*/
|
||||
usleep(300000);
|
||||
|
||||
if (set_speed(dev, ti, *speed) < 0) {
|
||||
fprintf(stderr, "can't set to new baud rate\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = set_rts(dev, 1);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "failed to set RTS\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = intel_read_evt(dev, evt, sizeof(evt));
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "failed to read evt(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (evt[4] != 0x00) {
|
||||
fprintf(stderr,
|
||||
"failed to change speed. use default speed %d\n",
|
||||
init_speed);
|
||||
*speed = init_speed;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* An entry point for Intel specific initialization
|
||||
*/
|
||||
int intel_init(int dev, int init_speed, int *speed, struct termios *ti)
|
||||
{
|
||||
int ret = 0;
|
||||
struct patch_ctx ctx;
|
||||
|
||||
if (change_baudrate(dev, init_speed, speed, ti) < 0)
|
||||
return -1;
|
||||
|
||||
ctx.dev = dev;
|
||||
ctx.patch_error = 0;
|
||||
ctx.reset_enable_patch = 0;
|
||||
|
||||
ret = intel_patch_device(&ctx);
|
||||
if (ret < 0)
|
||||
fprintf(stderr, "failed to initialize the device");
|
||||
|
||||
return ret;
|
||||
}
|
||||
273
external/cache/sources/hcitools/hciattach_qualcomm.c
vendored
Normal file
273
external/cache/sources/hcitools/hciattach_qualcomm.c
vendored
Normal file
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <syslog.h>
|
||||
#include <termios.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/hci.h>
|
||||
#include <bluetooth/hci_lib.h>
|
||||
|
||||
#include "hciattach.h"
|
||||
|
||||
#define FAILIF(x, args...) do { \
|
||||
if (x) { \
|
||||
fprintf(stderr, ##args); \
|
||||
return -1; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
typedef struct {
|
||||
uint8_t uart_prefix;
|
||||
hci_event_hdr hci_hdr;
|
||||
evt_cmd_complete cmd_complete;
|
||||
uint8_t status;
|
||||
uint8_t data[16];
|
||||
} __attribute__((packed)) command_complete_t;
|
||||
|
||||
static int read_command_complete(int fd,
|
||||
unsigned short opcode,
|
||||
unsigned char len)
|
||||
{
|
||||
command_complete_t resp;
|
||||
unsigned char vsevent[512];
|
||||
int n;
|
||||
|
||||
/* Read reply. */
|
||||
n = read_hci_event(fd, vsevent, sizeof(vsevent));
|
||||
FAILIF(n < 0, "Failed to read response");
|
||||
|
||||
FAILIF(vsevent[1] != 0xFF, "Failed to read response");
|
||||
|
||||
n = read_hci_event(fd, (unsigned char *)&resp, sizeof(resp));
|
||||
FAILIF(n < 0, "Failed to read response");
|
||||
|
||||
/* event must be event-complete */
|
||||
FAILIF(resp.hci_hdr.evt != EVT_CMD_COMPLETE,
|
||||
"Error in response: not a cmd-complete event, "
|
||||
"but 0x%02x!\n", resp.hci_hdr.evt);
|
||||
|
||||
FAILIF(resp.hci_hdr.plen < 4, /* plen >= 4 for EVT_CMD_COMPLETE */
|
||||
"Error in response: plen is not >= 4, but 0x%02x!\n",
|
||||
resp.hci_hdr.plen);
|
||||
|
||||
/* cmd-complete event: opcode */
|
||||
FAILIF(resp.cmd_complete.opcode != 0,
|
||||
"Error in response: opcode is 0x%04x, not 0!",
|
||||
resp.cmd_complete.opcode);
|
||||
|
||||
return resp.status == 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
static int qualcomm_load_firmware(int fd, const char *firmware, const char *bdaddr_s)
|
||||
{
|
||||
|
||||
int fw = open(firmware, O_RDONLY);
|
||||
|
||||
fprintf(stdout, "Opening firmware file: %s\n", firmware);
|
||||
|
||||
FAILIF(fw < 0,
|
||||
"Could not open firmware file %s: %s (%d).\n",
|
||||
firmware, strerror(errno), errno);
|
||||
|
||||
fprintf(stdout, "Uploading firmware...\n");
|
||||
do {
|
||||
/* Read each command and wait for a response. */
|
||||
unsigned char data[1024];
|
||||
unsigned char cmdp[1 + sizeof(hci_command_hdr)];
|
||||
hci_command_hdr *cmd = (hci_command_hdr *) (cmdp + 1);
|
||||
int nr;
|
||||
|
||||
nr = read(fw, cmdp, sizeof(cmdp));
|
||||
if (!nr)
|
||||
break;
|
||||
|
||||
FAILIF(nr != sizeof(cmdp),
|
||||
"Could not read H4 + HCI header!\n");
|
||||
FAILIF(*cmdp != HCI_COMMAND_PKT,
|
||||
"Command is not an H4 command packet!\n");
|
||||
|
||||
FAILIF(read(fw, data, cmd->plen) != cmd->plen,
|
||||
"Could not read %d bytes of data \
|
||||
for command with opcode %04x!\n",
|
||||
cmd->plen, cmd->opcode);
|
||||
|
||||
if ((data[0] == 1) && (data[1] == 2) && (data[2] == 6)) {
|
||||
bdaddr_t bdaddr;
|
||||
if (bdaddr_s != NULL) {
|
||||
str2ba(bdaddr_s, &bdaddr);
|
||||
memcpy(&data[3], &bdaddr, sizeof(bdaddr_t));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int nw;
|
||||
struct iovec iov_cmd[2];
|
||||
iov_cmd[0].iov_base = cmdp;
|
||||
iov_cmd[0].iov_len = sizeof(cmdp);
|
||||
iov_cmd[1].iov_base = data;
|
||||
iov_cmd[1].iov_len = cmd->plen;
|
||||
nw = writev(fd, iov_cmd, 2);
|
||||
FAILIF(nw != (int) sizeof(cmdp) + cmd->plen,
|
||||
"Could not send entire command \
|
||||
(sent only %d bytes)!\n",
|
||||
nw);
|
||||
}
|
||||
|
||||
/* Wait for response */
|
||||
if (read_command_complete(fd, cmd->opcode, cmd->plen) < 0)
|
||||
return -1;
|
||||
} while (1);
|
||||
fprintf(stdout, "Firmware upload successful.\n");
|
||||
|
||||
close(fw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qualcomm_init(int fd, int speed, struct termios *ti, const char *bdaddr)
|
||||
{
|
||||
struct timespec tm = {0, 50000};
|
||||
char cmd[5];
|
||||
unsigned char resp[100]; /* Response */
|
||||
char fw[100];
|
||||
int n;
|
||||
|
||||
memset(resp, 0, 100);
|
||||
|
||||
/* Get Manufacturer and LMP version */
|
||||
cmd[0] = HCI_COMMAND_PKT;
|
||||
cmd[1] = 0x01;
|
||||
cmd[2] = 0x10;
|
||||
cmd[3] = 0x00;
|
||||
|
||||
do {
|
||||
n = write(fd, cmd, 4);
|
||||
if (n < 4) {
|
||||
perror("Failed to write init command");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read reply. */
|
||||
if (read_hci_event(fd, resp, 100) < 0) {
|
||||
perror("Failed to read init response");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Wait for command complete event for our Opcode */
|
||||
} while (resp[4] != cmd[1] && resp[5] != cmd[2]);
|
||||
|
||||
/* Verify manufacturer */
|
||||
if ((resp[11] & 0xFF) != 0x1d)
|
||||
fprintf(stderr,
|
||||
"WARNING : module's manufacturer is not Qualcomm\n");
|
||||
|
||||
/* Print LMP version */
|
||||
fprintf(stderr,
|
||||
"Qualcomm module LMP version : 0x%02x\n", resp[10] & 0xFF);
|
||||
|
||||
/* Print LMP subversion */
|
||||
{
|
||||
unsigned short lmp_subv = resp[13] | (resp[14] << 8);
|
||||
|
||||
fprintf(stderr, "Qualcomm module LMP sub-version : 0x%04x\n",
|
||||
lmp_subv);
|
||||
}
|
||||
|
||||
/* Get SoC type */
|
||||
cmd[0] = HCI_COMMAND_PKT;
|
||||
cmd[1] = 0x00;
|
||||
cmd[2] = 0xFC;
|
||||
cmd[3] = 0x01;
|
||||
cmd[4] = 0x06;
|
||||
|
||||
do {
|
||||
n = write(fd, cmd, 5);
|
||||
if (n < 5) {
|
||||
perror("Failed to write vendor init command");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read reply. */
|
||||
if ((n = read_hci_event(fd, resp, 100)) < 0) {
|
||||
perror("Failed to read vendor init response");
|
||||
return -1;
|
||||
}
|
||||
|
||||
} while (resp[3] != 0 && resp[4] != 2);
|
||||
|
||||
snprintf(fw, sizeof(fw), "/etc/firmware/%c%c%c%c%c%c_%c%c%c%c.bin",
|
||||
resp[18], resp[19], resp[20], resp[21],
|
||||
resp[22], resp[23],
|
||||
resp[32], resp[33], resp[34], resp[35]);
|
||||
|
||||
/* Wait for command complete event for our Opcode */
|
||||
if (read_hci_event(fd, resp, 100) < 0) {
|
||||
perror("Failed to read init response");
|
||||
return -1;
|
||||
}
|
||||
|
||||
qualcomm_load_firmware(fd, fw, bdaddr);
|
||||
|
||||
/* Reset */
|
||||
cmd[0] = HCI_COMMAND_PKT;
|
||||
cmd[1] = 0x03;
|
||||
cmd[2] = 0x0C;
|
||||
cmd[3] = 0x00;
|
||||
|
||||
do {
|
||||
n = write(fd, cmd, 4);
|
||||
if (n < 4) {
|
||||
perror("Failed to write reset command");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read reply. */
|
||||
if ((n = read_hci_event(fd, resp, 100)) < 0) {
|
||||
perror("Failed to read reset response");
|
||||
return -1;
|
||||
}
|
||||
|
||||
} while (resp[4] != cmd[1] && resp[5] != cmd[2]);
|
||||
|
||||
nanosleep(&tm, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
2563
external/cache/sources/hcitools/hciattach_rtk.c
vendored
Normal file
2563
external/cache/sources/hcitools/hciattach_rtk.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
707
external/cache/sources/hcitools/hciattach_sprd.c
vendored
Normal file
707
external/cache/sources/hcitools/hciattach_sprd.c
vendored
Normal file
@@ -0,0 +1,707 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <limits.h>
|
||||
#include "hciattach.h"
|
||||
|
||||
/******************************************************************************
|
||||
** Constants & Macros
|
||||
******************************************************************************/
|
||||
#define LOG_STR "SPRD Bluetooth"
|
||||
#define DBG_ON 1
|
||||
|
||||
#define SPRD_DBG(fmt, arg...) \
|
||||
do { \
|
||||
if (DBG_ON) \
|
||||
fprintf(stderr, "%s: " fmt "\n" , LOG_STR, ##arg); \
|
||||
} while(0)
|
||||
|
||||
#define SPRD_ERR(fmt, arg...) \
|
||||
do { \
|
||||
fprintf(stderr, "%s ERROR: " fmt "\n", LOG_STR, ##arg);\
|
||||
perror(LOG_STR" ERROR reason"); \
|
||||
} while(0)
|
||||
|
||||
#define SPRD_DUMP(buffer, len) \
|
||||
fprintf(stderr, "%s: ", LOG_STR); \
|
||||
do { \
|
||||
for (int i = 0; i < len; i++) { \
|
||||
if (i && !(i % 16)) { \
|
||||
fprintf(stderr, "\n"); \
|
||||
fprintf(stderr, "%s: ", LOG_STR); \
|
||||
} \
|
||||
fprintf(stderr, "%02x ", buffer[i]); \
|
||||
} \
|
||||
fprintf(stderr, "\n"); \
|
||||
} while (0)
|
||||
|
||||
#define CONF_ITEM_TABLE(ITEM, ACTION, BUF, LEN) \
|
||||
{ #ITEM, ACTION, &(BUF.ITEM), LEN, (sizeof(BUF.ITEM) / LEN) }
|
||||
|
||||
#define UINT8_TO_STREAM(p, u8) \
|
||||
{ *(p)++ = (uint8_t)(u8); }
|
||||
|
||||
#define STREAM_TO_UINT8(u8, p) \
|
||||
{ \
|
||||
(u8) = (uint8_t)(*(p)); \
|
||||
(p) += 1; \
|
||||
}
|
||||
|
||||
#define UINT16_TO_STREAM(p, u16) \
|
||||
{ \
|
||||
*(p)++ = (uint8_t)(u16); \
|
||||
*(p)++ = (uint8_t)((u16) >> 8); \
|
||||
}
|
||||
|
||||
#define STREAM_TO_UINT16(u16, p) \
|
||||
{ \
|
||||
(u16) = ((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8)); \
|
||||
(p) += 2; \
|
||||
}
|
||||
|
||||
#define UINT32_TO_STREAM(p, u32) \
|
||||
{ \
|
||||
*(p)++ = (uint8_t)(u32); \
|
||||
*(p)++ = (uint8_t)((u32) >> 8); \
|
||||
*(p)++ = (uint8_t)((u32) >> 16); \
|
||||
*(p)++ = (uint8_t)((u32) >> 24); \
|
||||
}
|
||||
|
||||
#define CONF_COMMENT '#'
|
||||
#define CONF_DELIMITERS " =\n\r\t"
|
||||
#define CONF_VALUES_DELIMITERS "=\n\r\t#"
|
||||
#define CONF_VALUES_PARTITION " ,=\n\r\t#"
|
||||
#define CONF_MAX_LINE_LEN 255
|
||||
|
||||
#define HCI_PSKEY 0xFCA0
|
||||
#define HCI_VSC_ENABLE_COMMMAND 0xFCA1
|
||||
#define HCI_RF_PARA 0xFCA2
|
||||
|
||||
#define RESPONSE_LENGTH 100
|
||||
#define HCI_CMD_MAX_LEN 258
|
||||
#define HCI_EVT_CMD_CMPL_OPCODE 3
|
||||
#define HCI_PACKET_TYPE_COMMAND 1
|
||||
#define HCI_CMD_PREAMBLE_SIZE 3
|
||||
|
||||
#define FW_NODE_BYTE 6
|
||||
#define FW_DATE_D_BYTE 8
|
||||
#define FW_DATE_M_BYTE 9
|
||||
#define FW_DATE_Y_BYTE 10
|
||||
|
||||
#define BT_CONFIG_PATH "/lib/firmware"
|
||||
#define BT_HC_HDR_SIZE (sizeof(HC_BT_HDR))
|
||||
#define BT_VND_OP_RESULT_SUCCESS 0
|
||||
#define BT_VND_OP_RESULT_FAIL 1
|
||||
#define MSG_STACK_TO_HC_HCI_CMD 0x2000
|
||||
#define START_STOP_CMD_SIZE 3
|
||||
#define DUAL_MODE 0
|
||||
#define DISABLE_BT 0
|
||||
#define ENABLE_BT 1
|
||||
|
||||
typedef void (*hci_cback)(void *);
|
||||
typedef int (conf_action_t)(char *p_conf_name, char *p_conf_value, void *buf, int len, int size);
|
||||
|
||||
typedef struct {
|
||||
uint16_t event;
|
||||
uint16_t len;
|
||||
uint16_t offset;
|
||||
uint16_t layer_specific;
|
||||
uint8_t data[];
|
||||
} HC_BT_HDR;
|
||||
|
||||
typedef struct {
|
||||
uint32_t device_class;
|
||||
uint8_t feature_set[16];
|
||||
uint8_t device_addr[6];
|
||||
uint16_t comp_id;
|
||||
uint8_t g_sys_uart0_communication_supported;
|
||||
uint8_t cp2_log_mode;
|
||||
uint8_t LogLevel;
|
||||
uint8_t g_central_or_perpheral;
|
||||
uint16_t Log_BitMask;
|
||||
uint8_t super_ssp_enable;
|
||||
uint8_t common_rfu_b3;
|
||||
uint32_t common_rfu_w[2];
|
||||
uint32_t le_rfu_w[2];
|
||||
uint32_t lmp_rfu_w[2];
|
||||
uint32_t lc_rfu_w[2];
|
||||
uint16_t g_wbs_nv_117;
|
||||
uint16_t g_wbs_nv_118;
|
||||
uint16_t g_nbv_nv_117;
|
||||
uint16_t g_nbv_nv_118;
|
||||
uint8_t g_sys_sco_transmit_mode;
|
||||
uint8_t audio_rfu_b1;
|
||||
uint8_t audio_rfu_b2;
|
||||
uint8_t audio_rfu_b3;
|
||||
uint32_t audio_rfu_w[2];
|
||||
uint8_t g_sys_sleep_in_standby_supported;
|
||||
uint8_t g_sys_sleep_master_supported;
|
||||
uint8_t g_sys_sleep_slave_supported;
|
||||
uint8_t power_rfu_b1;
|
||||
uint32_t power_rfu_w[2];
|
||||
uint32_t win_ext;
|
||||
uint8_t edr_tx_edr_delay;
|
||||
uint8_t edr_rx_edr_delay;
|
||||
uint8_t tx_delay;
|
||||
uint8_t rx_delay;
|
||||
uint32_t bb_rfu_w[2];
|
||||
uint8_t agc_mode;
|
||||
uint8_t diff_or_eq;
|
||||
uint8_t ramp_mode;
|
||||
uint8_t modem_rfu_b1;
|
||||
uint32_t modem_rfu_w[2];
|
||||
uint32_t BQB_BitMask_1;
|
||||
uint32_t BQB_BitMask_2;
|
||||
uint16_t bt_coex_threshold[8];
|
||||
uint32_t other_rfu_w[6];
|
||||
} pskey_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t g_GainValue_A[6];
|
||||
uint16_t g_ClassicPowerValue_A[10];
|
||||
uint16_t g_LEPowerValue_A[16];
|
||||
uint16_t g_BRChannelpwrvalue_A[8];
|
||||
uint16_t g_EDRChannelpwrvalue_A[8];
|
||||
uint16_t g_LEChannelpwrvalue_A[8];
|
||||
uint16_t g_GainValue_B[6];
|
||||
uint16_t g_ClassicPowerValue_B[10];
|
||||
uint16_t g_LEPowerValue_B[16];
|
||||
uint16_t g_BRChannelpwrvalue_B[8];
|
||||
uint16_t g_EDRChannelpwrvalue_B[8];
|
||||
uint16_t g_LEChannelpwrvalue_B[8];
|
||||
uint16_t LE_fix_powerword;
|
||||
uint8_t Classic_pc_by_channel;
|
||||
uint8_t LE_pc_by_channel;
|
||||
uint8_t RF_switch_mode;
|
||||
uint8_t Data_Capture_Mode;
|
||||
uint8_t Analog_IQ_Debug_Mode;
|
||||
uint8_t RF_common_rfu_b3;
|
||||
uint32_t RF_common_rfu_w[5];
|
||||
} rf_config_t;
|
||||
|
||||
typedef struct {
|
||||
const char *conf_entry;
|
||||
conf_action_t *p_action;
|
||||
void *buf;
|
||||
int len;
|
||||
int size;
|
||||
} conf_entry_t;
|
||||
|
||||
static uint8_t local_bdaddr[6]={0x10, 0x11, 0x12, 0x13, 0x14, 0x15};
|
||||
static pskey_config_t marlin3_pskey;
|
||||
static rf_config_t marlin3_rf_config;
|
||||
static int s_bt_fd = -1;
|
||||
|
||||
static const conf_entry_t marlin3_pksey_table[] = {
|
||||
CONF_ITEM_TABLE(device_class, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(feature_set, 0, marlin3_pskey, 16),
|
||||
CONF_ITEM_TABLE(device_addr, 0, marlin3_pskey, 6),
|
||||
CONF_ITEM_TABLE(comp_id, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(g_sys_uart0_communication_supported, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(cp2_log_mode, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(LogLevel, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(g_central_or_perpheral, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(Log_BitMask, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(super_ssp_enable, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(common_rfu_b3, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(common_rfu_w, 0, marlin3_pskey, 2),
|
||||
CONF_ITEM_TABLE(le_rfu_w, 0, marlin3_pskey, 2),
|
||||
CONF_ITEM_TABLE(lmp_rfu_w, 0, marlin3_pskey, 2),
|
||||
CONF_ITEM_TABLE(lc_rfu_w, 0, marlin3_pskey, 2),
|
||||
CONF_ITEM_TABLE(g_wbs_nv_117, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(g_wbs_nv_118, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(g_nbv_nv_117, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(g_nbv_nv_118, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(g_sys_sco_transmit_mode, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(audio_rfu_b1, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(audio_rfu_b2, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(audio_rfu_b3, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(audio_rfu_w, 0, marlin3_pskey, 2),
|
||||
CONF_ITEM_TABLE(g_sys_sleep_in_standby_supported, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(g_sys_sleep_master_supported, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(g_sys_sleep_slave_supported, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(power_rfu_b1, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(power_rfu_w, 0, marlin3_pskey, 2),
|
||||
CONF_ITEM_TABLE(win_ext, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(edr_tx_edr_delay, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(edr_rx_edr_delay, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(tx_delay, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(rx_delay, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(bb_rfu_w, 0, marlin3_pskey, 2),
|
||||
CONF_ITEM_TABLE(agc_mode, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(diff_or_eq, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(ramp_mode, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(modem_rfu_b1, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(modem_rfu_w, 0, marlin3_pskey, 2),
|
||||
CONF_ITEM_TABLE(BQB_BitMask_1, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(BQB_BitMask_2, 0, marlin3_pskey, 1),
|
||||
CONF_ITEM_TABLE(bt_coex_threshold, 0, marlin3_pskey, 8),
|
||||
CONF_ITEM_TABLE(other_rfu_w, 0, marlin3_pskey, 6),
|
||||
{0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static const conf_entry_t marlin3_rf_table[] = {
|
||||
CONF_ITEM_TABLE(g_GainValue_A, 0, marlin3_rf_config, 6),
|
||||
CONF_ITEM_TABLE(g_ClassicPowerValue_A, 0, marlin3_rf_config, 10),
|
||||
CONF_ITEM_TABLE(g_LEPowerValue_A, 0, marlin3_rf_config, 16),
|
||||
CONF_ITEM_TABLE(g_BRChannelpwrvalue_A, 0, marlin3_rf_config, 8),
|
||||
CONF_ITEM_TABLE(g_EDRChannelpwrvalue_A, 0, marlin3_rf_config, 8),
|
||||
CONF_ITEM_TABLE(g_LEChannelpwrvalue_A, 0, marlin3_rf_config, 8),
|
||||
CONF_ITEM_TABLE(g_GainValue_B, 0, marlin3_rf_config, 6),
|
||||
CONF_ITEM_TABLE(g_ClassicPowerValue_B, 0, marlin3_rf_config, 10),
|
||||
CONF_ITEM_TABLE(g_LEPowerValue_B, 0, marlin3_rf_config, 16),
|
||||
CONF_ITEM_TABLE(g_BRChannelpwrvalue_B, 0, marlin3_rf_config, 8),
|
||||
CONF_ITEM_TABLE(g_EDRChannelpwrvalue_B, 0, marlin3_rf_config, 8),
|
||||
CONF_ITEM_TABLE(g_LEChannelpwrvalue_B, 0, marlin3_rf_config, 8),
|
||||
CONF_ITEM_TABLE(LE_fix_powerword, 0, marlin3_rf_config, 1),
|
||||
CONF_ITEM_TABLE(Classic_pc_by_channel, 0, marlin3_rf_config, 1),
|
||||
CONF_ITEM_TABLE(LE_pc_by_channel, 0, marlin3_rf_config, 1),
|
||||
CONF_ITEM_TABLE(RF_switch_mode, 0, marlin3_rf_config, 1),
|
||||
CONF_ITEM_TABLE(Data_Capture_Mode, 0, marlin3_rf_config, 1),
|
||||
CONF_ITEM_TABLE(Analog_IQ_Debug_Mode, 0, marlin3_rf_config, 1),
|
||||
CONF_ITEM_TABLE(RF_common_rfu_b3, 0, marlin3_rf_config, 1),
|
||||
CONF_ITEM_TABLE(RF_common_rfu_w, 0, marlin3_rf_config, 5),
|
||||
{0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static void log_bin_to_hexstr(uint8_t *bin, uint8_t binsz, const char *log_tag)
|
||||
{
|
||||
SPRD_DBG("%s", log_tag);
|
||||
SPRD_DUMP(bin, binsz);
|
||||
}
|
||||
|
||||
static void parse_number(char *p_conf_name, char *p_conf_value, void *buf, int len, int size)
|
||||
{
|
||||
uint8_t *dest = (uint8_t *)buf;
|
||||
char *sub_value, *p;
|
||||
uint32_t value;
|
||||
(void)p_conf_name;
|
||||
sub_value = strtok_r(p_conf_value, CONF_VALUES_PARTITION, &p);
|
||||
do {
|
||||
if (sub_value == NULL)
|
||||
break;
|
||||
|
||||
if (sub_value[0] == '0' && (sub_value[1] == 'x' || sub_value[1] == 'X'))
|
||||
value = strtoul(sub_value, 0, 16) & 0xFFFFFFFF;
|
||||
else
|
||||
value = strtoul(sub_value, 0, 10) & 0xFFFFFFFF;
|
||||
|
||||
switch (size) {
|
||||
case sizeof(uint8_t):
|
||||
*dest = value & 0xFF;
|
||||
dest += size;
|
||||
break;
|
||||
|
||||
case sizeof(uint16_t):
|
||||
*((uint16_t *)dest) = value & 0xFFFF;
|
||||
dest += size;
|
||||
break;
|
||||
|
||||
case sizeof(uint32_t):
|
||||
*((uint32_t *)dest) = value & 0xFFFFFFFF;
|
||||
dest += size;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sub_value = strtok_r(NULL, CONF_VALUES_PARTITION, &p);
|
||||
} while (--len);
|
||||
}
|
||||
|
||||
static void set_mac_address(uint8_t *addr)
|
||||
{
|
||||
int i = 0;
|
||||
SPRD_DBG("%s", __func__);
|
||||
for (i = 0; i < 6; i++)
|
||||
addr[5-i] = (unsigned char)local_bdaddr[i];
|
||||
}
|
||||
|
||||
static void vnd_load_configure(const char *p_path, const conf_entry_t *entry)
|
||||
{
|
||||
FILE *p_file;
|
||||
char *p_name, *p_value, *p;
|
||||
conf_entry_t *p_entry;
|
||||
char line[CONF_MAX_LINE_LEN + 1]; /* add 1 for \0 char */
|
||||
|
||||
SPRD_DBG("Attempt to load conf from %s", p_path);
|
||||
|
||||
if ((p_file = fopen(p_path, "r")) != NULL) {
|
||||
/* read line by line */
|
||||
while (fgets(line, CONF_MAX_LINE_LEN + 1, p_file) != NULL) {
|
||||
if (line[0] == CONF_COMMENT) continue;
|
||||
|
||||
p_name = strtok_r(line, CONF_DELIMITERS, &p);
|
||||
|
||||
if (NULL == p_name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
p_value = strtok_r(NULL, CONF_VALUES_DELIMITERS, &p);
|
||||
|
||||
if (NULL == p_value) {
|
||||
SPRD_DBG("vnd_load_conf: missing value for name: %s", p_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
p_entry = (conf_entry_t*)entry;
|
||||
|
||||
while (p_entry->conf_entry != NULL) {
|
||||
if (strcmp(p_entry->conf_entry, (const char *)p_name) == 0) {
|
||||
if (p_entry->p_action) {
|
||||
p_entry->p_action(p_name, p_value, p_entry->buf, p_entry->len,
|
||||
p_entry->size);
|
||||
} else {
|
||||
SPRD_DBG("%s -> %s", p_name, p_value);
|
||||
parse_number(p_name, p_value, p_entry->buf, p_entry->len,
|
||||
p_entry->size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
p_entry++;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(p_file);
|
||||
} else {
|
||||
SPRD_DBG("vnd_load_conf file >%s< not found", p_path);
|
||||
}
|
||||
}
|
||||
|
||||
static size_t H4Protocol_Send(uint8_t type, const uint8_t* data, size_t length)
|
||||
{
|
||||
struct iovec iov[] = {
|
||||
{&type, sizeof(type)},
|
||||
{(uint8_t *)data, length}};
|
||||
|
||||
ssize_t ret = 0;
|
||||
do {
|
||||
ret = writev(s_bt_fd, iov, sizeof(iov) / sizeof(iov[0]));
|
||||
} while (-1 == ret && EAGAIN == errno);
|
||||
|
||||
if (ret == -1) {
|
||||
SPRD_ERR("%s error writing to UART (%s)", __func__, strerror(errno));
|
||||
} else if (ret < length + 1) {
|
||||
SPRD_ERR("%s: %d / %d bytes written - something went wrong...", __func__, ret, length + 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *bt_vendor_alloc(int size)
|
||||
{
|
||||
void *p = (uint8_t *)malloc(size);
|
||||
return p;
|
||||
}
|
||||
|
||||
static void bt_vendor_free(void *buffer)
|
||||
{
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
static uint8_t bt_vendor_xmit(uint16_t opcode, void* buffer, hci_cback callback)
|
||||
{
|
||||
uint8_t type = HCI_PACKET_TYPE_COMMAND;
|
||||
(void)opcode;
|
||||
HC_BT_HDR* bt_hdr = (HC_BT_HDR *)buffer;
|
||||
H4Protocol_Send(type, bt_hdr->data, bt_hdr->len);
|
||||
return BT_VND_OP_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static uint8_t sprd_vnd_send_hci_vsc(uint16_t cmd, uint8_t *payload, uint8_t len, hci_cback cback)
|
||||
{
|
||||
HC_BT_HDR *p_buf;
|
||||
uint8_t *p, ret;
|
||||
|
||||
p_buf = (HC_BT_HDR *)bt_vendor_alloc(
|
||||
BT_HC_HDR_SIZE + HCI_CMD_PREAMBLE_SIZE + len);
|
||||
if (p_buf) {
|
||||
p_buf->event = MSG_STACK_TO_HC_HCI_CMD;
|
||||
p_buf->offset = 0;
|
||||
p_buf->layer_specific = 0;
|
||||
p_buf->len = HCI_CMD_PREAMBLE_SIZE + len;
|
||||
p = (uint8_t *)(p_buf + 1);
|
||||
|
||||
UINT16_TO_STREAM(p, cmd);
|
||||
*p++ = len;
|
||||
memcpy(p, payload, len);
|
||||
log_bin_to_hexstr((uint8_t *)(p_buf + 1), HCI_CMD_PREAMBLE_SIZE + len, __FUNCTION__);
|
||||
ret = bt_vendor_xmit(cmd, p_buf, cback);
|
||||
bt_vendor_free(p_buf);
|
||||
return ret;
|
||||
}
|
||||
return BT_VND_OP_RESULT_FAIL;
|
||||
}
|
||||
|
||||
static void hw_core_cback(void *p_mem)
|
||||
{
|
||||
uint8_t *p_evt_buf = (uint8_t *)p_mem;
|
||||
uint8_t *p, status;
|
||||
uint16_t opcode, mode;
|
||||
|
||||
p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE;
|
||||
STREAM_TO_UINT16(opcode,p);
|
||||
STREAM_TO_UINT16(mode,p);
|
||||
STREAM_TO_UINT8(status,p);
|
||||
SPRD_DBG("%s hw_core_cback response: [0x%04X, 0x%04X, 0x%02X]", __func__, opcode, mode, status);
|
||||
bt_vendor_free(p_evt_buf);
|
||||
}
|
||||
|
||||
static void hw_core_enable(unsigned char enable)
|
||||
{
|
||||
uint8_t *p, msg_req[HCI_CMD_MAX_LEN];
|
||||
p = msg_req;
|
||||
UINT16_TO_STREAM(p, DUAL_MODE);
|
||||
UINT8_TO_STREAM(p, enable ? ENABLE_BT : DISABLE_BT);
|
||||
sprd_vnd_send_hci_vsc(HCI_VSC_ENABLE_COMMMAND, msg_req, (uint8_t)(p - msg_req), NULL);
|
||||
}
|
||||
|
||||
static void hw_rf_cback(void *p_mem)
|
||||
{
|
||||
uint8_t *p_evt_buf = (uint8_t *)p_mem, len;
|
||||
uint8_t *p, status;
|
||||
uint16_t opcode, mode = 0;
|
||||
|
||||
p = (uint8_t *)(p_evt_buf + 1) + 1;
|
||||
STREAM_TO_UINT8(len, p);
|
||||
|
||||
p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE;
|
||||
STREAM_TO_UINT16(opcode, p);
|
||||
if (len == 6)
|
||||
STREAM_TO_UINT16(mode, p);
|
||||
|
||||
STREAM_TO_UINT8(status, p);
|
||||
|
||||
SPRD_DBG("%s hw_rf_cback response: [0x%04X, 0x%04X, 0x%02X]", __func__, opcode, mode, status);
|
||||
/* Must free the RX event buffer */
|
||||
bt_vendor_free(p_evt_buf);
|
||||
}
|
||||
|
||||
static int marlin3_rf_preload()
|
||||
{
|
||||
uint8_t *p, msg_req[HCI_CMD_MAX_LEN];
|
||||
int i;
|
||||
|
||||
SPRD_DBG("yujian.qin %s", __FUNCTION__);
|
||||
p = msg_req;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_GainValue_A[i]);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_ClassicPowerValue_A[i]);
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_LEPowerValue_A[i]);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_BRChannelpwrvalue_A[i]);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_EDRChannelpwrvalue_A[i]);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_LEChannelpwrvalue_A[i]);
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_GainValue_B[i]);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_ClassicPowerValue_B[i]);
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_LEPowerValue_B[i]);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_BRChannelpwrvalue_B[i]);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_EDRChannelpwrvalue_B[i]);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.g_LEChannelpwrvalue_B[i]);
|
||||
|
||||
UINT16_TO_STREAM(p, marlin3_rf_config.LE_fix_powerword);
|
||||
|
||||
UINT8_TO_STREAM(p, marlin3_rf_config.Classic_pc_by_channel);
|
||||
UINT8_TO_STREAM(p, marlin3_rf_config.LE_pc_by_channel);
|
||||
UINT8_TO_STREAM(p, marlin3_rf_config.RF_switch_mode);
|
||||
UINT8_TO_STREAM(p, marlin3_rf_config.Data_Capture_Mode);
|
||||
UINT8_TO_STREAM(p, marlin3_rf_config.Analog_IQ_Debug_Mode);
|
||||
UINT8_TO_STREAM(p, marlin3_rf_config.RF_common_rfu_b3);
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
UINT32_TO_STREAM(p, marlin3_rf_config.RF_common_rfu_w[i]);
|
||||
|
||||
sprd_vnd_send_hci_vsc(HCI_RF_PARA, msg_req, (uint8_t)(p - msg_req), NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void marlin3_pskey_cback(void *p_mem)
|
||||
{
|
||||
uint8_t *p_evt_buf = (uint8_t *)p_mem;
|
||||
|
||||
uint16_t opcode, node, year;
|
||||
uint8_t *p, month, day;
|
||||
(void)opcode;
|
||||
|
||||
p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE;
|
||||
STREAM_TO_UINT16(opcode, p);
|
||||
|
||||
p = (uint8_t *)(p_evt_buf + 1) + FW_NODE_BYTE;
|
||||
STREAM_TO_UINT16(node, p);
|
||||
p = (uint8_t *)(p_evt_buf + 1) + FW_DATE_Y_BYTE;
|
||||
STREAM_TO_UINT16(year, p);
|
||||
p = (uint8_t *)(p_evt_buf + 1) + FW_DATE_M_BYTE;
|
||||
STREAM_TO_UINT8(month, p);
|
||||
p = (uint8_t *)(p_evt_buf + 1) + FW_DATE_D_BYTE;
|
||||
STREAM_TO_UINT8(day, p);
|
||||
|
||||
SPRD_DBG("Bluetooth Firmware Node: %04X Date: %04x-%02x-%02x", node, year, month, day);
|
||||
|
||||
/* Must free the RX event buffer */
|
||||
bt_vendor_free(p_evt_buf);
|
||||
}
|
||||
|
||||
static int marlin3_pskey_preload(void *arg)
|
||||
{
|
||||
uint8_t *p, msg_req[HCI_CMD_MAX_LEN];
|
||||
int i;
|
||||
(void)arg;
|
||||
|
||||
SPRD_DBG("%s", __FUNCTION__);
|
||||
p = msg_req;
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.device_class);
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.feature_set[i]);
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.device_addr[i]);
|
||||
|
||||
UINT16_TO_STREAM(p, marlin3_pskey.comp_id);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.g_sys_uart0_communication_supported);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.cp2_log_mode);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.LogLevel);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.g_central_or_perpheral);
|
||||
|
||||
UINT16_TO_STREAM(p, marlin3_pskey.Log_BitMask);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.super_ssp_enable);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.common_rfu_b3);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.common_rfu_w[i]);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.le_rfu_w[i]);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.lmp_rfu_w[i]);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.lc_rfu_w[i]);
|
||||
|
||||
UINT16_TO_STREAM(p, marlin3_pskey.g_wbs_nv_117);
|
||||
UINT16_TO_STREAM(p, marlin3_pskey.g_wbs_nv_118);
|
||||
UINT16_TO_STREAM(p, marlin3_pskey.g_nbv_nv_117);
|
||||
UINT16_TO_STREAM(p, marlin3_pskey.g_nbv_nv_118);
|
||||
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.g_sys_sco_transmit_mode);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.audio_rfu_b1);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.audio_rfu_b2);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.audio_rfu_b3);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.audio_rfu_w[i]);
|
||||
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.g_sys_sleep_in_standby_supported);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.g_sys_sleep_master_supported);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.g_sys_sleep_slave_supported);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.power_rfu_b1);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.power_rfu_w[i]);
|
||||
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.win_ext);
|
||||
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.edr_tx_edr_delay);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.edr_rx_edr_delay);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.tx_delay);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.rx_delay);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.bb_rfu_w[i]);
|
||||
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.agc_mode);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.diff_or_eq);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.ramp_mode);
|
||||
UINT8_TO_STREAM(p, marlin3_pskey.modem_rfu_b1);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.modem_rfu_w[i]);
|
||||
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.BQB_BitMask_1);
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.BQB_BitMask_2);
|
||||
for (i = 0; i < 8; i++)
|
||||
UINT16_TO_STREAM(p, marlin3_pskey.bt_coex_threshold[i]);
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
UINT32_TO_STREAM(p, marlin3_pskey.other_rfu_w[i]);
|
||||
|
||||
sprd_vnd_send_hci_vsc(HCI_PSKEY, msg_req, (uint8_t)(p - msg_req), NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int sprd_config_init(int fd, struct uart_t *u, struct termios *ti)
|
||||
{
|
||||
uint8_t *recv = NULL;
|
||||
int len = 0;
|
||||
|
||||
s_bt_fd = fd;
|
||||
|
||||
memset(&marlin3_pskey, 0, sizeof(marlin3_pskey));
|
||||
memset(&marlin3_rf_config, 0, sizeof(marlin3_rf_config));
|
||||
vnd_load_configure(BT_CONFIG_PATH "/bt_configure_pskey.ini", &marlin3_pksey_table[0]);
|
||||
vnd_load_configure(BT_CONFIG_PATH "/bt_configure_rf.ini", &marlin3_rf_table[0]);
|
||||
set_mac_address(marlin3_pskey.device_addr);
|
||||
|
||||
marlin3_pskey_preload(NULL);
|
||||
recv = bt_vendor_alloc(RESPONSE_LENGTH);
|
||||
len = read_hci_event(s_bt_fd, recv, RESPONSE_LENGTH);
|
||||
SPRD_DBG("Received event, len: %d", len);
|
||||
SPRD_DUMP(recv, len);
|
||||
marlin3_pskey_cback(recv);
|
||||
|
||||
marlin3_rf_preload();
|
||||
recv = bt_vendor_alloc(RESPONSE_LENGTH);
|
||||
len = read_hci_event(s_bt_fd, recv, RESPONSE_LENGTH);
|
||||
SPRD_DBG("Received event, len: %d", len);
|
||||
SPRD_DUMP(recv, len);
|
||||
hw_rf_cback(recv);
|
||||
|
||||
hw_core_enable(1);
|
||||
recv = bt_vendor_alloc(RESPONSE_LENGTH);
|
||||
len = read_hci_event(s_bt_fd, recv, RESPONSE_LENGTH);
|
||||
SPRD_DBG("Received event, len: %d", len);
|
||||
SPRD_DUMP(recv, len);
|
||||
hw_core_cback(recv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sprd_config_post(int fd, struct uart_t *u, struct termios *ti)
|
||||
{
|
||||
SPRD_DBG("Done setting line discpline");
|
||||
return 0;
|
||||
}
|
||||
|
||||
278
external/cache/sources/hcitools/hciattach_st.c
vendored
Normal file
278
external/cache/sources/hcitools/hciattach_st.c
vendored
Normal file
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
|
||||
#include "hciattach.h"
|
||||
|
||||
static int debug = 0;
|
||||
|
||||
static int do_command(int fd, uint8_t ogf, uint16_t ocf,
|
||||
uint8_t *cparam, int clen, uint8_t *rparam, int rlen)
|
||||
{
|
||||
//uint16_t opcode = (uint16_t) ((ocf & 0x03ff) | (ogf << 10));
|
||||
unsigned char cp[260], rp[260];
|
||||
int len, size, offset = 3;
|
||||
|
||||
cp[0] = 0x01;
|
||||
cp[1] = ocf & 0xff;
|
||||
cp[2] = ogf << 2 | ocf >> 8;
|
||||
cp[3] = clen;
|
||||
|
||||
if (clen > 0)
|
||||
memcpy(cp + 4, cparam, clen);
|
||||
|
||||
if (debug) {
|
||||
int i;
|
||||
printf("[<");
|
||||
for (i = 0; i < clen + 4; i++)
|
||||
printf(" %02x", cp[i]);
|
||||
printf("]\n");
|
||||
}
|
||||
|
||||
if (write(fd, cp, clen + 4) < 0)
|
||||
return -1;
|
||||
|
||||
do {
|
||||
if (read(fd, rp, 1) < 1)
|
||||
return -1;
|
||||
} while (rp[0] != 0x04);
|
||||
|
||||
if (read(fd, rp + 1, 2) < 2)
|
||||
return -1;
|
||||
|
||||
do {
|
||||
len = read(fd, rp + offset, sizeof(rp) - offset);
|
||||
offset += len;
|
||||
} while (offset < rp[2] + 3);
|
||||
|
||||
if (debug) {
|
||||
int i;
|
||||
printf("[>");
|
||||
for (i = 0; i < offset; i++)
|
||||
printf(" %02x", rp[i]);
|
||||
printf("]\n");
|
||||
}
|
||||
|
||||
if (rp[0] != 0x04) {
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (rp[1]) {
|
||||
case 0x0e: /* command complete */
|
||||
if (rp[6] != 0x00)
|
||||
return -ENXIO;
|
||||
offset = 3 + 4;
|
||||
size = rp[2] - 4;
|
||||
break;
|
||||
case 0x0f: /* command status */
|
||||
/* fall through */
|
||||
default:
|
||||
offset = 3;
|
||||
size = rp[2];
|
||||
break;
|
||||
}
|
||||
|
||||
if (!rparam || rlen < size)
|
||||
return -ENXIO;
|
||||
|
||||
memcpy(rparam, rp + offset, size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static int load_file(int dd, uint16_t version, const char *suffix)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *d;
|
||||
char pathname[PATH_MAX], filename[NAME_MAX], prefix[20];
|
||||
unsigned char cmd[256];
|
||||
unsigned char buf[256];
|
||||
uint8_t seqnum = 0;
|
||||
int fd, size, len, found_fw_file;
|
||||
|
||||
memset(filename, 0, sizeof(filename));
|
||||
|
||||
snprintf(prefix, sizeof(prefix), "STLC2500_R%d_%02d_",
|
||||
version >> 8, version & 0xff);
|
||||
|
||||
strcpy(pathname, "/lib/firmware");
|
||||
dir = opendir(pathname);
|
||||
if (!dir) {
|
||||
strcpy(pathname, ".");
|
||||
dir = opendir(pathname);
|
||||
if (!dir)
|
||||
return -errno;
|
||||
}
|
||||
|
||||
found_fw_file = 0;
|
||||
while (1) {
|
||||
d = readdir(dir);
|
||||
if (!d)
|
||||
break;
|
||||
|
||||
if (strncmp(d->d_name + strlen(d->d_name) - strlen(suffix),
|
||||
suffix, strlen(suffix)))
|
||||
continue;
|
||||
|
||||
if (strncmp(d->d_name, prefix, strlen(prefix)))
|
||||
continue;
|
||||
|
||||
snprintf(filename, sizeof(filename), "%s/%s",
|
||||
pathname, d->d_name);
|
||||
found_fw_file = 1;
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
if (!found_fw_file)
|
||||
return -ENOENT;
|
||||
|
||||
printf("Loading file %s\n", filename);
|
||||
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
perror("Can't open firmware file");
|
||||
return -errno;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
size = read(fd, cmd + 1, 254);
|
||||
if (size <= 0)
|
||||
break;
|
||||
|
||||
cmd[0] = seqnum;
|
||||
|
||||
len = do_command(dd, 0xff, 0x002e, cmd, size + 1, buf, sizeof(buf));
|
||||
if (len < 1)
|
||||
break;
|
||||
|
||||
if (buf[0] != seqnum) {
|
||||
fprintf(stderr, "Sequence number mismatch\n");
|
||||
break;
|
||||
}
|
||||
|
||||
seqnum++;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stlc2500_init(int dd, bdaddr_t *bdaddr)
|
||||
{
|
||||
unsigned char cmd[16];
|
||||
unsigned char buf[254];
|
||||
uint16_t version;
|
||||
int len;
|
||||
int err;
|
||||
|
||||
/* Hci_Cmd_Ericsson_Read_Revision_Information */
|
||||
len = do_command(dd, 0xff, 0x000f, NULL, 0, buf, sizeof(buf));
|
||||
if (len < 0)
|
||||
return -1;
|
||||
|
||||
printf("%s\n", buf);
|
||||
|
||||
/* HCI_Read_Local_Version_Information */
|
||||
len = do_command(dd, 0x04, 0x0001, NULL, 0, buf, sizeof(buf));
|
||||
if (len < 0)
|
||||
return -1;
|
||||
|
||||
version = buf[2] << 8 | buf[1];
|
||||
|
||||
err = load_file(dd, version, ".ptc");
|
||||
if (err < 0) {
|
||||
if (err == -ENOENT)
|
||||
fprintf(stderr, "No ROM patch file loaded.\n");
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
err = load_file(dd, buf[2] << 8 | buf[1], ".ssf");
|
||||
if (err < 0) {
|
||||
if (err == -ENOENT)
|
||||
fprintf(stderr, "No static settings file loaded.\n");
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmd[0] = 0xfe;
|
||||
cmd[1] = 0x06;
|
||||
bacpy((bdaddr_t *) (cmd + 2), bdaddr);
|
||||
|
||||
/* Hci_Cmd_ST_Store_In_NVDS */
|
||||
len = do_command(dd, 0xff, 0x0022, cmd, 8, buf, sizeof(buf));
|
||||
if (len < 0)
|
||||
return -1;
|
||||
|
||||
/* HCI_Reset : applies parameters*/
|
||||
len = do_command(dd, 0x03, 0x0003, NULL, 0, buf, sizeof(buf));
|
||||
if (len < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bgb2xx_init(int dd, bdaddr_t *bdaddr)
|
||||
{
|
||||
unsigned char cmd[16];
|
||||
unsigned char buf[254];
|
||||
int len;
|
||||
|
||||
len = do_command(dd, 0xff, 0x000f, NULL, 0, buf, sizeof(buf));
|
||||
if (len < 0)
|
||||
return -1;
|
||||
|
||||
printf("%s\n", buf);
|
||||
|
||||
cmd[0] = 0xfe;
|
||||
cmd[1] = 0x06;
|
||||
bacpy((bdaddr_t *) (cmd + 2), bdaddr);
|
||||
|
||||
len = do_command(dd, 0xff, 0x0022, cmd, 8, buf, sizeof(buf));
|
||||
if (len < 0)
|
||||
return -1;
|
||||
|
||||
len = do_command(dd, 0x03, 0x0003, NULL, 0, buf, sizeof(buf));
|
||||
if (len < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
533
external/cache/sources/hcitools/hciattach_ti.c
vendored
Normal file
533
external/cache/sources/hcitools/hciattach_ti.c
vendored
Normal file
@@ -0,0 +1,533 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2007-2008 Texas Instruments, Inc.
|
||||
* Copyright (C) 2005-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/hci.h>
|
||||
#include <bluetooth/hci_lib.h>
|
||||
|
||||
#include "hciattach.h"
|
||||
|
||||
#ifdef HCIATTACH_DEBUG
|
||||
#define DPRINTF(x...) printf(x)
|
||||
#else
|
||||
#define DPRINTF(x...)
|
||||
#endif
|
||||
|
||||
#define HCIUARTGETDEVICE _IOR('U', 202, int)
|
||||
|
||||
#define MAKEWORD(a, b) ((uint16_t)(((uint8_t)(a)) | ((uint16_t)((uint8_t)(b))) << 8))
|
||||
|
||||
#define TI_MANUFACTURER_ID 13
|
||||
|
||||
#define FIRMWARE_DIRECTORY "/lib/firmware/ti-connectivity/"
|
||||
|
||||
#define ACTION_SEND_COMMAND 1
|
||||
#define ACTION_WAIT_EVENT 2
|
||||
#define ACTION_SERIAL 3
|
||||
#define ACTION_DELAY 4
|
||||
#define ACTION_RUN_SCRIPT 5
|
||||
#define ACTION_REMARKS 6
|
||||
|
||||
#define BRF_DEEP_SLEEP_OPCODE_BYTE_1 0x0c
|
||||
#define BRF_DEEP_SLEEP_OPCODE_BYTE_2 0xfd
|
||||
#define BRF_DEEP_SLEEP_OPCODE \
|
||||
(BRF_DEEP_SLEEP_OPCODE_BYTE_1 | (BRF_DEEP_SLEEP_OPCODE_BYTE_2 << 8))
|
||||
|
||||
#define FILE_HEADER_MAGIC 0x42535442
|
||||
|
||||
/*
|
||||
* BRF Firmware header
|
||||
*/
|
||||
struct bts_header {
|
||||
uint32_t magic;
|
||||
uint32_t version;
|
||||
uint8_t future[24];
|
||||
uint8_t actions[0];
|
||||
}__attribute__ ((packed));
|
||||
|
||||
/*
|
||||
* BRF Actions structure
|
||||
*/
|
||||
struct bts_action {
|
||||
uint16_t type;
|
||||
uint16_t size;
|
||||
uint8_t data[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bts_action_send {
|
||||
uint8_t data[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bts_action_wait {
|
||||
uint32_t msec;
|
||||
uint32_t size;
|
||||
uint8_t data[0];
|
||||
}__attribute__ ((packed));
|
||||
|
||||
struct bts_action_delay {
|
||||
uint32_t msec;
|
||||
}__attribute__ ((packed));
|
||||
|
||||
struct bts_action_serial {
|
||||
uint32_t baud;
|
||||
uint32_t flow_control;
|
||||
}__attribute__ ((packed));
|
||||
|
||||
static FILE *bts_load_script(const char *file_name, uint32_t *version)
|
||||
{
|
||||
struct bts_header header;
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen(file_name, "rb");
|
||||
if (!fp) {
|
||||
perror("can't open firmware file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (1 != fread(&header, sizeof(struct bts_header), 1, fp)) {
|
||||
perror("can't read firmware file");
|
||||
goto errclose;
|
||||
}
|
||||
|
||||
if (header.magic != FILE_HEADER_MAGIC) {
|
||||
fprintf(stderr, "%s not a legal TI firmware file\n", file_name);
|
||||
goto errclose;
|
||||
}
|
||||
|
||||
if (NULL != version)
|
||||
*version = header.version;
|
||||
|
||||
return fp;
|
||||
|
||||
errclose:
|
||||
fclose(fp);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static unsigned long bts_fetch_action(FILE *fp, unsigned char *action_buf,
|
||||
unsigned long buf_size, uint16_t *action_type)
|
||||
{
|
||||
struct bts_action action_hdr;
|
||||
unsigned long nread;
|
||||
|
||||
if (!fp)
|
||||
return 0;
|
||||
|
||||
if (1 != fread(&action_hdr, sizeof(struct bts_action), 1, fp))
|
||||
return 0;
|
||||
|
||||
if (action_hdr.size > buf_size) {
|
||||
fprintf(stderr, "bts_next_action: not enough space to read next action\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
nread = fread(action_buf, sizeof(uint8_t), action_hdr.size, fp);
|
||||
if (nread != (action_hdr.size)) {
|
||||
fprintf(stderr, "bts_next_action: fread failed to read next action\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*action_type = action_hdr.type;
|
||||
|
||||
return nread * sizeof(uint8_t);
|
||||
}
|
||||
|
||||
static void bts_unload_script(FILE *fp)
|
||||
{
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
static int is_it_texas(const uint8_t *respond)
|
||||
{
|
||||
uint16_t manufacturer_id;
|
||||
|
||||
manufacturer_id = MAKEWORD(respond[11], respond[12]);
|
||||
|
||||
return TI_MANUFACTURER_ID == manufacturer_id ? 1 : 0;
|
||||
}
|
||||
|
||||
static const char *get_firmware_name(const uint8_t *respond)
|
||||
{
|
||||
static char firmware_file_name[PATH_MAX] = {0};
|
||||
uint16_t version = 0, chip = 0, min_ver = 0, maj_ver = 0;
|
||||
|
||||
version = MAKEWORD(respond[13], respond[14]);
|
||||
chip = (version & 0x7C00) >> 10;
|
||||
min_ver = (version & 0x007F);
|
||||
maj_ver = (version & 0x0380) >> 7;
|
||||
|
||||
if (version & 0x8000)
|
||||
maj_ver |= 0x0008;
|
||||
|
||||
sprintf(firmware_file_name, FIRMWARE_DIRECTORY "TIInit_%d.%d.%d.bts", chip, maj_ver, min_ver);
|
||||
|
||||
return firmware_file_name;
|
||||
}
|
||||
|
||||
static void brf_delay(struct bts_action_delay *delay)
|
||||
{
|
||||
usleep(1000 * delay->msec);
|
||||
}
|
||||
|
||||
static int brf_set_serial_params(struct bts_action_serial *serial_action,
|
||||
int fd, int *speed, struct termios *ti)
|
||||
{
|
||||
fprintf(stderr, "texas: changing baud rate to %u, flow control to %u\n",
|
||||
serial_action->baud, serial_action->flow_control );
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
|
||||
if (serial_action->flow_control)
|
||||
ti->c_cflag |= CRTSCTS;
|
||||
else
|
||||
ti->c_cflag &= ~CRTSCTS;
|
||||
|
||||
if (tcsetattr(fd, TCSANOW, ti) < 0) {
|
||||
perror("Can't set port settings");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
|
||||
if (set_speed(fd, ti, serial_action->baud) < 0) {
|
||||
perror("Can't set baud rate");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (speed)
|
||||
*speed = serial_action->baud;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int brf_send_command_socket(int fd, struct bts_action_send *send_action)
|
||||
{
|
||||
char response[1024] = {0};
|
||||
hci_command_hdr *cmd = (hci_command_hdr *) send_action->data;
|
||||
uint16_t opcode = cmd->opcode;
|
||||
|
||||
struct hci_request rq;
|
||||
memset(&rq, 0, sizeof(rq));
|
||||
rq.ogf = cmd_opcode_ogf(opcode);
|
||||
rq.ocf = cmd_opcode_ocf(opcode);
|
||||
rq.event = EVT_CMD_COMPLETE;
|
||||
rq.cparam = &send_action->data[3];
|
||||
rq.clen = send_action->data[2];
|
||||
rq.rparam = response;
|
||||
rq.rlen = sizeof(response);
|
||||
|
||||
if (hci_send_req(fd, &rq, 15) < 0) {
|
||||
perror("Cannot send hci command to socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* verify success */
|
||||
if (response[0]) {
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int brf_send_command_file(int fd, struct bts_action_send *send_action,
|
||||
long size)
|
||||
{
|
||||
unsigned char response[1024] = {0};
|
||||
long ret = 0;
|
||||
|
||||
/* send command */
|
||||
if (size != write(fd, send_action, size)) {
|
||||
perror("Texas: Failed to write action command");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* read response */
|
||||
ret = read_hci_event(fd, response, sizeof(response));
|
||||
if (ret < 0) {
|
||||
perror("texas: failed to read command response");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* verify success */
|
||||
if (ret < 7 || 0 != response[6]) {
|
||||
fprintf( stderr, "TI init command failed.\n" );
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int brf_send_command(int fd, struct bts_action_send *send_action,
|
||||
long size, int hcill_installed)
|
||||
{
|
||||
int ret = 0;
|
||||
char *fixed_action;
|
||||
|
||||
/* remove packet type when giving to socket API */
|
||||
if (hcill_installed) {
|
||||
fixed_action = ((char *) send_action) + 1;
|
||||
ret = brf_send_command_socket(fd, (struct bts_action_send *) fixed_action);
|
||||
} else {
|
||||
ret = brf_send_command_file(fd, send_action, size);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int brf_do_action(uint16_t brf_type, uint8_t *brf_action, long brf_size,
|
||||
int fd, int *speed, struct termios *ti, int hcill_installed)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (brf_type) {
|
||||
case ACTION_SEND_COMMAND:
|
||||
DPRINTF("W");
|
||||
ret = brf_send_command(fd,
|
||||
(struct bts_action_send *) brf_action,
|
||||
brf_size, hcill_installed);
|
||||
break;
|
||||
case ACTION_WAIT_EVENT:
|
||||
DPRINTF("R");
|
||||
break;
|
||||
case ACTION_SERIAL:
|
||||
DPRINTF("S");
|
||||
ret = brf_set_serial_params((struct bts_action_serial *) brf_action, fd, speed, ti);
|
||||
break;
|
||||
case ACTION_DELAY:
|
||||
DPRINTF("D");
|
||||
brf_delay((struct bts_action_delay *) brf_action);
|
||||
break;
|
||||
case ACTION_REMARKS:
|
||||
DPRINTF("C");
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "brf_init: unknown firmware action type (%d)\n", brf_type);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* tests whether a given brf action is a HCI_VS_Sleep_Mode_Configurations cmd
|
||||
*/
|
||||
static int brf_action_is_deep_sleep(uint8_t *brf_action, long brf_size,
|
||||
uint16_t brf_type)
|
||||
{
|
||||
uint16_t opcode;
|
||||
|
||||
if (brf_type != ACTION_SEND_COMMAND)
|
||||
return 0;
|
||||
|
||||
if (brf_size < 3)
|
||||
return 0;
|
||||
|
||||
if (brf_action[0] != HCI_COMMAND_PKT)
|
||||
return 0;
|
||||
|
||||
/* HCI data is little endian */
|
||||
opcode = brf_action[1] | (brf_action[2] << 8);
|
||||
|
||||
if (opcode != BRF_DEEP_SLEEP_OPCODE)
|
||||
return 0;
|
||||
|
||||
/* action is deep sleep configuration command ! */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called twice.
|
||||
* The first time it is called, it loads the brf script, and executes its
|
||||
* commands until it reaches a deep sleep command (or its end).
|
||||
* The second time it is called, it assumes HCILL protocol is set up,
|
||||
* and sends rest of brf script via the supplied socket.
|
||||
*/
|
||||
static int brf_do_script(int fd, int *speed, struct termios *ti, const char *bts_file)
|
||||
{
|
||||
int ret = 0, hcill_installed = bts_file ? 0 : 1;
|
||||
uint32_t vers;
|
||||
static FILE *brf_script_file = NULL;
|
||||
static uint8_t brf_action[512];
|
||||
static long brf_size;
|
||||
static uint16_t brf_type;
|
||||
|
||||
/* is it the first time we are called ? */
|
||||
if (0 == hcill_installed) {
|
||||
DPRINTF("Sending script to serial device\n");
|
||||
brf_script_file = bts_load_script(bts_file, &vers );
|
||||
if (!brf_script_file) {
|
||||
fprintf(stderr, "Warning: cannot find BTS file: %s\n",
|
||||
bts_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf( stderr, "Loaded BTS script version %u\n", vers );
|
||||
|
||||
brf_size = bts_fetch_action(brf_script_file, brf_action,
|
||||
sizeof(brf_action), &brf_type);
|
||||
if (brf_size == 0) {
|
||||
fprintf(stderr, "Warning: BTS file is empty !");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
DPRINTF("Sending script to bluetooth socket\n");
|
||||
}
|
||||
|
||||
/* execute current action and continue to parse brf script file */
|
||||
while (brf_size != 0) {
|
||||
ret = brf_do_action(brf_type, brf_action, brf_size,
|
||||
fd, speed, ti, hcill_installed);
|
||||
if (ret == -1)
|
||||
break;
|
||||
|
||||
brf_size = bts_fetch_action(brf_script_file, brf_action,
|
||||
sizeof(brf_action), &brf_type);
|
||||
|
||||
/* if this is the first time we run (no HCILL yet) */
|
||||
/* and a deep sleep command is encountered */
|
||||
/* we exit */
|
||||
if (!hcill_installed &&
|
||||
brf_action_is_deep_sleep(brf_action,
|
||||
brf_size, brf_type))
|
||||
return 0;
|
||||
}
|
||||
|
||||
bts_unload_script(brf_script_file);
|
||||
brf_script_file = NULL;
|
||||
DPRINTF("\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int texas_init(int fd, int *speed, struct termios *ti)
|
||||
{
|
||||
struct timespec tm = {0, 50000};
|
||||
char cmd[4];
|
||||
unsigned char resp[100]; /* Response */
|
||||
const char *bts_file;
|
||||
int n;
|
||||
|
||||
memset(resp,'\0', 100);
|
||||
|
||||
/* It is possible to get software version with manufacturer specific
|
||||
HCI command HCI_VS_TI_Version_Number. But the only thing you get more
|
||||
is if this is point-to-point or point-to-multipoint module */
|
||||
|
||||
/* Get Manufacturer and LMP version */
|
||||
cmd[0] = HCI_COMMAND_PKT;
|
||||
cmd[1] = 0x01;
|
||||
cmd[2] = 0x10;
|
||||
cmd[3] = 0x00;
|
||||
|
||||
do {
|
||||
n = write(fd, cmd, 4);
|
||||
if (n < 0) {
|
||||
perror("Failed to write init command (READ_LOCAL_VERSION_INFORMATION)");
|
||||
return -1;
|
||||
}
|
||||
if (n < 4) {
|
||||
fprintf(stderr, "Wanted to write 4 bytes, could only write %d. Stop\n", n);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read reply. */
|
||||
if (read_hci_event(fd, resp, 100) < 0) {
|
||||
perror("Failed to read init response (READ_LOCAL_VERSION_INFORMATION)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Wait for command complete event for our Opcode */
|
||||
} while (resp[4] != cmd[1] && resp[5] != cmd[2]);
|
||||
|
||||
/* Verify manufacturer */
|
||||
if (! is_it_texas(resp)) {
|
||||
fprintf(stderr,"ERROR: module's manufacturer is not Texas Instruments\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Found a Texas Instruments' chip!\n");
|
||||
|
||||
bts_file = get_firmware_name(resp);
|
||||
fprintf(stderr, "Firmware file : %s\n", bts_file);
|
||||
|
||||
n = brf_do_script(fd, speed, ti, bts_file);
|
||||
|
||||
nanosleep(&tm, NULL);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int texas_post(int fd, struct termios *ti)
|
||||
{
|
||||
int dev_id, dd, ret = 0;
|
||||
|
||||
sleep(1);
|
||||
|
||||
dev_id = ioctl(fd, HCIUARTGETDEVICE, 0);
|
||||
if (dev_id < 0) {
|
||||
perror("cannot get device id");
|
||||
return -1;
|
||||
}
|
||||
|
||||
DPRINTF("\nAdded device hci%d\n", dev_id);
|
||||
|
||||
dd = hci_open_dev(dev_id);
|
||||
if (dd < 0) {
|
||||
perror("HCI device open failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(dd, HCIDEVUP, dev_id) < 0 && errno != EALREADY) {
|
||||
fprintf(stderr, "Can't init device hci%d: %s (%d)", dev_id,
|
||||
strerror(errno), errno);
|
||||
hci_close_dev(dd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = brf_do_script(dd, NULL, ti, NULL);
|
||||
|
||||
hci_close_dev(dd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
242
external/cache/sources/hcitools/hciattach_tialt.c
vendored
Normal file
242
external/cache/sources/hcitools/hciattach_tialt.c
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <syslog.h>
|
||||
#include <termios.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/hci.h>
|
||||
#include <bluetooth/hci_lib.h>
|
||||
|
||||
#include "hciattach.h"
|
||||
|
||||
#define FAILIF(x, args...) do { \
|
||||
if (x) { \
|
||||
fprintf(stderr, ##args); \
|
||||
return -1; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
typedef struct {
|
||||
uint8_t uart_prefix;
|
||||
hci_event_hdr hci_hdr;
|
||||
evt_cmd_complete cmd_complete;
|
||||
uint8_t status;
|
||||
uint8_t data[16];
|
||||
} __attribute__((packed)) command_complete_t;
|
||||
|
||||
static int read_command_complete(int fd, unsigned short opcode, unsigned char len) {
|
||||
command_complete_t resp;
|
||||
/* Read reply. */
|
||||
FAILIF(read_hci_event(fd, (unsigned char *)&resp, sizeof(resp)) < 0,
|
||||
"Failed to read response");
|
||||
|
||||
/* Parse speed-change reply */
|
||||
FAILIF(resp.uart_prefix != HCI_EVENT_PKT,
|
||||
"Error in response: not an event packet, but 0x%02x!\n",
|
||||
resp.uart_prefix);
|
||||
|
||||
FAILIF(resp.hci_hdr.evt != EVT_CMD_COMPLETE, /* event must be event-complete */
|
||||
"Error in response: not a cmd-complete event, "
|
||||
"but 0x%02x!\n", resp.hci_hdr.evt);
|
||||
|
||||
FAILIF(resp.hci_hdr.plen < 4, /* plen >= 4 for EVT_CMD_COMPLETE */
|
||||
"Error in response: plen is not >= 4, but 0x%02x!\n",
|
||||
resp.hci_hdr.plen);
|
||||
|
||||
/* cmd-complete event: opcode */
|
||||
FAILIF(resp.cmd_complete.opcode != (uint16_t)opcode,
|
||||
"Error in response: opcode is 0x%04x, not 0x%04x!",
|
||||
resp.cmd_complete.opcode, opcode);
|
||||
|
||||
return resp.status == 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uint8_t uart_prefix;
|
||||
hci_command_hdr hci_hdr;
|
||||
uint32_t speed;
|
||||
} __attribute__((packed)) texas_speed_change_cmd_t;
|
||||
|
||||
static int texas_change_speed(int fd, uint32_t speed)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int texas_load_firmware(int fd, const char *firmware) {
|
||||
|
||||
int fw = open(firmware, O_RDONLY);
|
||||
|
||||
fprintf(stdout, "Opening firmware file: %s\n", firmware);
|
||||
|
||||
FAILIF(fw < 0,
|
||||
"Could not open firmware file %s: %s (%d).\n",
|
||||
firmware, strerror(errno), errno);
|
||||
|
||||
fprintf(stdout, "Uploading firmware...\n");
|
||||
do {
|
||||
/* Read each command and wait for a response. */
|
||||
unsigned char data[1024];
|
||||
unsigned char cmdp[1 + sizeof(hci_command_hdr)];
|
||||
hci_command_hdr *cmd = (hci_command_hdr *)(cmdp + 1);
|
||||
int nr;
|
||||
nr = read(fw, cmdp, sizeof(cmdp));
|
||||
if (!nr)
|
||||
break;
|
||||
FAILIF(nr != sizeof(cmdp), "Could not read H4 + HCI header!\n");
|
||||
FAILIF(*cmdp != HCI_COMMAND_PKT, "Command is not an H4 command packet!\n");
|
||||
|
||||
FAILIF(read(fw, data, cmd->plen) != cmd->plen,
|
||||
"Could not read %d bytes of data for command with opcode %04x!\n",
|
||||
cmd->plen,
|
||||
cmd->opcode);
|
||||
|
||||
{
|
||||
int nw;
|
||||
#if 0
|
||||
fprintf(stdout, "\topcode 0x%04x (%d bytes of data).\n",
|
||||
cmd->opcode,
|
||||
cmd->plen);
|
||||
#endif
|
||||
struct iovec iov_cmd[2];
|
||||
iov_cmd[0].iov_base = cmdp;
|
||||
iov_cmd[0].iov_len = sizeof(cmdp);
|
||||
iov_cmd[1].iov_base = data;
|
||||
iov_cmd[1].iov_len = cmd->plen;
|
||||
nw = writev(fd, iov_cmd, 2);
|
||||
FAILIF(nw != (int) sizeof(cmd) + cmd->plen,
|
||||
"Could not send entire command (sent only %d bytes)!\n",
|
||||
nw);
|
||||
}
|
||||
|
||||
/* Wait for response */
|
||||
if (read_command_complete(fd,
|
||||
cmd->opcode,
|
||||
cmd->plen) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
} while(1);
|
||||
fprintf(stdout, "Firmware upload successful.\n");
|
||||
|
||||
close(fw);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int texasalt_init(int fd, int speed, struct termios *ti)
|
||||
{
|
||||
struct timespec tm = {0, 50000};
|
||||
char cmd[4];
|
||||
unsigned char resp[100]; /* Response */
|
||||
int n;
|
||||
|
||||
memset(resp,'\0', 100);
|
||||
|
||||
/* It is possible to get software version with manufacturer specific
|
||||
HCI command HCI_VS_TI_Version_Number. But the only thing you get more
|
||||
is if this is point-to-point or point-to-multipoint module */
|
||||
|
||||
/* Get Manufacturer and LMP version */
|
||||
cmd[0] = HCI_COMMAND_PKT;
|
||||
cmd[1] = 0x01;
|
||||
cmd[2] = 0x10;
|
||||
cmd[3] = 0x00;
|
||||
|
||||
do {
|
||||
n = write(fd, cmd, 4);
|
||||
if (n < 0) {
|
||||
perror("Failed to write init command (READ_LOCAL_VERSION_INFORMATION)");
|
||||
return -1;
|
||||
}
|
||||
if (n < 4) {
|
||||
fprintf(stderr, "Wanted to write 4 bytes, could only write %d. Stop\n", n);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read reply. */
|
||||
if (read_hci_event(fd, resp, 100) < 0) {
|
||||
perror("Failed to read init response (READ_LOCAL_VERSION_INFORMATION)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Wait for command complete event for our Opcode */
|
||||
} while (resp[4] != cmd[1] && resp[5] != cmd[2]);
|
||||
|
||||
/* Verify manufacturer */
|
||||
if ((resp[11] & 0xFF) != 0x0d)
|
||||
fprintf(stderr,"WARNING : module's manufacturer is not Texas Instrument\n");
|
||||
|
||||
/* Print LMP version */
|
||||
fprintf(stderr, "Texas module LMP version : 0x%02x\n", resp[10] & 0xFF);
|
||||
|
||||
/* Print LMP subversion */
|
||||
{
|
||||
unsigned short lmp_subv = resp[13] | (resp[14] << 8);
|
||||
unsigned short brf_chip = (lmp_subv & 0x7c00) >> 10;
|
||||
static const char *c_brf_chip[8] = {
|
||||
"unknown",
|
||||
"unknown",
|
||||
"brf6100",
|
||||
"brf6150",
|
||||
"brf6300",
|
||||
"brf6350",
|
||||
"unknown",
|
||||
"wl1271"
|
||||
};
|
||||
char fw[100];
|
||||
|
||||
fprintf(stderr, "Texas module LMP sub-version : 0x%04x\n", lmp_subv);
|
||||
|
||||
fprintf(stderr,
|
||||
"\tinternal version freeze: %d\n"
|
||||
"\tsoftware version: %d\n"
|
||||
"\tchip: %s (%d)\n",
|
||||
lmp_subv & 0x7f,
|
||||
((lmp_subv & 0x8000) >> (15-3)) | ((lmp_subv & 0x380) >> 7),
|
||||
((brf_chip > 7) ? "unknown" : c_brf_chip[brf_chip]),
|
||||
brf_chip);
|
||||
|
||||
sprintf(fw, "/etc/firmware/%s.bin", c_brf_chip[brf_chip]);
|
||||
texas_load_firmware(fd, fw);
|
||||
|
||||
texas_change_speed(fd, speed);
|
||||
}
|
||||
nanosleep(&tm, NULL);
|
||||
return 0;
|
||||
}
|
||||
557
external/cache/sources/hcitools/hciattach_xr.c
vendored
Normal file
557
external/cache/sources/hcitools/hciattach_xr.c
vendored
Normal file
@@ -0,0 +1,557 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <limits.h>
|
||||
#include "hciattach.h"
|
||||
|
||||
/******************************************************************************
|
||||
** Constants & Macros
|
||||
******************************************************************************/
|
||||
#define LOG_STR "XRADIO Bluetooth"
|
||||
#define DBG_ON 1
|
||||
|
||||
#define XR_DBG(fmt, arg...) \
|
||||
do { \
|
||||
if (DBG_ON) \
|
||||
fprintf(stderr, "%s: " fmt "\n" , LOG_STR, ##arg); \
|
||||
} while(0)
|
||||
|
||||
#define XR_ERR(fmt, arg...) \
|
||||
do { \
|
||||
fprintf(stderr, "%s ERROR: " fmt "\n", LOG_STR, ##arg);\
|
||||
perror(LOG_STR" ERROR reason"); \
|
||||
} while(0)
|
||||
|
||||
#define XR_DUMP(buffer, len) \
|
||||
fprintf(stderr, "%s: ", LOG_STR); \
|
||||
do { \
|
||||
for (int i = 0; i < len; i++) { \
|
||||
if (i && !(i % 16)) { \
|
||||
fprintf(stderr, "\n"); \
|
||||
fprintf(stderr, "%s: ", LOG_STR); \
|
||||
} \
|
||||
fprintf(stderr, "%02x ", buffer[i]); \
|
||||
} \
|
||||
fprintf(stderr, "\n"); \
|
||||
} while (0)
|
||||
|
||||
#define BT_FW_PATH_NAME "/system/vendor/etc/firmware/fw_xr829_bt.bin"
|
||||
#define BT_FW_LOAD_ADDR 0x0000
|
||||
#define BT_FW_JUMP_ADDR 0x0000
|
||||
#define AW1722 1
|
||||
#define AW1732 2
|
||||
#define CHIP_NAME AW1722
|
||||
|
||||
#define SZ_1K (0x00000400U )
|
||||
#define SZ_16K (0x00004000U )
|
||||
|
||||
#define SWAP16(d) (((d & 0xff) << 8) | ((d & 0xff00) >> 8))
|
||||
#define SWAP32(d) (((d & 0xff) << 24) | ((d & 0xff00) << 8) \
|
||||
| ((d & 0xff0000) >> 8) | ((d & 0xff000000) >> 24))
|
||||
|
||||
#define CMD_ID(group, key) (((group) << 3) | (key))
|
||||
|
||||
/*----------------------------*/
|
||||
/* COMMANDS FORM PC TO MCU */
|
||||
/*----------------------------*/
|
||||
#define CMD_ID_MEMRW 0x00
|
||||
#define CMD_ID_SEQRQ 0x01
|
||||
#define CMD_ID_SYSCTL 0x02
|
||||
#define CMD_ID_FLASH 0x03
|
||||
|
||||
#define CMD_ID_SEQRD CMD_ID(CMD_ID_SEQRQ, 0)
|
||||
#define CMD_ID_SEQWR CMD_ID(CMD_ID_SEQRQ, 1)
|
||||
/* uart commands */
|
||||
#define CMD_ID_SETUART CMD_ID(CMD_ID_SYSCTL, 0)
|
||||
#define CMD_ID_SETPC CMD_ID(CMD_ID_SYSCTL, 3)
|
||||
|
||||
#define CMD_WRITEN 0
|
||||
#define CMD_WRITESEQ 1
|
||||
#define CMD_SETBAUD 2
|
||||
#define CMD_SETPC 3
|
||||
#define DATA_RAW 4
|
||||
|
||||
/******************************************************************************
|
||||
** Type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* vendor serial control block */
|
||||
typedef struct
|
||||
{
|
||||
int fd; /* fd to Bluetooth device */
|
||||
struct termios *ti; /* serial terminal of BT port */
|
||||
} vnd_userial_cb_t;
|
||||
|
||||
#pragma pack(1)
|
||||
/* command header
|
||||
*
|
||||
* byte 0 byte 1 byte 2 byte 3 byte 4 byte 5 byte 6 -7 byte 8-11
|
||||
* ___________________________________________________________________________________________________
|
||||
* | | | | | | | | |
|
||||
* | 'B' | 'R' | 'O' | 'M' | Flags |Reserved | Checksum | Playload Length |
|
||||
* |_________|_________|_________|_________|_________|_________|__________ ________|___________________|
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t magic[4]; // magic "BROM"
|
||||
#define CMD_BROM_MAGIC "BROM"
|
||||
uint8_t flags;
|
||||
#define CMD_HFLAG_ERROR (0x1U << 0)
|
||||
#define CMD_HFLAG_ACK (0x1U << 1)
|
||||
#define CMD_HFLAG_CHECK (0x1U << 2)
|
||||
#define CMD_HFLAG_RETRY (0x1U << 3)
|
||||
#define CMD_HFLAG_EXE (0x1U << 4)
|
||||
uint8_t version:4;
|
||||
uint8_t reserved:4;
|
||||
uint16_t checksum;
|
||||
uint32_t payload_len;
|
||||
} __attribute__((packed)) cmd_header_t;
|
||||
#define MB_CMD_HEADER_SIZE (sizeof(cmd_header_t))
|
||||
|
||||
/* acknownledge structure */
|
||||
typedef struct {
|
||||
cmd_header_t h;
|
||||
uint8_t err;
|
||||
} __attribute__((packed)) cmd_ack_t;
|
||||
|
||||
/* sequence read/write command structure */
|
||||
typedef struct {
|
||||
cmd_header_t h;
|
||||
uint8_t cmdid;
|
||||
uint32_t addr;
|
||||
uint32_t dlen;
|
||||
uint16_t dcs;
|
||||
} __attribute__((packed)) cmd_seq_wr_t;
|
||||
|
||||
/* io change command structure */
|
||||
typedef struct {
|
||||
cmd_header_t h;
|
||||
uint8_t cmdid;
|
||||
uint32_t val;
|
||||
} __attribute__((packed)) cmd_sys_t;
|
||||
|
||||
typedef struct {
|
||||
cmd_header_t h;
|
||||
uint8_t cmdid;
|
||||
uint32_t lcr;
|
||||
} __attribute__((packed)) cmd_sys_setuart_t;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
static const uint8_t hci_reset[] = { 0x01, 0x03, 0x0c, 0x00 };
|
||||
static const uint8_t hci_update_baud_rate[] = { 0x01, 0x18, 0xfc, 0x04, 0x60, 0xE3, 0x16, 0x00};
|
||||
static vnd_userial_cb_t vnd_userial;
|
||||
|
||||
static int32_t cmd_sync_uart(void);
|
||||
static int32_t cmd_sync_baud(uint32_t lcr);
|
||||
static int32_t cmd_write_seq(uint32_t addr, uint32_t len, uint8_t *data);
|
||||
static int32_t cmd_set_pc(uint32_t pc);
|
||||
static void userial_set_hw_fctrl(uint8_t hw_fctrl);
|
||||
static uint32_t userial_read(uint8_t *p_buffer, uint32_t len, uint32_t timeout);
|
||||
static uint32_t userial_write(const uint8_t *p_data, uint32_t len);
|
||||
|
||||
/******************************************************************************
|
||||
** Functions
|
||||
******************************************************************************/
|
||||
static uint16_t CheckSum16(uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint16_t cs = 0;
|
||||
uint16_t *p = (uint16_t *)data;
|
||||
|
||||
while(len > 1) {
|
||||
cs += *p++;
|
||||
len -= 2;
|
||||
}
|
||||
if (len) {
|
||||
cs += *(uint8_t *)p;
|
||||
}
|
||||
return cs;
|
||||
}
|
||||
|
||||
static uint64_t time_gettimeofday_us(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return (uint64_t)tv.tv_sec * 1000000ULL + (uint64_t)tv.tv_usec;
|
||||
}
|
||||
|
||||
static uint8_t *memsearch(uint8_t *haystack, uint32_t hlen, uint8_t *needle, uint32_t nlen)
|
||||
{
|
||||
while (hlen-- >= nlen) {
|
||||
if (!memcmp(haystack, needle, nlen)) {
|
||||
return haystack;
|
||||
}
|
||||
haystack++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t xr_raw_write(int type, uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint8_t buffer[MB_CMD_HEADER_SIZE + 13] = {'B', 'R', 'O', 'M', 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
uint8_t *psend = data;
|
||||
uint32_t lsend = len;
|
||||
cmd_header_t *hdr = (cmd_header_t *)buffer;;
|
||||
cmd_ack_t *ack = (cmd_ack_t *)buffer;
|
||||
|
||||
if (type != DATA_RAW) {
|
||||
psend = buffer;
|
||||
lsend = MB_CMD_HEADER_SIZE + len;
|
||||
memcpy(buffer + MB_CMD_HEADER_SIZE, data, len);
|
||||
hdr->payload_len = len;
|
||||
#if ENABLE_DCS
|
||||
hdr->flags = CMD_HFLAG_CHECK;
|
||||
#endif
|
||||
hdr->checksum = ~CheckSum16(buffer, MB_CMD_HEADER_SIZE + len);
|
||||
hdr->payload_len = SWAP32(hdr->payload_len);
|
||||
hdr->checksum = SWAP16(hdr->checksum);
|
||||
switch (type) {
|
||||
case CMD_WRITESEQ:
|
||||
{
|
||||
cmd_seq_wr_t *cmd = (cmd_seq_wr_t *)buffer;
|
||||
cmd->addr = SWAP32(cmd->addr);
|
||||
cmd->dlen = SWAP32(cmd->dlen);
|
||||
cmd->dcs = SWAP16(cmd->dcs);
|
||||
}
|
||||
break;
|
||||
case CMD_SETBAUD:
|
||||
{
|
||||
cmd_sys_setuart_t *cmd = (cmd_sys_setuart_t*)buffer;
|
||||
cmd->lcr = SWAP32(cmd->lcr);
|
||||
}
|
||||
break;
|
||||
case CMD_SETPC:
|
||||
{
|
||||
cmd_sys_t *cmd = (cmd_sys_t*)buffer;
|
||||
cmd->val = SWAP32(cmd->val);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
XR_ERR("%s: Unsupport type %d", __func__, type);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t ret_w, ret_r;
|
||||
uint64_t t0, t1, t2, t3;
|
||||
|
||||
tcflush(vnd_userial.fd, TCIOFLUSH);
|
||||
|
||||
t0 = time_gettimeofday_us();
|
||||
ret_w = userial_write(psend, lsend);
|
||||
t1 = time_gettimeofday_us();
|
||||
|
||||
memset(buffer, 0, MB_CMD_HEADER_SIZE + 1);
|
||||
|
||||
t2 = time_gettimeofday_us();
|
||||
ret_r = userial_read(buffer, MB_CMD_HEADER_SIZE, 100000);
|
||||
t3 = time_gettimeofday_us();
|
||||
|
||||
XR_DBG("%s, type: %d, write len: %5d, ret: %5d, time: %6lluus, read len: %2d, ret: %2d, %6lluus",
|
||||
__func__, type, lsend, ret_w, t1 - t0, MB_CMD_HEADER_SIZE, ret_r, t3 - t2);
|
||||
|
||||
uint8_t *p = (uint8_t *)memsearch(buffer, MB_CMD_HEADER_SIZE, (uint8_t *)"BROM", 4);
|
||||
if (p != buffer) {
|
||||
if (p == NULL) {
|
||||
XR_ERR("%s: invalid response", __func__);
|
||||
return -1;
|
||||
}
|
||||
uint32_t nowread = buffer + MB_CMD_HEADER_SIZE - p;
|
||||
uint32_t needread = p - buffer;
|
||||
XR_DBG("%s: Index error, re-find header magic", __func__);
|
||||
memcpy(buffer, p, nowread);
|
||||
memset(buffer + nowread, 0x0, needread);
|
||||
userial_read(buffer + nowread, needread, 100000);
|
||||
}
|
||||
|
||||
/* check response */
|
||||
if (ack->h.flags & CMD_HFLAG_ERROR) {
|
||||
userial_read(buffer + MB_CMD_HEADER_SIZE, 1, 100000);
|
||||
XR_ERR("%s: resp error flag, type %d", __func__, ack->err);
|
||||
return -ack->err;
|
||||
}
|
||||
|
||||
if (ack->h.flags & CMD_HFLAG_ACK) {
|
||||
/* convert network byte order to host byte order */
|
||||
ack->h.payload_len = SWAP32(ack->h.payload_len);
|
||||
ack->h.checksum = SWAP16(ack->h.checksum);
|
||||
if (ack->h.payload_len != 0) {
|
||||
XR_ERR("%s: data payload len %d != 0", __func__, ack->h.payload_len);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ack->h.flags & CMD_HFLAG_CHECK) {
|
||||
if (CheckSum16(buffer, MB_CMD_HEADER_SIZE) != 0xffff) {
|
||||
XR_ERR("%s: write data response 0 checksum error", __func__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t cmd_sync_uart(void)
|
||||
{
|
||||
uint8_t sync = 0x55;
|
||||
uint8_t ack[3] = {0};
|
||||
ssize_t ret = -1;
|
||||
uint32_t cnt = 0;
|
||||
|
||||
do {
|
||||
XR_DBG("uart sync count:%d.", cnt);
|
||||
tcflush(vnd_userial.fd, TCIOFLUSH);
|
||||
userial_write(&sync, 1);
|
||||
ret = userial_read(ack, 2, 2000);
|
||||
if (ret == 2 && ((ack[0] == 'O' && ack[1] == 'K') || (ack[0] == 'K' && ack[1] == 'O'))) {
|
||||
XR_DBG("Receive %s, uart Sync done.", ack);
|
||||
return 0;
|
||||
}
|
||||
} while (cnt++ < 50);
|
||||
|
||||
XR_DBG("uart sync fail.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int32_t cmd_sync_baud(uint32_t lcr)
|
||||
{
|
||||
uint8_t buffer[MB_CMD_HEADER_SIZE + 5];
|
||||
cmd_sys_setuart_t *cmd = (cmd_sys_setuart_t*)buffer;
|
||||
|
||||
cmd->cmdid = CMD_ID_SETUART;
|
||||
cmd->lcr = lcr;
|
||||
|
||||
uint8_t cnt = 0;
|
||||
int ret = -1;
|
||||
|
||||
do {
|
||||
XR_DBG("%s count:%d.", __func__, cnt);
|
||||
ret = xr_raw_write(CMD_SETBAUD, buffer + MB_CMD_HEADER_SIZE, 5);
|
||||
if (ret == 0) {
|
||||
set_speed(vnd_userial.fd, vnd_userial.ti, lcr & 0xffffff);
|
||||
return cmd_sync_uart();
|
||||
}
|
||||
} while (cnt++ < 3);
|
||||
|
||||
XR_DBG("cmd_sync_baud fail.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int32_t cmd_write_seq(uint32_t addr, uint32_t len, uint8_t *data)
|
||||
{
|
||||
int ret = -1;
|
||||
uint8_t buffer[MB_CMD_HEADER_SIZE + 13];
|
||||
cmd_seq_wr_t *cmd = (cmd_seq_wr_t *)buffer;
|
||||
|
||||
cmd->cmdid = CMD_ID_SEQWR;
|
||||
cmd->addr = addr;
|
||||
cmd->dlen = len;
|
||||
#if ENABLE_DCS
|
||||
cmd->dcs = ~CheckSum16(data, len);
|
||||
#endif
|
||||
|
||||
ret = xr_raw_write(CMD_WRITESEQ, buffer + MB_CMD_HEADER_SIZE, 11);
|
||||
if (ret == 0) {
|
||||
return xr_raw_write(DATA_RAW, data, len);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t cmd_set_pc(uint32_t pc)
|
||||
{
|
||||
uint8_t buffer[MB_CMD_HEADER_SIZE + 5];
|
||||
cmd_sys_t *cmd = (cmd_sys_t*)buffer;
|
||||
|
||||
cmd->cmdid = CMD_ID_SETPC;
|
||||
cmd->val = pc;
|
||||
XR_DBG("set pc %x, val %x", pc, cmd->val);
|
||||
|
||||
return xr_raw_write(CMD_SETPC, buffer + MB_CMD_HEADER_SIZE, 5);
|
||||
}
|
||||
|
||||
static void userial_set_hw_fctrl(uint8_t hw_fctrl)
|
||||
{
|
||||
if (vnd_userial.fd == -1) {
|
||||
XR_ERR("vnd_userial.fd is -1");
|
||||
return;
|
||||
}
|
||||
|
||||
if (hw_fctrl) {
|
||||
XR_DBG("Set HW FlowControl On");
|
||||
vnd_userial.ti->c_cflag |= CRTSCTS;
|
||||
} else {
|
||||
XR_DBG("Set HW FlowControl Off");
|
||||
vnd_userial.ti->c_cflag &= ~CRTSCTS;
|
||||
}
|
||||
tcsetattr(vnd_userial.fd, TCSANOW, vnd_userial.ti);
|
||||
tcflush(vnd_userial.fd, TCIOFLUSH);
|
||||
}
|
||||
|
||||
static uint32_t userial_read(uint8_t *buffer, uint32_t len, uint32_t timeout)
|
||||
{
|
||||
fd_set set;
|
||||
struct timeval tv;
|
||||
int rv;
|
||||
|
||||
FD_ZERO(&set); /* clear the set */
|
||||
FD_SET(vnd_userial.fd, &set); /* add our file descriptor to the set */
|
||||
|
||||
/* there was data to read */
|
||||
ssize_t r;
|
||||
uint8_t *pos = (uint8_t*)buffer;
|
||||
|
||||
while (len > 0) {
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = timeout;
|
||||
|
||||
rv = select(vnd_userial.fd + 1, &set, NULL, NULL, &tv);
|
||||
if(rv == -1) {
|
||||
XR_ERR("select error"); /* an error accured */
|
||||
break;
|
||||
} else if(rv == 0) {
|
||||
XR_ERR("read timeout"); /* a timeout occured */
|
||||
break;
|
||||
}
|
||||
|
||||
r = read(vnd_userial.fd, pos, len);
|
||||
if (r < 1)
|
||||
break;
|
||||
|
||||
len -= r;
|
||||
pos += r;
|
||||
}
|
||||
|
||||
return pos - buffer;
|
||||
}
|
||||
|
||||
static uint32_t userial_write(const uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
ssize_t r;
|
||||
uint8_t *pos = (uint8_t*)buffer;
|
||||
|
||||
while (len > 0) {
|
||||
r = write(vnd_userial.fd, pos, len);
|
||||
if (r < 1)
|
||||
break;
|
||||
|
||||
len -= r;
|
||||
pos += r;
|
||||
}
|
||||
|
||||
return pos - buffer;
|
||||
}
|
||||
|
||||
static int32_t load_btfirmware(void)
|
||||
{
|
||||
FILE *fwfile_fd = NULL;
|
||||
uint32_t len;
|
||||
uint8_t *data = NULL;
|
||||
uint32_t addr = BT_FW_LOAD_ADDR;
|
||||
uint32_t section = SZ_16K;
|
||||
|
||||
fwfile_fd = fopen(BT_FW_PATH_NAME, "rb");
|
||||
XR_DBG("BT firmware: %s", BT_FW_PATH_NAME);
|
||||
if(!fwfile_fd) {
|
||||
XR_ERR("Unable to open BT firmware %s", BT_FW_PATH_NAME);
|
||||
return -1;
|
||||
}
|
||||
|
||||
data = (uint8_t*)malloc(section);
|
||||
if (data == NULL) {
|
||||
XR_DBG("failed to alloc %d byte memory.", section);
|
||||
fclose(fwfile_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
XR_DBG("load bt firmware starting.");
|
||||
while ((len = fread(data, 1, section, fwfile_fd)) > 0) {
|
||||
cmd_write_seq(addr, len, data);
|
||||
addr += len;
|
||||
}
|
||||
|
||||
free(data);
|
||||
fclose(fwfile_fd);
|
||||
XR_DBG("load firmware done.");
|
||||
|
||||
XR_DBG("Firmware run from address 0x%08X", BT_FW_JUMP_ADDR);
|
||||
cmd_set_pc(BT_FW_JUMP_ADDR);
|
||||
|
||||
if (CHIP_NAME == AW1732) {
|
||||
XR_DBG("second time sync starting....");
|
||||
if (cmd_sync_uart() < 0)
|
||||
return -1;
|
||||
cmd_set_pc(BT_FW_JUMP_ADDR);
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
static int hci_cmd_handle(const uint8_t *cmd, uint32_t cmd_len, uint32_t event_len)
|
||||
{
|
||||
uint8_t buffer[256];
|
||||
|
||||
XR_DBG("send hci command");
|
||||
userial_write(cmd, cmd_len);
|
||||
XR_DUMP(cmd, cmd_len);
|
||||
|
||||
if (read_hci_event(vnd_userial.fd, buffer, event_len) != event_len) {
|
||||
XR_ERR("Event read error");
|
||||
return -1;
|
||||
}
|
||||
XR_DBG("Received event");
|
||||
XR_DUMP(buffer, event_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xr_init(int fd, struct uart_t *u, struct termios *ti)
|
||||
{
|
||||
vnd_userial.fd = fd;
|
||||
vnd_userial.ti = ti;
|
||||
|
||||
XR_DBG("uart sync starting....");
|
||||
if (cmd_sync_uart() < 0)
|
||||
goto END;
|
||||
XR_DBG("set bandrate to %d.", u->speed);
|
||||
if (cmd_sync_baud(((u->speed) | (3<<24))) < 0)
|
||||
goto END;
|
||||
if (load_btfirmware() < 0)
|
||||
goto END;
|
||||
XR_DBG("bt firmware is running....");
|
||||
|
||||
XR_DBG("set baudrate to %d", u->init_speed);
|
||||
set_speed(vnd_userial.fd, vnd_userial.ti, u->init_speed);
|
||||
userial_set_hw_fctrl(1);
|
||||
usleep(50000);
|
||||
|
||||
XR_DBG("process hci reset...");
|
||||
if (hci_cmd_handle(hci_reset, sizeof(hci_reset), 7) < 0)
|
||||
goto END;
|
||||
|
||||
XR_DBG("process hci update baud...");
|
||||
if (hci_cmd_handle(hci_update_baud_rate, sizeof(hci_update_baud_rate), 7) < 0)
|
||||
goto END;
|
||||
|
||||
usleep(100000);
|
||||
|
||||
return 0;
|
||||
|
||||
END:
|
||||
XR_DBG("device fd = %d close", fd);
|
||||
close(vnd_userial.fd);
|
||||
vnd_userial.fd = -1;
|
||||
vnd_userial.ti = NULL;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int xr_post(int fd, struct uart_t *u, struct termios *ti)
|
||||
{
|
||||
XR_DBG("Done setting line discpline");
|
||||
return 0;
|
||||
}
|
||||
|
||||
2052
external/cache/sources/hcitools/hciconfig.c
vendored
Normal file
2052
external/cache/sources/hcitools/hciconfig.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3122
external/cache/sources/hcitools/hcitool.c
vendored
Normal file
3122
external/cache/sources/hcitools/hcitool.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
149
external/cache/sources/hcitools/lib/a2mp.h
vendored
Normal file
149
external/cache/sources/hcitools/lib/a2mp.h
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2012 Intel Corporation. All rights reserved.
|
||||
* Copyright (c) 2012 Code Aurora Forum. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __A2MP_H
|
||||
#define __A2MP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* A2MP Protocol */
|
||||
|
||||
/* A2MP command codes */
|
||||
|
||||
#define A2MP_COMMAND_REJ 0x01
|
||||
#define A2MP_DISCOVER_REQ 0x02
|
||||
#define A2MP_DISCOVER_RSP 0x03
|
||||
#define A2MP_CHANGE_NOTIFY 0x04
|
||||
#define A2MP_CHANGE_RSP 0x05
|
||||
#define A2MP_INFO_REQ 0x06
|
||||
#define A2MP_INFO_RSP 0x07
|
||||
#define A2MP_ASSOC_REQ 0x08
|
||||
#define A2MP_ASSOC_RSP 0x09
|
||||
#define A2MP_CREATE_REQ 0x0a
|
||||
#define A2MP_CREATE_RSP 0x0b
|
||||
#define A2MP_DISCONN_REQ 0x0c
|
||||
#define A2MP_DISCONN_RSP 0x0d
|
||||
|
||||
struct a2mp_hdr {
|
||||
uint8_t code;
|
||||
uint8_t ident;
|
||||
uint16_t len;
|
||||
} __attribute__ ((packed));
|
||||
#define A2MP_HDR_SIZE 4
|
||||
|
||||
struct a2mp_command_rej {
|
||||
uint16_t reason;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct a2mp_discover_req {
|
||||
uint16_t mtu;
|
||||
uint16_t mask;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct a2mp_ctrl {
|
||||
uint8_t id;
|
||||
uint8_t type;
|
||||
uint8_t status;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct a2mp_discover_rsp {
|
||||
uint16_t mtu;
|
||||
uint16_t mask;
|
||||
struct a2mp_ctrl ctrl_list[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct a2mp_info_req {
|
||||
uint8_t id;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct a2mp_info_rsp {
|
||||
uint8_t id;
|
||||
uint8_t status;
|
||||
uint32_t total_bw;
|
||||
uint32_t max_bw;
|
||||
uint32_t min_latency;
|
||||
uint16_t pal_caps;
|
||||
uint16_t assoc_size;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct a2mp_assoc_req {
|
||||
uint8_t id;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct a2mp_assoc_rsp {
|
||||
uint8_t id;
|
||||
uint8_t status;
|
||||
uint8_t assoc_data[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct a2mp_create_req {
|
||||
uint8_t local_id;
|
||||
uint8_t remote_id;
|
||||
uint8_t assoc_data[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct a2mp_create_rsp {
|
||||
uint8_t local_id;
|
||||
uint8_t remote_id;
|
||||
uint8_t status;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct a2mp_disconn_req {
|
||||
uint8_t local_id;
|
||||
uint8_t remote_id;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct a2mp_disconn_rsp {
|
||||
uint8_t local_id;
|
||||
uint8_t remote_id;
|
||||
uint8_t status;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define A2MP_COMMAND_NOT_RECOGNIZED 0x0000
|
||||
|
||||
/* AMP controller status */
|
||||
#define AMP_CTRL_POWERED_DOWN 0x00
|
||||
#define AMP_CTRL_BLUETOOTH_ONLY 0x01
|
||||
#define AMP_CTRL_NO_CAPACITY 0x02
|
||||
#define AMP_CTRL_LOW_CAPACITY 0x03
|
||||
#define AMP_CTRL_MEDIUM_CAPACITY 0x04
|
||||
#define AMP_CTRL_HIGH_CAPACITY 0x05
|
||||
#define AMP_CTRL_FULL_CAPACITY 0x06
|
||||
|
||||
/* A2MP response status */
|
||||
#define A2MP_STATUS_SUCCESS 0x00
|
||||
#define A2MP_STATUS_INVALID_CTRL_ID 0x01
|
||||
#define A2MP_STATUS_UNABLE_START_LINK_CREATION 0x02
|
||||
#define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02
|
||||
#define A2MP_STATUS_COLLISION_OCCURED 0x03
|
||||
#define A2MP_STATUS_DISCONN_REQ_RECVD 0x04
|
||||
#define A2MP_STATUS_PHYS_LINK_EXISTS 0x05
|
||||
#define A2MP_STATUS_SECURITY_VIOLATION 0x06
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __A2MP_H */
|
||||
172
external/cache/sources/hcitools/lib/amp.h
vendored
Normal file
172
external/cache/sources/hcitools/lib/amp.h
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2010-2011 Code Aurora Forum. All rights reserved.
|
||||
* Copyright (C) 2012 Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __AMP_H
|
||||
#define __AMP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AMP_MGR_CID 0x03
|
||||
|
||||
/* AMP manager codes */
|
||||
#define AMP_COMMAND_REJ 0x01
|
||||
#define AMP_DISCOVER_REQ 0x02
|
||||
#define AMP_DISCOVER_RSP 0x03
|
||||
#define AMP_CHANGE_NOTIFY 0x04
|
||||
#define AMP_CHANGE_RSP 0x05
|
||||
#define AMP_INFO_REQ 0x06
|
||||
#define AMP_INFO_RSP 0x07
|
||||
#define AMP_ASSOC_REQ 0x08
|
||||
#define AMP_ASSOC_RSP 0x09
|
||||
#define AMP_LINK_REQ 0x0a
|
||||
#define AMP_LINK_RSP 0x0b
|
||||
#define AMP_DISCONN_REQ 0x0c
|
||||
#define AMP_DISCONN_RSP 0x0d
|
||||
|
||||
typedef struct {
|
||||
uint8_t code;
|
||||
uint8_t ident;
|
||||
uint16_t len;
|
||||
} __attribute__ ((packed)) amp_mgr_hdr;
|
||||
#define AMP_MGR_HDR_SIZE 4
|
||||
|
||||
/* AMP ASSOC structure */
|
||||
typedef struct {
|
||||
uint8_t type_id;
|
||||
uint16_t len;
|
||||
uint8_t data[0];
|
||||
} __attribute__ ((packed)) amp_assoc_tlv;
|
||||
|
||||
typedef struct {
|
||||
uint16_t reason;
|
||||
} __attribute__ ((packed)) amp_cmd_rej_parms;
|
||||
|
||||
typedef struct {
|
||||
uint16_t mtu;
|
||||
uint16_t mask;
|
||||
} __attribute__ ((packed)) amp_discover_req_parms;
|
||||
|
||||
typedef struct {
|
||||
uint16_t mtu;
|
||||
uint16_t mask;
|
||||
uint8_t controller_list[0];
|
||||
} __attribute__ ((packed)) amp_discover_rsp_parms;
|
||||
|
||||
typedef struct {
|
||||
uint8_t id;
|
||||
} __attribute__ ((packed)) amp_info_req_parms;
|
||||
|
||||
typedef struct {
|
||||
uint8_t id;
|
||||
uint8_t status;
|
||||
uint32_t total_bandwidth;
|
||||
uint32_t max_bandwidth;
|
||||
uint32_t min_latency;
|
||||
uint16_t pal_caps;
|
||||
uint16_t assoc_size;
|
||||
} __attribute__ ((packed)) amp_info_rsp_parms;
|
||||
|
||||
typedef struct {
|
||||
uint8_t id;
|
||||
uint8_t status;
|
||||
amp_assoc_tlv assoc;
|
||||
} __attribute__ ((packed)) amp_assoc_rsp_parms;
|
||||
|
||||
typedef struct {
|
||||
uint8_t local_id;
|
||||
uint8_t remote_id;
|
||||
amp_assoc_tlv assoc;
|
||||
} __attribute__ ((packed)) amp_link_req_parms;
|
||||
|
||||
typedef struct {
|
||||
uint8_t local_id;
|
||||
uint8_t remote_id;
|
||||
uint8_t status;
|
||||
} __attribute__ ((packed)) amp_link_rsp_parms;
|
||||
|
||||
typedef struct {
|
||||
uint8_t local_id;
|
||||
uint8_t remote_id;
|
||||
} __attribute__ ((packed)) amp_disconn_req_parms;
|
||||
|
||||
#define A2MP_MAC_ADDR_TYPE 1
|
||||
#define A2MP_PREF_CHANLIST_TYPE 2
|
||||
#define A2MP_CONNECTED_CHAN 3
|
||||
#define A2MP_PAL_CAP_TYPE 4
|
||||
#define A2MP_PAL_VER_INFO 5
|
||||
|
||||
struct amp_tlv {
|
||||
uint8_t type;
|
||||
uint16_t len;
|
||||
uint8_t val[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct amp_pal_ver {
|
||||
uint8_t ver;
|
||||
uint16_t company_id;
|
||||
uint16_t sub_ver;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct amp_country_triplet {
|
||||
union {
|
||||
struct {
|
||||
uint8_t first_channel;
|
||||
uint8_t num_channels;
|
||||
int8_t max_power;
|
||||
} __attribute__ ((packed)) chans;
|
||||
struct {
|
||||
uint8_t reg_extension_id;
|
||||
uint8_t reg_class;
|
||||
uint8_t coverage_class;
|
||||
} __attribute__ ((packed)) ext;
|
||||
};
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct amp_chan_list {
|
||||
uint8_t country_code[3];
|
||||
struct amp_country_triplet triplets[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define AMP_COMMAND_NOT_RECOGNIZED 0x0000
|
||||
|
||||
/* AMP controller status */
|
||||
#define AMP_CT_POWERED_DOWN 0x00
|
||||
#define AMP_CT_BLUETOOTH_ONLY 0x01
|
||||
#define AMP_CT_NO_CAPACITY 0x02
|
||||
#define AMP_CT_LOW_CAPACITY 0x03
|
||||
#define AMP_CT_MEDIUM_CAPACITY 0x04
|
||||
#define AMP_CT_HIGH_CAPACITY 0x05
|
||||
#define AMP_CT_FULL_CAPACITY 0x06
|
||||
|
||||
/* AMP response status */
|
||||
#define AMP_STATUS_SUCCESS 0x00
|
||||
#define AMP_STATUS_INVALID_CTRL_ID 0x01
|
||||
#define AMP_STATUS_UNABLE_START_LINK_CREATION 0x02
|
||||
#define AMP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02
|
||||
#define AMP_STATUS_COLLISION_OCCURED 0x03
|
||||
#define AMP_STATUS_DISCONN_REQ_RECVD 0x04
|
||||
#define AMP_STATUS_PHYS_LINK_EXISTS 0x05
|
||||
#define AMP_STATUS_SECURITY_VIOLATION 0x06
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __AMP_H */
|
||||
765
external/cache/sources/hcitools/lib/bluetooth.c
vendored
Normal file
765
external/cache/sources/hcitools/lib/bluetooth.c
vendored
Normal file
@@ -0,0 +1,765 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2000-2001 Qualcomm Incorporated
|
||||
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
|
||||
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "bluetooth.h"
|
||||
#include "hci.h"
|
||||
|
||||
void baswap(bdaddr_t *dst, const bdaddr_t *src)
|
||||
{
|
||||
register unsigned char *d = (unsigned char *) dst;
|
||||
register const unsigned char *s = (const unsigned char *) src;
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
d[i] = s[5-i];
|
||||
}
|
||||
|
||||
char *batostr(const bdaddr_t *ba)
|
||||
{
|
||||
char *str = bt_malloc(18);
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
|
||||
ba->b[0], ba->b[1], ba->b[2],
|
||||
ba->b[3], ba->b[4], ba->b[5]);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
bdaddr_t *strtoba(const char *str)
|
||||
{
|
||||
bdaddr_t b;
|
||||
bdaddr_t *ba = bt_malloc(sizeof(*ba));
|
||||
|
||||
if (ba) {
|
||||
str2ba(str, &b);
|
||||
baswap(ba, &b);
|
||||
}
|
||||
|
||||
return ba;
|
||||
}
|
||||
|
||||
int ba2str(const bdaddr_t *ba, char *str)
|
||||
{
|
||||
return sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
|
||||
ba->b[5], ba->b[4], ba->b[3], ba->b[2], ba->b[1], ba->b[0]);
|
||||
}
|
||||
|
||||
int str2ba(const char *str, bdaddr_t *ba)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (bachk(str) < 0) {
|
||||
memset(ba, 0, sizeof(*ba));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 5; i >= 0; i--, str += 3)
|
||||
ba->b[i] = strtol(str, NULL, 16);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ba2oui(const bdaddr_t *ba, char *str)
|
||||
{
|
||||
return sprintf(str, "%2.2X-%2.2X-%2.2X", ba->b[5], ba->b[4], ba->b[3]);
|
||||
}
|
||||
|
||||
int bachk(const char *str)
|
||||
{
|
||||
if (!str)
|
||||
return -1;
|
||||
|
||||
if (strlen(str) != 17)
|
||||
return -1;
|
||||
|
||||
while (*str) {
|
||||
if (!isxdigit(*str++))
|
||||
return -1;
|
||||
|
||||
if (!isxdigit(*str++))
|
||||
return -1;
|
||||
|
||||
if (*str == 0)
|
||||
break;
|
||||
|
||||
if (*str++ != ':')
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int baprintf(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int len;
|
||||
|
||||
va_start(ap, format);
|
||||
len = vprintf(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int bafprintf(FILE *stream, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int len;
|
||||
|
||||
va_start(ap, format);
|
||||
len = vfprintf(stream, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int basprintf(char *str, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int len;
|
||||
|
||||
va_start(ap, format);
|
||||
len = vsnprintf(str, (~0U) >> 1, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int basnprintf(char *str, size_t size, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int len;
|
||||
|
||||
va_start(ap, format);
|
||||
len = vsnprintf(str, size, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void *bt_malloc(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void bt_free(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
/* Bluetooth error codes to Unix errno mapping */
|
||||
int bt_error(uint16_t code)
|
||||
{
|
||||
switch (code) {
|
||||
case 0:
|
||||
return 0;
|
||||
case HCI_UNKNOWN_COMMAND:
|
||||
return EBADRQC;
|
||||
case HCI_NO_CONNECTION:
|
||||
return ENOTCONN;
|
||||
case HCI_HARDWARE_FAILURE:
|
||||
return EIO;
|
||||
case HCI_PAGE_TIMEOUT:
|
||||
return EHOSTDOWN;
|
||||
case HCI_AUTHENTICATION_FAILURE:
|
||||
return EACCES;
|
||||
case HCI_PIN_OR_KEY_MISSING:
|
||||
return EINVAL;
|
||||
case HCI_MEMORY_FULL:
|
||||
return ENOMEM;
|
||||
case HCI_CONNECTION_TIMEOUT:
|
||||
return ETIMEDOUT;
|
||||
case HCI_MAX_NUMBER_OF_CONNECTIONS:
|
||||
case HCI_MAX_NUMBER_OF_SCO_CONNECTIONS:
|
||||
return EMLINK;
|
||||
case HCI_ACL_CONNECTION_EXISTS:
|
||||
return EALREADY;
|
||||
case HCI_COMMAND_DISALLOWED:
|
||||
case HCI_TRANSACTION_COLLISION:
|
||||
case HCI_ROLE_SWITCH_PENDING:
|
||||
return EBUSY;
|
||||
case HCI_REJECTED_LIMITED_RESOURCES:
|
||||
case HCI_REJECTED_PERSONAL:
|
||||
case HCI_QOS_REJECTED:
|
||||
return ECONNREFUSED;
|
||||
case HCI_HOST_TIMEOUT:
|
||||
return ETIMEDOUT;
|
||||
case HCI_UNSUPPORTED_FEATURE:
|
||||
case HCI_QOS_NOT_SUPPORTED:
|
||||
case HCI_PAIRING_NOT_SUPPORTED:
|
||||
case HCI_CLASSIFICATION_NOT_SUPPORTED:
|
||||
case HCI_UNSUPPORTED_LMP_PARAMETER_VALUE:
|
||||
case HCI_PARAMETER_OUT_OF_RANGE:
|
||||
case HCI_QOS_UNACCEPTABLE_PARAMETER:
|
||||
return EOPNOTSUPP;
|
||||
case HCI_INVALID_PARAMETERS:
|
||||
case HCI_SLOT_VIOLATION:
|
||||
return EINVAL;
|
||||
case HCI_OE_USER_ENDED_CONNECTION:
|
||||
case HCI_OE_LOW_RESOURCES:
|
||||
case HCI_OE_POWER_OFF:
|
||||
return ECONNRESET;
|
||||
case HCI_CONNECTION_TERMINATED:
|
||||
return ECONNABORTED;
|
||||
case HCI_REPEATED_ATTEMPTS:
|
||||
return ELOOP;
|
||||
case HCI_REJECTED_SECURITY:
|
||||
case HCI_PAIRING_NOT_ALLOWED:
|
||||
case HCI_INSUFFICIENT_SECURITY:
|
||||
return EACCES;
|
||||
case HCI_UNSUPPORTED_REMOTE_FEATURE:
|
||||
return EPROTONOSUPPORT;
|
||||
case HCI_SCO_OFFSET_REJECTED:
|
||||
return ECONNREFUSED;
|
||||
case HCI_UNKNOWN_LMP_PDU:
|
||||
case HCI_INVALID_LMP_PARAMETERS:
|
||||
case HCI_LMP_ERROR_TRANSACTION_COLLISION:
|
||||
case HCI_LMP_PDU_NOT_ALLOWED:
|
||||
case HCI_ENCRYPTION_MODE_NOT_ACCEPTED:
|
||||
return EPROTO;
|
||||
default:
|
||||
return ENOSYS;
|
||||
}
|
||||
}
|
||||
|
||||
const char *bt_compidtostr(int compid)
|
||||
{
|
||||
switch (compid) {
|
||||
case 0:
|
||||
return "Ericsson Technology Licensing";
|
||||
case 1:
|
||||
return "Nokia Mobile Phones";
|
||||
case 2:
|
||||
return "Intel Corp.";
|
||||
case 3:
|
||||
return "IBM Corp.";
|
||||
case 4:
|
||||
return "Toshiba Corp.";
|
||||
case 5:
|
||||
return "3Com";
|
||||
case 6:
|
||||
return "Microsoft";
|
||||
case 7:
|
||||
return "Lucent";
|
||||
case 8:
|
||||
return "Motorola";
|
||||
case 9:
|
||||
return "Infineon Technologies AG";
|
||||
case 10:
|
||||
return "Cambridge Silicon Radio";
|
||||
case 11:
|
||||
return "Silicon Wave";
|
||||
case 12:
|
||||
return "Digianswer A/S";
|
||||
case 13:
|
||||
return "Texas Instruments Inc.";
|
||||
case 14:
|
||||
return "Ceva, Inc. (formerly Parthus Technologies, Inc.)";
|
||||
case 15:
|
||||
return "Broadcom Corporation";
|
||||
case 16:
|
||||
return "Mitel Semiconductor";
|
||||
case 17:
|
||||
return "Widcomm, Inc";
|
||||
case 18:
|
||||
return "Zeevo, Inc.";
|
||||
case 19:
|
||||
return "Atmel Corporation";
|
||||
case 20:
|
||||
return "Mitsubishi Electric Corporation";
|
||||
case 21:
|
||||
return "RTX Telecom A/S";
|
||||
case 22:
|
||||
return "KC Technology Inc.";
|
||||
case 23:
|
||||
return "NewLogic";
|
||||
case 24:
|
||||
return "Transilica, Inc.";
|
||||
case 25:
|
||||
return "Rohde & Schwarz GmbH & Co. KG";
|
||||
case 26:
|
||||
return "TTPCom Limited";
|
||||
case 27:
|
||||
return "Signia Technologies, Inc.";
|
||||
case 28:
|
||||
return "Conexant Systems Inc.";
|
||||
case 29:
|
||||
return "Qualcomm";
|
||||
case 30:
|
||||
return "Inventel";
|
||||
case 31:
|
||||
return "AVM Berlin";
|
||||
case 32:
|
||||
return "BandSpeed, Inc.";
|
||||
case 33:
|
||||
return "Mansella Ltd";
|
||||
case 34:
|
||||
return "NEC Corporation";
|
||||
case 35:
|
||||
return "WavePlus Technology Co., Ltd.";
|
||||
case 36:
|
||||
return "Alcatel";
|
||||
case 37:
|
||||
return "Philips Semiconductors";
|
||||
case 38:
|
||||
return "C Technologies";
|
||||
case 39:
|
||||
return "Open Interface";
|
||||
case 40:
|
||||
return "R F Micro Devices";
|
||||
case 41:
|
||||
return "Hitachi Ltd";
|
||||
case 42:
|
||||
return "Symbol Technologies, Inc.";
|
||||
case 43:
|
||||
return "Tenovis";
|
||||
case 44:
|
||||
return "Macronix International Co. Ltd.";
|
||||
case 45:
|
||||
return "GCT Semiconductor";
|
||||
case 46:
|
||||
return "Norwood Systems";
|
||||
case 47:
|
||||
return "MewTel Technology Inc.";
|
||||
case 48:
|
||||
return "ST Microelectronics";
|
||||
case 49:
|
||||
return "Synopsis";
|
||||
case 50:
|
||||
return "Red-M (Communications) Ltd";
|
||||
case 51:
|
||||
return "Commil Ltd";
|
||||
case 52:
|
||||
return "Computer Access Technology Corporation (CATC)";
|
||||
case 53:
|
||||
return "Eclipse (HQ Espana) S.L.";
|
||||
case 54:
|
||||
return "Renesas Technology Corp.";
|
||||
case 55:
|
||||
return "Mobilian Corporation";
|
||||
case 56:
|
||||
return "Terax";
|
||||
case 57:
|
||||
return "Integrated System Solution Corp.";
|
||||
case 58:
|
||||
return "Matsushita Electric Industrial Co., Ltd.";
|
||||
case 59:
|
||||
return "Gennum Corporation";
|
||||
case 60:
|
||||
return "Research In Motion";
|
||||
case 61:
|
||||
return "IPextreme, Inc.";
|
||||
case 62:
|
||||
return "Systems and Chips, Inc.";
|
||||
case 63:
|
||||
return "Bluetooth SIG, Inc.";
|
||||
case 64:
|
||||
return "Seiko Epson Corporation";
|
||||
case 65:
|
||||
return "Integrated Silicon Solution Taiwan, Inc.";
|
||||
case 66:
|
||||
return "CONWISE Technology Corporation Ltd";
|
||||
case 67:
|
||||
return "PARROT SA";
|
||||
case 68:
|
||||
return "Socket Mobile";
|
||||
case 69:
|
||||
return "Atheros Communications, Inc.";
|
||||
case 70:
|
||||
return "MediaTek, Inc.";
|
||||
case 71:
|
||||
return "Bluegiga";
|
||||
case 72:
|
||||
return "Marvell Technology Group Ltd.";
|
||||
case 73:
|
||||
return "3DSP Corporation";
|
||||
case 74:
|
||||
return "Accel Semiconductor Ltd.";
|
||||
case 75:
|
||||
return "Continental Automotive Systems";
|
||||
case 76:
|
||||
return "Apple, Inc.";
|
||||
case 77:
|
||||
return "Staccato Communications, Inc.";
|
||||
case 78:
|
||||
return "Avago Technologies";
|
||||
case 79:
|
||||
return "APT Licensing Ltd.";
|
||||
case 80:
|
||||
return "SiRF Technology";
|
||||
case 81:
|
||||
return "Tzero Technologies, Inc.";
|
||||
case 82:
|
||||
return "J&M Corporation";
|
||||
case 83:
|
||||
return "Free2move AB";
|
||||
case 84:
|
||||
return "3DiJoy Corporation";
|
||||
case 85:
|
||||
return "Plantronics, Inc.";
|
||||
case 86:
|
||||
return "Sony Ericsson Mobile Communications";
|
||||
case 87:
|
||||
return "Harman International Industries, Inc.";
|
||||
case 88:
|
||||
return "Vizio, Inc.";
|
||||
case 89:
|
||||
return "Nordic Semiconductor ASA";
|
||||
case 90:
|
||||
return "EM Microelectronic-Marin SA";
|
||||
case 91:
|
||||
return "Ralink Technology Corporation";
|
||||
case 92:
|
||||
return "Belkin International, Inc.";
|
||||
case 93:
|
||||
return "Realtek Semiconductor Corporation";
|
||||
case 94:
|
||||
return "Stonestreet One, LLC";
|
||||
case 95:
|
||||
return "Wicentric, Inc.";
|
||||
case 96:
|
||||
return "RivieraWaves S.A.S";
|
||||
case 97:
|
||||
return "RDA Microelectronics";
|
||||
case 98:
|
||||
return "Gibson Guitars";
|
||||
case 99:
|
||||
return "MiCommand Inc.";
|
||||
case 100:
|
||||
return "Band XI International, LLC";
|
||||
case 101:
|
||||
return "Hewlett-Packard Company";
|
||||
case 102:
|
||||
return "9Solutions Oy";
|
||||
case 103:
|
||||
return "GN Netcom A/S";
|
||||
case 104:
|
||||
return "General Motors";
|
||||
case 105:
|
||||
return "A&D Engineering, Inc.";
|
||||
case 106:
|
||||
return "MindTree Ltd.";
|
||||
case 107:
|
||||
return "Polar Electro OY";
|
||||
case 108:
|
||||
return "Beautiful Enterprise Co., Ltd.";
|
||||
case 109:
|
||||
return "BriarTek, Inc.";
|
||||
case 110:
|
||||
return "Summit Data Communications, Inc.";
|
||||
case 111:
|
||||
return "Sound ID";
|
||||
case 112:
|
||||
return "Monster, LLC";
|
||||
case 113:
|
||||
return "connectBlue AB";
|
||||
case 114:
|
||||
return "ShangHai Super Smart Electronics Co. Ltd.";
|
||||
case 115:
|
||||
return "Group Sense Ltd.";
|
||||
case 116:
|
||||
return "Zomm, LLC";
|
||||
case 117:
|
||||
return "Samsung Electronics Co. Ltd.";
|
||||
case 118:
|
||||
return "Creative Technology Ltd.";
|
||||
case 119:
|
||||
return "Laird Technologies";
|
||||
case 120:
|
||||
return "Nike, Inc.";
|
||||
case 121:
|
||||
return "lesswire AG";
|
||||
case 122:
|
||||
return "MStar Semiconductor, Inc.";
|
||||
case 123:
|
||||
return "Hanlynn Technologies";
|
||||
case 124:
|
||||
return "A & R Cambridge";
|
||||
case 125:
|
||||
return "Seers Technology Co. Ltd";
|
||||
case 126:
|
||||
return "Sports Tracking Technologies Ltd.";
|
||||
case 127:
|
||||
return "Autonet Mobile";
|
||||
case 128:
|
||||
return "DeLorme Publishing Company, Inc.";
|
||||
case 129:
|
||||
return "WuXi Vimicro";
|
||||
case 130:
|
||||
return "Sennheiser Communications A/S";
|
||||
case 131:
|
||||
return "TimeKeeping Systems, Inc.";
|
||||
case 132:
|
||||
return "Ludus Helsinki Ltd.";
|
||||
case 133:
|
||||
return "BlueRadios, Inc.";
|
||||
case 134:
|
||||
return "equinox AG";
|
||||
case 135:
|
||||
return "Garmin International, Inc.";
|
||||
case 136:
|
||||
return "Ecotest";
|
||||
case 137:
|
||||
return "GN ReSound A/S";
|
||||
case 138:
|
||||
return "Jawbone";
|
||||
case 139:
|
||||
return "Topcorn Positioning Systems, LLC";
|
||||
case 140:
|
||||
return "Qualcomm Labs, Inc.";
|
||||
case 141:
|
||||
return "Zscan Software";
|
||||
case 142:
|
||||
return "Quintic Corp.";
|
||||
case 143:
|
||||
return "Stollman E+V GmbH";
|
||||
case 144:
|
||||
return "Funai Electric Co., Ltd.";
|
||||
case 145:
|
||||
return "Advanced PANMOBIL Systems GmbH & Co. KG";
|
||||
case 146:
|
||||
return "ThinkOptics, Inc.";
|
||||
case 147:
|
||||
return "Universal Electronics, Inc.";
|
||||
case 148:
|
||||
return "Airoha Technology Corp.";
|
||||
case 149:
|
||||
return "NEC Lighting, Ltd.";
|
||||
case 150:
|
||||
return "ODM Technology, Inc.";
|
||||
case 151:
|
||||
return "ConnecteDevice Ltd.";
|
||||
case 152:
|
||||
return "zer01.tv GmbH";
|
||||
case 153:
|
||||
return "i.Tech Dynamic Global Distribution Ltd.";
|
||||
case 154:
|
||||
return "Alpwise";
|
||||
case 155:
|
||||
return "Jiangsu Toppower Automotive Electronics Co., Ltd.";
|
||||
case 156:
|
||||
return "Colorfy, Inc.";
|
||||
case 157:
|
||||
return "Geoforce Inc.";
|
||||
case 158:
|
||||
return "Bose Corporation";
|
||||
case 159:
|
||||
return "Suunto Oy";
|
||||
case 160:
|
||||
return "Kensington Computer Products Group";
|
||||
case 161:
|
||||
return "SR-Medizinelektronik";
|
||||
case 162:
|
||||
return "Vertu Corporation Limited";
|
||||
case 163:
|
||||
return "Meta Watch Ltd.";
|
||||
case 164:
|
||||
return "LINAK A/S";
|
||||
case 165:
|
||||
return "OTL Dynamics LLC";
|
||||
case 166:
|
||||
return "Panda Ocean Inc.";
|
||||
case 167:
|
||||
return "Visteon Corporation";
|
||||
case 168:
|
||||
return "ARP Devices Limited";
|
||||
case 169:
|
||||
return "Magneti Marelli S.p.A";
|
||||
case 170:
|
||||
return "CAEN RFID srl";
|
||||
case 171:
|
||||
return "Ingenieur-Systemgruppe Zahn GmbH";
|
||||
case 172:
|
||||
return "Green Throttle Games";
|
||||
case 173:
|
||||
return "Peter Systemtechnik GmbH";
|
||||
case 174:
|
||||
return "Omegawave Oy";
|
||||
case 175:
|
||||
return "Cinetix";
|
||||
case 176:
|
||||
return "Passif Semiconductor Corp";
|
||||
case 177:
|
||||
return "Saris Cycling Group, Inc";
|
||||
case 178:
|
||||
return "Bekey A/S";
|
||||
case 179:
|
||||
return "Clarinox Technologies Pty. Ltd.";
|
||||
case 180:
|
||||
return "BDE Technology Co., Ltd.";
|
||||
case 181:
|
||||
return "Swirl Networks";
|
||||
case 182:
|
||||
return "Meso international";
|
||||
case 183:
|
||||
return "TreLab Ltd";
|
||||
case 184:
|
||||
return "Qualcomm Innovation Center, Inc. (QuIC)";
|
||||
case 185:
|
||||
return "Johnson Controls, Inc.";
|
||||
case 186:
|
||||
return "Starkey Laboratories Inc.";
|
||||
case 187:
|
||||
return "S-Power Electronics Limited";
|
||||
case 188:
|
||||
return "Ace Sensor Inc";
|
||||
case 189:
|
||||
return "Aplix Corporation";
|
||||
case 190:
|
||||
return "AAMP of America";
|
||||
case 191:
|
||||
return "Stalmart Technology Limited";
|
||||
case 192:
|
||||
return "AMICCOM Electronics Corporation";
|
||||
case 193:
|
||||
return "Shenzhen Excelsecu Data Technology Co.,Ltd";
|
||||
case 194:
|
||||
return "Geneq Inc.";
|
||||
case 195:
|
||||
return "adidas AG";
|
||||
case 196:
|
||||
return "LG Electronics";
|
||||
case 197:
|
||||
return "Onset Computer Corporation";
|
||||
case 198:
|
||||
return "Selfly BV";
|
||||
case 199:
|
||||
return "Quuppa Oy.";
|
||||
case 200:
|
||||
return "GeLo Inc";
|
||||
case 201:
|
||||
return "Evluma";
|
||||
case 202:
|
||||
return "MC10";
|
||||
case 203:
|
||||
return "Binauric SE";
|
||||
case 204:
|
||||
return "Beats Electronics";
|
||||
case 205:
|
||||
return "Microchip Technology Inc.";
|
||||
case 206:
|
||||
return "Elgato Systems GmbH";
|
||||
case 207:
|
||||
return "ARCHOS SA";
|
||||
case 209:
|
||||
return "Polar Electro Europe B.V.";
|
||||
case 210:
|
||||
return "Dialog Semiconductor B.V.";
|
||||
case 211:
|
||||
return "Taixingbang Technology (HK) Co,. LTD.";
|
||||
case 212:
|
||||
return "Kawantech";
|
||||
case 213:
|
||||
return "Austco Communication Systems";
|
||||
case 214:
|
||||
return "Timex Group USA, Inc.";
|
||||
case 215:
|
||||
return "Qualcomm Technologies, Inc.";
|
||||
case 216:
|
||||
return "Qualcomm Connected Experiences, Inc.";
|
||||
case 217:
|
||||
return "Voyetra Turtle Beach";
|
||||
case 218:
|
||||
return "txtr GmbH";
|
||||
case 219:
|
||||
return "Biosentronics";
|
||||
case 220:
|
||||
return "Procter & Gamble";
|
||||
case 221:
|
||||
return "Hosiden Corporation";
|
||||
case 222:
|
||||
return "Muzik LLC";
|
||||
case 223:
|
||||
return "Misfit Wearables Corp";
|
||||
case 224:
|
||||
return "Google";
|
||||
case 225:
|
||||
return "Danlers Ltd";
|
||||
case 226:
|
||||
return "Semilink Inc";
|
||||
case 227:
|
||||
return "inMusic Brands, Inc";
|
||||
case 228:
|
||||
return "L.S. Research Inc.";
|
||||
case 229:
|
||||
return "Eden Software Consultants Ltd.";
|
||||
case 230:
|
||||
return "Freshtemp";
|
||||
case 231:
|
||||
return "KS Technologies";
|
||||
case 232:
|
||||
return "ACTS Technologies";
|
||||
case 233:
|
||||
return "Vtrack Systems";
|
||||
case 234:
|
||||
return "Nielsen-Kellerman Company";
|
||||
case 235:
|
||||
return "Server Technology, Inc.";
|
||||
case 236:
|
||||
return "BioResearch Associates";
|
||||
case 237:
|
||||
return "Jolly Logic, LLC";
|
||||
case 238:
|
||||
return "Above Average Outcomes, Inc.";
|
||||
case 239:
|
||||
return "Bitsplitters GmbH";
|
||||
case 240:
|
||||
return "PayPal, Inc.";
|
||||
case 241:
|
||||
return "Witron Technology Limited";
|
||||
case 242:
|
||||
return "Morse Project Inc.";
|
||||
case 243:
|
||||
return "Kent Displays Inc.";
|
||||
case 244:
|
||||
return "Nautilus Inc.";
|
||||
case 245:
|
||||
return "Smartifier Oy";
|
||||
case 246:
|
||||
return "Elcometer Limited";
|
||||
case 247:
|
||||
return "VSN Technologies Inc.";
|
||||
case 248:
|
||||
return "AceUni Corp., Ltd.";
|
||||
case 65535:
|
||||
return "internal use";
|
||||
default:
|
||||
return "not assigned";
|
||||
}
|
||||
}
|
||||
389
external/cache/sources/hcitools/lib/bluetooth/bluetooth.h
vendored
Normal file
389
external/cache/sources/hcitools/lib/bluetooth/bluetooth.h
vendored
Normal file
@@ -0,0 +1,389 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2000-2001 Qualcomm Incorporated
|
||||
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
|
||||
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __BLUETOOTH_H
|
||||
#define __BLUETOOTH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <endian.h>
|
||||
#include <byteswap.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#ifndef AF_BLUETOOTH
|
||||
#define AF_BLUETOOTH 31
|
||||
#define PF_BLUETOOTH AF_BLUETOOTH
|
||||
#endif
|
||||
|
||||
#define BTPROTO_L2CAP 0
|
||||
#define BTPROTO_HCI 1
|
||||
#define BTPROTO_SCO 2
|
||||
#define BTPROTO_RFCOMM 3
|
||||
#define BTPROTO_BNEP 4
|
||||
#define BTPROTO_CMTP 5
|
||||
#define BTPROTO_HIDP 6
|
||||
#define BTPROTO_AVDTP 7
|
||||
|
||||
#define SOL_HCI 0
|
||||
#define SOL_L2CAP 6
|
||||
#define SOL_SCO 17
|
||||
#define SOL_RFCOMM 18
|
||||
|
||||
#ifndef SOL_BLUETOOTH
|
||||
#define SOL_BLUETOOTH 274
|
||||
#endif
|
||||
|
||||
#define BT_SECURITY 4
|
||||
struct bt_security {
|
||||
uint8_t level;
|
||||
uint8_t key_size;
|
||||
};
|
||||
#define BT_SECURITY_SDP 0
|
||||
#define BT_SECURITY_LOW 1
|
||||
#define BT_SECURITY_MEDIUM 2
|
||||
#define BT_SECURITY_HIGH 3
|
||||
|
||||
#define BT_DEFER_SETUP 7
|
||||
|
||||
#define BT_FLUSHABLE 8
|
||||
|
||||
#define BT_FLUSHABLE_OFF 0
|
||||
#define BT_FLUSHABLE_ON 1
|
||||
|
||||
#define BT_CHANNEL_POLICY 10
|
||||
|
||||
/* BR/EDR only (default policy)
|
||||
* AMP controllers cannot be used.
|
||||
* Channel move requests from the remote device are denied.
|
||||
* If the L2CAP channel is currently using AMP, move the channel to BR/EDR.
|
||||
*/
|
||||
#define BT_CHANNEL_POLICY_BREDR_ONLY 0
|
||||
|
||||
/* BR/EDR Preferred
|
||||
* Allow use of AMP controllers.
|
||||
* If the L2CAP channel is currently on AMP, move it to BR/EDR.
|
||||
* Channel move requests from the remote device are allowed.
|
||||
*/
|
||||
#define BT_CHANNEL_POLICY_BREDR_PREFERRED 1
|
||||
|
||||
/* AMP Preferred
|
||||
* Allow use of AMP controllers
|
||||
* If the L2CAP channel is currently on BR/EDR and AMP controller
|
||||
* resources are available, initiate a channel move to AMP.
|
||||
* Channel move requests from the remote device are allowed.
|
||||
* If the L2CAP socket has not been connected yet, try to create
|
||||
* and configure the channel directly on an AMP controller rather
|
||||
* than BR/EDR.
|
||||
*/
|
||||
#define BT_CHANNEL_POLICY_AMP_PREFERRED 2
|
||||
|
||||
#define BT_VOICE 11
|
||||
struct bt_voice {
|
||||
uint16_t setting;
|
||||
};
|
||||
|
||||
#define BT_VOICE_TRANSPARENT 0x0003
|
||||
#define BT_VOICE_CVSD_16BIT 0x0060
|
||||
|
||||
/* Connection and socket states */
|
||||
enum {
|
||||
BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
|
||||
BT_OPEN,
|
||||
BT_BOUND,
|
||||
BT_LISTEN,
|
||||
BT_CONNECT,
|
||||
BT_CONNECT2,
|
||||
BT_CONFIG,
|
||||
BT_DISCONN,
|
||||
BT_CLOSED
|
||||
};
|
||||
|
||||
/* Byte order conversions */
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define htobs(d) (d)
|
||||
#define htobl(d) (d)
|
||||
#define htobll(d) (d)
|
||||
#define btohs(d) (d)
|
||||
#define btohl(d) (d)
|
||||
#define btohll(d) (d)
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define htobs(d) bswap_16(d)
|
||||
#define htobl(d) bswap_32(d)
|
||||
#define htobll(d) bswap_64(d)
|
||||
#define btohs(d) bswap_16(d)
|
||||
#define btohl(d) bswap_32(d)
|
||||
#define btohll(d) bswap_64(d)
|
||||
#else
|
||||
#error "Unknown byte order"
|
||||
#endif
|
||||
|
||||
/* Bluetooth unaligned access */
|
||||
#define bt_get_unaligned(ptr) \
|
||||
({ \
|
||||
struct __attribute__((packed)) { \
|
||||
typeof(*(ptr)) __v; \
|
||||
} *__p = (typeof(__p)) (ptr); \
|
||||
__p->__v; \
|
||||
})
|
||||
|
||||
#define bt_put_unaligned(val, ptr) \
|
||||
do { \
|
||||
struct __attribute__((packed)) { \
|
||||
typeof(*(ptr)) __v; \
|
||||
} *__p = (typeof(__p)) (ptr); \
|
||||
__p->__v = (val); \
|
||||
} while(0)
|
||||
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
static inline uint64_t bt_get_le64(const void *ptr)
|
||||
{
|
||||
return bt_get_unaligned((const uint64_t *) ptr);
|
||||
}
|
||||
|
||||
static inline uint64_t bt_get_be64(const void *ptr)
|
||||
{
|
||||
return bswap_64(bt_get_unaligned((const uint64_t *) ptr));
|
||||
}
|
||||
|
||||
static inline uint32_t bt_get_le32(const void *ptr)
|
||||
{
|
||||
return bt_get_unaligned((const uint32_t *) ptr);
|
||||
}
|
||||
|
||||
static inline uint32_t bt_get_be32(const void *ptr)
|
||||
{
|
||||
return bswap_32(bt_get_unaligned((const uint32_t *) ptr));
|
||||
}
|
||||
|
||||
static inline uint16_t bt_get_le16(const void *ptr)
|
||||
{
|
||||
return bt_get_unaligned((const uint16_t *) ptr);
|
||||
}
|
||||
|
||||
static inline uint16_t bt_get_be16(const void *ptr)
|
||||
{
|
||||
return bswap_16(bt_get_unaligned((const uint16_t *) ptr));
|
||||
}
|
||||
|
||||
static inline void bt_put_le64(uint64_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(val, (uint64_t *) ptr);
|
||||
}
|
||||
|
||||
static inline void bt_put_be64(uint64_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(bswap_64(val), (uint64_t *) ptr);
|
||||
}
|
||||
|
||||
static inline void bt_put_le32(uint32_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(val, (uint32_t *) ptr);
|
||||
}
|
||||
|
||||
static inline void bt_put_be32(uint32_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(bswap_32(val), (uint32_t *) ptr);
|
||||
}
|
||||
|
||||
static inline void bt_put_le16(uint16_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(val, (uint16_t *) ptr);
|
||||
}
|
||||
|
||||
static inline void bt_put_be16(uint16_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(bswap_16(val), (uint16_t *) ptr);
|
||||
}
|
||||
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
static inline uint64_t bt_get_le64(const void *ptr)
|
||||
{
|
||||
return bswap_64(bt_get_unaligned((const uint64_t *) ptr));
|
||||
}
|
||||
|
||||
static inline uint64_t bt_get_be64(const void *ptr)
|
||||
{
|
||||
return bt_get_unaligned((const uint64_t *) ptr);
|
||||
}
|
||||
|
||||
static inline uint32_t bt_get_le32(const void *ptr)
|
||||
{
|
||||
return bswap_32(bt_get_unaligned((const uint32_t *) ptr));
|
||||
}
|
||||
|
||||
static inline uint32_t bt_get_be32(const void *ptr)
|
||||
{
|
||||
return bt_get_unaligned((const uint32_t *) ptr);
|
||||
}
|
||||
|
||||
static inline uint16_t bt_get_le16(const void *ptr)
|
||||
{
|
||||
return bswap_16(bt_get_unaligned((const uint16_t *) ptr));
|
||||
}
|
||||
|
||||
static inline uint16_t bt_get_be16(const void *ptr)
|
||||
{
|
||||
return bt_get_unaligned((const uint16_t *) ptr);
|
||||
}
|
||||
|
||||
static inline void bt_put_le64(uint64_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(bswap_64(val), (uint64_t *) ptr);
|
||||
}
|
||||
|
||||
static inline void bt_put_be64(uint64_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(val, (uint64_t *) ptr);
|
||||
}
|
||||
|
||||
static inline void bt_put_le32(uint32_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(bswap_32(val), (uint32_t *) ptr);
|
||||
}
|
||||
|
||||
static inline void bt_put_be32(uint32_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(val, (uint32_t *) ptr);
|
||||
}
|
||||
|
||||
static inline void bt_put_le16(uint16_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(bswap_16(val), (uint16_t *) ptr);
|
||||
}
|
||||
|
||||
static inline void bt_put_be16(uint16_t val, const void *ptr)
|
||||
{
|
||||
bt_put_unaligned(val, (uint16_t *) ptr);
|
||||
}
|
||||
#else
|
||||
#error "Unknown byte order"
|
||||
#endif
|
||||
|
||||
/* BD Address */
|
||||
typedef struct {
|
||||
uint8_t b[6];
|
||||
} __attribute__((packed)) bdaddr_t;
|
||||
|
||||
/* BD Address type */
|
||||
#define BDADDR_BREDR 0x00
|
||||
#define BDADDR_LE_PUBLIC 0x01
|
||||
#define BDADDR_LE_RANDOM 0x02
|
||||
|
||||
#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
|
||||
#define BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
|
||||
#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
|
||||
|
||||
/* Copy, swap, convert BD Address */
|
||||
static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
|
||||
{
|
||||
return memcmp(ba1, ba2, sizeof(bdaddr_t));
|
||||
}
|
||||
static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
|
||||
{
|
||||
memcpy(dst, src, sizeof(bdaddr_t));
|
||||
}
|
||||
|
||||
void baswap(bdaddr_t *dst, const bdaddr_t *src);
|
||||
bdaddr_t *strtoba(const char *str);
|
||||
char *batostr(const bdaddr_t *ba);
|
||||
int ba2str(const bdaddr_t *ba, char *str);
|
||||
int str2ba(const char *str, bdaddr_t *ba);
|
||||
int ba2oui(const bdaddr_t *ba, char *oui);
|
||||
int bachk(const char *str);
|
||||
|
||||
int baprintf(const char *format, ...);
|
||||
int bafprintf(FILE *stream, const char *format, ...);
|
||||
int basprintf(char *str, const char *format, ...);
|
||||
int basnprintf(char *str, size_t size, const char *format, ...);
|
||||
|
||||
void *bt_malloc(size_t size);
|
||||
void bt_free(void *ptr);
|
||||
|
||||
int bt_error(uint16_t code);
|
||||
const char *bt_compidtostr(int id);
|
||||
|
||||
typedef struct {
|
||||
uint8_t data[16];
|
||||
} uint128_t;
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
|
||||
#define ntoh64(x) (x)
|
||||
|
||||
static inline void ntoh128(const uint128_t *src, uint128_t *dst)
|
||||
{
|
||||
memcpy(dst, src, sizeof(uint128_t));
|
||||
}
|
||||
|
||||
static inline void btoh128(const uint128_t *src, uint128_t *dst)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
dst->data[15 - i] = src->data[i];
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline uint64_t ntoh64(uint64_t n)
|
||||
{
|
||||
uint64_t h;
|
||||
uint64_t tmp = ntohl(n & 0x00000000ffffffff);
|
||||
|
||||
h = ntohl(n >> 32);
|
||||
h |= tmp << 32;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
static inline void ntoh128(const uint128_t *src, uint128_t *dst)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
dst->data[15 - i] = src->data[i];
|
||||
}
|
||||
|
||||
static inline void btoh128(const uint128_t *src, uint128_t *dst)
|
||||
{
|
||||
memcpy(dst, src, sizeof(uint128_t));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define hton64(x) ntoh64(x)
|
||||
#define hton128(x, y) ntoh128(x, y)
|
||||
#define htob128(x, y) btoh128(x, y)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BLUETOOTH_H */
|
||||
153
external/cache/sources/hcitools/lib/bluetooth/bnep.h
vendored
Normal file
153
external/cache/sources/hcitools/lib/bluetooth/bnep.h
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
|
||||
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __BNEP_H
|
||||
#define __BNEP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
|
||||
#ifndef ETH_ALEN
|
||||
#define ETH_ALEN 6 /* from <net/ethernet.h> */
|
||||
#endif
|
||||
|
||||
/* BNEP UUIDs */
|
||||
#define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB
|
||||
#define BNEP_UUID16 0x02
|
||||
#define BNEP_UUID32 0x04
|
||||
#define BNEP_UUID128 0x16
|
||||
|
||||
#define BNEP_SVC_PANU 0x1115
|
||||
#define BNEP_SVC_NAP 0x1116
|
||||
#define BNEP_SVC_GN 0x1117
|
||||
|
||||
/* BNEP packet types */
|
||||
#define BNEP_GENERAL 0x00
|
||||
#define BNEP_CONTROL 0x01
|
||||
#define BNEP_COMPRESSED 0x02
|
||||
#define BNEP_COMPRESSED_SRC_ONLY 0x03
|
||||
#define BNEP_COMPRESSED_DST_ONLY 0x04
|
||||
|
||||
/* BNEP control types */
|
||||
#define BNEP_CMD_NOT_UNDERSTOOD 0x00
|
||||
#define BNEP_SETUP_CONN_REQ 0x01
|
||||
#define BNEP_SETUP_CONN_RSP 0x02
|
||||
#define BNEP_FILTER_NET_TYPE_SET 0x03
|
||||
#define BNEP_FILTER_NET_TYPE_RSP 0x04
|
||||
#define BNEP_FILTER_MULT_ADDR_SET 0x05
|
||||
#define BNEP_FILTER_MULT_ADDR_RSP 0x06
|
||||
|
||||
/* BNEP response messages */
|
||||
#define BNEP_SUCCESS 0x00
|
||||
|
||||
#define BNEP_CONN_INVALID_DST 0x01
|
||||
#define BNEP_CONN_INVALID_SRC 0x02
|
||||
#define BNEP_CONN_INVALID_SVC 0x03
|
||||
#define BNEP_CONN_NOT_ALLOWED 0x04
|
||||
|
||||
#define BNEP_FILTER_UNSUPPORTED_REQ 0x01
|
||||
#define BNEP_FILTER_INVALID_RANGE 0x02
|
||||
#define BNEP_FILTER_INVALID_MCADDR 0x02
|
||||
#define BNEP_FILTER_LIMIT_REACHED 0x03
|
||||
#define BNEP_FILTER_DENIED_SECURITY 0x04
|
||||
|
||||
/* L2CAP settings */
|
||||
#define BNEP_MTU 1691
|
||||
#define BNEP_FLUSH_TO 0xffff
|
||||
#define BNEP_CONNECT_TO 15
|
||||
#define BNEP_FILTER_TO 15
|
||||
|
||||
#ifndef BNEP_PSM
|
||||
#define BNEP_PSM 0x0f
|
||||
#endif
|
||||
|
||||
/* BNEP headers */
|
||||
#define BNEP_TYPE_MASK 0x7f
|
||||
#define BNEP_EXT_HEADER 0x80
|
||||
|
||||
struct bnep_setup_conn_req {
|
||||
uint8_t type;
|
||||
uint8_t ctrl;
|
||||
uint8_t uuid_size;
|
||||
uint8_t service[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct bnep_set_filter_req {
|
||||
uint8_t type;
|
||||
uint8_t ctrl;
|
||||
uint16_t len;
|
||||
uint8_t list[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct bnep_control_rsp {
|
||||
uint8_t type;
|
||||
uint8_t ctrl;
|
||||
uint16_t resp;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct bnep_ext_hdr {
|
||||
uint8_t type;
|
||||
uint8_t len;
|
||||
uint8_t data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
/* BNEP ioctl defines */
|
||||
#define BNEPCONNADD _IOW('B', 200, int)
|
||||
#define BNEPCONNDEL _IOW('B', 201, int)
|
||||
#define BNEPGETCONNLIST _IOR('B', 210, int)
|
||||
#define BNEPGETCONNINFO _IOR('B', 211, int)
|
||||
|
||||
struct bnep_connadd_req {
|
||||
int sock; /* Connected socket */
|
||||
uint32_t flags;
|
||||
uint16_t role;
|
||||
char device[16]; /* Name of the Ethernet device */
|
||||
};
|
||||
|
||||
struct bnep_conndel_req {
|
||||
uint32_t flags;
|
||||
uint8_t dst[ETH_ALEN];
|
||||
};
|
||||
|
||||
struct bnep_conninfo {
|
||||
uint32_t flags;
|
||||
uint16_t role;
|
||||
uint16_t state;
|
||||
uint8_t dst[ETH_ALEN];
|
||||
char device[16];
|
||||
};
|
||||
|
||||
struct bnep_connlist_req {
|
||||
uint32_t cnum;
|
||||
struct bnep_conninfo *ci;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BNEP_H */
|
||||
69
external/cache/sources/hcitools/lib/bluetooth/cmtp.h
vendored
Normal file
69
external/cache/sources/hcitools/lib/bluetooth/cmtp.h
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __CMTP_H
|
||||
#define __CMTP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* CMTP defaults */
|
||||
#define CMTP_MINIMUM_MTU 152
|
||||
#define CMTP_DEFAULT_MTU 672
|
||||
|
||||
/* CMTP ioctl defines */
|
||||
#define CMTPCONNADD _IOW('C', 200, int)
|
||||
#define CMTPCONNDEL _IOW('C', 201, int)
|
||||
#define CMTPGETCONNLIST _IOR('C', 210, int)
|
||||
#define CMTPGETCONNINFO _IOR('C', 211, int)
|
||||
|
||||
#define CMTP_LOOPBACK 0
|
||||
|
||||
struct cmtp_connadd_req {
|
||||
int sock; /* Connected socket */
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
struct cmtp_conndel_req {
|
||||
bdaddr_t bdaddr;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
struct cmtp_conninfo {
|
||||
bdaddr_t bdaddr;
|
||||
uint32_t flags;
|
||||
uint16_t state;
|
||||
int num;
|
||||
};
|
||||
|
||||
struct cmtp_connlist_req {
|
||||
uint32_t cnum;
|
||||
struct cmtp_conninfo *ci;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMTP_H */
|
||||
2418
external/cache/sources/hcitools/lib/bluetooth/hci.h
vendored
Normal file
2418
external/cache/sources/hcitools/lib/bluetooth/hci.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
235
external/cache/sources/hcitools/lib/bluetooth/hci_lib.h
vendored
Normal file
235
external/cache/sources/hcitools/lib/bluetooth/hci_lib.h
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2000-2001 Qualcomm Incorporated
|
||||
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
|
||||
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __HCI_LIB_H
|
||||
#define __HCI_LIB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct hci_request {
|
||||
uint16_t ogf;
|
||||
uint16_t ocf;
|
||||
int event;
|
||||
void *cparam;
|
||||
int clen;
|
||||
void *rparam;
|
||||
int rlen;
|
||||
};
|
||||
|
||||
struct hci_version {
|
||||
uint16_t manufacturer;
|
||||
uint8_t hci_ver;
|
||||
uint16_t hci_rev;
|
||||
uint8_t lmp_ver;
|
||||
uint16_t lmp_subver;
|
||||
};
|
||||
|
||||
int hci_open_dev(int dev_id);
|
||||
int hci_close_dev(int dd);
|
||||
int hci_send_cmd(int dd, uint16_t ogf, uint16_t ocf, uint8_t plen, void *param);
|
||||
int hci_send_req(int dd, struct hci_request *req, int timeout);
|
||||
|
||||
int hci_create_connection(int dd, const bdaddr_t *bdaddr, uint16_t ptype, uint16_t clkoffset, uint8_t rswitch, uint16_t *handle, int to);
|
||||
int hci_disconnect(int dd, uint16_t handle, uint8_t reason, int to);
|
||||
|
||||
int hci_inquiry(int dev_id, int len, int num_rsp, const uint8_t *lap, inquiry_info **ii, long flags);
|
||||
int hci_devinfo(int dev_id, struct hci_dev_info *di);
|
||||
int hci_devba(int dev_id, bdaddr_t *bdaddr);
|
||||
int hci_devid(const char *str);
|
||||
|
||||
int hci_read_local_name(int dd, int len, char *name, int to);
|
||||
int hci_write_local_name(int dd, const char *name, int to);
|
||||
int hci_read_remote_name(int dd, const bdaddr_t *bdaddr, int len, char *name, int to);
|
||||
int hci_read_remote_name_with_clock_offset(int dd, const bdaddr_t *bdaddr, uint8_t pscan_rep_mode, uint16_t clkoffset, int len, char *name, int to);
|
||||
int hci_read_remote_name_cancel(int dd, const bdaddr_t *bdaddr, int to);
|
||||
int hci_read_remote_version(int dd, uint16_t handle, struct hci_version *ver, int to);
|
||||
int hci_read_remote_features(int dd, uint16_t handle, uint8_t *features, int to);
|
||||
int hci_read_remote_ext_features(int dd, uint16_t handle, uint8_t page, uint8_t *max_page, uint8_t *features, int to);
|
||||
int hci_read_clock_offset(int dd, uint16_t handle, uint16_t *clkoffset, int to);
|
||||
int hci_read_local_version(int dd, struct hci_version *ver, int to);
|
||||
int hci_read_local_commands(int dd, uint8_t *commands, int to);
|
||||
int hci_read_local_features(int dd, uint8_t *features, int to);
|
||||
int hci_read_local_ext_features(int dd, uint8_t page, uint8_t *max_page, uint8_t *features, int to);
|
||||
int hci_read_bd_addr(int dd, bdaddr_t *bdaddr, int to);
|
||||
int hci_read_class_of_dev(int dd, uint8_t *cls, int to);
|
||||
int hci_write_class_of_dev(int dd, uint32_t cls, int to);
|
||||
int hci_read_voice_setting(int dd, uint16_t *vs, int to);
|
||||
int hci_write_voice_setting(int dd, uint16_t vs, int to);
|
||||
int hci_read_current_iac_lap(int dd, uint8_t *num_iac, uint8_t *lap, int to);
|
||||
int hci_write_current_iac_lap(int dd, uint8_t num_iac, uint8_t *lap, int to);
|
||||
int hci_read_stored_link_key(int dd, bdaddr_t *bdaddr, uint8_t all, int to);
|
||||
int hci_write_stored_link_key(int dd, bdaddr_t *bdaddr, uint8_t *key, int to);
|
||||
int hci_delete_stored_link_key(int dd, bdaddr_t *bdaddr, uint8_t all, int to);
|
||||
int hci_authenticate_link(int dd, uint16_t handle, int to);
|
||||
int hci_encrypt_link(int dd, uint16_t handle, uint8_t encrypt, int to);
|
||||
int hci_change_link_key(int dd, uint16_t handle, int to);
|
||||
int hci_switch_role(int dd, bdaddr_t *bdaddr, uint8_t role, int to);
|
||||
int hci_park_mode(int dd, uint16_t handle, uint16_t max_interval, uint16_t min_interval, int to);
|
||||
int hci_exit_park_mode(int dd, uint16_t handle, int to);
|
||||
int hci_read_inquiry_scan_type(int dd, uint8_t *type, int to);
|
||||
int hci_write_inquiry_scan_type(int dd, uint8_t type, int to);
|
||||
int hci_read_inquiry_mode(int dd, uint8_t *mode, int to);
|
||||
int hci_write_inquiry_mode(int dd, uint8_t mode, int to);
|
||||
int hci_read_afh_mode(int dd, uint8_t *mode, int to);
|
||||
int hci_write_afh_mode(int dd, uint8_t mode, int to);
|
||||
int hci_read_ext_inquiry_response(int dd, uint8_t *fec, uint8_t *data, int to);
|
||||
int hci_write_ext_inquiry_response(int dd, uint8_t fec, uint8_t *data, int to);
|
||||
int hci_read_simple_pairing_mode(int dd, uint8_t *mode, int to);
|
||||
int hci_write_simple_pairing_mode(int dd, uint8_t mode, int to);
|
||||
int hci_read_local_oob_data(int dd, uint8_t *hash, uint8_t *randomizer, int to);
|
||||
int hci_read_inq_response_tx_power_level(int dd, int8_t *level, int to);
|
||||
int hci_read_inquiry_transmit_power_level(int dd, int8_t *level, int to);
|
||||
int hci_write_inquiry_transmit_power_level(int dd, int8_t level, int to);
|
||||
int hci_read_transmit_power_level(int dd, uint16_t handle, uint8_t type, int8_t *level, int to);
|
||||
int hci_read_link_policy(int dd, uint16_t handle, uint16_t *policy, int to);
|
||||
int hci_write_link_policy(int dd, uint16_t handle, uint16_t policy, int to);
|
||||
int hci_read_link_supervision_timeout(int dd, uint16_t handle, uint16_t *timeout, int to);
|
||||
int hci_write_link_supervision_timeout(int dd, uint16_t handle, uint16_t timeout, int to);
|
||||
int hci_set_afh_classification(int dd, uint8_t *map, int to);
|
||||
int hci_read_link_quality(int dd, uint16_t handle, uint8_t *link_quality, int to);
|
||||
int hci_read_rssi(int dd, uint16_t handle, int8_t *rssi, int to);
|
||||
int hci_read_afh_map(int dd, uint16_t handle, uint8_t *mode, uint8_t *map, int to);
|
||||
int hci_read_clock(int dd, uint16_t handle, uint8_t which, uint32_t *clock, uint16_t *accuracy, int to);
|
||||
|
||||
int hci_le_set_scan_enable(int dev_id, uint8_t enable, uint8_t filter_dup, int to);
|
||||
int hci_le_set_scan_parameters(int dev_id, uint8_t type, uint16_t interval,
|
||||
uint16_t window, uint8_t own_type,
|
||||
uint8_t filter, int to);
|
||||
int hci_le_set_advertise_enable(int dev_id, uint8_t enable, int to);
|
||||
int hci_le_create_conn(int dd, uint16_t interval, uint16_t window,
|
||||
uint8_t initiator_filter, uint8_t peer_bdaddr_type,
|
||||
bdaddr_t peer_bdaddr, uint8_t own_bdaddr_type,
|
||||
uint16_t min_interval, uint16_t max_interval,
|
||||
uint16_t latency, uint16_t supervision_timeout,
|
||||
uint16_t min_ce_length, uint16_t max_ce_length,
|
||||
uint16_t *handle, int to);
|
||||
|
||||
int hci_le_conn_update(int dd, uint16_t handle, uint16_t min_interval,
|
||||
uint16_t max_interval, uint16_t latency,
|
||||
uint16_t supervision_timeout, int to);
|
||||
int hci_le_add_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type, int to);
|
||||
int hci_le_rm_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type, int to);
|
||||
int hci_le_read_white_list_size(int dd, uint8_t *size, int to);
|
||||
int hci_le_clear_white_list(int dd, int to);
|
||||
int hci_for_each_dev(int flag, int(*func)(int dd, int dev_id, long arg), long arg);
|
||||
int hci_get_route(bdaddr_t *bdaddr);
|
||||
|
||||
char *hci_bustostr(int bus);
|
||||
char *hci_typetostr(int type);
|
||||
char *hci_dtypetostr(int type);
|
||||
char *hci_dflagstostr(uint32_t flags);
|
||||
char *hci_ptypetostr(unsigned int ptype);
|
||||
int hci_strtoptype(char *str, unsigned int *val);
|
||||
char *hci_scoptypetostr(unsigned int ptype);
|
||||
int hci_strtoscoptype(char *str, unsigned int *val);
|
||||
char *hci_lptostr(unsigned int ptype);
|
||||
int hci_strtolp(char *str, unsigned int *val);
|
||||
char *hci_lmtostr(unsigned int ptype);
|
||||
int hci_strtolm(char *str, unsigned int *val);
|
||||
|
||||
char *hci_cmdtostr(unsigned int cmd);
|
||||
char *hci_commandstostr(uint8_t *commands, char *pref, int width);
|
||||
|
||||
char *hci_vertostr(unsigned int ver);
|
||||
int hci_strtover(char *str, unsigned int *ver);
|
||||
char *lmp_vertostr(unsigned int ver);
|
||||
int lmp_strtover(char *str, unsigned int *ver);
|
||||
char *pal_vertostr(unsigned int ver);
|
||||
int pal_strtover(char *str, unsigned int *ver);
|
||||
|
||||
char *lmp_featurestostr(uint8_t *features, char *pref, int width);
|
||||
|
||||
static inline void hci_set_bit(int nr, void *addr)
|
||||
{
|
||||
*((uint32_t *) addr + (nr >> 5)) |= (1 << (nr & 31));
|
||||
}
|
||||
|
||||
static inline void hci_clear_bit(int nr, void *addr)
|
||||
{
|
||||
*((uint32_t *) addr + (nr >> 5)) &= ~(1 << (nr & 31));
|
||||
}
|
||||
|
||||
static inline int hci_test_bit(int nr, void *addr)
|
||||
{
|
||||
return *((uint32_t *) addr + (nr >> 5)) & (1 << (nr & 31));
|
||||
}
|
||||
|
||||
/* HCI filter tools */
|
||||
static inline void hci_filter_clear(struct hci_filter *f)
|
||||
{
|
||||
memset(f, 0, sizeof(*f));
|
||||
}
|
||||
static inline void hci_filter_set_ptype(int t, struct hci_filter *f)
|
||||
{
|
||||
hci_set_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
|
||||
}
|
||||
static inline void hci_filter_clear_ptype(int t, struct hci_filter *f)
|
||||
{
|
||||
hci_clear_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
|
||||
}
|
||||
static inline int hci_filter_test_ptype(int t, struct hci_filter *f)
|
||||
{
|
||||
return hci_test_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
|
||||
}
|
||||
static inline void hci_filter_all_ptypes(struct hci_filter *f)
|
||||
{
|
||||
memset((void *) &f->type_mask, 0xff, sizeof(f->type_mask));
|
||||
}
|
||||
static inline void hci_filter_set_event(int e, struct hci_filter *f)
|
||||
{
|
||||
hci_set_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
|
||||
}
|
||||
static inline void hci_filter_clear_event(int e, struct hci_filter *f)
|
||||
{
|
||||
hci_clear_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
|
||||
}
|
||||
static inline int hci_filter_test_event(int e, struct hci_filter *f)
|
||||
{
|
||||
return hci_test_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
|
||||
}
|
||||
static inline void hci_filter_all_events(struct hci_filter *f)
|
||||
{
|
||||
memset((void *) f->event_mask, 0xff, sizeof(f->event_mask));
|
||||
}
|
||||
static inline void hci_filter_set_opcode(int opcode, struct hci_filter *f)
|
||||
{
|
||||
f->opcode = opcode;
|
||||
}
|
||||
static inline void hci_filter_clear_opcode(struct hci_filter *f)
|
||||
{
|
||||
f->opcode = 0;
|
||||
}
|
||||
static inline int hci_filter_test_opcode(int opcode, struct hci_filter *f)
|
||||
{
|
||||
return (f->opcode == opcode);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __HCI_LIB_H */
|
||||
85
external/cache/sources/hcitools/lib/bluetooth/hidp.h
vendored
Normal file
85
external/cache/sources/hcitools/lib/bluetooth/hidp.h
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2003-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __HIDP_H
|
||||
#define __HIDP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* HIDP defaults */
|
||||
#define HIDP_MINIMUM_MTU 48
|
||||
#define HIDP_DEFAULT_MTU 48
|
||||
|
||||
/* HIDP ioctl defines */
|
||||
#define HIDPCONNADD _IOW('H', 200, int)
|
||||
#define HIDPCONNDEL _IOW('H', 201, int)
|
||||
#define HIDPGETCONNLIST _IOR('H', 210, int)
|
||||
#define HIDPGETCONNINFO _IOR('H', 211, int)
|
||||
|
||||
#define HIDP_VIRTUAL_CABLE_UNPLUG 0
|
||||
#define HIDP_BOOT_PROTOCOL_MODE 1
|
||||
#define HIDP_BLUETOOTH_VENDOR_ID 9
|
||||
|
||||
struct hidp_connadd_req {
|
||||
int ctrl_sock; /* Connected control socket */
|
||||
int intr_sock; /* Connected interrupt socket */
|
||||
uint16_t parser; /* Parser version */
|
||||
uint16_t rd_size; /* Report descriptor size */
|
||||
uint8_t *rd_data; /* Report descriptor data */
|
||||
uint8_t country;
|
||||
uint8_t subclass;
|
||||
uint16_t vendor;
|
||||
uint16_t product;
|
||||
uint16_t version;
|
||||
uint32_t flags;
|
||||
uint32_t idle_to;
|
||||
char name[128]; /* Device name */
|
||||
};
|
||||
|
||||
struct hidp_conndel_req {
|
||||
bdaddr_t bdaddr;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
struct hidp_conninfo {
|
||||
bdaddr_t bdaddr;
|
||||
uint32_t flags;
|
||||
uint16_t state;
|
||||
uint16_t vendor;
|
||||
uint16_t product;
|
||||
uint16_t version;
|
||||
char name[128];
|
||||
};
|
||||
|
||||
struct hidp_connlist_req {
|
||||
uint32_t cnum;
|
||||
struct hidp_conninfo *ci;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __HIDP_H */
|
||||
279
external/cache/sources/hcitools/lib/bluetooth/l2cap.h
vendored
Normal file
279
external/cache/sources/hcitools/lib/bluetooth/l2cap.h
vendored
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2000-2001 Qualcomm Incorporated
|
||||
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
|
||||
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
* Copyright (c) 2012 Code Aurora Forum. All rights reserved.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __L2CAP_H
|
||||
#define __L2CAP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
/* L2CAP defaults */
|
||||
#define L2CAP_DEFAULT_MTU 672
|
||||
#define L2CAP_DEFAULT_FLUSH_TO 0xFFFF
|
||||
|
||||
/* L2CAP socket address */
|
||||
struct sockaddr_l2 {
|
||||
sa_family_t l2_family;
|
||||
unsigned short l2_psm;
|
||||
bdaddr_t l2_bdaddr;
|
||||
unsigned short l2_cid;
|
||||
uint8_t l2_bdaddr_type;
|
||||
};
|
||||
|
||||
/* L2CAP socket options */
|
||||
#define L2CAP_OPTIONS 0x01
|
||||
struct l2cap_options {
|
||||
uint16_t omtu;
|
||||
uint16_t imtu;
|
||||
uint16_t flush_to;
|
||||
uint8_t mode;
|
||||
uint8_t fcs;
|
||||
uint8_t max_tx;
|
||||
uint16_t txwin_size;
|
||||
};
|
||||
|
||||
#define L2CAP_CONNINFO 0x02
|
||||
struct l2cap_conninfo {
|
||||
uint16_t hci_handle;
|
||||
uint8_t dev_class[3];
|
||||
};
|
||||
|
||||
#define L2CAP_LM 0x03
|
||||
#define L2CAP_LM_MASTER 0x0001
|
||||
#define L2CAP_LM_AUTH 0x0002
|
||||
#define L2CAP_LM_ENCRYPT 0x0004
|
||||
#define L2CAP_LM_TRUSTED 0x0008
|
||||
#define L2CAP_LM_RELIABLE 0x0010
|
||||
#define L2CAP_LM_SECURE 0x0020
|
||||
|
||||
/* L2CAP command codes */
|
||||
#define L2CAP_COMMAND_REJ 0x01
|
||||
#define L2CAP_CONN_REQ 0x02
|
||||
#define L2CAP_CONN_RSP 0x03
|
||||
#define L2CAP_CONF_REQ 0x04
|
||||
#define L2CAP_CONF_RSP 0x05
|
||||
#define L2CAP_DISCONN_REQ 0x06
|
||||
#define L2CAP_DISCONN_RSP 0x07
|
||||
#define L2CAP_ECHO_REQ 0x08
|
||||
#define L2CAP_ECHO_RSP 0x09
|
||||
#define L2CAP_INFO_REQ 0x0a
|
||||
#define L2CAP_INFO_RSP 0x0b
|
||||
#define L2CAP_CREATE_REQ 0x0c
|
||||
#define L2CAP_CREATE_RSP 0x0d
|
||||
#define L2CAP_MOVE_REQ 0x0e
|
||||
#define L2CAP_MOVE_RSP 0x0f
|
||||
#define L2CAP_MOVE_CFM 0x10
|
||||
#define L2CAP_MOVE_CFM_RSP 0x11
|
||||
|
||||
/* L2CAP extended feature mask */
|
||||
#define L2CAP_FEAT_FLOWCTL 0x00000001
|
||||
#define L2CAP_FEAT_RETRANS 0x00000002
|
||||
#define L2CAP_FEAT_BIDIR_QOS 0x00000004
|
||||
#define L2CAP_FEAT_ERTM 0x00000008
|
||||
#define L2CAP_FEAT_STREAMING 0x00000010
|
||||
#define L2CAP_FEAT_FCS 0x00000020
|
||||
#define L2CAP_FEAT_EXT_FLOW 0x00000040
|
||||
#define L2CAP_FEAT_FIXED_CHAN 0x00000080
|
||||
#define L2CAP_FEAT_EXT_WINDOW 0x00000100
|
||||
#define L2CAP_FEAT_UCD 0x00000200
|
||||
|
||||
/* L2CAP fixed channels */
|
||||
#define L2CAP_FC_L2CAP 0x02
|
||||
#define L2CAP_FC_CONNLESS 0x04
|
||||
#define L2CAP_FC_A2MP 0x08
|
||||
|
||||
/* L2CAP structures */
|
||||
typedef struct {
|
||||
uint16_t len;
|
||||
uint16_t cid;
|
||||
} __attribute__ ((packed)) l2cap_hdr;
|
||||
#define L2CAP_HDR_SIZE 4
|
||||
|
||||
typedef struct {
|
||||
uint8_t code;
|
||||
uint8_t ident;
|
||||
uint16_t len;
|
||||
} __attribute__ ((packed)) l2cap_cmd_hdr;
|
||||
#define L2CAP_CMD_HDR_SIZE 4
|
||||
|
||||
typedef struct {
|
||||
uint16_t reason;
|
||||
} __attribute__ ((packed)) l2cap_cmd_rej;
|
||||
#define L2CAP_CMD_REJ_SIZE 2
|
||||
|
||||
typedef struct {
|
||||
uint16_t psm;
|
||||
uint16_t scid;
|
||||
} __attribute__ ((packed)) l2cap_conn_req;
|
||||
#define L2CAP_CONN_REQ_SIZE 4
|
||||
|
||||
typedef struct {
|
||||
uint16_t dcid;
|
||||
uint16_t scid;
|
||||
uint16_t result;
|
||||
uint16_t status;
|
||||
} __attribute__ ((packed)) l2cap_conn_rsp;
|
||||
#define L2CAP_CONN_RSP_SIZE 8
|
||||
|
||||
/* connect result */
|
||||
#define L2CAP_CR_SUCCESS 0x0000
|
||||
#define L2CAP_CR_PEND 0x0001
|
||||
#define L2CAP_CR_BAD_PSM 0x0002
|
||||
#define L2CAP_CR_SEC_BLOCK 0x0003
|
||||
#define L2CAP_CR_NO_MEM 0x0004
|
||||
|
||||
/* connect status */
|
||||
#define L2CAP_CS_NO_INFO 0x0000
|
||||
#define L2CAP_CS_AUTHEN_PEND 0x0001
|
||||
#define L2CAP_CS_AUTHOR_PEND 0x0002
|
||||
|
||||
typedef struct {
|
||||
uint16_t dcid;
|
||||
uint16_t flags;
|
||||
uint8_t data[0];
|
||||
} __attribute__ ((packed)) l2cap_conf_req;
|
||||
#define L2CAP_CONF_REQ_SIZE 4
|
||||
|
||||
typedef struct {
|
||||
uint16_t scid;
|
||||
uint16_t flags;
|
||||
uint16_t result;
|
||||
uint8_t data[0];
|
||||
} __attribute__ ((packed)) l2cap_conf_rsp;
|
||||
#define L2CAP_CONF_RSP_SIZE 6
|
||||
|
||||
#define L2CAP_CONF_SUCCESS 0x0000
|
||||
#define L2CAP_CONF_UNACCEPT 0x0001
|
||||
#define L2CAP_CONF_REJECT 0x0002
|
||||
#define L2CAP_CONF_UNKNOWN 0x0003
|
||||
#define L2CAP_CONF_PENDING 0x0004
|
||||
#define L2CAP_CONF_EFS_REJECT 0x0005
|
||||
|
||||
typedef struct {
|
||||
uint8_t type;
|
||||
uint8_t len;
|
||||
uint8_t val[0];
|
||||
} __attribute__ ((packed)) l2cap_conf_opt;
|
||||
#define L2CAP_CONF_OPT_SIZE 2
|
||||
|
||||
#define L2CAP_CONF_MTU 0x01
|
||||
#define L2CAP_CONF_FLUSH_TO 0x02
|
||||
#define L2CAP_CONF_QOS 0x03
|
||||
#define L2CAP_CONF_RFC 0x04
|
||||
#define L2CAP_CONF_FCS 0x05
|
||||
#define L2CAP_CONF_EFS 0x06
|
||||
#define L2CAP_CONF_EWS 0x07
|
||||
|
||||
#define L2CAP_CONF_MAX_SIZE 22
|
||||
|
||||
#define L2CAP_MODE_BASIC 0x00
|
||||
#define L2CAP_MODE_RETRANS 0x01
|
||||
#define L2CAP_MODE_FLOWCTL 0x02
|
||||
#define L2CAP_MODE_ERTM 0x03
|
||||
#define L2CAP_MODE_STREAMING 0x04
|
||||
|
||||
#define L2CAP_SERVTYPE_NOTRAFFIC 0x00
|
||||
#define L2CAP_SERVTYPE_BESTEFFORT 0x01
|
||||
#define L2CAP_SERVTYPE_GUARANTEED 0x02
|
||||
|
||||
typedef struct {
|
||||
uint16_t dcid;
|
||||
uint16_t scid;
|
||||
} __attribute__ ((packed)) l2cap_disconn_req;
|
||||
#define L2CAP_DISCONN_REQ_SIZE 4
|
||||
|
||||
typedef struct {
|
||||
uint16_t dcid;
|
||||
uint16_t scid;
|
||||
} __attribute__ ((packed)) l2cap_disconn_rsp;
|
||||
#define L2CAP_DISCONN_RSP_SIZE 4
|
||||
|
||||
typedef struct {
|
||||
uint16_t type;
|
||||
} __attribute__ ((packed)) l2cap_info_req;
|
||||
#define L2CAP_INFO_REQ_SIZE 2
|
||||
|
||||
typedef struct {
|
||||
uint16_t type;
|
||||
uint16_t result;
|
||||
uint8_t data[0];
|
||||
} __attribute__ ((packed)) l2cap_info_rsp;
|
||||
#define L2CAP_INFO_RSP_SIZE 4
|
||||
|
||||
/* info type */
|
||||
#define L2CAP_IT_CL_MTU 0x0001
|
||||
#define L2CAP_IT_FEAT_MASK 0x0002
|
||||
|
||||
/* info result */
|
||||
#define L2CAP_IR_SUCCESS 0x0000
|
||||
#define L2CAP_IR_NOTSUPP 0x0001
|
||||
|
||||
typedef struct {
|
||||
uint16_t psm;
|
||||
uint16_t scid;
|
||||
uint8_t id;
|
||||
} __attribute__ ((packed)) l2cap_create_req;
|
||||
#define L2CAP_CREATE_REQ_SIZE 5
|
||||
|
||||
typedef struct {
|
||||
uint16_t dcid;
|
||||
uint16_t scid;
|
||||
uint16_t result;
|
||||
uint16_t status;
|
||||
} __attribute__ ((packed)) l2cap_create_rsp;
|
||||
#define L2CAP_CREATE_RSP_SIZE 8
|
||||
|
||||
typedef struct {
|
||||
uint16_t icid;
|
||||
uint8_t id;
|
||||
} __attribute__ ((packed)) l2cap_move_req;
|
||||
#define L2CAP_MOVE_REQ_SIZE 3
|
||||
|
||||
typedef struct {
|
||||
uint16_t icid;
|
||||
uint16_t result;
|
||||
} __attribute__ ((packed)) l2cap_move_rsp;
|
||||
#define L2CAP_MOVE_RSP_SIZE 4
|
||||
|
||||
typedef struct {
|
||||
uint16_t icid;
|
||||
uint16_t result;
|
||||
} __attribute__ ((packed)) l2cap_move_cfm;
|
||||
#define L2CAP_MOVE_CFM_SIZE 4
|
||||
|
||||
typedef struct {
|
||||
uint16_t icid;
|
||||
} __attribute__ ((packed)) l2cap_move_cfm_rsp;
|
||||
#define L2CAP_MOVE_CFM_RSP_SIZE 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __L2CAP_H */
|
||||
99
external/cache/sources/hcitools/lib/bluetooth/rfcomm.h
vendored
Normal file
99
external/cache/sources/hcitools/lib/bluetooth/rfcomm.h
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
|
||||
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __RFCOMM_H
|
||||
#define __RFCOMM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
/* RFCOMM defaults */
|
||||
#define RFCOMM_DEFAULT_MTU 127
|
||||
|
||||
#define RFCOMM_PSM 3
|
||||
|
||||
/* RFCOMM socket address */
|
||||
struct sockaddr_rc {
|
||||
sa_family_t rc_family;
|
||||
bdaddr_t rc_bdaddr;
|
||||
uint8_t rc_channel;
|
||||
};
|
||||
|
||||
/* RFCOMM socket options */
|
||||
#define RFCOMM_CONNINFO 0x02
|
||||
struct rfcomm_conninfo {
|
||||
uint16_t hci_handle;
|
||||
uint8_t dev_class[3];
|
||||
};
|
||||
|
||||
#define RFCOMM_LM 0x03
|
||||
#define RFCOMM_LM_MASTER 0x0001
|
||||
#define RFCOMM_LM_AUTH 0x0002
|
||||
#define RFCOMM_LM_ENCRYPT 0x0004
|
||||
#define RFCOMM_LM_TRUSTED 0x0008
|
||||
#define RFCOMM_LM_RELIABLE 0x0010
|
||||
#define RFCOMM_LM_SECURE 0x0020
|
||||
|
||||
/* RFCOMM TTY support */
|
||||
#define RFCOMM_MAX_DEV 256
|
||||
|
||||
#define RFCOMMCREATEDEV _IOW('R', 200, int)
|
||||
#define RFCOMMRELEASEDEV _IOW('R', 201, int)
|
||||
#define RFCOMMGETDEVLIST _IOR('R', 210, int)
|
||||
#define RFCOMMGETDEVINFO _IOR('R', 211, int)
|
||||
|
||||
struct rfcomm_dev_req {
|
||||
int16_t dev_id;
|
||||
uint32_t flags;
|
||||
bdaddr_t src;
|
||||
bdaddr_t dst;
|
||||
uint8_t channel;
|
||||
};
|
||||
#define RFCOMM_REUSE_DLC 0
|
||||
#define RFCOMM_RELEASE_ONHUP 1
|
||||
#define RFCOMM_HANGUP_NOW 2
|
||||
#define RFCOMM_TTY_ATTACHED 3
|
||||
|
||||
struct rfcomm_dev_info {
|
||||
int16_t id;
|
||||
uint32_t flags;
|
||||
uint16_t state;
|
||||
bdaddr_t src;
|
||||
bdaddr_t dst;
|
||||
uint8_t channel;
|
||||
};
|
||||
|
||||
struct rfcomm_dev_list_req {
|
||||
uint16_t dev_num;
|
||||
struct rfcomm_dev_info dev_info[0];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __RFCOMM_H */
|
||||
62
external/cache/sources/hcitools/lib/bluetooth/sco.h
vendored
Normal file
62
external/cache/sources/hcitools/lib/bluetooth/sco.h
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
|
||||
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SCO_H
|
||||
#define __SCO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* SCO defaults */
|
||||
#define SCO_DEFAULT_MTU 500
|
||||
#define SCO_DEFAULT_FLUSH_TO 0xFFFF
|
||||
|
||||
#define SCO_CONN_TIMEOUT (HZ * 40)
|
||||
#define SCO_DISCONN_TIMEOUT (HZ * 2)
|
||||
#define SCO_CONN_IDLE_TIMEOUT (HZ * 60)
|
||||
|
||||
/* SCO socket address */
|
||||
struct sockaddr_sco {
|
||||
sa_family_t sco_family;
|
||||
bdaddr_t sco_bdaddr;
|
||||
};
|
||||
|
||||
/* set/get sockopt defines */
|
||||
#define SCO_OPTIONS 0x01
|
||||
struct sco_options {
|
||||
uint16_t mtu;
|
||||
};
|
||||
|
||||
#define SCO_CONNINFO 0x02
|
||||
struct sco_conninfo {
|
||||
uint16_t hci_handle;
|
||||
uint8_t dev_class[3];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SCO_H */
|
||||
532
external/cache/sources/hcitools/lib/bluetooth/sdp.h
vendored
Normal file
532
external/cache/sources/hcitools/lib/bluetooth/sdp.h
vendored
Normal file
@@ -0,0 +1,532 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2001-2002 Nokia Corporation
|
||||
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
|
||||
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
* Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SDP_H
|
||||
#define __SDP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <bluetooth/bluetooth.h>
|
||||
|
||||
#define SDP_UNIX_PATH "/var/run/sdp"
|
||||
#define SDP_RESPONSE_TIMEOUT 20
|
||||
#define SDP_REQ_BUFFER_SIZE 2048
|
||||
#define SDP_RSP_BUFFER_SIZE 65535
|
||||
#define SDP_PDU_CHUNK_SIZE 1024
|
||||
|
||||
/*
|
||||
* All definitions are based on Bluetooth Assigned Numbers
|
||||
* of the Bluetooth Specification
|
||||
*/
|
||||
#define SDP_PSM 0x0001
|
||||
|
||||
/*
|
||||
* Protocol UUIDs
|
||||
*/
|
||||
#define SDP_UUID 0x0001
|
||||
#define UDP_UUID 0x0002
|
||||
#define RFCOMM_UUID 0x0003
|
||||
#define TCP_UUID 0x0004
|
||||
#define TCS_BIN_UUID 0x0005
|
||||
#define TCS_AT_UUID 0x0006
|
||||
#define ATT_UUID 0x0007
|
||||
#define OBEX_UUID 0x0008
|
||||
#define IP_UUID 0x0009
|
||||
#define FTP_UUID 0x000a
|
||||
#define HTTP_UUID 0x000c
|
||||
#define WSP_UUID 0x000e
|
||||
#define BNEP_UUID 0x000f
|
||||
#define UPNP_UUID 0x0010
|
||||
#define HIDP_UUID 0x0011
|
||||
#define HCRP_CTRL_UUID 0x0012
|
||||
#define HCRP_DATA_UUID 0x0014
|
||||
#define HCRP_NOTE_UUID 0x0016
|
||||
#define AVCTP_UUID 0x0017
|
||||
#define AVDTP_UUID 0x0019
|
||||
#define CMTP_UUID 0x001b
|
||||
#define UDI_UUID 0x001d
|
||||
#define MCAP_CTRL_UUID 0x001e
|
||||
#define MCAP_DATA_UUID 0x001f
|
||||
#define L2CAP_UUID 0x0100
|
||||
|
||||
/*
|
||||
* Service class identifiers of standard services and service groups
|
||||
*/
|
||||
#define SDP_SERVER_SVCLASS_ID 0x1000
|
||||
#define BROWSE_GRP_DESC_SVCLASS_ID 0x1001
|
||||
#define PUBLIC_BROWSE_GROUP 0x1002
|
||||
#define SERIAL_PORT_SVCLASS_ID 0x1101
|
||||
#define LAN_ACCESS_SVCLASS_ID 0x1102
|
||||
#define DIALUP_NET_SVCLASS_ID 0x1103
|
||||
#define IRMC_SYNC_SVCLASS_ID 0x1104
|
||||
#define OBEX_OBJPUSH_SVCLASS_ID 0x1105
|
||||
#define OBEX_FILETRANS_SVCLASS_ID 0x1106
|
||||
#define IRMC_SYNC_CMD_SVCLASS_ID 0x1107
|
||||
#define HEADSET_SVCLASS_ID 0x1108
|
||||
#define CORDLESS_TELEPHONY_SVCLASS_ID 0x1109
|
||||
#define AUDIO_SOURCE_SVCLASS_ID 0x110a
|
||||
#define AUDIO_SINK_SVCLASS_ID 0x110b
|
||||
#define AV_REMOTE_TARGET_SVCLASS_ID 0x110c
|
||||
#define ADVANCED_AUDIO_SVCLASS_ID 0x110d
|
||||
#define AV_REMOTE_SVCLASS_ID 0x110e
|
||||
#define AV_REMOTE_CONTROLLER_SVCLASS_ID 0x110f
|
||||
#define INTERCOM_SVCLASS_ID 0x1110
|
||||
#define FAX_SVCLASS_ID 0x1111
|
||||
#define HEADSET_AGW_SVCLASS_ID 0x1112
|
||||
#define WAP_SVCLASS_ID 0x1113
|
||||
#define WAP_CLIENT_SVCLASS_ID 0x1114
|
||||
#define PANU_SVCLASS_ID 0x1115
|
||||
#define NAP_SVCLASS_ID 0x1116
|
||||
#define GN_SVCLASS_ID 0x1117
|
||||
#define DIRECT_PRINTING_SVCLASS_ID 0x1118
|
||||
#define REFERENCE_PRINTING_SVCLASS_ID 0x1119
|
||||
#define IMAGING_SVCLASS_ID 0x111a
|
||||
#define IMAGING_RESPONDER_SVCLASS_ID 0x111b
|
||||
#define IMAGING_ARCHIVE_SVCLASS_ID 0x111c
|
||||
#define IMAGING_REFOBJS_SVCLASS_ID 0x111d
|
||||
#define HANDSFREE_SVCLASS_ID 0x111e
|
||||
#define HANDSFREE_AGW_SVCLASS_ID 0x111f
|
||||
#define DIRECT_PRT_REFOBJS_SVCLASS_ID 0x1120
|
||||
#define REFLECTED_UI_SVCLASS_ID 0x1121
|
||||
#define BASIC_PRINTING_SVCLASS_ID 0x1122
|
||||
#define PRINTING_STATUS_SVCLASS_ID 0x1123
|
||||
#define HID_SVCLASS_ID 0x1124
|
||||
#define HCR_SVCLASS_ID 0x1125
|
||||
#define HCR_PRINT_SVCLASS_ID 0x1126
|
||||
#define HCR_SCAN_SVCLASS_ID 0x1127
|
||||
#define CIP_SVCLASS_ID 0x1128
|
||||
#define VIDEO_CONF_GW_SVCLASS_ID 0x1129
|
||||
#define UDI_MT_SVCLASS_ID 0x112a
|
||||
#define UDI_TA_SVCLASS_ID 0x112b
|
||||
#define AV_SVCLASS_ID 0x112c
|
||||
#define SAP_SVCLASS_ID 0x112d
|
||||
#define PBAP_PCE_SVCLASS_ID 0x112e
|
||||
#define PBAP_PSE_SVCLASS_ID 0x112f
|
||||
#define PBAP_SVCLASS_ID 0x1130
|
||||
#define MAP_MSE_SVCLASS_ID 0x1132
|
||||
#define MAP_MCE_SVCLASS_ID 0x1133
|
||||
#define MAP_SVCLASS_ID 0x1134
|
||||
#define GNSS_SVCLASS_ID 0x1135
|
||||
#define GNSS_SERVER_SVCLASS_ID 0x1136
|
||||
#define PNP_INFO_SVCLASS_ID 0x1200
|
||||
#define GENERIC_NETWORKING_SVCLASS_ID 0x1201
|
||||
#define GENERIC_FILETRANS_SVCLASS_ID 0x1202
|
||||
#define GENERIC_AUDIO_SVCLASS_ID 0x1203
|
||||
#define GENERIC_TELEPHONY_SVCLASS_ID 0x1204
|
||||
#define UPNP_SVCLASS_ID 0x1205
|
||||
#define UPNP_IP_SVCLASS_ID 0x1206
|
||||
#define UPNP_PAN_SVCLASS_ID 0x1300
|
||||
#define UPNP_LAP_SVCLASS_ID 0x1301
|
||||
#define UPNP_L2CAP_SVCLASS_ID 0x1302
|
||||
#define VIDEO_SOURCE_SVCLASS_ID 0x1303
|
||||
#define VIDEO_SINK_SVCLASS_ID 0x1304
|
||||
#define VIDEO_DISTRIBUTION_SVCLASS_ID 0x1305
|
||||
#define HDP_SVCLASS_ID 0x1400
|
||||
#define HDP_SOURCE_SVCLASS_ID 0x1401
|
||||
#define HDP_SINK_SVCLASS_ID 0x1402
|
||||
#define APPLE_AGENT_SVCLASS_ID 0x2112
|
||||
#define GENERIC_ATTRIB_SVCLASS_ID 0x1801
|
||||
|
||||
/*
|
||||
* Standard profile descriptor identifiers; note these
|
||||
* may be identical to some of the service classes defined above
|
||||
*/
|
||||
#define SDP_SERVER_PROFILE_ID SDP_SERVER_SVCLASS_ID
|
||||
#define BROWSE_GRP_DESC_PROFILE_ID BROWSE_GRP_DESC_SVCLASS_ID
|
||||
#define SERIAL_PORT_PROFILE_ID SERIAL_PORT_SVCLASS_ID
|
||||
#define LAN_ACCESS_PROFILE_ID LAN_ACCESS_SVCLASS_ID
|
||||
#define DIALUP_NET_PROFILE_ID DIALUP_NET_SVCLASS_ID
|
||||
#define IRMC_SYNC_PROFILE_ID IRMC_SYNC_SVCLASS_ID
|
||||
#define OBEX_OBJPUSH_PROFILE_ID OBEX_OBJPUSH_SVCLASS_ID
|
||||
#define OBEX_FILETRANS_PROFILE_ID OBEX_FILETRANS_SVCLASS_ID
|
||||
#define IRMC_SYNC_CMD_PROFILE_ID IRMC_SYNC_CMD_SVCLASS_ID
|
||||
#define HEADSET_PROFILE_ID HEADSET_SVCLASS_ID
|
||||
#define CORDLESS_TELEPHONY_PROFILE_ID CORDLESS_TELEPHONY_SVCLASS_ID
|
||||
#define AUDIO_SOURCE_PROFILE_ID AUDIO_SOURCE_SVCLASS_ID
|
||||
#define AUDIO_SINK_PROFILE_ID AUDIO_SINK_SVCLASS_ID
|
||||
#define AV_REMOTE_TARGET_PROFILE_ID AV_REMOTE_TARGET_SVCLASS_ID
|
||||
#define ADVANCED_AUDIO_PROFILE_ID ADVANCED_AUDIO_SVCLASS_ID
|
||||
#define AV_REMOTE_PROFILE_ID AV_REMOTE_SVCLASS_ID
|
||||
#define VIDEO_CONF_PROFILE_ID VIDEO_CONF_SVCLASS_ID
|
||||
#define INTERCOM_PROFILE_ID INTERCOM_SVCLASS_ID
|
||||
#define FAX_PROFILE_ID FAX_SVCLASS_ID
|
||||
#define HEADSET_AGW_PROFILE_ID HEADSET_AGW_SVCLASS_ID
|
||||
#define WAP_PROFILE_ID WAP_SVCLASS_ID
|
||||
#define WAP_CLIENT_PROFILE_ID WAP_CLIENT_SVCLASS_ID
|
||||
#define PANU_PROFILE_ID PANU_SVCLASS_ID
|
||||
#define NAP_PROFILE_ID NAP_SVCLASS_ID
|
||||
#define GN_PROFILE_ID GN_SVCLASS_ID
|
||||
#define DIRECT_PRINTING_PROFILE_ID DIRECT_PRINTING_SVCLASS_ID
|
||||
#define REFERENCE_PRINTING_PROFILE_ID REFERENCE_PRINTING_SVCLASS_ID
|
||||
#define IMAGING_PROFILE_ID IMAGING_SVCLASS_ID
|
||||
#define IMAGING_RESPONDER_PROFILE_ID IMAGING_RESPONDER_SVCLASS_ID
|
||||
#define IMAGING_ARCHIVE_PROFILE_ID IMAGING_ARCHIVE_SVCLASS_ID
|
||||
#define IMAGING_REFOBJS_PROFILE_ID IMAGING_REFOBJS_SVCLASS_ID
|
||||
#define HANDSFREE_PROFILE_ID HANDSFREE_SVCLASS_ID
|
||||
#define HANDSFREE_AGW_PROFILE_ID HANDSFREE_AGW_SVCLASS_ID
|
||||
#define DIRECT_PRT_REFOBJS_PROFILE_ID DIRECT_PRT_REFOBJS_SVCLASS_ID
|
||||
#define REFLECTED_UI_PROFILE_ID REFLECTED_UI_SVCLASS_ID
|
||||
#define BASIC_PRINTING_PROFILE_ID BASIC_PRINTING_SVCLASS_ID
|
||||
#define PRINTING_STATUS_PROFILE_ID PRINTING_STATUS_SVCLASS_ID
|
||||
#define HID_PROFILE_ID HID_SVCLASS_ID
|
||||
#define HCR_PROFILE_ID HCR_SCAN_SVCLASS_ID
|
||||
#define HCR_PRINT_PROFILE_ID HCR_PRINT_SVCLASS_ID
|
||||
#define HCR_SCAN_PROFILE_ID HCR_SCAN_SVCLASS_ID
|
||||
#define CIP_PROFILE_ID CIP_SVCLASS_ID
|
||||
#define VIDEO_CONF_GW_PROFILE_ID VIDEO_CONF_GW_SVCLASS_ID
|
||||
#define UDI_MT_PROFILE_ID UDI_MT_SVCLASS_ID
|
||||
#define UDI_TA_PROFILE_ID UDI_TA_SVCLASS_ID
|
||||
#define AV_PROFILE_ID AV_SVCLASS_ID
|
||||
#define SAP_PROFILE_ID SAP_SVCLASS_ID
|
||||
#define PBAP_PCE_PROFILE_ID PBAP_PCE_SVCLASS_ID
|
||||
#define PBAP_PSE_PROFILE_ID PBAP_PSE_SVCLASS_ID
|
||||
#define PBAP_PROFILE_ID PBAP_SVCLASS_ID
|
||||
#define PNP_INFO_PROFILE_ID PNP_INFO_SVCLASS_ID
|
||||
#define GENERIC_NETWORKING_PROFILE_ID GENERIC_NETWORKING_SVCLASS_ID
|
||||
#define GENERIC_FILETRANS_PROFILE_ID GENERIC_FILETRANS_SVCLASS_ID
|
||||
#define GENERIC_AUDIO_PROFILE_ID GENERIC_AUDIO_SVCLASS_ID
|
||||
#define GENERIC_TELEPHONY_PROFILE_ID GENERIC_TELEPHONY_SVCLASS_ID
|
||||
#define UPNP_PROFILE_ID UPNP_SVCLASS_ID
|
||||
#define UPNP_IP_PROFILE_ID UPNP_IP_SVCLASS_ID
|
||||
#define UPNP_PAN_PROFILE_ID UPNP_PAN_SVCLASS_ID
|
||||
#define UPNP_LAP_PROFILE_ID UPNP_LAP_SVCLASS_ID
|
||||
#define UPNP_L2CAP_PROFILE_ID UPNP_L2CAP_SVCLASS_ID
|
||||
#define VIDEO_SOURCE_PROFILE_ID VIDEO_SOURCE_SVCLASS_ID
|
||||
#define VIDEO_SINK_PROFILE_ID VIDEO_SINK_SVCLASS_ID
|
||||
#define VIDEO_DISTRIBUTION_PROFILE_ID VIDEO_DISTRIBUTION_SVCLASS_ID
|
||||
#define HDP_PROFILE_ID HDP_SVCLASS_ID
|
||||
#define HDP_SOURCE_PROFILE_ID HDP_SOURCE_SVCLASS_ID
|
||||
#define HDP_SINK_PROFILE_ID HDP_SINK_SVCLASS_ID
|
||||
#define APPLE_AGENT_PROFILE_ID APPLE_AGENT_SVCLASS_ID
|
||||
#define GENERIC_ACCESS_PROFILE_ID 0x1800
|
||||
#define GENERIC_ATTRIB_PROFILE_ID GENERIC_ATTRIB_SVCLASS_ID
|
||||
|
||||
/*
|
||||
* Compatibility macros for the old MDP acronym
|
||||
*/
|
||||
#define MDP_SVCLASS_ID HDP_SVCLASS_ID
|
||||
#define MDP_SOURCE_SVCLASS_ID HDP_SOURCE_SVCLASS_ID
|
||||
#define MDP_SINK_SVCLASS_ID HDP_SINK_SVCLASS_ID
|
||||
#define MDP_PROFILE_ID HDP_PROFILE_ID
|
||||
#define MDP_SOURCE_PROFILE_ID HDP_SOURCE_PROFILE_ID
|
||||
#define MDP_SINK_PROFILE_ID HDP_SINK_PROFILE_ID
|
||||
|
||||
/*
|
||||
* Attribute identifier codes
|
||||
*/
|
||||
#define SDP_SERVER_RECORD_HANDLE 0x0000
|
||||
|
||||
/*
|
||||
* Possible values for attribute-id are listed below.
|
||||
* See SDP Spec, section "Service Attribute Definitions" for more details.
|
||||
*/
|
||||
#define SDP_ATTR_RECORD_HANDLE 0x0000
|
||||
#define SDP_ATTR_SVCLASS_ID_LIST 0x0001
|
||||
#define SDP_ATTR_RECORD_STATE 0x0002
|
||||
#define SDP_ATTR_SERVICE_ID 0x0003
|
||||
#define SDP_ATTR_PROTO_DESC_LIST 0x0004
|
||||
#define SDP_ATTR_BROWSE_GRP_LIST 0x0005
|
||||
#define SDP_ATTR_LANG_BASE_ATTR_ID_LIST 0x0006
|
||||
#define SDP_ATTR_SVCINFO_TTL 0x0007
|
||||
#define SDP_ATTR_SERVICE_AVAILABILITY 0x0008
|
||||
#define SDP_ATTR_PFILE_DESC_LIST 0x0009
|
||||
#define SDP_ATTR_DOC_URL 0x000a
|
||||
#define SDP_ATTR_CLNT_EXEC_URL 0x000b
|
||||
#define SDP_ATTR_ICON_URL 0x000c
|
||||
#define SDP_ATTR_ADD_PROTO_DESC_LIST 0x000d
|
||||
|
||||
#define SDP_ATTR_GROUP_ID 0x0200
|
||||
#define SDP_ATTR_IP_SUBNET 0x0200
|
||||
#define SDP_ATTR_VERSION_NUM_LIST 0x0200
|
||||
#define SDP_ATTR_SUPPORTED_FEATURES_LIST 0x0200
|
||||
#define SDP_ATTR_GOEP_L2CAP_PSM 0x0200
|
||||
#define SDP_ATTR_SVCDB_STATE 0x0201
|
||||
|
||||
#define SDP_ATTR_SERVICE_VERSION 0x0300
|
||||
#define SDP_ATTR_EXTERNAL_NETWORK 0x0301
|
||||
#define SDP_ATTR_SUPPORTED_DATA_STORES_LIST 0x0301
|
||||
#define SDP_ATTR_DATA_EXCHANGE_SPEC 0x0301
|
||||
#define SDP_ATTR_NETWORK 0x0301
|
||||
#define SDP_ATTR_FAX_CLASS1_SUPPORT 0x0302
|
||||
#define SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL 0x0302
|
||||
#define SDP_ATTR_MCAP_SUPPORTED_PROCEDURES 0x0302
|
||||
#define SDP_ATTR_FAX_CLASS20_SUPPORT 0x0303
|
||||
#define SDP_ATTR_SUPPORTED_FORMATS_LIST 0x0303
|
||||
#define SDP_ATTR_FAX_CLASS2_SUPPORT 0x0304
|
||||
#define SDP_ATTR_AUDIO_FEEDBACK_SUPPORT 0x0305
|
||||
#define SDP_ATTR_NETWORK_ADDRESS 0x0306
|
||||
#define SDP_ATTR_WAP_GATEWAY 0x0307
|
||||
#define SDP_ATTR_HOMEPAGE_URL 0x0308
|
||||
#define SDP_ATTR_WAP_STACK_TYPE 0x0309
|
||||
#define SDP_ATTR_SECURITY_DESC 0x030a
|
||||
#define SDP_ATTR_NET_ACCESS_TYPE 0x030b
|
||||
#define SDP_ATTR_MAX_NET_ACCESSRATE 0x030c
|
||||
#define SDP_ATTR_IP4_SUBNET 0x030d
|
||||
#define SDP_ATTR_IP6_SUBNET 0x030e
|
||||
#define SDP_ATTR_SUPPORTED_CAPABILITIES 0x0310
|
||||
#define SDP_ATTR_SUPPORTED_FEATURES 0x0311
|
||||
#define SDP_ATTR_SUPPORTED_FUNCTIONS 0x0312
|
||||
#define SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY 0x0313
|
||||
#define SDP_ATTR_SUPPORTED_REPOSITORIES 0x0314
|
||||
#define SDP_ATTR_MAS_INSTANCE_ID 0x0315
|
||||
#define SDP_ATTR_SUPPORTED_MESSAGE_TYPES 0x0316
|
||||
|
||||
#define SDP_ATTR_SPECIFICATION_ID 0x0200
|
||||
#define SDP_ATTR_VENDOR_ID 0x0201
|
||||
#define SDP_ATTR_PRODUCT_ID 0x0202
|
||||
#define SDP_ATTR_VERSION 0x0203
|
||||
#define SDP_ATTR_PRIMARY_RECORD 0x0204
|
||||
#define SDP_ATTR_VENDOR_ID_SOURCE 0x0205
|
||||
|
||||
#define SDP_ATTR_HID_DEVICE_RELEASE_NUMBER 0x0200
|
||||
#define SDP_ATTR_HID_PARSER_VERSION 0x0201
|
||||
#define SDP_ATTR_HID_DEVICE_SUBCLASS 0x0202
|
||||
#define SDP_ATTR_HID_COUNTRY_CODE 0x0203
|
||||
#define SDP_ATTR_HID_VIRTUAL_CABLE 0x0204
|
||||
#define SDP_ATTR_HID_RECONNECT_INITIATE 0x0205
|
||||
#define SDP_ATTR_HID_DESCRIPTOR_LIST 0x0206
|
||||
#define SDP_ATTR_HID_LANG_ID_BASE_LIST 0x0207
|
||||
#define SDP_ATTR_HID_SDP_DISABLE 0x0208
|
||||
#define SDP_ATTR_HID_BATTERY_POWER 0x0209
|
||||
#define SDP_ATTR_HID_REMOTE_WAKEUP 0x020a
|
||||
#define SDP_ATTR_HID_PROFILE_VERSION 0x020b
|
||||
#define SDP_ATTR_HID_SUPERVISION_TIMEOUT 0x020c
|
||||
#define SDP_ATTR_HID_NORMALLY_CONNECTABLE 0x020d
|
||||
#define SDP_ATTR_HID_BOOT_DEVICE 0x020e
|
||||
|
||||
/*
|
||||
* These identifiers are based on the SDP spec stating that
|
||||
* "base attribute id of the primary (universal) language must be 0x0100"
|
||||
*
|
||||
* Other languages should have their own offset; e.g.:
|
||||
* #define XXXLangBase yyyy
|
||||
* #define AttrServiceName_XXX 0x0000+XXXLangBase
|
||||
*/
|
||||
#define SDP_PRIMARY_LANG_BASE 0x0100
|
||||
|
||||
#define SDP_ATTR_SVCNAME_PRIMARY 0x0000 + SDP_PRIMARY_LANG_BASE
|
||||
#define SDP_ATTR_SVCDESC_PRIMARY 0x0001 + SDP_PRIMARY_LANG_BASE
|
||||
#define SDP_ATTR_PROVNAME_PRIMARY 0x0002 + SDP_PRIMARY_LANG_BASE
|
||||
|
||||
/*
|
||||
* The Data representation in SDP PDUs (pps 339, 340 of BT SDP Spec)
|
||||
* These are the exact data type+size descriptor values
|
||||
* that go into the PDU buffer.
|
||||
*
|
||||
* The datatype (leading 5bits) + size descriptor (last 3 bits)
|
||||
* is 8 bits. The size descriptor is critical to extract the
|
||||
* right number of bytes for the data value from the PDU.
|
||||
*
|
||||
* For most basic types, the datatype+size descriptor is
|
||||
* straightforward. However for constructed types and strings,
|
||||
* the size of the data is in the next "n" bytes following the
|
||||
* 8 bits (datatype+size) descriptor. Exactly what the "n" is
|
||||
* specified in the 3 bits of the data size descriptor.
|
||||
*
|
||||
* TextString and URLString can be of size 2^{8, 16, 32} bytes
|
||||
* DataSequence and DataSequenceAlternates can be of size 2^{8, 16, 32}
|
||||
* The size are computed post-facto in the API and are not known apriori
|
||||
*/
|
||||
#define SDP_DATA_NIL 0x00
|
||||
#define SDP_UINT8 0x08
|
||||
#define SDP_UINT16 0x09
|
||||
#define SDP_UINT32 0x0A
|
||||
#define SDP_UINT64 0x0B
|
||||
#define SDP_UINT128 0x0C
|
||||
#define SDP_INT8 0x10
|
||||
#define SDP_INT16 0x11
|
||||
#define SDP_INT32 0x12
|
||||
#define SDP_INT64 0x13
|
||||
#define SDP_INT128 0x14
|
||||
#define SDP_UUID_UNSPEC 0x18
|
||||
#define SDP_UUID16 0x19
|
||||
#define SDP_UUID32 0x1A
|
||||
#define SDP_UUID128 0x1C
|
||||
#define SDP_TEXT_STR_UNSPEC 0x20
|
||||
#define SDP_TEXT_STR8 0x25
|
||||
#define SDP_TEXT_STR16 0x26
|
||||
#define SDP_TEXT_STR32 0x27
|
||||
#define SDP_BOOL 0x28
|
||||
#define SDP_SEQ_UNSPEC 0x30
|
||||
#define SDP_SEQ8 0x35
|
||||
#define SDP_SEQ16 0x36
|
||||
#define SDP_SEQ32 0x37
|
||||
#define SDP_ALT_UNSPEC 0x38
|
||||
#define SDP_ALT8 0x3D
|
||||
#define SDP_ALT16 0x3E
|
||||
#define SDP_ALT32 0x3F
|
||||
#define SDP_URL_STR_UNSPEC 0x40
|
||||
#define SDP_URL_STR8 0x45
|
||||
#define SDP_URL_STR16 0x46
|
||||
#define SDP_URL_STR32 0x47
|
||||
|
||||
/*
|
||||
* The PDU identifiers of SDP packets between client and server
|
||||
*/
|
||||
#define SDP_ERROR_RSP 0x01
|
||||
#define SDP_SVC_SEARCH_REQ 0x02
|
||||
#define SDP_SVC_SEARCH_RSP 0x03
|
||||
#define SDP_SVC_ATTR_REQ 0x04
|
||||
#define SDP_SVC_ATTR_RSP 0x05
|
||||
#define SDP_SVC_SEARCH_ATTR_REQ 0x06
|
||||
#define SDP_SVC_SEARCH_ATTR_RSP 0x07
|
||||
|
||||
/*
|
||||
* Some additions to support service registration.
|
||||
* These are outside the scope of the Bluetooth specification
|
||||
*/
|
||||
#define SDP_SVC_REGISTER_REQ 0x75
|
||||
#define SDP_SVC_REGISTER_RSP 0x76
|
||||
#define SDP_SVC_UPDATE_REQ 0x77
|
||||
#define SDP_SVC_UPDATE_RSP 0x78
|
||||
#define SDP_SVC_REMOVE_REQ 0x79
|
||||
#define SDP_SVC_REMOVE_RSP 0x80
|
||||
|
||||
/*
|
||||
* SDP Error codes
|
||||
*/
|
||||
#define SDP_INVALID_VERSION 0x0001
|
||||
#define SDP_INVALID_RECORD_HANDLE 0x0002
|
||||
#define SDP_INVALID_SYNTAX 0x0003
|
||||
#define SDP_INVALID_PDU_SIZE 0x0004
|
||||
#define SDP_INVALID_CSTATE 0x0005
|
||||
|
||||
/*
|
||||
* SDP PDU
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t pdu_id;
|
||||
uint16_t tid;
|
||||
uint16_t plen;
|
||||
} __attribute__ ((packed)) sdp_pdu_hdr_t;
|
||||
|
||||
/*
|
||||
* Common definitions for attributes in the SDP.
|
||||
* Should the type of any of these change, you need only make a change here.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint8_t type;
|
||||
union {
|
||||
uint16_t uuid16;
|
||||
uint32_t uuid32;
|
||||
uint128_t uuid128;
|
||||
} value;
|
||||
} uuid_t;
|
||||
|
||||
#define SDP_IS_UUID(x) ((x) == SDP_UUID16 || (x) == SDP_UUID32 || \
|
||||
(x) == SDP_UUID128)
|
||||
#define SDP_IS_ALT(x) ((x) == SDP_ALT8 || (x) == SDP_ALT16 || (x) == SDP_ALT32)
|
||||
#define SDP_IS_SEQ(x) ((x) == SDP_SEQ8 || (x) == SDP_SEQ16 || (x) == SDP_SEQ32)
|
||||
#define SDP_IS_TEXT_STR(x) ((x) == SDP_TEXT_STR8 || (x) == SDP_TEXT_STR16 || \
|
||||
(x) == SDP_TEXT_STR32)
|
||||
|
||||
typedef struct _sdp_list sdp_list_t;
|
||||
struct _sdp_list {
|
||||
sdp_list_t *next;
|
||||
void *data;
|
||||
};
|
||||
|
||||
/*
|
||||
* User-visible strings can be in many languages
|
||||
* in addition to the universal language.
|
||||
*
|
||||
* Language meta-data includes language code in ISO639
|
||||
* followed by the encoding format. The third field in this
|
||||
* structure is the attribute offset for the language.
|
||||
* User-visible strings in the specified language can be
|
||||
* obtained at this offset.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t code_ISO639;
|
||||
uint16_t encoding;
|
||||
uint16_t base_offset;
|
||||
} sdp_lang_attr_t;
|
||||
|
||||
/*
|
||||
* Profile descriptor is the Bluetooth profile metadata. If a
|
||||
* service conforms to a well-known profile, then its profile
|
||||
* identifier (UUID) is an attribute of the service. In addition,
|
||||
* if the profile has a version number it is specified here.
|
||||
*/
|
||||
typedef struct {
|
||||
uuid_t uuid;
|
||||
uint16_t version;
|
||||
} sdp_profile_desc_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
} sdp_version_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t *data;
|
||||
uint32_t data_size;
|
||||
uint32_t buf_size;
|
||||
} sdp_buf_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t handle;
|
||||
|
||||
/* Search pattern: a sequence of all UUIDs seen in this record */
|
||||
sdp_list_t *pattern;
|
||||
sdp_list_t *attrlist;
|
||||
|
||||
/* Main service class for Extended Inquiry Response */
|
||||
uuid_t svclass;
|
||||
} sdp_record_t;
|
||||
|
||||
typedef struct sdp_data_struct sdp_data_t;
|
||||
struct sdp_data_struct {
|
||||
uint8_t dtd;
|
||||
uint16_t attrId;
|
||||
union {
|
||||
int8_t int8;
|
||||
int16_t int16;
|
||||
int32_t int32;
|
||||
int64_t int64;
|
||||
uint128_t int128;
|
||||
uint8_t uint8;
|
||||
uint16_t uint16;
|
||||
uint32_t uint32;
|
||||
uint64_t uint64;
|
||||
uint128_t uint128;
|
||||
uuid_t uuid;
|
||||
char *str;
|
||||
sdp_data_t *dataseq;
|
||||
} val;
|
||||
sdp_data_t *next;
|
||||
int unitSize;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SDP_H */
|
||||
633
external/cache/sources/hcitools/lib/bluetooth/sdp_lib.h
vendored
Normal file
633
external/cache/sources/hcitools/lib/bluetooth/sdp_lib.h
vendored
Normal file
@@ -0,0 +1,633 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2001-2002 Nokia Corporation
|
||||
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
|
||||
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
* Copyright (C) 2002-2003 Stephen Crane <steve.crane@rococosoft.com>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SDP_LIB_H
|
||||
#define __SDP_LIB_H
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/hci.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* SDP lists
|
||||
*/
|
||||
typedef void(*sdp_list_func_t)(void *, void *);
|
||||
typedef void(*sdp_free_func_t)(void *);
|
||||
typedef int (*sdp_comp_func_t)(const void *, const void *);
|
||||
|
||||
sdp_list_t *sdp_list_append(sdp_list_t *list, void *d);
|
||||
sdp_list_t *sdp_list_remove(sdp_list_t *list, void *d);
|
||||
sdp_list_t *sdp_list_insert_sorted(sdp_list_t *list, void *data, sdp_comp_func_t f);
|
||||
void sdp_list_free(sdp_list_t *list, sdp_free_func_t f);
|
||||
|
||||
static inline int sdp_list_len(const sdp_list_t *list)
|
||||
{
|
||||
int n = 0;
|
||||
for (; list; list = list->next)
|
||||
n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline sdp_list_t *sdp_list_find(sdp_list_t *list, void *u, sdp_comp_func_t f)
|
||||
{
|
||||
for (; list; list = list->next)
|
||||
if (f(list->data, u) == 0)
|
||||
return list;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void sdp_list_foreach(sdp_list_t *list, sdp_list_func_t f, void *u)
|
||||
{
|
||||
for (; list; list = list->next)
|
||||
f(list->data, u);
|
||||
}
|
||||
|
||||
/*
|
||||
* Values of the flags parameter to sdp_record_register
|
||||
*/
|
||||
#define SDP_RECORD_PERSIST 0x01
|
||||
#define SDP_DEVICE_RECORD 0x02
|
||||
|
||||
/*
|
||||
* Values of the flags parameter to sdp_connect
|
||||
*/
|
||||
#define SDP_RETRY_IF_BUSY 0x01
|
||||
#define SDP_WAIT_ON_CLOSE 0x02
|
||||
#define SDP_NON_BLOCKING 0x04
|
||||
|
||||
/*
|
||||
* a session with an SDP server
|
||||
*/
|
||||
typedef struct {
|
||||
int sock;
|
||||
int state;
|
||||
int local;
|
||||
int flags;
|
||||
uint16_t tid; /* Current transaction ID */
|
||||
void *priv;
|
||||
} sdp_session_t;
|
||||
|
||||
typedef enum {
|
||||
/*
|
||||
* Attributes are specified as individual elements
|
||||
*/
|
||||
SDP_ATTR_REQ_INDIVIDUAL = 1,
|
||||
/*
|
||||
* Attributes are specified as a range
|
||||
*/
|
||||
SDP_ATTR_REQ_RANGE
|
||||
} sdp_attrreq_type_t;
|
||||
|
||||
/*
|
||||
* When the pdu_id(type) is a sdp error response, check the status value
|
||||
* to figure out the error reason. For status values 0x0001-0x0006 check
|
||||
* Bluetooth SPEC. If the status is 0xffff, call sdp_get_error function
|
||||
* to get the real reason:
|
||||
* - wrong transaction ID(EPROTO)
|
||||
* - wrong PDU id or(EPROTO)
|
||||
* - I/O error
|
||||
*/
|
||||
typedef void sdp_callback_t(uint8_t type, uint16_t status, uint8_t *rsp, size_t size, void *udata);
|
||||
|
||||
/*
|
||||
* create an L2CAP connection to a Bluetooth device
|
||||
*
|
||||
* INPUT:
|
||||
*
|
||||
* bdaddr_t *src:
|
||||
* Address of the local device to use to make the connection
|
||||
* (or BDADDR_ANY)
|
||||
*
|
||||
* bdaddr_t *dst:
|
||||
* Address of the SDP server device
|
||||
*/
|
||||
sdp_session_t *sdp_connect(const bdaddr_t *src, const bdaddr_t *dst, uint32_t flags);
|
||||
int sdp_close(sdp_session_t *session);
|
||||
int sdp_get_socket(const sdp_session_t *session);
|
||||
|
||||
/*
|
||||
* SDP transaction: functions for asynchronous search.
|
||||
*/
|
||||
sdp_session_t *sdp_create(int sk, uint32_t flags);
|
||||
int sdp_get_error(sdp_session_t *session);
|
||||
int sdp_process(sdp_session_t *session);
|
||||
int sdp_set_notify(sdp_session_t *session, sdp_callback_t *func, void *udata);
|
||||
|
||||
int sdp_service_search_async(sdp_session_t *session, const sdp_list_t *search, uint16_t max_rec_num);
|
||||
int sdp_service_attr_async(sdp_session_t *session, uint32_t handle, sdp_attrreq_type_t reqtype, const sdp_list_t *attrid_list);
|
||||
int sdp_service_search_attr_async(sdp_session_t *session, const sdp_list_t *search, sdp_attrreq_type_t reqtype, const sdp_list_t *attrid_list);
|
||||
|
||||
uint16_t sdp_gen_tid(sdp_session_t *session);
|
||||
|
||||
/*
|
||||
* find all devices in the piconet
|
||||
*/
|
||||
int sdp_general_inquiry(inquiry_info *ii, int dev_num, int duration, uint8_t *found);
|
||||
|
||||
/* flexible extraction of basic attributes - Jean II */
|
||||
int sdp_get_int_attr(const sdp_record_t *rec, uint16_t attr, int *value);
|
||||
int sdp_get_string_attr(const sdp_record_t *rec, uint16_t attr, char *value, int valuelen);
|
||||
|
||||
/*
|
||||
* Basic sdp data functions
|
||||
*/
|
||||
sdp_data_t *sdp_data_alloc(uint8_t dtd, const void *value);
|
||||
sdp_data_t *sdp_data_alloc_with_length(uint8_t dtd, const void *value, uint32_t length);
|
||||
void sdp_data_free(sdp_data_t *data);
|
||||
sdp_data_t *sdp_data_get(const sdp_record_t *rec, uint16_t attr_id);
|
||||
|
||||
sdp_data_t *sdp_seq_alloc(void **dtds, void **values, int len);
|
||||
sdp_data_t *sdp_seq_alloc_with_length(void **dtds, void **values, int *length, int len);
|
||||
sdp_data_t *sdp_seq_append(sdp_data_t *seq, sdp_data_t *data);
|
||||
|
||||
int sdp_attr_add(sdp_record_t *rec, uint16_t attr, sdp_data_t *data);
|
||||
void sdp_attr_remove(sdp_record_t *rec, uint16_t attr);
|
||||
void sdp_attr_replace(sdp_record_t *rec, uint16_t attr, sdp_data_t *data);
|
||||
int sdp_set_uuidseq_attr(sdp_record_t *rec, uint16_t attr, sdp_list_t *seq);
|
||||
int sdp_get_uuidseq_attr(const sdp_record_t *rec, uint16_t attr, sdp_list_t **seqp);
|
||||
|
||||
/*
|
||||
* NOTE that none of the functions below will update the SDP server,
|
||||
* unless the {register, update}sdp_record_t() function is invoked.
|
||||
* All functions which return an integer value, return 0 on success
|
||||
* or -1 on failure.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Create an attribute and add it to the service record's attribute list.
|
||||
* This consists of the data type descriptor of the attribute,
|
||||
* the value of the attribute and the attribute identifier.
|
||||
*/
|
||||
int sdp_attr_add_new(sdp_record_t *rec, uint16_t attr, uint8_t dtd, const void *p);
|
||||
|
||||
/*
|
||||
* Set the information attributes of the service record.
|
||||
* The set of attributes comprises service name, description
|
||||
* and provider name
|
||||
*/
|
||||
void sdp_set_info_attr(sdp_record_t *rec, const char *name, const char *prov, const char *desc);
|
||||
|
||||
/*
|
||||
* Set the ServiceClassID attribute to the sequence specified by seq.
|
||||
* Note that the identifiers need to be in sorted order from the most
|
||||
* specific to the most generic service class that this service
|
||||
* conforms to.
|
||||
*/
|
||||
static inline int sdp_set_service_classes(sdp_record_t *rec, sdp_list_t *seq)
|
||||
{
|
||||
return sdp_set_uuidseq_attr(rec, SDP_ATTR_SVCLASS_ID_LIST, seq);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the service classes to which the service conforms.
|
||||
*
|
||||
* When set, the list contains elements of ServiceClassIdentifer(uint16_t)
|
||||
* ordered from most specific to most generic
|
||||
*/
|
||||
static inline int sdp_get_service_classes(const sdp_record_t *rec, sdp_list_t **seqp)
|
||||
{
|
||||
return sdp_get_uuidseq_attr(rec, SDP_ATTR_SVCLASS_ID_LIST, seqp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the BrowseGroupList attribute to the list specified by seq.
|
||||
*
|
||||
* A service can belong to one or more service groups
|
||||
* and the list comprises such group identifiers (UUIDs)
|
||||
*/
|
||||
static inline int sdp_set_browse_groups(sdp_record_t *rec, sdp_list_t *seq)
|
||||
{
|
||||
return sdp_set_uuidseq_attr(rec, SDP_ATTR_BROWSE_GRP_LIST, seq);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the access protocols of the record to those specified in proto
|
||||
*/
|
||||
int sdp_set_access_protos(sdp_record_t *rec, const sdp_list_t *proto);
|
||||
|
||||
/*
|
||||
* Set the additional access protocols of the record to those specified in proto
|
||||
*/
|
||||
int sdp_set_add_access_protos(sdp_record_t *rec, const sdp_list_t *proto);
|
||||
|
||||
/*
|
||||
* Get protocol port (i.e. PSM for L2CAP, Channel for RFCOMM)
|
||||
*/
|
||||
int sdp_get_proto_port(const sdp_list_t *list, int proto);
|
||||
|
||||
/*
|
||||
* Get protocol descriptor.
|
||||
*/
|
||||
sdp_data_t *sdp_get_proto_desc(sdp_list_t *list, int proto);
|
||||
|
||||
/*
|
||||
* Set the LanguageBase attributes to the values specified in list
|
||||
* (a linked list of sdp_lang_attr_t objects, one for each language in
|
||||
* which user-visible attributes are present).
|
||||
*/
|
||||
int sdp_set_lang_attr(sdp_record_t *rec, const sdp_list_t *list);
|
||||
|
||||
/*
|
||||
* Set the ServiceInfoTimeToLive attribute of the service.
|
||||
* This is the number of seconds that this record is guaranteed
|
||||
* not to change after being obtained by a client.
|
||||
*/
|
||||
static inline int sdp_set_service_ttl(sdp_record_t *rec, uint32_t ttl)
|
||||
{
|
||||
return sdp_attr_add_new(rec, SDP_ATTR_SVCINFO_TTL, SDP_UINT32, &ttl);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the ServiceRecordState attribute of a service. This is
|
||||
* guaranteed to change if there is any kind of modification to
|
||||
* the record.
|
||||
*/
|
||||
static inline int sdp_set_record_state(sdp_record_t *rec, uint32_t state)
|
||||
{
|
||||
return sdp_attr_add_new(rec, SDP_ATTR_RECORD_STATE, SDP_UINT32, &state);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the ServiceID attribute of a service.
|
||||
*/
|
||||
void sdp_set_service_id(sdp_record_t *rec, uuid_t uuid);
|
||||
|
||||
/*
|
||||
* Set the GroupID attribute of a service
|
||||
*/
|
||||
void sdp_set_group_id(sdp_record_t *rec, uuid_t grouuuid);
|
||||
|
||||
/*
|
||||
* Set the ServiceAvailability attribute of a service.
|
||||
*
|
||||
* Note that this represents the relative availability
|
||||
* of the service: 0x00 means completely unavailable;
|
||||
* 0xFF means maximum availability.
|
||||
*/
|
||||
static inline int sdp_set_service_avail(sdp_record_t *rec, uint8_t avail)
|
||||
{
|
||||
return sdp_attr_add_new(rec, SDP_ATTR_SERVICE_AVAILABILITY, SDP_UINT8, &avail);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the profile descriptor list attribute of a record.
|
||||
*
|
||||
* Each element in the list is an object of type
|
||||
* sdp_profile_desc_t which is a definition of the
|
||||
* Bluetooth profile that this service conforms to.
|
||||
*/
|
||||
int sdp_set_profile_descs(sdp_record_t *rec, const sdp_list_t *desc);
|
||||
|
||||
/*
|
||||
* Set URL attributes of a record.
|
||||
*
|
||||
* ClientExecutableURL: a URL to a client's platform specific (WinCE,
|
||||
* PalmOS) executable code that can be used to access this service.
|
||||
*
|
||||
* DocumentationURL: a URL pointing to service documentation
|
||||
*
|
||||
* IconURL: a URL to an icon that can be used to represent this service.
|
||||
*
|
||||
* Note: pass NULL for any URLs that you don't want to set or remove
|
||||
*/
|
||||
void sdp_set_url_attr(sdp_record_t *rec, const char *clientExecURL, const char *docURL, const char *iconURL);
|
||||
|
||||
/*
|
||||
* a service search request.
|
||||
*
|
||||
* INPUT :
|
||||
*
|
||||
* sdp_list_t *search
|
||||
* list containing elements of the search
|
||||
* pattern. Each entry in the list is a UUID
|
||||
* of the service to be searched
|
||||
*
|
||||
* uint16_t max_rec_num
|
||||
* An integer specifying the maximum number of
|
||||
* entries that the client can handle in the response.
|
||||
*
|
||||
* OUTPUT :
|
||||
*
|
||||
* int return value
|
||||
* 0
|
||||
* The request completed successfully. This does not
|
||||
* mean the requested services were found
|
||||
* -1
|
||||
* The request completed unsuccessfully
|
||||
*
|
||||
* sdp_list_t *rsp_list
|
||||
* This variable is set on a successful return if there are
|
||||
* non-zero service handles. It is a singly linked list of
|
||||
* service record handles (uint16_t)
|
||||
*/
|
||||
int sdp_service_search_req(sdp_session_t *session, const sdp_list_t *search, uint16_t max_rec_num, sdp_list_t **rsp_list);
|
||||
|
||||
/*
|
||||
* a service attribute request.
|
||||
*
|
||||
* INPUT :
|
||||
*
|
||||
* uint32_t handle
|
||||
* The handle of the service for which the attribute(s) are
|
||||
* requested
|
||||
*
|
||||
* sdp_attrreq_type_t reqtype
|
||||
* Attribute identifiers are 16 bit unsigned integers specified
|
||||
* in one of 2 ways described below :
|
||||
* SDP_ATTR_REQ_INDIVIDUAL - 16bit individual identifiers
|
||||
* They are the actual attribute identifiers in ascending order
|
||||
*
|
||||
* SDP_ATTR_REQ_RANGE - 32bit identifier range
|
||||
* The high-order 16bits is the start of range
|
||||
* the low-order 16bits are the end of range
|
||||
* 0x0000 to 0xFFFF gets all attributes
|
||||
*
|
||||
* sdp_list_t *attrid_list
|
||||
* Singly linked list containing attribute identifiers desired.
|
||||
* Every element is either a uint16_t(attrSpec = SDP_ATTR_REQ_INDIVIDUAL)
|
||||
* or a uint32_t(attrSpec=SDP_ATTR_REQ_RANGE)
|
||||
*
|
||||
* OUTPUT :
|
||||
* int return value
|
||||
* 0
|
||||
* The request completed successfully. This does not
|
||||
* mean the requested services were found
|
||||
* -1
|
||||
* The request completed unsuccessfully due to a timeout
|
||||
*/
|
||||
sdp_record_t *sdp_service_attr_req(sdp_session_t *session, uint32_t handle, sdp_attrreq_type_t reqtype, const sdp_list_t *attrid_list);
|
||||
|
||||
/*
|
||||
* This is a service search request combined with the service
|
||||
* attribute request. First a service class match is done and
|
||||
* for matching service, requested attributes are extracted
|
||||
*
|
||||
* INPUT :
|
||||
*
|
||||
* sdp_list_t *search
|
||||
* Singly linked list containing elements of the search
|
||||
* pattern. Each entry in the list is a UUID(DataTypeSDP_UUID16)
|
||||
* of the service to be searched
|
||||
*
|
||||
* AttributeSpecification attrSpec
|
||||
* Attribute identifiers are 16 bit unsigned integers specified
|
||||
* in one of 2 ways described below :
|
||||
* SDP_ATTR_REQ_INDIVIDUAL - 16bit individual identifiers
|
||||
* They are the actual attribute identifiers in ascending order
|
||||
*
|
||||
* SDP_ATTR_REQ_RANGE - 32bit identifier range
|
||||
* The high-order 16bits is the start of range
|
||||
* the low-order 16bits are the end of range
|
||||
* 0x0000 to 0xFFFF gets all attributes
|
||||
*
|
||||
* sdp_list_t *attrid_list
|
||||
* Singly linked list containing attribute identifiers desired.
|
||||
* Every element is either a uint16_t(attrSpec = SDP_ATTR_REQ_INDIVIDUAL)
|
||||
* or a uint32_t(attrSpec=SDP_ATTR_REQ_RANGE)
|
||||
*
|
||||
* OUTPUT :
|
||||
* int return value
|
||||
* 0
|
||||
* The request completed successfully. This does not
|
||||
* mean the requested services were found
|
||||
* -1
|
||||
* The request completed unsuccessfully due to a timeout
|
||||
*
|
||||
* sdp_list_t *rsp_list
|
||||
* This variable is set on a successful return to point to
|
||||
* service(s) found. Each element of this list is of type
|
||||
* sdp_record_t *.
|
||||
*/
|
||||
int sdp_service_search_attr_req(sdp_session_t *session, const sdp_list_t *search, sdp_attrreq_type_t reqtype, const sdp_list_t *attrid_list, sdp_list_t **rsp_list);
|
||||
|
||||
/*
|
||||
* Allocate/free a service record and its attributes
|
||||
*/
|
||||
sdp_record_t *sdp_record_alloc(void);
|
||||
void sdp_record_free(sdp_record_t *rec);
|
||||
|
||||
/*
|
||||
* Register a service record.
|
||||
*
|
||||
* Note: It is the responsbility of the Service Provider to create the
|
||||
* record first and set its attributes using setXXX() methods.
|
||||
*
|
||||
* The service provider must then call sdp_record_register() to make
|
||||
* the service record visible to SDP clients. This function returns 0
|
||||
* on success or -1 on failure (and sets errno).
|
||||
*/
|
||||
int sdp_device_record_register_binary(sdp_session_t *session, bdaddr_t *device, uint8_t *data, uint32_t size, uint8_t flags, uint32_t *handle);
|
||||
int sdp_device_record_register(sdp_session_t *session, bdaddr_t *device, sdp_record_t *rec, uint8_t flags);
|
||||
int sdp_record_register(sdp_session_t *session, sdp_record_t *rec, uint8_t flags);
|
||||
|
||||
/*
|
||||
* Unregister a service record.
|
||||
*/
|
||||
int sdp_device_record_unregister_binary(sdp_session_t *session, bdaddr_t *device, uint32_t handle);
|
||||
int sdp_device_record_unregister(sdp_session_t *session, bdaddr_t *device, sdp_record_t *rec);
|
||||
int sdp_record_unregister(sdp_session_t *session, sdp_record_t *rec);
|
||||
|
||||
/*
|
||||
* Update an existing service record. (Calling this function
|
||||
* before a previous call to sdp_record_register() will result
|
||||
* in an error.)
|
||||
*/
|
||||
int sdp_device_record_update_binary(sdp_session_t *session, bdaddr_t *device, uint32_t handle, uint8_t *data, uint32_t size);
|
||||
int sdp_device_record_update(sdp_session_t *session, bdaddr_t *device, const sdp_record_t *rec);
|
||||
int sdp_record_update(sdp_session_t *sess, const sdp_record_t *rec);
|
||||
|
||||
void sdp_record_print(const sdp_record_t *rec);
|
||||
|
||||
/*
|
||||
* UUID functions
|
||||
*/
|
||||
uuid_t *sdp_uuid16_create(uuid_t *uuid, uint16_t data);
|
||||
uuid_t *sdp_uuid32_create(uuid_t *uuid, uint32_t data);
|
||||
uuid_t *sdp_uuid128_create(uuid_t *uuid, const void *data);
|
||||
int sdp_uuid16_cmp(const void *p1, const void *p2);
|
||||
int sdp_uuid128_cmp(const void *p1, const void *p2);
|
||||
int sdp_uuid_cmp(const void *p1, const void *p2);
|
||||
uuid_t *sdp_uuid_to_uuid128(const uuid_t *uuid);
|
||||
void sdp_uuid16_to_uuid128(uuid_t *uuid128, const uuid_t *uuid16);
|
||||
void sdp_uuid32_to_uuid128(uuid_t *uuid128, const uuid_t *uuid32);
|
||||
int sdp_uuid128_to_uuid(uuid_t *uuid);
|
||||
int sdp_uuid_to_proto(uuid_t *uuid);
|
||||
int sdp_uuid_extract(const uint8_t *buffer, int bufsize, uuid_t *uuid, int *scanned);
|
||||
void sdp_uuid_print(const uuid_t *uuid);
|
||||
|
||||
#define MAX_LEN_UUID_STR 37
|
||||
#define MAX_LEN_PROTOCOL_UUID_STR 8
|
||||
#define MAX_LEN_SERVICECLASS_UUID_STR 28
|
||||
#define MAX_LEN_PROFILEDESCRIPTOR_UUID_STR 28
|
||||
|
||||
int sdp_uuid2strn(const uuid_t *uuid, char *str, size_t n);
|
||||
int sdp_proto_uuid2strn(const uuid_t *uuid, char *str, size_t n);
|
||||
int sdp_svclass_uuid2strn(const uuid_t *uuid, char *str, size_t n);
|
||||
int sdp_profile_uuid2strn(const uuid_t *uuid, char *str, size_t n);
|
||||
|
||||
/*
|
||||
* In all the sdp_get_XXX(handle, XXX *xxx) functions below,
|
||||
* the XXX * is set to point to the value, should it exist
|
||||
* and 0 is returned. If the value does not exist, -1 is
|
||||
* returned and errno set to ENODATA.
|
||||
*
|
||||
* In all the methods below, the memory management rules are
|
||||
* simple. Don't free anything! The pointer returned, in the
|
||||
* case of constructed types, is a pointer to the contents
|
||||
* of the sdp_record_t.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Get the access protocols from the service record
|
||||
*/
|
||||
int sdp_get_access_protos(const sdp_record_t *rec, sdp_list_t **protos);
|
||||
|
||||
/*
|
||||
* Get the additional access protocols from the service record
|
||||
*/
|
||||
int sdp_get_add_access_protos(const sdp_record_t *rec, sdp_list_t **protos);
|
||||
|
||||
/*
|
||||
* Extract the list of browse groups to which the service belongs.
|
||||
* When set, seqp contains elements of GroupID (uint16_t)
|
||||
*/
|
||||
static inline int sdp_get_browse_groups(const sdp_record_t *rec, sdp_list_t **seqp)
|
||||
{
|
||||
return sdp_get_uuidseq_attr(rec, SDP_ATTR_BROWSE_GRP_LIST, seqp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract language attribute meta-data of the service record.
|
||||
* For each language in the service record, LangSeq has a struct of type
|
||||
* sdp_lang_attr_t.
|
||||
*/
|
||||
int sdp_get_lang_attr(const sdp_record_t *rec, sdp_list_t **langSeq);
|
||||
|
||||
/*
|
||||
* Extract the Bluetooth profile descriptor sequence from a record.
|
||||
* Each element in the list is of type sdp_profile_desc_t
|
||||
* which contains the UUID of the profile and its version number
|
||||
* (encoded as major and minor in the high-order 8bits
|
||||
* and low-order 8bits respectively of the uint16_t)
|
||||
*/
|
||||
int sdp_get_profile_descs(const sdp_record_t *rec, sdp_list_t **profDesc);
|
||||
|
||||
/*
|
||||
* Extract SDP server version numbers
|
||||
*
|
||||
* Note: that this is an attribute of the SDP server only and
|
||||
* contains a list of uint16_t each of which represent the
|
||||
* major and minor SDP version numbers supported by this server
|
||||
*/
|
||||
int sdp_get_server_ver(const sdp_record_t *rec, sdp_list_t **pVnumList);
|
||||
|
||||
int sdp_get_service_id(const sdp_record_t *rec, uuid_t *uuid);
|
||||
int sdp_get_group_id(const sdp_record_t *rec, uuid_t *uuid);
|
||||
int sdp_get_record_state(const sdp_record_t *rec, uint32_t *svcRecState);
|
||||
int sdp_get_service_avail(const sdp_record_t *rec, uint8_t *svcAvail);
|
||||
int sdp_get_service_ttl(const sdp_record_t *rec, uint32_t *svcTTLInfo);
|
||||
int sdp_get_database_state(const sdp_record_t *rec, uint32_t *svcDBState);
|
||||
|
||||
static inline int sdp_get_service_name(const sdp_record_t *rec, char *str, int len)
|
||||
{
|
||||
return sdp_get_string_attr(rec, SDP_ATTR_SVCNAME_PRIMARY, str, len);
|
||||
}
|
||||
|
||||
static inline int sdp_get_service_desc(const sdp_record_t *rec, char *str, int len)
|
||||
{
|
||||
return sdp_get_string_attr(rec, SDP_ATTR_SVCDESC_PRIMARY, str, len);
|
||||
}
|
||||
|
||||
static inline int sdp_get_provider_name(const sdp_record_t *rec, char *str, int len)
|
||||
{
|
||||
return sdp_get_string_attr(rec, SDP_ATTR_PROVNAME_PRIMARY, str, len);
|
||||
}
|
||||
|
||||
static inline int sdp_get_doc_url(const sdp_record_t *rec, char *str, int len)
|
||||
{
|
||||
return sdp_get_string_attr(rec, SDP_ATTR_DOC_URL, str, len);
|
||||
}
|
||||
|
||||
static inline int sdp_get_clnt_exec_url(const sdp_record_t *rec, char *str, int len)
|
||||
{
|
||||
return sdp_get_string_attr(rec, SDP_ATTR_CLNT_EXEC_URL, str, len);
|
||||
}
|
||||
|
||||
static inline int sdp_get_icon_url(const sdp_record_t *rec, char *str, int len)
|
||||
{
|
||||
return sdp_get_string_attr(rec, SDP_ATTR_ICON_URL, str, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the supported features
|
||||
* sf should be a list of list with each feature data
|
||||
* Returns 0 on success -1 on fail
|
||||
*/
|
||||
int sdp_set_supp_feat(sdp_record_t *rec, const sdp_list_t *sf);
|
||||
|
||||
/*
|
||||
* Get the supported features
|
||||
* seqp is set to a list of list with each feature data
|
||||
* Returns 0 on success, if an error occurred -1 is returned and errno is set
|
||||
*/
|
||||
int sdp_get_supp_feat(const sdp_record_t *rec, sdp_list_t **seqp);
|
||||
|
||||
sdp_record_t *sdp_extract_pdu(const uint8_t *pdata, int bufsize, int *scanned);
|
||||
sdp_record_t *sdp_copy_record(sdp_record_t *rec);
|
||||
|
||||
void sdp_data_print(sdp_data_t *data);
|
||||
void sdp_print_service_attr(sdp_list_t *alist);
|
||||
|
||||
int sdp_attrid_comp_func(const void *key1, const void *key2);
|
||||
|
||||
void sdp_set_seq_len(uint8_t *ptr, uint32_t length);
|
||||
void sdp_set_attrid(sdp_buf_t *pdu, uint16_t id);
|
||||
void sdp_append_to_pdu(sdp_buf_t *dst, sdp_data_t *d);
|
||||
void sdp_append_to_buf(sdp_buf_t *dst, uint8_t *data, uint32_t len);
|
||||
|
||||
int sdp_gen_pdu(sdp_buf_t *pdu, sdp_data_t *data);
|
||||
int sdp_gen_record_pdu(const sdp_record_t *rec, sdp_buf_t *pdu);
|
||||
|
||||
int sdp_extract_seqtype(const uint8_t *buf, int bufsize, uint8_t *dtdp, int *size);
|
||||
|
||||
sdp_data_t *sdp_extract_attr(const uint8_t *pdata, int bufsize, int *extractedLength, sdp_record_t *rec);
|
||||
|
||||
void sdp_pattern_add_uuid(sdp_record_t *rec, uuid_t *uuid);
|
||||
void sdp_pattern_add_uuidseq(sdp_record_t *rec, sdp_list_t *seq);
|
||||
|
||||
int sdp_send_req_w4_rsp(sdp_session_t *session, uint8_t *req, uint8_t *rsp, uint32_t reqsize, uint32_t *rspsize);
|
||||
|
||||
void sdp_add_lang_attr(sdp_record_t *rec);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SDP_LIB_H */
|
||||
2928
external/cache/sources/hcitools/lib/hci.c
vendored
Normal file
2928
external/cache/sources/hcitools/lib/hci.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
594
external/cache/sources/hcitools/lib/mgmt.h
vendored
Normal file
594
external/cache/sources/hcitools/lib/mgmt.h
vendored
Normal file
@@ -0,0 +1,594 @@
|
||||
/*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2010 Nokia Corporation
|
||||
* Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __packed
|
||||
#define __packed __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#define MGMT_INDEX_NONE 0xFFFF
|
||||
|
||||
#define MGMT_STATUS_SUCCESS 0x00
|
||||
#define MGMT_STATUS_UNKNOWN_COMMAND 0x01
|
||||
#define MGMT_STATUS_NOT_CONNECTED 0x02
|
||||
#define MGMT_STATUS_FAILED 0x03
|
||||
#define MGMT_STATUS_CONNECT_FAILED 0x04
|
||||
#define MGMT_STATUS_AUTH_FAILED 0x05
|
||||
#define MGMT_STATUS_NOT_PAIRED 0x06
|
||||
#define MGMT_STATUS_NO_RESOURCES 0x07
|
||||
#define MGMT_STATUS_TIMEOUT 0x08
|
||||
#define MGMT_STATUS_ALREADY_CONNECTED 0x09
|
||||
#define MGMT_STATUS_BUSY 0x0a
|
||||
#define MGMT_STATUS_REJECTED 0x0b
|
||||
#define MGMT_STATUS_NOT_SUPPORTED 0x0c
|
||||
#define MGMT_STATUS_INVALID_PARAMS 0x0d
|
||||
#define MGMT_STATUS_DISCONNECTED 0x0e
|
||||
#define MGMT_STATUS_NOT_POWERED 0x0f
|
||||
#define MGMT_STATUS_CANCELLED 0x10
|
||||
#define MGMT_STATUS_INVALID_INDEX 0x11
|
||||
#define MGMT_STATUS_RFKILLED 0x12
|
||||
|
||||
struct mgmt_hdr {
|
||||
uint16_t opcode;
|
||||
uint16_t index;
|
||||
uint16_t len;
|
||||
} __packed;
|
||||
#define MGMT_HDR_SIZE 6
|
||||
|
||||
struct mgmt_addr_info {
|
||||
bdaddr_t bdaddr;
|
||||
uint8_t type;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_READ_VERSION 0x0001
|
||||
struct mgmt_rp_read_version {
|
||||
uint8_t version;
|
||||
uint16_t revision;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_READ_COMMANDS 0x0002
|
||||
struct mgmt_rp_read_commands {
|
||||
uint16_t num_commands;
|
||||
uint16_t num_events;
|
||||
uint16_t opcodes[0];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_READ_INDEX_LIST 0x0003
|
||||
struct mgmt_rp_read_index_list {
|
||||
uint16_t num_controllers;
|
||||
uint16_t index[0];
|
||||
} __packed;
|
||||
|
||||
/* Reserve one extra byte for names in management messages so that they
|
||||
* are always guaranteed to be nul-terminated */
|
||||
#define MGMT_MAX_NAME_LENGTH (248 + 1)
|
||||
#define MGMT_MAX_SHORT_NAME_LENGTH (10 + 1)
|
||||
|
||||
#define MGMT_SETTING_POWERED 0x00000001
|
||||
#define MGMT_SETTING_CONNECTABLE 0x00000002
|
||||
#define MGMT_SETTING_FAST_CONNECTABLE 0x00000004
|
||||
#define MGMT_SETTING_DISCOVERABLE 0x00000008
|
||||
#define MGMT_SETTING_PAIRABLE 0x00000010
|
||||
#define MGMT_SETTING_LINK_SECURITY 0x00000020
|
||||
#define MGMT_SETTING_SSP 0x00000040
|
||||
#define MGMT_SETTING_BREDR 0x00000080
|
||||
#define MGMT_SETTING_HS 0x00000100
|
||||
#define MGMT_SETTING_LE 0x00000200
|
||||
#define MGMT_SETTING_ADVERTISING 0x00000400
|
||||
|
||||
#define MGMT_OP_READ_INFO 0x0004
|
||||
struct mgmt_rp_read_info {
|
||||
bdaddr_t bdaddr;
|
||||
uint8_t version;
|
||||
uint16_t manufacturer;
|
||||
uint32_t supported_settings;
|
||||
uint32_t current_settings;
|
||||
uint8_t dev_class[3];
|
||||
uint8_t name[MGMT_MAX_NAME_LENGTH];
|
||||
uint8_t short_name[MGMT_MAX_SHORT_NAME_LENGTH];
|
||||
} __packed;
|
||||
|
||||
struct mgmt_mode {
|
||||
uint8_t val;
|
||||
} __packed;
|
||||
|
||||
struct mgmt_cod {
|
||||
uint8_t val[3];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_SET_POWERED 0x0005
|
||||
|
||||
#define MGMT_OP_SET_DISCOVERABLE 0x0006
|
||||
struct mgmt_cp_set_discoverable {
|
||||
uint8_t val;
|
||||
uint16_t timeout;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_SET_CONNECTABLE 0x0007
|
||||
|
||||
#define MGMT_OP_SET_FAST_CONNECTABLE 0x0008
|
||||
|
||||
#define MGMT_OP_SET_PAIRABLE 0x0009
|
||||
|
||||
#define MGMT_OP_SET_LINK_SECURITY 0x000A
|
||||
|
||||
#define MGMT_OP_SET_SSP 0x000B
|
||||
|
||||
#define MGMT_OP_SET_HS 0x000C
|
||||
|
||||
#define MGMT_OP_SET_LE 0x000D
|
||||
|
||||
#define MGMT_OP_SET_DEV_CLASS 0x000E
|
||||
struct mgmt_cp_set_dev_class {
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_SET_LOCAL_NAME 0x000F
|
||||
struct mgmt_cp_set_local_name {
|
||||
uint8_t name[MGMT_MAX_NAME_LENGTH];
|
||||
uint8_t short_name[MGMT_MAX_SHORT_NAME_LENGTH];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_ADD_UUID 0x0010
|
||||
struct mgmt_cp_add_uuid {
|
||||
uint8_t uuid[16];
|
||||
uint8_t svc_hint;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_REMOVE_UUID 0x0011
|
||||
struct mgmt_cp_remove_uuid {
|
||||
uint8_t uuid[16];
|
||||
} __packed;
|
||||
|
||||
struct mgmt_link_key_info {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t type;
|
||||
uint8_t val[16];
|
||||
uint8_t pin_len;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_LOAD_LINK_KEYS 0x0012
|
||||
struct mgmt_cp_load_link_keys {
|
||||
uint8_t debug_keys;
|
||||
uint16_t key_count;
|
||||
struct mgmt_link_key_info keys[0];
|
||||
} __packed;
|
||||
|
||||
struct mgmt_ltk_info {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t authenticated;
|
||||
uint8_t master;
|
||||
uint8_t enc_size;
|
||||
uint16_t ediv;
|
||||
uint8_t rand[8];
|
||||
uint8_t val[16];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_LOAD_LONG_TERM_KEYS 0x0013
|
||||
struct mgmt_cp_load_long_term_keys {
|
||||
uint16_t key_count;
|
||||
struct mgmt_ltk_info keys[0];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_DISCONNECT 0x0014
|
||||
struct mgmt_cp_disconnect {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
struct mgmt_rp_disconnect {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_GET_CONNECTIONS 0x0015
|
||||
struct mgmt_rp_get_connections {
|
||||
uint16_t conn_count;
|
||||
struct mgmt_addr_info addr[0];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_PIN_CODE_REPLY 0x0016
|
||||
struct mgmt_cp_pin_code_reply {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t pin_len;
|
||||
uint8_t pin_code[16];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017
|
||||
struct mgmt_cp_pin_code_neg_reply {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_SET_IO_CAPABILITY 0x0018
|
||||
struct mgmt_cp_set_io_capability {
|
||||
uint8_t io_capability;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_PAIR_DEVICE 0x0019
|
||||
struct mgmt_cp_pair_device {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t io_cap;
|
||||
} __packed;
|
||||
struct mgmt_rp_pair_device {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_CANCEL_PAIR_DEVICE 0x001A
|
||||
|
||||
#define MGMT_OP_UNPAIR_DEVICE 0x001B
|
||||
struct mgmt_cp_unpair_device {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t disconnect;
|
||||
} __packed;
|
||||
struct mgmt_rp_unpair_device {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_USER_CONFIRM_REPLY 0x001C
|
||||
struct mgmt_cp_user_confirm_reply {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
struct mgmt_rp_user_confirm_reply {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D
|
||||
|
||||
#define MGMT_OP_USER_PASSKEY_REPLY 0x001E
|
||||
struct mgmt_cp_user_passkey_reply {
|
||||
struct mgmt_addr_info addr;
|
||||
uint32_t passkey;
|
||||
} __packed;
|
||||
struct mgmt_rp_user_passkey_reply {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F
|
||||
struct mgmt_cp_user_passkey_neg_reply {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020
|
||||
struct mgmt_rp_read_local_oob_data {
|
||||
uint8_t hash[16];
|
||||
uint8_t randomizer[16];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0021
|
||||
struct mgmt_cp_add_remote_oob_data {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t hash[16];
|
||||
uint8_t randomizer[16];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022
|
||||
struct mgmt_cp_remove_remote_oob_data {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_START_DISCOVERY 0x0023
|
||||
struct mgmt_cp_start_discovery {
|
||||
uint8_t type;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_STOP_DISCOVERY 0x0024
|
||||
struct mgmt_cp_stop_discovery {
|
||||
uint8_t type;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_CONFIRM_NAME 0x0025
|
||||
struct mgmt_cp_confirm_name {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t name_known;
|
||||
} __packed;
|
||||
struct mgmt_rp_confirm_name {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_BLOCK_DEVICE 0x0026
|
||||
struct mgmt_cp_block_device {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_UNBLOCK_DEVICE 0x0027
|
||||
struct mgmt_cp_unblock_device {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_SET_DEVICE_ID 0x0028
|
||||
struct mgmt_cp_set_device_id {
|
||||
uint16_t source;
|
||||
uint16_t vendor;
|
||||
uint16_t product;
|
||||
uint16_t version;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_SET_ADVERTISING 0x0029
|
||||
|
||||
#define MGMT_OP_SET_BREDR 0x002A
|
||||
|
||||
#define MGMT_OP_SET_STATIC_ADDRESS 0x002B
|
||||
struct mgmt_cp_set_static_address {
|
||||
bdaddr_t bdaddr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_OP_SET_SCAN_PARAMS 0x002C
|
||||
struct mgmt_cp_set_scan_params {
|
||||
uint16_t interval;
|
||||
uint16_t window;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_CMD_COMPLETE 0x0001
|
||||
struct mgmt_ev_cmd_complete {
|
||||
uint16_t opcode;
|
||||
uint8_t status;
|
||||
uint8_t data[0];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_CMD_STATUS 0x0002
|
||||
struct mgmt_ev_cmd_status {
|
||||
uint16_t opcode;
|
||||
uint8_t status;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_CONTROLLER_ERROR 0x0003
|
||||
struct mgmt_ev_controller_error {
|
||||
uint8_t error_code;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_INDEX_ADDED 0x0004
|
||||
|
||||
#define MGMT_EV_INDEX_REMOVED 0x0005
|
||||
|
||||
#define MGMT_EV_NEW_SETTINGS 0x0006
|
||||
|
||||
#define MGMT_EV_CLASS_OF_DEV_CHANGED 0x0007
|
||||
struct mgmt_ev_class_of_dev_changed {
|
||||
uint8_t class_of_dev[3];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_LOCAL_NAME_CHANGED 0x0008
|
||||
struct mgmt_ev_local_name_changed {
|
||||
uint8_t name[MGMT_MAX_NAME_LENGTH];
|
||||
uint8_t short_name[MGMT_MAX_SHORT_NAME_LENGTH];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_NEW_LINK_KEY 0x0009
|
||||
struct mgmt_ev_new_link_key {
|
||||
uint8_t store_hint;
|
||||
struct mgmt_link_key_info key;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_NEW_LONG_TERM_KEY 0x000A
|
||||
struct mgmt_ev_new_long_term_key {
|
||||
uint8_t store_hint;
|
||||
struct mgmt_ltk_info key;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_DEVICE_CONNECTED 0x000B
|
||||
struct mgmt_ev_device_connected {
|
||||
struct mgmt_addr_info addr;
|
||||
uint32_t flags;
|
||||
uint16_t eir_len;
|
||||
uint8_t eir[0];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_DEV_DISCONN_UNKNOWN 0x00
|
||||
#define MGMT_DEV_DISCONN_TIMEOUT 0x01
|
||||
#define MGMT_DEV_DISCONN_LOCAL_HOST 0x02
|
||||
#define MGMT_DEV_DISCONN_REMOTE 0x03
|
||||
|
||||
#define MGMT_EV_DEVICE_DISCONNECTED 0x000C
|
||||
struct mgmt_ev_device_disconnected {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t reason;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_CONNECT_FAILED 0x000D
|
||||
struct mgmt_ev_connect_failed {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t status;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_PIN_CODE_REQUEST 0x000E
|
||||
struct mgmt_ev_pin_code_request {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t secure;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_USER_CONFIRM_REQUEST 0x000F
|
||||
struct mgmt_ev_user_confirm_request {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t confirm_hint;
|
||||
uint32_t value;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_USER_PASSKEY_REQUEST 0x0010
|
||||
struct mgmt_ev_user_passkey_request {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_AUTH_FAILED 0x0011
|
||||
struct mgmt_ev_auth_failed {
|
||||
struct mgmt_addr_info addr;
|
||||
uint8_t status;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_DEV_FOUND_CONFIRM_NAME 0x01
|
||||
#define MGMT_DEV_FOUND_LEGACY_PAIRING 0x02
|
||||
|
||||
#define MGMT_EV_DEVICE_FOUND 0x0012
|
||||
struct mgmt_ev_device_found {
|
||||
struct mgmt_addr_info addr;
|
||||
int8_t rssi;
|
||||
uint32_t flags;
|
||||
uint16_t eir_len;
|
||||
uint8_t eir[0];
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_DISCOVERING 0x0013
|
||||
struct mgmt_ev_discovering {
|
||||
uint8_t type;
|
||||
uint8_t discovering;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_DEVICE_BLOCKED 0x0014
|
||||
struct mgmt_ev_device_blocked {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_DEVICE_UNBLOCKED 0x0015
|
||||
struct mgmt_ev_device_unblocked {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_DEVICE_UNPAIRED 0x0016
|
||||
struct mgmt_ev_device_unpaired {
|
||||
struct mgmt_addr_info addr;
|
||||
} __packed;
|
||||
|
||||
#define MGMT_EV_PASSKEY_NOTIFY 0x0017
|
||||
struct mgmt_ev_passkey_notify {
|
||||
struct mgmt_addr_info addr;
|
||||
uint32_t passkey;
|
||||
uint8_t entered;
|
||||
} __packed;
|
||||
|
||||
static const char *mgmt_op[] = {
|
||||
"<0x0000>",
|
||||
"Read Version",
|
||||
"Read Commands",
|
||||
"Read Index List",
|
||||
"Read Controller Info",
|
||||
"Set Powered",
|
||||
"Set Discoverable",
|
||||
"Set Connectable",
|
||||
"Set Fast Connectable", /* 0x0008 */
|
||||
"Set Pairable",
|
||||
"Set Link Security",
|
||||
"Set Secure Simple Pairing",
|
||||
"Set High Speed",
|
||||
"Set Low Energy",
|
||||
"Set Dev Class",
|
||||
"Set Local Name",
|
||||
"Add UUID", /* 0x0010 */
|
||||
"Remove UUID",
|
||||
"Load Link Keys",
|
||||
"Load Long Term Keys",
|
||||
"Disconnect",
|
||||
"Get Connections",
|
||||
"PIN Code Reply",
|
||||
"PIN Code Neg Reply",
|
||||
"Set IO Capability", /* 0x0018 */
|
||||
"Pair Device",
|
||||
"Cancel Pair Device",
|
||||
"Unpair Device",
|
||||
"User Confirm Reply",
|
||||
"User Confirm Neg Reply",
|
||||
"User Passkey Reply",
|
||||
"User Passkey Neg Reply",
|
||||
"Read Local OOB Data", /* 0x0020 */
|
||||
"Add Remote OOB Data",
|
||||
"Remove Remove OOB Data",
|
||||
"Start Discovery",
|
||||
"Stop Discovery",
|
||||
"Confirm Name",
|
||||
"Block Device",
|
||||
"Unblock Device",
|
||||
"Set Device ID",
|
||||
"Set Advertising",
|
||||
"Set BR/EDR",
|
||||
"Set Static Address",
|
||||
"Set Scan Parameters",
|
||||
};
|
||||
|
||||
static const char *mgmt_ev[] = {
|
||||
"<0x0000>",
|
||||
"Command Complete",
|
||||
"Command Status",
|
||||
"Controller Error",
|
||||
"Index Added",
|
||||
"Index Removed",
|
||||
"New Settings",
|
||||
"Class of Device Changed",
|
||||
"Local Name Changed", /* 0x0008 */
|
||||
"New Link Key",
|
||||
"New Long Term Key",
|
||||
"Device Connected",
|
||||
"Device Disconnected",
|
||||
"Connect Failed",
|
||||
"PIN Code Request",
|
||||
"User Confirm Request",
|
||||
"User Passkey Request", /* 0x0010 */
|
||||
"Authentication Failed",
|
||||
"Device Found",
|
||||
"Discovering",
|
||||
"Device Blocked",
|
||||
"Device Unblocked",
|
||||
"Device Unpaired",
|
||||
"Passkey Notify",
|
||||
};
|
||||
|
||||
static const char *mgmt_status[] = {
|
||||
"Success",
|
||||
"Unknown Command",
|
||||
"Not Connected",
|
||||
"Failed",
|
||||
"Connect Failed",
|
||||
"Authentication Failed",
|
||||
"Not Paired",
|
||||
"No Resources",
|
||||
"Timeout",
|
||||
"Already Connected",
|
||||
"Busy",
|
||||
"Rejected",
|
||||
"Not Supported",
|
||||
"Invalid Parameters",
|
||||
"Disconnected",
|
||||
"Not Powered",
|
||||
"Cancelled",
|
||||
"Invalid Index",
|
||||
"Blocked through rfkill",
|
||||
};
|
||||
|
||||
#ifndef NELEM
|
||||
#define NELEM(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
static inline const char *mgmt_opstr(uint16_t op)
|
||||
{
|
||||
if (op >= NELEM(mgmt_op))
|
||||
return "<unknown opcode>";
|
||||
return mgmt_op[op];
|
||||
}
|
||||
|
||||
static inline const char *mgmt_evstr(uint16_t ev)
|
||||
{
|
||||
if (ev >= NELEM(mgmt_ev))
|
||||
return "<unknown event>";
|
||||
return mgmt_ev[ev];
|
||||
}
|
||||
|
||||
static inline const char *mgmt_errstr(uint8_t status)
|
||||
{
|
||||
if (status >= NELEM(mgmt_status))
|
||||
return "<unknown status>";
|
||||
return mgmt_status[status];
|
||||
}
|
||||
4919
external/cache/sources/hcitools/lib/sdp.c
vendored
Normal file
4919
external/cache/sources/hcitools/lib/sdp.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
278
external/cache/sources/hcitools/lib/uuid.c
vendored
Normal file
278
external/cache/sources/hcitools/lib/uuid.c
vendored
Normal file
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2011 Nokia Corporation
|
||||
* Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "uuid.h"
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
static uint128_t bluetooth_base_uuid = {
|
||||
.data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB }
|
||||
};
|
||||
|
||||
#define BASE_UUID16_OFFSET 2
|
||||
#define BASE_UUID32_OFFSET 0
|
||||
|
||||
#else
|
||||
static uint128_t bluetooth_base_uuid = {
|
||||
.data = { 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
};
|
||||
|
||||
#define BASE_UUID16_OFFSET 12
|
||||
#define BASE_UUID32_OFFSET BASE_UUID16_OFFSET
|
||||
|
||||
#endif
|
||||
|
||||
static void bt_uuid16_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst)
|
||||
{
|
||||
dst->value.u128 = bluetooth_base_uuid;
|
||||
dst->type = BT_UUID128;
|
||||
|
||||
memcpy(&dst->value.u128.data[BASE_UUID16_OFFSET],
|
||||
&src->value.u16, sizeof(src->value.u16));
|
||||
}
|
||||
|
||||
static void bt_uuid32_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst)
|
||||
{
|
||||
dst->value.u128 = bluetooth_base_uuid;
|
||||
dst->type = BT_UUID128;
|
||||
|
||||
memcpy(&dst->value.u128.data[BASE_UUID32_OFFSET],
|
||||
&src->value.u32, sizeof(src->value.u32));
|
||||
}
|
||||
|
||||
void bt_uuid_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst)
|
||||
{
|
||||
switch (src->type) {
|
||||
case BT_UUID128:
|
||||
*dst = *src;
|
||||
break;
|
||||
case BT_UUID32:
|
||||
bt_uuid32_to_uuid128(src, dst);
|
||||
break;
|
||||
case BT_UUID16:
|
||||
bt_uuid16_to_uuid128(src, dst);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int bt_uuid128_cmp(const bt_uuid_t *u1, const bt_uuid_t *u2)
|
||||
{
|
||||
return memcmp(&u1->value.u128, &u2->value.u128, sizeof(uint128_t));
|
||||
}
|
||||
|
||||
int bt_uuid16_create(bt_uuid_t *btuuid, uint16_t value)
|
||||
{
|
||||
memset(btuuid, 0, sizeof(bt_uuid_t));
|
||||
btuuid->type = BT_UUID16;
|
||||
btuuid->value.u16 = value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_uuid32_create(bt_uuid_t *btuuid, uint32_t value)
|
||||
{
|
||||
memset(btuuid, 0, sizeof(bt_uuid_t));
|
||||
btuuid->type = BT_UUID32;
|
||||
btuuid->value.u32 = value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_uuid128_create(bt_uuid_t *btuuid, uint128_t value)
|
||||
{
|
||||
memset(btuuid, 0, sizeof(bt_uuid_t));
|
||||
btuuid->type = BT_UUID128;
|
||||
btuuid->value.u128 = value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_uuid_cmp(const bt_uuid_t *uuid1, const bt_uuid_t *uuid2)
|
||||
{
|
||||
bt_uuid_t u1, u2;
|
||||
|
||||
bt_uuid_to_uuid128(uuid1, &u1);
|
||||
bt_uuid_to_uuid128(uuid2, &u2);
|
||||
|
||||
return bt_uuid128_cmp(&u1, &u2);
|
||||
}
|
||||
|
||||
/*
|
||||
* convert the UUID to string, copying a maximum of n characters.
|
||||
*/
|
||||
int bt_uuid_to_string(const bt_uuid_t *uuid, char *str, size_t n)
|
||||
{
|
||||
if (!uuid) {
|
||||
snprintf(str, n, "NULL");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (uuid->type) {
|
||||
case BT_UUID16:
|
||||
snprintf(str, n, "%.4x", uuid->value.u16);
|
||||
break;
|
||||
case BT_UUID32:
|
||||
snprintf(str, n, "%.8x", uuid->value.u32);
|
||||
break;
|
||||
case BT_UUID128: {
|
||||
unsigned int data0;
|
||||
unsigned short data1;
|
||||
unsigned short data2;
|
||||
unsigned short data3;
|
||||
unsigned int data4;
|
||||
unsigned short data5;
|
||||
|
||||
uint128_t nvalue;
|
||||
const uint8_t *data = (uint8_t *) &nvalue;
|
||||
|
||||
hton128(&uuid->value.u128, &nvalue);
|
||||
|
||||
memcpy(&data0, &data[0], 4);
|
||||
memcpy(&data1, &data[4], 2);
|
||||
memcpy(&data2, &data[6], 2);
|
||||
memcpy(&data3, &data[8], 2);
|
||||
memcpy(&data4, &data[10], 4);
|
||||
memcpy(&data5, &data[14], 2);
|
||||
|
||||
snprintf(str, n, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x",
|
||||
ntohl(data0), ntohs(data1),
|
||||
ntohs(data2), ntohs(data3),
|
||||
ntohl(data4), ntohs(data5));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
snprintf(str, n, "Type of UUID (%x) unknown.", uuid->type);
|
||||
return -EINVAL; /* Enum type of UUID not set */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int is_uuid128(const char *string)
|
||||
{
|
||||
return (strlen(string) == 36 &&
|
||||
string[8] == '-' &&
|
||||
string[13] == '-' &&
|
||||
string[18] == '-' &&
|
||||
string[23] == '-');
|
||||
}
|
||||
|
||||
static inline int is_uuid32(const char *string)
|
||||
{
|
||||
return (strlen(string) == 8 || strlen(string) == 10);
|
||||
}
|
||||
|
||||
static inline int is_uuid16(const char *string)
|
||||
{
|
||||
return (strlen(string) == 4 || strlen(string) == 6);
|
||||
}
|
||||
|
||||
static int bt_string_to_uuid16(bt_uuid_t *uuid, const char *string)
|
||||
{
|
||||
uint16_t u16;
|
||||
char *endptr = NULL;
|
||||
|
||||
u16 = strtol(string, &endptr, 16);
|
||||
if (endptr && *endptr == '\0') {
|
||||
bt_uuid16_create(uuid, u16);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int bt_string_to_uuid32(bt_uuid_t *uuid, const char *string)
|
||||
{
|
||||
uint32_t u32;
|
||||
char *endptr = NULL;
|
||||
|
||||
u32 = strtol(string, &endptr, 16);
|
||||
if (endptr && *endptr == '\0') {
|
||||
bt_uuid32_create(uuid, u32);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int bt_string_to_uuid128(bt_uuid_t *uuid, const char *string)
|
||||
{
|
||||
uint32_t data0, data4;
|
||||
uint16_t data1, data2, data3, data5;
|
||||
uint128_t n128, u128;
|
||||
uint8_t *val = (uint8_t *) &n128;
|
||||
|
||||
if (sscanf(string, "%08x-%04hx-%04hx-%04hx-%08x%04hx",
|
||||
&data0, &data1, &data2,
|
||||
&data3, &data4, &data5) != 6)
|
||||
return -EINVAL;
|
||||
|
||||
data0 = htonl(data0);
|
||||
data1 = htons(data1);
|
||||
data2 = htons(data2);
|
||||
data3 = htons(data3);
|
||||
data4 = htonl(data4);
|
||||
data5 = htons(data5);
|
||||
|
||||
memcpy(&val[0], &data0, 4);
|
||||
memcpy(&val[4], &data1, 2);
|
||||
memcpy(&val[6], &data2, 2);
|
||||
memcpy(&val[8], &data3, 2);
|
||||
memcpy(&val[10], &data4, 4);
|
||||
memcpy(&val[14], &data5, 2);
|
||||
|
||||
ntoh128(&n128, &u128);
|
||||
|
||||
bt_uuid128_create(uuid, u128);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_string_to_uuid(bt_uuid_t *uuid, const char *string)
|
||||
{
|
||||
if (is_uuid128(string))
|
||||
return bt_string_to_uuid128(uuid, string);
|
||||
else if (is_uuid32(string))
|
||||
return bt_string_to_uuid32(uuid, string);
|
||||
else if (is_uuid16(string))
|
||||
return bt_string_to_uuid16(uuid, string);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int bt_uuid_strcmp(const void *a, const void *b)
|
||||
{
|
||||
return strcasecmp(a, b);
|
||||
}
|
||||
140
external/cache/sources/hcitools/lib/uuid.h
vendored
Normal file
140
external/cache/sources/hcitools/lib/uuid.h
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2011 Nokia Corporation
|
||||
* Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __BLUETOOTH_UUID_H
|
||||
#define __BLUETOOTH_UUID_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <bluetooth/bluetooth.h>
|
||||
|
||||
#define GENERIC_AUDIO_UUID "00001203-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define HSP_HS_UUID "00001108-0000-1000-8000-00805f9b34fb"
|
||||
#define HSP_AG_UUID "00001112-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define HFP_HS_UUID "0000111e-0000-1000-8000-00805f9b34fb"
|
||||
#define HFP_AG_UUID "0000111f-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define ADVANCED_AUDIO_UUID "0000110d-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define A2DP_SOURCE_UUID "0000110a-0000-1000-8000-00805f9b34fb"
|
||||
#define A2DP_SINK_UUID "0000110b-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define AVRCP_REMOTE_UUID "0000110e-0000-1000-8000-00805f9b34fb"
|
||||
#define AVRCP_TARGET_UUID "0000110c-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define PANU_UUID "00001115-0000-1000-8000-00805f9b34fb"
|
||||
#define NAP_UUID "00001116-0000-1000-8000-00805f9b34fb"
|
||||
#define GN_UUID "00001117-0000-1000-8000-00805f9b34fb"
|
||||
#define BNEP_SVC_UUID "0000000f-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define PNPID_UUID "00002a50-0000-1000-8000-00805f9b34fb"
|
||||
#define DEVICE_INFORMATION_UUID "0000180a-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define GATT_UUID "00001801-0000-1000-8000-00805f9b34fb"
|
||||
#define IMMEDIATE_ALERT_UUID "00001802-0000-1000-8000-00805f9b34fb"
|
||||
#define LINK_LOSS_UUID "00001803-0000-1000-8000-00805f9b34fb"
|
||||
#define TX_POWER_UUID "00001804-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define SAP_UUID "0000112D-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define HEART_RATE_UUID "0000180d-0000-1000-8000-00805f9b34fb"
|
||||
#define HEART_RATE_MEASUREMENT_UUID "00002a37-0000-1000-8000-00805f9b34fb"
|
||||
#define BODY_SENSOR_LOCATION_UUID "00002a38-0000-1000-8000-00805f9b34fb"
|
||||
#define HEART_RATE_CONTROL_POINT_UUID "00002a39-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define HEALTH_THERMOMETER_UUID "00001809-0000-1000-8000-00805f9b34fb"
|
||||
#define TEMPERATURE_MEASUREMENT_UUID "00002a1c-0000-1000-8000-00805f9b34fb"
|
||||
#define TEMPERATURE_TYPE_UUID "00002a1d-0000-1000-8000-00805f9b34fb"
|
||||
#define INTERMEDIATE_TEMPERATURE_UUID "00002a1e-0000-1000-8000-00805f9b34fb"
|
||||
#define MEASUREMENT_INTERVAL_UUID "00002a21-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define CYCLING_SC_UUID "00001816-0000-1000-8000-00805f9b34fb"
|
||||
#define CSC_MEASUREMENT_UUID "00002a5b-0000-1000-8000-00805f9b34fb"
|
||||
#define CSC_FEATURE_UUID "00002a5c-0000-1000-8000-00805f9b34fb"
|
||||
#define SENSOR_LOCATION_UUID "00002a5d-0000-1000-8000-00805f9b34fb"
|
||||
#define SC_CONTROL_POINT_UUID "00002a55-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define RFCOMM_UUID_STR "00000003-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define HDP_UUID "00001400-0000-1000-8000-00805f9b34fb"
|
||||
#define HDP_SOURCE_UUID "00001401-0000-1000-8000-00805f9b34fb"
|
||||
#define HDP_SINK_UUID "00001402-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define HID_UUID "00001124-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define DUN_GW_UUID "00001103-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define GAP_UUID "00001800-0000-1000-8000-00805f9b34fb"
|
||||
#define PNP_UUID "00001200-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define SPP_UUID "00001101-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
#define OBEX_SYNC_UUID "00001104-0000-1000-8000-00805f9b34fb"
|
||||
#define OBEX_OPP_UUID "00001105-0000-1000-8000-00805f9b34fb"
|
||||
#define OBEX_FTP_UUID "00001106-0000-1000-8000-00805f9b34fb"
|
||||
#define OBEX_PCE_UUID "0000112e-0000-1000-8000-00805f9b34fb"
|
||||
#define OBEX_PSE_UUID "0000112f-0000-1000-8000-00805f9b34fb"
|
||||
#define OBEX_PBAP_UUID "00001130-0000-1000-8000-00805f9b34fb"
|
||||
#define OBEX_MAS_UUID "00001132-0000-1000-8000-00805f9b34fb"
|
||||
#define OBEX_MNS_UUID "00001133-0000-1000-8000-00805f9b34fb"
|
||||
#define OBEX_MAP_UUID "00001134-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
typedef struct {
|
||||
enum {
|
||||
BT_UUID_UNSPEC = 0,
|
||||
BT_UUID16 = 16,
|
||||
BT_UUID32 = 32,
|
||||
BT_UUID128 = 128,
|
||||
} type;
|
||||
union {
|
||||
uint16_t u16;
|
||||
uint32_t u32;
|
||||
uint128_t u128;
|
||||
} value;
|
||||
} bt_uuid_t;
|
||||
|
||||
int bt_uuid_strcmp(const void *a, const void *b);
|
||||
|
||||
int bt_uuid16_create(bt_uuid_t *btuuid, uint16_t value);
|
||||
int bt_uuid32_create(bt_uuid_t *btuuid, uint32_t value);
|
||||
int bt_uuid128_create(bt_uuid_t *btuuid, uint128_t value);
|
||||
|
||||
int bt_uuid_cmp(const bt_uuid_t *uuid1, const bt_uuid_t *uuid2);
|
||||
void bt_uuid_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst);
|
||||
|
||||
#define MAX_LEN_UUID_STR 37
|
||||
|
||||
int bt_uuid_to_string(const bt_uuid_t *uuid, char *str, size_t n);
|
||||
int bt_string_to_uuid(bt_uuid_t *uuid, const char *string);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BLUETOOTH_UUID_H */
|
||||
2149
external/cache/sources/hcitools/monitor/bt.h
vendored
Normal file
2149
external/cache/sources/hcitools/monitor/bt.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
423
external/cache/sources/hcitools/monitor/btsnoop.c
vendored
Normal file
423
external/cache/sources/hcitools/monitor/btsnoop.c
vendored
Normal file
@@ -0,0 +1,423 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2011-2012 Intel Corporation
|
||||
* Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/hci.h>
|
||||
|
||||
#include "btsnoop.h"
|
||||
|
||||
struct btsnoop_hdr {
|
||||
uint8_t id[8]; /* Identification Pattern */
|
||||
uint32_t version; /* Version Number = 1 */
|
||||
uint32_t type; /* Datalink Type */
|
||||
} __attribute__ ((packed));
|
||||
#define BTSNOOP_HDR_SIZE (sizeof(struct btsnoop_hdr))
|
||||
|
||||
struct btsnoop_pkt {
|
||||
uint32_t size; /* Original Length */
|
||||
uint32_t len; /* Included Length */
|
||||
uint32_t flags; /* Packet Flags */
|
||||
uint32_t drops; /* Cumulative Drops */
|
||||
uint64_t ts; /* Timestamp microseconds */
|
||||
uint8_t data[0]; /* Packet Data */
|
||||
} __attribute__ ((packed));
|
||||
#define BTSNOOP_PKT_SIZE (sizeof(struct btsnoop_pkt))
|
||||
|
||||
static const uint8_t btsnoop_id[] = { 0x62, 0x74, 0x73, 0x6e,
|
||||
0x6f, 0x6f, 0x70, 0x00 };
|
||||
|
||||
static const uint32_t btsnoop_version = 1;
|
||||
static uint32_t btsnoop_type = 0;
|
||||
|
||||
static int btsnoop_fd = -1;
|
||||
static uint16_t btsnoop_index = 0xffff;
|
||||
|
||||
void btsnoop_create(const char *path, uint32_t type)
|
||||
{
|
||||
struct btsnoop_hdr hdr;
|
||||
ssize_t written;
|
||||
|
||||
if (btsnoop_fd >= 0)
|
||||
return;
|
||||
|
||||
btsnoop_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
if (btsnoop_fd < 0)
|
||||
return;
|
||||
|
||||
btsnoop_type = type;
|
||||
|
||||
memcpy(hdr.id, btsnoop_id, sizeof(btsnoop_id));
|
||||
hdr.version = htonl(btsnoop_version);
|
||||
hdr.type = htonl(btsnoop_type);
|
||||
|
||||
written = write(btsnoop_fd, &hdr, BTSNOOP_HDR_SIZE);
|
||||
if (written < 0) {
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void btsnoop_write(struct timeval *tv, uint32_t flags,
|
||||
const void *data, uint16_t size)
|
||||
{
|
||||
struct btsnoop_pkt pkt;
|
||||
uint64_t ts;
|
||||
ssize_t written;
|
||||
|
||||
ts = (tv->tv_sec - 946684800ll) * 1000000ll + tv->tv_usec;
|
||||
|
||||
pkt.size = htonl(size);
|
||||
pkt.len = htonl(size);
|
||||
pkt.flags = htonl(flags);
|
||||
pkt.drops = htonl(0);
|
||||
pkt.ts = hton64(ts + 0x00E03AB44A676000ll);
|
||||
|
||||
written = write(btsnoop_fd, &pkt, BTSNOOP_PKT_SIZE);
|
||||
if (written < 0)
|
||||
return;
|
||||
|
||||
if (data && size > 0) {
|
||||
written = write(btsnoop_fd, data, size);
|
||||
if (written < 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t get_flags_from_opcode(uint16_t opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case BTSNOOP_OPCODE_NEW_INDEX:
|
||||
case BTSNOOP_OPCODE_DEL_INDEX:
|
||||
break;
|
||||
case BTSNOOP_OPCODE_COMMAND_PKT:
|
||||
return 0x02;
|
||||
case BTSNOOP_OPCODE_EVENT_PKT:
|
||||
return 0x03;
|
||||
case BTSNOOP_OPCODE_ACL_TX_PKT:
|
||||
return 0x00;
|
||||
case BTSNOOP_OPCODE_ACL_RX_PKT:
|
||||
return 0x01;
|
||||
case BTSNOOP_OPCODE_SCO_TX_PKT:
|
||||
case BTSNOOP_OPCODE_SCO_RX_PKT:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
void btsnoop_write_hci(struct timeval *tv, uint16_t index, uint16_t opcode,
|
||||
const void *data, uint16_t size)
|
||||
{
|
||||
uint32_t flags;
|
||||
|
||||
if (!tv)
|
||||
return;
|
||||
|
||||
if (btsnoop_fd < 0)
|
||||
return;
|
||||
|
||||
switch (btsnoop_type) {
|
||||
case BTSNOOP_TYPE_HCI:
|
||||
if (btsnoop_index == 0xffff)
|
||||
btsnoop_index = index;
|
||||
|
||||
if (index != btsnoop_index)
|
||||
return;
|
||||
|
||||
flags = get_flags_from_opcode(opcode);
|
||||
if (flags == 0xff)
|
||||
return;
|
||||
break;
|
||||
|
||||
case BTSNOOP_TYPE_EXTENDED_HCI:
|
||||
flags = (index << 16) | opcode;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
btsnoop_write(tv, flags, data, size);
|
||||
}
|
||||
|
||||
void btsnoop_write_phy(struct timeval *tv, uint16_t frequency,
|
||||
const void *data, uint16_t size)
|
||||
{
|
||||
uint32_t flags;
|
||||
|
||||
if (!tv)
|
||||
return;
|
||||
|
||||
if (btsnoop_fd < 0)
|
||||
return;
|
||||
|
||||
switch (btsnoop_type) {
|
||||
case BTSNOOP_TYPE_EXTENDED_PHY:
|
||||
flags = (1 << 16) | frequency;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
btsnoop_write(tv, flags, data, size);
|
||||
}
|
||||
|
||||
int btsnoop_open(const char *path, uint32_t *type)
|
||||
{
|
||||
struct btsnoop_hdr hdr;
|
||||
ssize_t len;
|
||||
|
||||
if (btsnoop_fd >= 0) {
|
||||
fprintf(stderr, "Too many open files\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
btsnoop_fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||
if (btsnoop_fd < 0) {
|
||||
perror("Failed to open file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = read(btsnoop_fd, &hdr, BTSNOOP_HDR_SIZE);
|
||||
if (len < 0 || len != BTSNOOP_HDR_SIZE) {
|
||||
perror("Failed to read header");
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (memcmp(hdr.id, btsnoop_id, sizeof(btsnoop_id))) {
|
||||
fprintf(stderr, "Invalid btsnoop header\n");
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ntohl(hdr.version) != btsnoop_version) {
|
||||
fprintf(stderr, "Invalid btsnoop version\n");
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
btsnoop_type = ntohl(hdr.type);
|
||||
|
||||
if (type)
|
||||
*type = btsnoop_type;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint16_t get_opcode_from_flags(uint8_t type, uint32_t flags)
|
||||
{
|
||||
switch (type) {
|
||||
case HCI_COMMAND_PKT:
|
||||
return BTSNOOP_OPCODE_COMMAND_PKT;
|
||||
case HCI_ACLDATA_PKT:
|
||||
if (flags & 0x01)
|
||||
return BTSNOOP_OPCODE_ACL_RX_PKT;
|
||||
else
|
||||
return BTSNOOP_OPCODE_ACL_TX_PKT;
|
||||
case HCI_SCODATA_PKT:
|
||||
if (flags & 0x01)
|
||||
return BTSNOOP_OPCODE_SCO_RX_PKT;
|
||||
else
|
||||
return BTSNOOP_OPCODE_SCO_TX_PKT;
|
||||
case HCI_EVENT_PKT:
|
||||
return BTSNOOP_OPCODE_EVENT_PKT;
|
||||
case 0xff:
|
||||
if (flags & 0x02) {
|
||||
if (flags & 0x01)
|
||||
return BTSNOOP_OPCODE_EVENT_PKT;
|
||||
else
|
||||
return BTSNOOP_OPCODE_COMMAND_PKT;
|
||||
} else {
|
||||
if (flags & 0x01)
|
||||
return BTSNOOP_OPCODE_ACL_RX_PKT;
|
||||
else
|
||||
return BTSNOOP_OPCODE_ACL_TX_PKT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
int btsnoop_read_hci(struct timeval *tv, uint16_t *index, uint16_t *opcode,
|
||||
void *data, uint16_t *size)
|
||||
{
|
||||
struct btsnoop_pkt pkt;
|
||||
uint32_t toread, flags;
|
||||
uint64_t ts;
|
||||
uint8_t pkt_type;
|
||||
ssize_t len;
|
||||
|
||||
if (btsnoop_fd < 0)
|
||||
return -1;
|
||||
|
||||
len = read(btsnoop_fd, &pkt, BTSNOOP_PKT_SIZE);
|
||||
if (len == 0)
|
||||
return -1;
|
||||
|
||||
if (len < 0 || len != BTSNOOP_PKT_SIZE) {
|
||||
perror("Failed to read packet");
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
toread = ntohl(pkt.size);
|
||||
flags = ntohl(pkt.flags);
|
||||
|
||||
ts = ntoh64(pkt.ts) - 0x00E03AB44A676000ll;
|
||||
tv->tv_sec = (ts / 1000000ll) + 946684800ll;
|
||||
tv->tv_usec = ts % 1000000ll;
|
||||
|
||||
switch (btsnoop_type) {
|
||||
case BTSNOOP_TYPE_HCI:
|
||||
*index = 0;
|
||||
*opcode = get_opcode_from_flags(0xff, flags);
|
||||
break;
|
||||
|
||||
case BTSNOOP_TYPE_UART:
|
||||
len = read(btsnoop_fd, &pkt_type, 1);
|
||||
if (len < 0) {
|
||||
perror("Failed to read packet type");
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
toread--;
|
||||
|
||||
*index = 0;
|
||||
*opcode = get_opcode_from_flags(pkt_type, flags);
|
||||
break;
|
||||
|
||||
case BTSNOOP_TYPE_EXTENDED_HCI:
|
||||
*index = flags >> 16;
|
||||
*opcode = flags & 0xffff;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unknown packet type\n");
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = read(btsnoop_fd, data, toread);
|
||||
if (len < 0) {
|
||||
perror("Failed to read data");
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*size = toread;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int btsnoop_read_phy(struct timeval *tv, uint16_t *frequency,
|
||||
void *data, uint16_t *size)
|
||||
{
|
||||
struct btsnoop_pkt pkt;
|
||||
uint32_t toread, flags;
|
||||
uint64_t ts;
|
||||
ssize_t len;
|
||||
|
||||
if (btsnoop_fd < 0)
|
||||
return -1;
|
||||
|
||||
len = read(btsnoop_fd, &pkt, BTSNOOP_PKT_SIZE);
|
||||
if (len == 0)
|
||||
return -1;
|
||||
|
||||
if (len < 0 || len != BTSNOOP_PKT_SIZE) {
|
||||
perror("Failed to read packet");
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
toread = ntohl(pkt.size);
|
||||
flags = ntohl(pkt.flags);
|
||||
|
||||
ts = ntoh64(pkt.ts) - 0x00E03AB44A676000ll;
|
||||
tv->tv_sec = (ts / 1000000ll) + 946684800ll;
|
||||
tv->tv_usec = ts % 1000000ll;
|
||||
|
||||
switch (btsnoop_type) {
|
||||
case BTSNOOP_TYPE_EXTENDED_PHY:
|
||||
if ((flags >> 16) != 1)
|
||||
break;
|
||||
*frequency = flags & 0xffff;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unknown packet type\n");
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = read(btsnoop_fd, data, toread);
|
||||
if (len < 0) {
|
||||
perror("Failed to read data");
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*size = toread;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void btsnoop_close(void)
|
||||
{
|
||||
if (btsnoop_fd < 0)
|
||||
return;
|
||||
|
||||
close(btsnoop_fd);
|
||||
btsnoop_fd = -1;
|
||||
|
||||
btsnoop_index = 0xffff;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user