上一个问题如何从Bluez/Linux上的GATT服务器获取断开连接事件解决了Bluez堆栈的断开连接事件.
然而,由于断开检测是在GATT层,因此在GATT层检测到断开需要一段时间.对于许多应用来说,延迟断开检测将是一个问题.
Bluez提供HCI API以在BLE层连接/断开连接:
int hci_le_create_conn();
int hci_disconnect();
Run Code Online (Sandbox Code Playgroud)
应用程序如何捕获HCI事件,指示由hci_le_create_conn()创建的BLE连接现在已断开连接.
虽然看起来很简单 - 我没有使用正则表达式的perl代码的一个很好的例子,它提取浮出一个(任何)字符串,如下所示:
my $str = "process.pl: process workflow took 2.41153311729431 seconds.";
my $processTime = parseFloatFromString($str);
print "$processTime\n";
and gives 2.41
Run Code Online (Sandbox Code Playgroud)
我想提取一个不太精确的值 - 例如2个小数点.
谢谢.