[haiku-commits] r36729 - in haiku/trunk: headers/os/bluetooth headers/os/bluetooth/HCI src/kits/bluetooth src/servers/bluetooth

  • From: oliver.ruiz.dorantes@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 7 May 2010 20:25:09 +0200 (CEST)

Author: oruizdorantes
Date: 2010-05-07 20:25:09 +0200 (Fri, 07 May 2010)
New Revision: 36729
Changeset: http://dev.haiku-os.org/changeset/36729/haiku

Modified:
   haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h
   haiku/trunk/headers/os/bluetooth/LocalDevice.h
   haiku/trunk/src/kits/bluetooth/LocalDevice.cpp
   haiku/trunk/src/servers/bluetooth/LocalDeviceImpl.cpp
Log:
- Add possibility yo set a custom friendly name to our device. Which will be 
seen by remotes devices at discovery


Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h
===================================================================
--- haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h        2010-05-07 
18:13:14 UTC (rev 36728)
+++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h        2010-05-07 
18:25:09 UTC (rev 36729)
@@ -96,6 +96,10 @@
 
 
        #define OCF_WRITE_LOCAL_NAME            0x0013
+       struct hci_write_local_name {
+               char            local_name[HCI_DEVICE_NAME_SIZE];
+       } __attribute__ ((packed));
+
        #define OCF_READ_LOCAL_NAME                     0x0014
        struct hci_rp_read_local_name {
                uint8           status;

Modified: haiku/trunk/headers/os/bluetooth/LocalDevice.h
===================================================================
--- haiku/trunk/headers/os/bluetooth/LocalDevice.h      2010-05-07 18:13:14 UTC 
(rev 36728)
+++ haiku/trunk/headers/os/bluetooth/LocalDevice.h      2010-05-07 18:25:09 UTC 
(rev 36729)
@@ -33,6 +33,7 @@
 
                        DiscoveryAgent* GetDiscoveryAgent();
                        BString                 GetFriendlyName();
+                       status_t                SetFriendlyName(BString& name);
                        DeviceClass             GetDeviceClass();
                        status_t                SetDeviceClass(DeviceClass 
deviceClass);
 

Modified: haiku/trunk/src/kits/bluetooth/LocalDevice.cpp
===================================================================
--- haiku/trunk/src/kits/bluetooth/LocalDevice.cpp      2010-05-07 18:13:14 UTC 
(rev 36728)
+++ haiku/trunk/src/kits/bluetooth/LocalDevice.cpp      2010-05-07 18:25:09 UTC 
(rev 36729)
@@ -273,6 +273,36 @@
 }
 
 
+status_t
+LocalDevice::SetFriendlyName(BString& name)
+{
+       int8 btStatus = BT_ERROR;
+
+       if (fMessenger == NULL)
+               return btStatus;
+
+       BluetoothCommand<typed_command(hci_write_local_name)>
+               writeName(OGF_CONTROL_BASEBAND, OCF_WRITE_LOCAL_NAME);
+
+       strcpy(writeName->local_name, name.String());
+
+       BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST);
+       BMessage reply;
+
+       request.AddInt32("hci_id", fHid);
+       request.AddData("raw command", B_ANY_TYPE,
+               writeName.Data(), writeName.Size());
+       request.AddInt16("eventExpected",  HCI_EVENT_CMD_COMPLETE);
+       request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND,
+               OCF_WRITE_LOCAL_NAME));
+
+       if (fMessenger->SendMessage(&request, &reply) == B_OK)
+               reply.FindInt8("status", &btStatus);
+
+       return btStatus;
+}
+
+
 DeviceClass
 LocalDevice::GetDeviceClass()
 {
@@ -521,6 +551,11 @@
        _ReadTimeouts();
        _ReadLinkKeys();
 
+       // Uncomment this if you want your device to have a nicer default name
+       // BString name("HaikuBluetooth");
+       // SetFriendlyName(name);
+
+
        uint32 value;
 
        // HARDCODE -> move this to addons

Modified: haiku/trunk/src/servers/bluetooth/LocalDeviceImpl.cpp
===================================================================
--- haiku/trunk/src/servers/bluetooth/LocalDeviceImpl.cpp       2010-05-07 
18:13:14 UTC (rev 36728)
+++ haiku/trunk/src/servers/bluetooth/LocalDeviceImpl.cpp       2010-05-07 
18:25:09 UTC (rev 36729)
@@ -649,6 +649,7 @@
                case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_PG_TIMEOUT):
                case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_CA_TIMEOUT):
                case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_AUTH_ENABLE):
+               case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_LOCAL_NAME):
                case PACK_OPCODE(OGF_VENDOR_CMD, OCF_WRITE_BCM2035_BDADDR):
                {
                        reply.AddInt8("status", *(uint8*)(event + 1));


Other related posts:

  • » [haiku-commits] r36729 - in haiku/trunk: headers/os/bluetooth headers/os/bluetooth/HCI src/kits/bluetooth src/servers/bluetooth - oliver . ruiz . dorantes