lambdaisland / lambdaisland/dbus-client

java.nio.BufferUnderflowException when trying to set Bluetooth SPP profile

Open
#1 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
10
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Hi!

This code gets the buffer underflow exception.

(defn start-fake-hardware []
  (let [client (dbus/init-client! (dbus/system-sock)
                                  (fn [v]
                                    (println "DBus Reply: " v)))
        result (dbus/write-message
                 client
                 {:type    :method-call
                  :headers {:path "/org/bluez"
                            :member "RegisterProfile"
                            :interface "org.bluez.ProfileManager1"
                            :destination "org.bluez"
                            :signature "osa{sv}"}
                  :body    ["/org/bluez/spp"                       ; Profile path
                            "00001101-0000-1000-8000-00805f9b34fb" ; SPP UUID
                            {"Name"    "Serial Port"
                             "Channel" 1}]})]
    (prn @result)))

One thing to note is that the "Channel" value that is sent should be a variant containing a uint16, and it seems like the code will encode it wrong. I don't know if that's the problem.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied start-fake-hardware example and trace dbus/write-message while comparing the osa{sv} signature with the body, especially the Channel value. Verify how variants and uint16 values are encoded; done means the message no longer raises BufferUnderflowException and the Bluetooth SPP profile registration succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.