- 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:
@@ -96,6 +96,10 @@ struct hci_command_header {
|
|||||||
|
|
||||||
|
|
||||||
#define OCF_WRITE_LOCAL_NAME 0x0013
|
#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
|
#define OCF_READ_LOCAL_NAME 0x0014
|
||||||
struct hci_rp_read_local_name {
|
struct hci_rp_read_local_name {
|
||||||
uint8 status;
|
uint8 status;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public:
|
|||||||
|
|
||||||
DiscoveryAgent* GetDiscoveryAgent();
|
DiscoveryAgent* GetDiscoveryAgent();
|
||||||
BString GetFriendlyName();
|
BString GetFriendlyName();
|
||||||
|
status_t SetFriendlyName(BString& name);
|
||||||
DeviceClass GetDeviceClass();
|
DeviceClass GetDeviceClass();
|
||||||
status_t SetDeviceClass(DeviceClass deviceClass);
|
status_t SetDeviceClass(DeviceClass deviceClass);
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
DeviceClass
|
||||||
LocalDevice::GetDeviceClass()
|
LocalDevice::GetDeviceClass()
|
||||||
{
|
{
|
||||||
@@ -521,6 +551,11 @@ LocalDevice::LocalDevice(hci_id hid)
|
|||||||
_ReadTimeouts();
|
_ReadTimeouts();
|
||||||
_ReadLinkKeys();
|
_ReadLinkKeys();
|
||||||
|
|
||||||
|
// Uncomment this if you want your device to have a nicer default name
|
||||||
|
// BString name("HaikuBluetooth");
|
||||||
|
// SetFriendlyName(name);
|
||||||
|
|
||||||
|
|
||||||
uint32 value;
|
uint32 value;
|
||||||
|
|
||||||
// HARDCODE -> move this to addons
|
// 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_PG_TIMEOUT):
|
||||||
case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_CA_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_AUTH_ENABLE):
|
||||||
|
case PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_LOCAL_NAME):
|
||||||
case PACK_OPCODE(OGF_VENDOR_CMD, OCF_WRITE_BCM2035_BDADDR):
|
case PACK_OPCODE(OGF_VENDOR_CMD, OCF_WRITE_BCM2035_BDADDR):
|
||||||
{
|
{
|
||||||
reply.AddInt8("status", *(uint8*)(event + 1));
|
reply.AddInt8("status", *(uint8*)(event + 1));
|
||||||
|
|||||||
Reference in New Issue
Block a user