How do I used bluetoothctl's gatt menu to make an RFCOMMM discoverable?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Hi All,

I have a very simple application that I've spent way too much time on.
I have a Raspberry pi 5, I've created a bluetooth serial port using rfcomm.
Now I want this new serial port to be announced by the rpi5.  Conceptually
simple.  I've spent time going through the bluetooth spec, and reading the
serial port profile spec.  It took some time to track things down.  I can't
say I understood everything, but I enjoyed it.

The bluetoothctl gatt menu looks like it has exactly the capability I want.
But I've had a very hard time understanding how to use it.  I haven't been
able to find good explanations or many examples of how to use it.

(1) Can anyone point me to examples and documentation of bluetoothctl's gatt?
Maybe I just haven't tried the right search terms and there is a trove sitting
out there.

I tried looking the bluez user mailing list.
As referenced from here
But I'm getting server not found.
The list at works.

I tried reading the sourcecode for bluez/client.  But It's hopeless. I learned
a few things, but the effort is too high to find what I need.

I found blues/client/scripts.  That was helpful, but there aren't enough
examples to answer the questions I have.

I've found a number of docs like this:
but they don't go into how to create gatt entries.

>From the serial port profile doc,,
I want to declare the following information.

ServicClass0 UUID  0x1101 == SerialPort
Protocol0 0x100 == L2CAP
Protocol1 0x3 == RFCOMMM
ProtocolSpecificParameter0 1 == channel #
ServiceName(0x0000) String "MySerialPort"

>From experimenting, I gather the gatt menu uses a nested strategy.
- Start with register-service
- continue by adding a characteristic with register-characteristic.
  You can't add a characteristic unless you have a service.
- If the characteristic is a list, add entries to it using
  register-descriptor.  Again, you can't add a descriptor unless
  you're working on a characteristic.

I tried
    #Version 5.66

    register-service 0x1101 #(Serial port profile)
    #It asks it if this a primary service, I answer yes.

    # Here I'm trying to start the service class ID list.
    register-chacteristic 0x0001 read
    #Ooops, it is showing SDP.
    # [NEW] Characteristic (Handle 0x0000)
    #   /org/bluez/app/service0/chrc0
    #   0x0001
    #   SDP
    # And it's asking for a value.  What is the value for?
    # (2) What I'm I misunderstanding here?

    # Now I want to add a descriptor to the list.
    register-descriptor 0x1101 read
    # [NEW] Descriptor (Handle 0x0000)
    #    /org/bluez/app/service0/chrc0/desc0
    #    0x1101
    #    Serial Port
    # [/org/bluez/app/service0/chrc0/desc0] Enter value:
    # (3) Do I want to specify 0x1101 again, it was already
    #     used in register service?
    # (4) And again, what is the value it is asking for.

    # I would then go on to add other characteristics, but there
    # is no point in continuing without understing better.

    # If this had all worked, I would do
    # And the service would be available for other bluetooth
    # devices to see.

(5)  I also don't understand when to use acquire-write, release-write
     and write.  Pointers to docs?

(6) Are there any other steps I have to do?  Do you see other
    glaring misconnections I have?

I think bluez is quite an amazing project.


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux