cd source-code/readline-8.2/ ./configure --prefix=$bluez_output CC=$bluez_cc CXX=$bluez_cxx --host=$bluez_host CFLAGS="-fPIC" make -j8 && make install
CFLAGS=”-fPIC” : 为了后面方便连接静态库
ncurses交叉编译
cd source-code/ncurses-6.4/ ./configure --prefix=$bluez_output CC=$bluez_cc CXX=$bluez_cxx --host=$bluez_host --with-shared make -j8 && make install
–with-shared 默认生成静态库,加这个参数同时生成静态库和动态库
glib-2.46.2编译前准备
在正式编译glib之前需要提前编译依赖库
gettext交叉编译
解决:You must have either have gettext support in your C library, or use the GNU gettext library.
cd source-code/gettext-0.22.5/ ./configure --prefix=$bluez_output CC=$bluez_cc CXX=$bluez_cxx --host=$bluez_host CFLAGS="-fPIC" make -j8 && make install
编译libffi
解决: gclosure.c:28:10: fatal error: ffi.h: No such file or directory
cd source-code/libffi-3.4.5 ./configure --prefix=$bluez_output CC=$bluez_cc CXX=$bluez_cxx --host=$bluez_host CFLAGS="-fPIC" make -j8 && make install
编译zlib
解决:gzlibcompressor.c:26:10: fatal error: zlib.h: No such file or directory
cd source-code/zlib-1.3.1/ ./configure --prefix=$bluez_output
Agent registered uetoothd... [CHG] Controller EB:BF:AD:FC:FD:FE Pairable: yes [bluetooth]# help Menu main: Available commands: ------------------- advertise Advertise Options Submenu monitor Advertisement Monitor Options Submenu scan Scan Options Submenu gatt Generic Attribute Submenu admin Admin Policy Submenu player Media Player Submenu endpoint Media Endpoint Submenu transport Media Transport Submenu list List available controllers show [ctrl] Controller information select <ctrl> Select default controller devices [Paired/Bonded/Trusted/Connected] List available devices, with an optional property as the filter system-alias <name> Set controller alias reset-alias Reset controller alias power <on/off> Set controller power pairable <on/off> Set controller pairable mode discoverable <on/off> Set controller discoverable mode discoverable-timeout [value] Set discoverable timeout agent <on/off/capability> Enable/disable agent with given capability default-agent Set agent as the default one advertise <on/off/type> Enable/disable advertising with given type set-alias <alias> Set device alias scan <on/off/bredr/le> Scan for devices info [dev] Device information pair [dev] Pair with device cancel-pairing [dev] Cancel pairing with device trust [dev] Trust device untrust [dev] Untrust device block [dev] Block device unblock [dev] Unblock device remove <dev> Remove device connect <dev> Connect device disconnect [dev] Disconnect device menu <name> Select submenu version Display version quit Quit program exit Quit program help Display help about this program export Print environment variables [bluetooth]#
// 创建 signalfd sfd = signalfd(-1, &mask, 0); if (sfd == -1) { perror("signalfd"); //此处报错Function not implemented exit(EXIT_FAILURE); }
// 读取信号 while (1) { ssize_t s = read(sfd, &fdsi, sizeof(fdsi)); if (s != sizeof(fdsi)) { perror("read"); exit(EXIT_FAILURE); } if (fdsi.ssi_signo == SIGINT) { printf("Received SIGINT\n"); } }
// 关闭文件描述符 close(sfd);
return0; }
bluetoothctl报错
Failed to start discovery: org.bluez.Error.NotReady
[bluetooth]# scan on Failed to start discovery: org.bluez.Error.NotReady [bluetooth]# power on Changing power on succeeded [CHG] Controller EB:BF:AD:FC:FD:FE Powered: yes
Failed to start discovery: org.bluez.Error.InProgress
[bluetooth]# scan on Failed to start discovery: org.bluez.Error.InProgress