linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Registering a profile
@ 2018-09-28 22:38 Neil Benn
  2018-10-01 22:29 ` Neil Benn
  0 siblings, 1 reply; 15+ messages in thread
From: Neil Benn @ 2018-09-28 22:38 UTC (permalink / raw)
  To: linux-bluetooth

Hello,

  I'm trying to setup a RPi0 operating a Bluetooth device; I've setup
the device using the following call:
---
    #configure the bluetooth hardware device
    def init_bt_device(self):

        print("Configuring for name " + BTKbDevice.MY_DEV_NAME)

        #set the device class to a barcode scanner and set the name
        os.system("hciconfig hcio class 0x002560")
        os.system("hciconfig hcio name " + BTKbDevice.MY_DEV_NAME)

        #make the device discoverable
        os.system("hciconfig hcio piscan")

  Then after that I attempt to setup the profile using the following code:
---
    #set up a bluez profile to advertise device capabilities from a
loaded service record
    def init_bluez_profile(self):

        print("Configuring Bluez Profile")

        #setup profile options
        service_record=self.read_sdp_service_record()

        opts = {
            "ServiceRecord":service_record,
            "Role":"server",
            "RequireAuthentication":False,
            "RequireAuthorization":False,
            "Name":BTKbDevice.MY_DEV_NAME,
            "AutoConnect":True
        }

        #retrieve a proxy for the bluez profile interface
        bus = dbus.SystemBus()
        self.manager =
dbus.Interface(bus.get_object("org.bluez","/org/bluez"),
"org.bluez.ProfileManager1")
        self.profile = BTKbBluezProfile(bus, BTKbDevice.PROFILE_DBUS_PATH)
        self.manager.RegisterProfile(BTKbDevice.PROFILE_DBUS_PATH,
BTKbDevice.UUID, opts)
        print("Profile registered ")
---
  The sdp record is available from https://textuploader.com/dv8xt.
The profile in question is basically the same as the one defined in
the test-profile as shown below:
---
class BTKbBluezProfile(dbus.service.Object):
    fd = -1

    @dbus.service.method("org.bluez.Profile1",
                                    in_signature="", out_signature="")
    def Release(self):
            print("Release")
            mainloop.quit()

    @dbus.service.method("org.bluez.Profile1",
                                    in_signature="", out_signature="")
    def Cancel(self):
            print("Cancel")

    @dbus.service.method("org.bluez.Profile1", in_signature="oha{sv}",
out_signature="")
    def NewConnection(self, path, fd, properties):
            self.fd = fd.take()
            print("NewConnection(%s, %d)" % (path, self.fd))
            for key in properties.keys():
                    print ('key ' + key + ' value ' + properties[key])
                    if key == "Version" or key == "Features":
                            print("  %s = 0x%04x" % (key, properties[key]))
                    else:
                            print("  %s = %s" % (key, properties[key]))

    @dbus.service.method("org.bluez.Profile1", in_signature="o",
out_signature="")
    def RequestDisconnection(self, path):
            print("RequestDisconnection(%s)" % (path))

            if (self.fd > 0):
                    os.close(self.fd)
                    self.fd = -1

    def __init__(self, bus, path):
            dbus.service.Object.__init__(self, bus, path)
---
  However it seems like the profile is not being registered, or least
the methods in the profile are not being called.  I'm sorry to ask
such a basic question but can someone please point me in the right
direction as to why the profile is either not being registered or the
callbacks on the profile are not being called.

  Thank you very much for reading this far and any and all help is
most appreciated!

Cheers,

Neil

-- 

Neil Benn MSc
Ziath Ltd
Phone: +44 (0) 1223 855021
http://www.ziath.com

Please consider the environment before printing this email.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-10-03 18:45 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-28 22:38 Registering a profile Neil Benn
2018-10-01 22:29 ` Neil Benn
2018-10-02  8:37   ` Luiz Augusto von Dentz
2018-10-02 10:39     ` Neil Benn
2018-10-02 11:27       ` Luiz Augusto von Dentz
2018-10-02 12:28         ` Neil Benn
2018-10-02 12:47           ` Luiz Augusto von Dentz
2018-10-02 14:57             ` Barry Byford
2018-10-02 18:31               ` Neil Benn
2018-10-03 10:35               ` Luiz Augusto von Dentz
2018-10-03 13:49                 ` Neil Benn
2018-10-03 14:03                   ` Luiz Augusto von Dentz
2018-10-03 15:28                     ` Neil Benn
2018-10-03 18:08                       ` Luiz Augusto von Dentz
2018-10-03 18:45                         ` Neil Benn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).