C Language Development Kit/Functions/BltIsConnected

From OptiWiki

Jump to: navigation, search
Description Checks if there is a bluetooth connection in the RFCOMM layer.
Syntax
int blt_is_connected(void);
Arguments None
Returns
NG Connection cannot be determined yet.
TRUE Connected.
FALSE Not connected.
Remarks blt_is_connected() function checks to see if the RFCOMM layer is connected. When connected there is a small amount of time that the connection cannot be determined. The function then returns NG.
Example
#include "lib.h"
#include <stdio.h>
 
void check_connection( void )
{
    switch( blt_is_connected())
    {
        case NG:
            printf("\fNot available yet.");
            break;
        case TRUE:
            printf("\fConnected.");
            break;
        case FALSE:
            printf("\fNot connected.");
            break;
    }
}
 
void main( void )
{
    autopowerdown( ON, 3000 ); // 60 seconds
    systemsetting("7G");       // show charging indication LED
 
    cursor( NOWRAP );
    comopen( COM3 );           // SPP connection port
    for(;;)
    {
        check_connection();
        if( kbhit() )
        {
            resetkey();
            comclose( COM3 );
            check_connection();
            comopen( COM3 );
        }
        delay(5);
    }
}


Views
Personal tools