Handling the Local Device Name

Each Bluetooth device has a name for identifying the device to users or applications. This document shows you how to get or set device names.

How to get and set the local device name

The local device name is read and set through the RHostResolver functions GetHostName() and SetHostName() respectively.

Getting the Local Device Name

The following code shows how to get the local name:

  1. Link against the following libraries:

  2. Connect to the socket server

    RSocketServ socketServ;
    TProtocolDesc pInfo;
    _LIT(KL2Cap, "L2CAP");
  3. Create and initialise an RHostResolver

    RHostResolver hr;
  4. Get the local device name

    THostName name;
    TInt ret=hr.GetHostName(name);

Setting the Local Device Name

Setting the device name differs only in the final step, where you will use the RHostResolver::SetHostName() function.

TInt ret=hr.SetHostName(KDeviceName);


THostName is a descriptor buffer of a suitable minimum size.

Where Next?

This tutorial set takes you through all the steps involved in setting up and communicating over a Bluetooth connection.