编译 tinyB 蓝牙库

编译 tinyB 蓝牙库

我正在尝试编译来自英特尔的 TinyB 库。我找到了这个脚本: https://gist.github.com/StevenRudenko/b6c032c3c1fdfb5c641ff95883e6cd02

https://github.com/intel-iot-devkit/tinyb

https://mcuoneclipse.com/2016/12/19/tutorial-ble-pairing-the-raspberry-pi-3-model-b-with-hexiwear/


# Update BlueZ
sudo apt-get update
sudo apt-get install git build-essential autoconf cmake libtool libglib2.0 libdbus-1-dev libudev-dev libical-dev libreadline-dev
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.39.tar.xz
tar xvf bluez-5.39.tar.xz 
cd bluez-5.39/

aclocal 
autoheader 
automake --force-missing --add-missing 
autoconf
./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-experimental --with-systemdsystemunitdir=/lib/systemd/system --with-systemduserunitdir=/usr/lib/systemd

./configure --prefix=/usr \
            --mandir=/usr/share/man \
            --sysconfdir=/etc \
            --localstatedir=/var \
            --enable-experimental \
            --enable-maintainer-mode

make
sudo make install
sudo cp attrib/gatttool /usr/local/bin
sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/' /lib/systemd/system/bluetooth.service
sudo ln -s /lib/firmware /etc/firmware
sudo systemctl enable bluetooth
sudo systemctl daemon-reload

sudo apt-mark hold bluez



sudo nano /lib/systemd/system/bluetooth.service
  ExecStart=/usr/local/libexec/bluetooth/bluetoothd --experimental  
sudo systemctl daemon-reload
sudo systemctl restart bluetooth

bluetoothctl
  power on
  agent on
  scan on
  scan off
  info 00:34:40:0A:00:4E
  pair 00:34:40:0A:00:4E
  devices
  list-attributes 00:34:40:0A:00:4E
  read
  atribute-info
  select-attribute /org/bluez/hci0/dev_00_32_40_08_00_12/service002e/char002f
  write 0x3 0x4 0x10 0x20 0x30 0x40
  disconnect 00:32:40:08:00:12
  quit

sudo apt-get install cmake build-essentials check-install libglib2.0-dev doxygen

git clone https://github.com/intel-iot-devkit/tinyb.git

mkdir build
cd build
cmake -DBUILDJAVA=ON ..
make
sudo checkinstall install
// to remove dpkg -r build

java -Djava.library.path=/usr/lib/jni -cp /usr/share/java/RXTXcomm.jar -jar your.jar

但这有点不相关。你能帮我解决这个问题吗?

首先:

此脚本希望使用 -enable-experimental 标志编译 bluez-5.39。现在真的有必要吗?我可以只下载最新版本的库吗?如果不行,那么在编译 BlueZ 时,会出现许多警告,使用 -Werror 标志完成编译。此外,“SIOCGSTAMP”函数存在问题,我不知道这里应该使用哪个函数:“SIOCGSTAMP_NEW”还是“SIOCGSTAMP_OLD”?

第二:sudo systemctl enable bluetooth不起作用,因为Unit file /etc/systemd/system/bluetooth.service is masked.我应该揭露它吗?

第三:这个命令到底起什么作用:

sudo nano /lib/systemd/system/bluetooth.service
  ExecStart=/usr/local/libexec/bluetooth/bluetoothd --experimental  

为什么我需要它?

我没有进一步研究脚本,因为第三部分对我来说似乎毫无意义。为什么在文件开头重复 ExecStart=/usr/local/libexec/bluetooth/bluetoothd --experimental?希望对您有所帮助。

也许某些存储库已经有可运行的已编译 tinyB 库?

答案1

好的,我做到了。我使用了 SIOCGSTAMP_OLD,忽略奇怪的版本:“

sudo nano /lib/systemd/system/bluetooth.service
  ExecStart=/usr/local/libexec/bluetooth/bluetoothd --experimental 

“,(这就足够了):

sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/' /lib/systemd/system/bluetooth.service

忽略部分:”

bluetoothctl
  power on
  agent on
  scan on
  scan off
  info 00:34:40:0A:00:4E
  pair 00:34:40:0A:00:4E
  devices
  list-attributes 00:34:40:0A:00:4E
  read
  atribute-info
  select-attribute /org/bluez/hci0/dev_00_32_40_08_00_12/service002e/char002f
  write 0x3 0x4 0x10 0x20 0x30 0x40
  disconnect 00:32:40:08:00:12
  quit

“并像这样编译:

export PATH=/usr/lib/jvm/java-8-openjdk/bin/:$PATH
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk/
mkdir build
cd build
cmake -DBUILDJAVA=ON -DCMAKE_INSTALL_PREFIX=/usr ..
make install

https://github.com/intel-iot-devkit/tinyb/issues/27

TinyB 现在对我有用,包括 c++ 和 Java 版本。祝你好运。

相关内容