Date: Thu, 8 Feb 2024 21:57:49 +0100 From: Gergely Czuczy <gergely.czuczy@harmless.hu> To: freebsd-bluetooth@freebsd.org Subject: Re: Help with Bluetooth LE stack Message-ID: <2ceca8ac-2ca0-4c97-b241-dd2ef2843c32@harmless.hu> In-Reply-To: <6bf90a8f-5ccb-4ea9-b509-97acfe0a74ac@harmless.hu> References: <6bf90a8f-5ccb-4ea9-b509-97acfe0a74ac@harmless.hu>
next in thread | previous in thread | raw e-mail | index | archive | help
In the meantime I've noticed some messages from the kernel: ng_hci_process_command_complete: ubt0hci - HCI command failed, OGF=0x8, OCF=0xb, status=0x12 I think it might be originating from here: https://github.com/freebsd/freebsd-src/blob/d5677b0b8b8a1505edeaafab5606c4f890c1a42d/sys/netgraph/bluetooth/hci/ng_hci_cmds.c#L863C11-L863C17 But EINVAL has the value of dec22, and 0x12 points to EXDEV, which does not seem related here. Also, this is not an errno, but a status code. The same calls are succeeding with the example code at [1], and the difference is, i'm using libbluetooth instead of manually implementing the communication over the device. What might be causing this? On 2024. 02. 08. 20:09, Gergely Czuczy wrote: > Hello, > > I would like to ask for a bit of help. I'm absolutely not familiar > with bluetooth, and one of my components for my project is a bluetooth > LE device[1], and I'm having some troubles with the BT stack. > > Initially I've based my code on the FreeBSD-BLE[2] examples, and my > stack worked. However, there was a power outage and the device > restarted, and this example stuff is still getting data, but my stack > is not anymore. What so far I have (and used to work but doesn't > anymore) is at [3]. > > I've tried reading through the manuals and docs, but it's absolutely > blurry. Like NG_HCI(4) tells me to do 3 things during HCI init > (Read_BD_ADDR, Read_Local_Supported_Features, Read_Buffer_Size) but > doesn't exactly tells me how. I'm using the bluetooth(4), and it's > told the bt_* calls return -1 on error, but how do I get the actual > error is nowhere explained. Especially for things like > NGM_HCI_NODE_GET_BDADDR, I don't know what the output data structure > to bt_devreq looks like, and how to get any error codes out, the call > like I do is not touching the output buffer. > > Also, what I couldn't get done using the example code in [2] is to > make this work from userspace, even the example only returns data as > root. > > I'm on FreeBSD 14.0-STABLE arm64 if it matters. > > Could I please get some help on how to work with the BTLE stack properly? > > Best regards, > Gergely > > [1] https://kvurd.com/blog/tilt-hydrometer-ibeacon-data-format/ > [2] https://github.com/takawata/FreeBSD-BLE/tree/master/le_enable > [3] > https://github.com/gczuczy/aegir/blob/fermd/controllers/fermd/Bluetooth.cc > >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2ceca8ac-2ca0-4c97-b241-dd2ef2843c32>