From nobody Thu Feb 8 19:09:53 2024 X-Original-To: freebsd-bluetooth@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TW64M43CLz5BD9q for ; Thu, 8 Feb 2024 19:09:55 +0000 (UTC) (envelope-from gergely.czuczy@harmless.hu) Received: from marvin.harmless.hu (marvin.harmless.hu [195.56.55.204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4TW64L2sYPz4mBy for ; Thu, 8 Feb 2024 19:09:54 +0000 (UTC) (envelope-from gergely.czuczy@harmless.hu) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=harmless.hu header.s=marvin header.b=d3kxOHrR; dmarc=pass (policy=quarantine) header.from=harmless.hu; spf=pass (mx1.freebsd.org: domain of gergely.czuczy@harmless.hu designates 195.56.55.204 as permitted sender) smtp.mailfrom=gergely.czuczy@harmless.hu DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=harmless.hu ; s=marvin; h=Content-Transfer-Encoding:Content-Type:Subject:From:To: MIME-Version:Date:Message-ID:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CPGnUGre7NR9JEhZcjb2Jld06v4tFCT/nwe4m6VyLHs=; b=d3kxOHrROt0vdTPcKXMAxfeHYb 1or6fq7DxZFf/WDtAaNiPpLwo09Ieif0K0WBhwTZsLC6RDFO6vf9YPAiTBi7yzWYF9rsjFYrQLs0q HxbGQX5KvyQsvthYDuit738GZJ9xLAiw5tYl3FAXGi/orlm3mXWJLkT7OuEzm9Q/TYmk=; Received: from 87-97-12-22.pool.digikabel.hu ([87.97.12.22] helo=[10.219.18.1]) by marvin.harmless.hu with esmtpsa (TLS1.3) tls TLS_AES_128_GCM_SHA256 (envelope-from ) id 1rY9mS-00014l-29 for freebsd-bluetooth@FreeBSD.org; Thu, 08 Feb 2024 19:09:52 +0000 Message-ID: <6bf90a8f-5ccb-4ea9-b509-97acfe0a74ac@harmless.hu> Date: Thu, 8 Feb 2024 20:09:53 +0100 List-Id: Using Bluetooth in FreeBSD environments List-Archive: https://lists.freebsd.org/archives/freebsd-bluetooth List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bluetooth@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: freebsd-bluetooth@FreeBSD.org Content-Language: en-US From: Gergely Czuczy Subject: Help with Bluetooth LE stack Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-HD-Spam-Score: -0.1 X-HD-Spam-Report: Action: no action Symbol: ARC_NA(0.00) Symbol: RCVD_VIA_SMTP_AUTH(0.00) Symbol: XM_UA_NO_VERSION(0.01) Symbol: FROM_HAS_DN(0.00) Symbol: TO_MATCH_ENVRCPT_ALL(0.00) Symbol: MIME_GOOD(-0.10) Symbol: TO_DN_NONE(0.00) Symbol: RCPT_COUNT_ONE(0.00) Symbol: NEURAL_HAM(-0.00) Symbol: RCVD_COUNT_ONE(0.00) Symbol: FROM_EQ_ENVFROM(0.00) Symbol: MIME_TRACE(0.00) Symbol: ASN(0.00) Symbol: RCVD_TLS_ALL(0.00) Symbol: MID_RHS_MATCH_FROM(0.00) Message-ID: 6bf90a8f-5ccb-4ea9-b509-97acfe0a74ac@harmless.hu X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.89 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; DMARC_POLICY_ALLOW(-0.50)[harmless.hu,quarantine]; R_SPF_ALLOW(-0.20)[+mx]; R_DKIM_ALLOW(-0.20)[harmless.hu:s=marvin]; MIME_GOOD(-0.10)[text/plain]; ONCE_RECEIVED(0.10)[]; XM_UA_NO_VERSION(0.01)[]; RCPT_COUNT_ONE(0.00)[1]; ASN(0.00)[asn:5588, ipnet:195.56.0.0/16, country:CZ]; RCVD_TLS_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_ONE(0.00)[1]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; MLMMJ_DEST(0.00)[freebsd-bluetooth@FreeBSD.org]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[harmless.hu:+] X-Rspamd-Queue-Id: 4TW64L2sYPz4mBy 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