QString QBtLocalDevicePrivate::GetLocalDeviceName()
{
    BTINT32 result = BTSDK_FALSE;
    BTUINT8 devName[BTSDK_DEVNAME_LEN] = {0};
    BTUINT16 nameSize = BTSDK_DEVNAME_LEN;

    result = Btsdk_GetLocalName(devName, &nameSize);

    if(result == BTSDK_OK)
        return QString::fromUtf8((char*)devName);
    else
        return "Unknown";
}
Beispiel #2
0
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
	This function prints information of local device
Arguments:
	void
Return:
	void 
---------------------------------------------------------------------------*/
void Test_Print_Local_Info(void)
{
	int j = 0;
	BTUINT8 szName[BTSDK_DEVNAME_LEN] = {0};
	BTUINT8 szBDAddr[BTSDK_BDADDR_LEN] = {0};
	BTUINT32 ulDevClass = 0;
	BTUINT16 usMode = 0;
	BTUINT16 usLen = BTSDK_DEVNAME_LEN;

	printf("\n");

	/* display the local device name */
	PrintErrorMessage(Btsdk_GetLocalName(szName, &usLen), BTSDK_TRUE);
	printf("Local Name = \"%s\"\n", szName);

	/* display the Bluetooth Address of the local device */
	PrintErrorMessage(Btsdk_GetLocalDeviceAddress(szBDAddr), BTSDK_TRUE);
	printf("BD Addr: ");
	for(j = 5; j > 0; j--)
	{
		printf("%02X:", szBDAddr[j]);
	}
	printf("%02X\n", szBDAddr[0]);

	/* display the device class of the local device */
	PrintErrorMessage(Btsdk_GetLocalDeviceClass(&ulDevClass), BTSDK_TRUE);
	printf("Device Class: %08lX\n", ulDevClass);

	/* display the discovery mode of the local device */
	PrintErrorMessage(Btsdk_GetDiscoveryMode(&usMode), BTSDK_TRUE);
	printf("Discovery Mode: ");
	if (usMode & BTSDK_GENERAL_DISCOVERABLE)
	{
		printf("GENERAL_DISCOVERABLE |");
	}
	if (usMode & BTSDK_LIMITED_DISCOVERABLE)
	{
		printf(" LIMITED_DISCOVERABLE |");
	}
	if (usMode & BTSDK_CONNECTABLE)
	{
		printf(" CONNECTABLE |");
	}
	if (usMode & BTSDK_PAIRABLE)
	{
		printf(" PAIRABLE\n");
	}
	printf("\n");	
}