我已经尝试过了(下面的代码可能在int main(/*...*/)中)。
int a = hci_get_route(NULL);
if(a < 0)
{
return 1;
}
int b = hci_open_dev(a);
if(b < 0)
{
return 1;
}
if(hci_write_local_name(b, "abcd", 0) < 0)
{
return 1;
}
return 0;然而..已到达hci_write_local_name,但失败(因此返回1)。
发布于 2021-08-08 18:17:31
好的。显然,在hci.c中,errno被考虑在内(参见https://github.com/Vudentz/BlueZ/blob/master/lib/hci.c#L1112)。
我检查了errno是什么,它是1(即“权限被拒绝”)。
用sudo运行我的应用程序解决了这个问题。
https://stackoverflow.com/questions/68701873
复制相似问题