Starts to discover Bluetooth devices.

Syntax

int BltStartDiscovery(
  int max_count
);

Parameters

max_count
[in] Maximum number of the device to be discovered. (Minimum = 2)

Return value

Return COM_ERROR_00 if the function succeeds. Otherwise, return other value.

Remarks

Get search results with BltFetchDiscovery .
Do not use during Bluetooth communication.
This function consumes heap memory.
Be sure to call BltEndDiscovery after the search is complete.

Requirements

Header file:
lib.h : System 5.0 or later.
Library file:
libSTARTUPOPH5000.a : System 5.0 or later.

Sample

#include <stdio.h>
#include "lib.h"

void main(void)
{
    BLT_DISCOVER_RESULT *pResult;
    BLT_DISCOVER_DEVICE_INFO *pInfo;
    int i;
    unsigned int startTick;

    printf( "Discover Bluetooth\n\n" );

    while(1){
        printf("Press SCAN key");
        while (getchar() != SCAN_KEY){
            Idle();
        }
        ClearDisplay();
        GotoXY(0, 6);
        printf("Press BS to stop");

        BltStartDiscovery(5);

        startTick = GetTickCount();
        while (1){
            pResult = BltFetchDiscovery();

            if (GetTickCount() - startTick > (500/20)){
                if (pResult->count){
                    pInfo = pResult->dev_info;
                    for (i = 0; i < pResult->count; i++, pInfo++){
                        GotoXY(0, i);
                        printf("%d:%s[%d]%s\n", i, pInfo->bd_address, pInfo->rssi, (pInfo->active)? "  ": " X");
                    }
                }
                startTick = GetTickCount();
            }
            if (getchar() == BS_KEY){
                break;
            }
            Idle();
        }

        BltEndDiscovery();

        GotoXY(0, 6);
        printf("Stopped.           \n");
    }
}

Last updated: 2022/01/13