- Add possibility yo set a custom friendly name to our device. Which will be seen by remotes devices at discovery

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36729 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2010-05-07 18:25:09 +00:00
parent 9cafc5db2b
commit 125183f9e5
4 changed files with 41 additions and 0 deletions
+4
View File
@@ -96,6 +96,10 @@ struct hci_command_header {
#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;
+1
View File
@@ -33,6 +33,7 @@ public:
DiscoveryAgent* GetDiscoveryAgent();
BString GetFriendlyName();
status_t SetFriendlyName(BString& name);
DeviceClass GetDeviceClass();
status_t SetDeviceClass(DeviceClass deviceClass);
+35
View File
@@ -273,6 +273,36 @@ LocalDevice::GetFriendlyName()
}
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 @@ LocalDevice::LocalDevice(hci_id hid)
_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
@@ -649,6 +649,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event,
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));