Syntax
boolean accept(
    size_t time_out, 
    const char * MACAddr
);
ContentsIndex
PreviousUpNext
LBTServerClass::accept Method (size_t, char *)
LBTServerClass Class | Example
Syntax
boolean accept(
    size_t time_out, 
    const char * MACAddr
);
Description

Accepts Bluetooth SPP client's connection request from a specified Bluetooth address. Returns as long as the connection is made or the request reaches timeout.

Parameters
Parameters 
Description 
size_t time_out 
The timeout for accepting connection.
 
const char * MACAddr 
The string format (const char *), for example: "12:34:56:ab:cd:ef". 
Returns

true: Successful. 

false: Failed.

Example
#include <LBT.h>
#include <LBTServer.h>
  
void setup()
{
  Serial.begin(9600);
  bool success = LBTServer.begin();
  if( !success )
  {
      Serial.println("Cannot begin Bluetooth Server successfully");
      // Do nothing.
      while(true);
  }
  else
  {
      Serial.println("Bluetooth Server begins successfully");
  }
 
  // Waiting for a Bluetooth SPP Client to connect.
  bool connected = LBTServer.accept(20, "12:34:56:ab:cd:ef");
 
  if( !connected )
  {
      Serial.println("No connection request yet");
      // Do nothing.
      while(true);
  }
  else
  {
      Serial.println("Connected");
  }
}
 
void loop()
{
 
}
File

LBTServer.h

Class