Syntax
boolean connect(
    LBTAddress & address, 
    const char* pinCode = NULL
);
ContentsIndex
PreviousUpNext
LBTClientClass::connect Method (LBTAddress &, char*)
LBTClientClass Class | Example
Syntax
boolean connect(
    LBTAddress & address, 
    const char* pinCode = NULL
);
Description

Connects Bluetooth SPP server with Bluetooth address.

Parameters
Parameters 
Description 
LBTAddress & address 
Refer to LBTAddress type
 
const char* pinCode = NULL 
The Bluetooth 2.0 pincode. If you set it as a constant string, it will enable LinkIt One to communicate with a Bluetooth 2.0 device. 
Returns

true: Successful. 

false: Failed.

Example
#include <LBT.h>
#include <LBTClient.h>
  
void setup()
{
  Serial.begin(9600);
  bool success = LBTClient.begin();
  if( !success )
  {
      Serial.println("Cannot begin Bluetooth Client successfully");
      // Do nothing.
      while(true);
  }
  else
  {
      Serial.println("Bluetooth Client begins successfully");
      // start scan, at most scan 15 seconds
      int num = LBTClient.scan(15);
 
      if(num > 0)
      {
          LBTDeviceInfo info = {0};
          if( LBTClient.getDeviceInfo(0, &info) )
          {
              bool conn_result = LBTClient.connect(info.address);//bool conn_result = LBTClient.connect(info.address, "1234");
              if( !conn_result )
              {
                  Serial.println("Cannot connect to SPP Server successfully");
                  // Do nothing.
                  while(true);
              }
              else
              {
                 Serial.println("Connect to SPP Server successfully");
              }
          }
          else
          {
              Serial.println("Device index not correct");
              // Do nothing.
              while(true);
          }
      } 
  }
}
File

LBTClient.h

Class