bool QBtLocalDevicePrivate::GetBluetoothPowerState()
{
    return Btsdk_IsBluetoothReady();
}
Exemple #2
0
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
	This function is the main function
Arguments:
	void
Return:
	always return 0
---------------------------------------------------------------------------*/
int main(void)
{
    BTUINT8 chInputCmd = 0;
    BTUINT8 chEnterChoice = 0;

    printf("IVT BlueSoleil SDK is being Initialized....\n");
    if (FALSE == InitBlueSoleilForSample())
    {
        printf("Fail to initialize BlueSoleil, assure BlueSoleil is installed!\n");
        printf("Press any key to exit this application please.\n");
        scanf(" %c", &chEnterChoice);
        getchar();
        return 1;
    }
    else
    {
        RegAppIndCallback();
        Test_RegisterGetStatusCBK();

        if (BTSDK_TRUE != Btsdk_IsBluetoothHardwareExisted())
        {
            printf("There isn't any Bluetooth hardware detected.\n");
            printf("1. Enter 'N' to exit this application.\n");
            printf("2. Plug a Bluetooth hardware and enter 'Y' to continue.\n");

            while (TRUE)
            {
                scanf(" %c",&chEnterChoice);
                getchar();

                if (('y'==chEnterChoice)||('Y'==chEnterChoice))
                {
                    if (BTSDK_TRUE == Btsdk_IsBluetoothHardwareExisted())
                    {
                        printf("Bluetooth hardware is detected.\n");
                        break;
                    }
                    else
                    {
                        printf("Bluetooth hardware isn't detected and plug it again please.\n");
                        printf("Enter 'Y' to try again, Enter 'N' to exit this application.\n");
                        printf(">");
                    }
                }
                else if(('n'==chEnterChoice)||('N'== chEnterChoice))
                {
                    return 1;
                }
                else
                {
                    printf("You have entered into an invalid character.\n");
                }
            }
        }

        if (BTSDK_FALSE == Btsdk_IsBluetoothReady())
        {
            Btsdk_StartBluetooth();
        }

        if (BTSDK_TRUE == Btsdk_IsBluetoothReady())
        {
            /*we default expect this application runs on desktop platform.
            	of course, you can set another device class according to your need. */
            Btsdk_SetLocalDeviceClass(BTSDK_COMPCLS_DESKTOP);

            SdkTestShowMenu();
            while (chInputCmd != 'q')
            {
                scanf(" %c", &chInputCmd);
                getchar();
                if ('\n' == chInputCmd)
                {
                    printf(">>");
                }
                else
                {
                    ExecInputCmd(chInputCmd);
                    printf("\n");
                    if (chInputCmd != 'q')
                    {
                        SdkTestShowMenu();
                    }
                }
            }

        }
        else
        {
            printf("BlueSoleil fail to reset hardware...\n");
        }

        printf("IVT BlueSoleil SDK is being quitted....\n");
        Btsdk_RegisterGetStatusInfoCB4ThirdParty(NULL);
        UnRegAppIndCallback();
        Btsdk_Done();
        return 0;

    }
}